Hi all, I try to get the “firebase_ESP_client” together with websockets running on the same ESP32. But both seem to use identical JSON definitions, so during compilation I get dozens of errors (see at the end of my post).
This is my configuration:
– ESP32 running in WiFi mode softAP plus station AP: “WiFi.mode(WIFI_AP_STA);”
– I use AsyncTCP + ESPASyncWebServer + ASyncElegantOTA
– I can start an AsyncWebserver + Websokets, and I can distinguish between traffic from SoftAP and StationAP.
– the handler of websockets uses a function “handleWebSocketMessage()” which in turn gets the states from a function “getOutputStates()”, and in this function there is a JSON-structure which depends on the include-file named “Arduino_JSON.h”. I got this idea from your book “Build Web Servers with ESP32…” / modue 3 / chapter 2.5 for example.
– When I comment “#include Arduino_JSON.h” and clear “getOutputStates()” everything compiles just fine, and my two APs (soft and station) are responding, but the websocket obviously is silent.
So my conclusion is that firebase_ESP_client and websockets both use JSON from different include-files and the two files use the same names (see error messages below). What can I do to get websockets running?
Why do I have this configuration?
– I would like to have a simple webserver running on port 80 on my softAP. I can onnect to this website over WiFi. This website contains a simple webformular to enter new SSID and PASS. SSID and PASS get stored via SPIFFS
– When I reboot my ESP32 the stationAP connects with this freshly configured SSID / PASS to the internet and connects to my firebase.
– The softAP and its IP is static, that way I can always connect to them. That way I can configure the stationAP with different SSIDs, because I want to use my ESP32 in different locations.
*********************************************************************************
libraries/Arduino_JSON/cjson/cJSON.c.o: In function `cJSON_GetErrorPtr’:
/home/nutzer/Dokumente/Arduino/Sketches/libraries/Arduino_JSON/src/cjson/cJSON.c:71: multiple definition of `cJSON_GetErrorPtr’
libraries/Firebase_Arduino_Client_Library_for_ESP8266_and_ESP32/json/cJSON/cJSON.c.o:/home/nutzer/Dokumente/Arduino/Sketches/libraries/Firebase_Arduino_Client_Library_for_ESP8266_and_ESP32/src/json/cJSON/cJSON.c:103: first defined here
libraries/Arduino_JSON/cjson/cJSON.c.o: In function `cJSON_Version’:
cJSON.c:(.text.cJSON_Version+0x0): multiple definition of `cJSON_Version’
libraries/Firebase_Arduino_Client_Library_for_ESP8266_and_ESP32/json/cJSON/cJSON.c.o:cJSON.c:(.text.cJSON_Version+0x0): first defined here
libraries/Arduino_JSON/cjson/cJSON.c.o: In function `cJSON_InitHooks’:
cJSON.c:(.text.cJSON_InitHooks+0x0): multiple definition of `cJSON_InitHooks’
libraries/Firebase_Arduino_Client_Library_for_ESP8266_and_ESP32/json/cJSON/cJSON.c.o:cJSON.c:(.text.cJSON_InitHooks+0x0): first defined here
…etc
Hi.
Yes, the FirebaseClient library uses its own JSON library: https://github.com/mobizt/Firebase-ESP-Client#create-edit-serializing-and-deserializing-the-json-objects.
So, that’s probably what is causing the issue.
To be honest, I’m not sure what’s the best way to use both libraries at the same time. Maybe you can ask on the library page and see what they suggest: https://github.com/mobizt/Firebase-ESP-Client/discussions
Regards,
Sara
I would guess that one of those libraries is either a later version of the other or one is a fork of the other. Try deleting one of the JSON library’s and give it a try. If that doesn’t work. try the other way around.
Hi all,
I got in touch with the developer of firebase-client library. He took care of my issue and it seems to be resolved, just update to firebase-client library v2.7.0 After that I can use both libraries together and both with JSON.
Best, Michael.