void *handleCheckInternetConnectThread(void * arg) { while (true){ sleep(60); cout << "Проверка доступа к интернету...\n"; char *hostname; struct hostent *hostinfo; hostname = (char *)"google.com"; hostinfo = gethostbyname (hostname); if (hostinfo != NULL){ cout << "Доступ к интернету имеется\n"; } else { cout << "Доступ к интернету отсутствует\n"; internetConnect(); } } return 0; }
void setup() { // Setup debug serial output DebugSerial.begin(115200); DebugSerial.println(F("Coordinator Starting...")); // Setup XBee serial communication XBeeSerial.begin(9600); xbee.begin(XBeeSerial); delay(1); internetConnect(); delay(500); mqttConnect(); // Setup callbacks xbee.onPacketError(printErrorCb, (uintptr_t)(Print * ) & DebugSerial); xbee.onResponse(printErrorCb, (uintptr_t)(Print * ) & DebugSerial); xbee.onZBRxResponse(processRxPacket); }