void InitApp(void) { /* Initialize peripherals */ // Configure UART modules UARTConfigure(UART_CMD_MODULE_ID, UART_ENABLE_PINS_TX_RX_ONLY); UARTSetFifoMode(UART_CMD_MODULE_ID, UART_INTERRUPT_ON_TX_NOT_FULL | UART_INTERRUPT_ON_RX_NOT_EMPTY); UARTSetLineControl(UART_CMD_MODULE_ID, UART_DATA_SIZE_8_BITS | UART_PARITY_NONE | UART_STOP_BITS_1); UARTSetDataRate(UART_CMD_MODULE_ID, GetPeripheralClock(), DESIRED_CMD_BAUDRATE); UARTEnable(UART_CMD_MODULE_ID, UART_ENABLE_FLAGS(UART_PERIPHERAL | UART_RX | UART_TX)); UARTConfigure(UART_WIFI_MODULE_ID, UART_ENABLE_PINS_TX_RX_ONLY); UARTSetFifoMode(UART_WIFI_MODULE_ID, UART_INTERRUPT_ON_TX_NOT_FULL | UART_INTERRUPT_ON_RX_NOT_EMPTY); UARTSetLineControl(UART_WIFI_MODULE_ID, UART_DATA_SIZE_8_BITS | UART_PARITY_NONE | UART_STOP_BITS_1); UARTSetDataRate(UART_WIFI_MODULE_ID, GetPeripheralClock(), DESIRED_WIFI_BAUDRATE); UARTEnable(UART_WIFI_MODULE_ID, UART_ENABLE_FLAGS(UART_PERIPHERAL | UART_RX | UART_TX)); // Configure UART Interrupts INTEnable(INT_SOURCE_UART_RX(UART_CMD_MODULE_ID), INT_ENABLED); INTSetVectorPriority(INT_VECTOR_UART(UART_CMD_MODULE_ID), INT_PRIORITY_LEVEL_2); INTSetVectorSubPriority(INT_VECTOR_UART(UART_CMD_MODULE_ID), INT_SUB_PRIORITY_LEVEL_0); INTEnable(INT_SOURCE_UART_RX(UART_WIFI_MODULE_ID), INT_ENABLED); INTSetVectorPriority(INT_VECTOR_UART(UART_WIFI_MODULE_ID), INT_PRIORITY_LEVEL_1); INTSetVectorSubPriority(INT_VECTOR_UART(UART_WIFI_MODULE_ID), INT_SUB_PRIORITY_LEVEL_0); // Make the requests to Wifi service - they will be picked up when the service needs them ConnectToAccessPoint(&routerConnection, &DefaultWifiService); SendHttpRequest(&DnsDynamicHttpRequest, &DefaultWifiService); }
void TcpClient::ExampleRun() { const std::string host = "127.0.0.1"; int port = 666; ConnectToHost(host, port); ShowEndpointInfos(); _isRunning = true; while (_isRunning) { std::string request; std::cout << "Enter request: "; getline(std::cin, request); if (request == "END") _isRunning = false; else if (request == "") request = "HELLO-HOW-SHOULD-I-WORK"; SendHttpRequest(host, request); WaitForResponse(); ReceiveResponse(true); //DisplayResults(); //_isRunning = false; } CloseConnection(); }