Sending QJsonArray over socket
-
Then print out what you really receive to see if it's what you're sending. Also print out what you really send on the sender side.
-
So i did this
void Socket::sendCommandStrip(const QString &bName, const QJsonValue bValue) { m_webSocket.sendTextMessage(QJsonDocument(QJsonObject{{bName, bValue}}).toJson(QJsonDocument::Compact)); qDebug() << QJsonDocument(QJsonObject{{bName, bValue}}).toJson(QJsonDocument::Compact); }
and got
"{\"pixArt\":[]}"
now my question is, why? :S
if i do this
socket.sendCommandStrip(QString("pixArt"), QJsonValue(RGB565).toArray());
i get the correct output (im not copying all 16k + here)
"{\"pixArt\":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,30912,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,30912,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,30912,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,30912,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,30912,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,30912,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,30912,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,30912,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,30912,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,30912,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,30912,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,30912,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,30912,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,
it ends with this
0,0,0,0,0,0,0,0,0]}" [SOCKET][INFO] We are closing the connection
again it disconnects me after :S
on the ESP32 side i get this
Incoming data from socket! Empty input! [SOCKET][STATUS] [0] Disconnected!
-
I said you should output what you really send, not what you pass to a function you wrote.
-
I said you should output what you really send, not what you pass to a function you wrote.
@Christian-Ehrlicher that is what i send....
qDebug() << QJsonDocument(QJsonObject{{bName, bValue}}).toJson(QJsonDocument::Compact);
-
So what do you get on the esp side?
-
So what do you get on the esp side?
@Christian-Ehrlicher the same as stated above
Incoming data from socket! Empty input! [SOCKET][STATUS] [0] Disconnected!
it claims
inData['pixArt']
is empty and the disconnects me :S -
@Kris-Revi said in Sending QJsonArray over socket:
the same as stated above
I don't want processed output but the raw data (for the third time...)
-
@Kris-Revi said in Sending QJsonArray over socket:
the same as stated above
I don't want processed output but the raw data (for the third time...)
@Christian-Ehrlicher
like this?JsonArray test = inData["pixArt"]; Serial.println(test); Serial.println(inData["pixArt"].as<JsonArray>());
this just gives me
Incoming data from socket! 0 0 Empty input! [SOCKET][STATUS] [0] Disconnected!
-
I'm giving up... don't know what's so hard to print out the raw incoming data. Good luck.
-
@Christian-Ehrlicher
like this?JsonArray test = inData["pixArt"]; Serial.println(test); Serial.println(inData["pixArt"].as<JsonArray>());
this just gives me
Incoming data from socket! 0 0 Empty input! [SOCKET][STATUS] [0] Disconnected!
@Kris-Revi said in Sending QJsonArray over socket:
like this?
No. Please show us your payload. What does it look like before you passed it into
deserializeJson()
? (This is what @Christian-Ehrlicher meant by "raw data")Also:
- What is the value of
length
in webSocketEvent()? - Converting an image into a QJsonArray is very expensive and inefficient. What is the purpose using QJsonArray here?
- What is the value of