painlessMesh 主要依賴這四個library
- ArduinoJson
- TaskScheduler
- ESPAsyncTCP (ESP8266)
- AsyncTCP (ESP32)
其中需要注意的是,ArduinoJson需使用5.X的版本。
並且若需使用ARDUINO_ESP8266_RELEASE_2_5_0這個版本的話
需要修正painlessMeshSTA.cpp的一個function
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | void ICACHE_FLASH_ATTR painlessMesh::tcpConnect(void) { // TODO: move to Connection or StationConnection? debugMsg(GENERAL, "tcpConnect():\n"); if (stationScan.manual && stationScan.port == 0) return; // We have been configured not to connect to the mesh // TODO: We could pass this to tcpConnect instead of loading it here //Make backward compatible pre ESP_SDK 2.5 #ifdef ARDUINO_ESP8266_RELEASE_2_5_0 if (_station_got_ip && WiFi.localIP().isSet() != 0) { #else if (_station_got_ip && WiFi.localIP() != 0) { #endif AsyncClient *pConn = new AsyncClient(); pConn->onError([](void *, AsyncClient * client, int8_t err) { staticThis->debugMsg(CONNECTION, "tcp_err(): tcpStationConnection %d\n", err); if (client->connected()) client->close(); WiFi.disconnect(); }); IPAddress ip = WiFi.gatewayIP(); //Make backward compatible pre ESP_SDK 2.5 #ifdef ARDUINO_ESP8266_RELEASE_2_5_0 if (stationScan.manualIP.isSet() != 0) { #else if (stationScan.manualIP != 0) { #endif ip = stationScan.manualIP; } pConn->onConnect([](void *, AsyncClient *client) { staticThis->debugMsg(CONNECTION, "New STA connection incoming\n"); auto conn = std::make_shared<MeshConnection>(client, staticThis, true); staticThis->_connections.push_back(conn); }, NULL); pConn->connect(ip, stationScan.port); } else { debugMsg(ERROR, "tcpConnect(): err Something un expected in tcpConnect()\n"); } } |
如此即可順利編譯成功!