void EthernetCommunication::onSend(const boost::system::error_code& error, size_t bytesSent) { if (error) { std::cout << "- Socket send error: " << error << ", bytesSent: " << bytesSent << std::endl; } if (running) { receiveNext(); } }
void* EthernetCommunication::run() { std::cout << "! Starting communication socket connection to " << host << ":" << port << std::endl; running = true; socket = new udp::socket(ioService, udp::endpoint(udp::v4(), port)); remoteEndpoint = boost::asio::ip::udp::endpoint( boost::asio::ip::address::from_string(host), port ); //receiveBuffer2 = boost::asio::buffer(receiveBuffer, MAX_SIZE); receiveNext(); ioService.run(); return NULL; }
void simpleConfigUI(char in) { static int string_index = 0; char teststr[15]; switch (menuState) { case IDLE: receiveNext(in); break; case SSID: display_now = false; getNewSSID(in); break; case PWD: display_now = false; getNewPassword(in); break; default: break; } }
void EthernetCommunication::onReceive(const boost::system::error_code& error, size_t bytesReceived) { if (bytesReceived >= MAX_SIZE) { std::cout << "- Too large socket message received: " << bytesReceived << std::endl; } if ((!error || error == boost::asio::error::message_size) && bytesReceived > 0) { std::string msg = std::string(receiveBuffer, bytesReceived); //std::string msg = std::string(receiveBuffer.data(), bytesReceived); //if (msg.substr(0, 7) != "<speeds") { // outgoing message // std::cout << "RECV: " << msg << ", bytesReceived: " << bytesReceived << std::endl; //} boost::mutex::scoped_lock lock(messagesMutex); messages.push(msg); } else if (error.value() != 995) { std::cout << "- Socket receive error: " << error << ", bytesReceived: " << bytesReceived << std::endl; } if (running) { receiveNext(); } }