I want to communicate two (2) ESP32's via Json commands using ESPAsyncWeb.h. The master should have specific operations to execute and respond to the client, and the client should be able to send specific Json commands to ask questions and receive responses. I have tried the method below but is throwing me weird errors such as
cannot bind non-const lvalue reference of type 'ArduinoJson::JsonObject&' {aka 'ArduinoJson6185_91::OBjectRef&'} to an rvalue of type 'ArduinoJson6185_91::enable_if<true, ArduinJson6185_91::ObjectRef>::type' {aka 'ArduinoJson6185_91::ObjectRef'}
I am not sure how to implement the operations for sending Json and receiving response from the Server using ArduinoJson 6. If anyone could enligthen me on how to conduct such transactions I'd appreciate it.
void setup(){
//start serial comm
//Broadcast as WiFi SoftAP
server.on("/command", HTTP_POST, [](AsyncWebServerRequest *request, JsonVariant &json)
{JsonObject& jsonObj = json.as<JsonObject>();
uint8_t command = jsonObj["C"];
String response;
switch(command){
case 0: response = "{\"SCAN\":\"received_scan\"}";
request -> send(200, "application/json", response);
return;
case 1: /*...similar stuff */
case 2: /*...*/
}});
server.begin();
}