ESP Rainmaker switch Device adding parameter as esp_rmaker_obj()

dalohar
Posts: 33
Joined: Tue Jul 28, 2020 6:42 am

ESP Rainmaker switch Device adding parameter as esp_rmaker_obj()

Postby dalohar » Tue May 10, 2022 6:35 am

Hi,

I trying to add esp_rmaker_obj() parameter to a Switch device.
After firmware program when I try to set JSON object value as mentioned below, I getting error in JSON parsing at esp_rmaker_handle_set_params() in esp_rmaker_param.c file and I am not receiving write_cb().

JSON Object value which I am trying to set is
  1. {\"name1\":[{\"name2_1\":\"value2_1_str\",\"name2_2\":val2_2_int,\"name2_3\":val2_3_int},{\"name3_1\":\"value3_1_str\",\"name3_2\":val3_2_int,\"name3_3\":val3_3_int}]}
Also after updating this value from App, I receive JSON data as below
  1. {"Switch 1":{"mapping":"{\"name1\":[{\"name2_1\":\"value2_1_str\",\"name2_2\":val2_2_int,\"name2_3\":val2_3_int},{\"name3_1\":\"value3_1_str\",\"name3_2\":val3_2_int,\"name3_3\":val3_3_int}]}"}}
Also please note that in parsing jsmntype is assigned as JSMN_STRING, I think it should be JSMN_OBJECT for correct execution.
Please let me know whether I am making any mistake here. If so please guide me on the same.

Thanks in advance.

Regards,

Dinesh

ESP_Piyush
Posts: 309
Joined: Wed Feb 20, 2019 7:02 am

Re: ESP Rainmaker switch Device adding parameter as esp_rmaker_obj()

Postby ESP_Piyush » Tue May 10, 2022 10:21 am

Hi Dinesh,

As per my understanding, you have a device named "Switch 1", with a parameter named "mapping" whose type is JSON Object, right? Note that the RainMaker phone apps do not support JSON objects. The textbox is shown just because the phone app does not know what UI to display. Any update from phone app gets pushed as a string rather than a JSON object, thereby causing parsing errors. A better option would be to use RainMaker CLI for your testing. Going ahead, we will add checks on phone app to handle arrays and objects properly.

Regards,
Piyush

dalohar
Posts: 33
Joined: Tue Jul 28, 2020 6:42 am

Re: ESP Rainmaker switch Device adding parameter as esp_rmaker_obj()

Postby dalohar » Tue May 10, 2022 1:05 pm

ESP_Piyush wrote:
Tue May 10, 2022 10:21 am
Hi Dinesh,

As per my understanding, you have a device named "Switch 1", with a parameter named "mapping" whose type is JSON Object, right? Note that the RainMaker phone apps do not support JSON objects. The textbox is shown just because the phone app does not know what UI to display. Any update from phone app gets pushed as a string rather than a JSON object, thereby causing parsing errors. A better option would be to use RainMaker CLI for your testing. Going ahead, we will add checks on phone app to handle arrays and objects properly.

Regards,
Piyush
Hi Piyush,

Greetings!

Thanks for your quick reply.
I will check with RainMaker CLI and will get back.

Regards,

Dinesh

dalohar
Posts: 33
Joined: Tue Jul 28, 2020 6:42 am

Re: ESP Rainmaker switch Device adding parameter as esp_rmaker_obj()

Postby dalohar » Thu May 12, 2022 11:03 am

dalohar wrote:
Tue May 10, 2022 1:05 pm
ESP_Piyush wrote:
Tue May 10, 2022 10:21 am
Hi Dinesh,

As per my understanding, you have a device named "Switch 1", with a parameter named "mapping" whose type is JSON Object, right? Note that the RainMaker phone apps do not support JSON objects. The textbox is shown just because the phone app does not know what UI to display. Any update from phone app gets pushed as a string rather than a JSON object, thereby causing parsing errors. A better option would be to use RainMaker CLI for your testing. Going ahead, we will add checks on phone app to handle arrays and objects properly.

Regards,
Piyush
Hi Piyush,

Greetings!

Thanks for your quick reply.
I will check with RainMaker CLI and will get back.

Regards,

Dinesh
Hi Piyush,

I have checked JSON value with RainMaker CLI and it serves my purpose.
Thanks for your quick and kind in-time help.
Further we will wait for app release for the same. I hope it will come soon.

Thanks once again.

Regards,

Dinesh

Who is online

Users browsing this forum: No registered users and 15 guests