-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ESP32 RPC response reply only 1.695175409 #167
Comments
I am also facing the same issue with the examples. I just get a different number. |
The For the return value I think there is some kind of misunderstanding, because you don't have to add the What happens if you run your code again, but with the other lines commented out and the size decreased to 1, and only Because the |
I try with your suggestion. please suggest me. |
The aforementioned code is correct, because nothing to do is the case, because we do not need to do anything in the constructor body, we do pass the given variable to the base class tough. In this case You can ignore that code section, that is not why it is not working correctly. For testing purposes can you replace your return statement with this |
For the previous example, If it is 1, then adjust the return to Additionally the debug messages are helpful, can you attach the debug message for the initial example you had, with the additionally enabled debug mode. |
I try to using return RPC_Response(nullptr, switch_state); It timeout like picture. |
I think the problem is that the message, in this case without a key, is not sent. Because there is no log message printing that something was sent. |
Thingsboard client sdk : 0.12.0 |
Can you adjust the code to something like this: StaticJsonDocument<JSON_OBJECT_SIZE(1)> doc;
JsonVariant variant = doc.to<JsonVariant>();
variant.set(switch_state);
return RPC_Response(doc); |
I'll have to try it myself, but as far as I know multiple keys are not possible, you should be able to send one big string containing a |
I don't think so I'll check if it is possible to return more than one value. |
I try to put json via JsonVariant like below code.
|
I verify about this issues. But, I not have idea for solve it. I will tell you. The first one. Then after line 1792 I try to by pass this point. It work. |
I'm not 100% sure what you mean, so if you skip line 1781 to 1792, it works like expected. And with work like expected you mean that the |
@sirapol I'm trying to replicate your solution and you made use of a function called "splitString()". I can't find any reference of this function. |
|
So I have done all the mods, but it seems there is some key element I'm missing somewhere. The ESP32 reboots after it has built the response topic. Received the set switch method abort() was called at PC 0x4013f72b on core 1 Backtrace: 0x40083669:0x3ffcb880 0x4008cd81:0x3ffcb8a0 0x400920f9:0x3ffcb8c0 0x4013f72b:0x3ffcb940 0x4013f772:0x3ffcb960 0x4013f6d3:0x3ffcb980 0x4014125b:0x3ffcb9a0 0x40140302:0x3ffcbc30 0x40140b44:0x3ffcbc50 0x400d4e9a:0x3ffcbc70 0x400d6825:0x3ffcbf10 0x40175029:0x3ffcc050 0x400d7405:0x3ffcc070 0x400d75d5:0x3ffcc0c0 0x400d6261:0x3ffcc0e0 0x400dbe1d:0x3ffcc150 |
Please try to update ArduinoJson Lib. |
First of all thanks a lot for your detailed descriptions about the issue and the screenshots. I'm relatively sure I know what the underlying issue is know. I'll work on a fix, but it will take a while, if a quick fix is required there is no need to change the library. Instead the RPC callback methods have to be changed like shown below. Second of all I am relatively sure it is not a memory leak, that would mean that we are not erasing heap memory even tough we should. I'm pretty sure that is not the case, because the library more or less does not utilise heap memory, especially when But what it probably is, is that we are accessing a reference to a local object that has been deleted. In more detail: We are returning a This is the case because stack memory is not really "deleted", but it allows other portions of the code to write into that memory and that would explain the mangled data. That is probably the reason for the behaviour we saw previously. One way to fix that is to immediately copy the return value from the method to another object, because the data is still on the stack and if we immediately copy it we can "restore" it, but that is also very bad practice and a dirty fix to the problem. Instead I'll work on a cleaner fix, that instead of returning a reference we instead pass a To test that hypothesis @munya-gwena . It would be nice if you could simply try to allocate the That should also remove the need for the workaround. StaticJsonDocument<JSON_OBJECT_SIZE(2)> doc;
RPC_Response processTemperatureChange(const RPC_Data &data) {
doc.clear();
doc["example1"] = 42;
doc["example2"] = "test";
return RPC_Response(doc);
} |
Okay perfect thanks a lot for confirming. For now use that workaround. I will work on a fix and mention this issue in the pull request once the fix has been completed and is going to be merged. |
Let close this issues ? |
It's fine it will be closed once the pull request gets merged anyway and until there isn't a fix in the library itself it's better if it's still open so others can easily find this issue if they have the same problem. |
Hey @MathewHDYT ! |
I using examples/0010-esp8266_esp32_rpc/0010-esp8266_esp32_rpc.ino .
ESP32 can receive data from rpc request from server.
When ESP32 reply , It reply only 1.695175409.
I want it echo data or another thing.
Is it bug or my bad ?
The text was updated successfully, but these errors were encountered: