I am trying to implement a simple solution for sending data using JSON via TCP/UDP. Here's what I have been doing so far (as understood from IoT Demo):
1) In user init, start a tcp connection and start receiving.
2) Parse incoming data in web server receive and call json_send.
3) Call json_ws_send, this in turn calls the JSON callback function which has set and get methods as defined below:
LOCAL struct jsontree_callback wifi_connect_ap_callback = JSONTREE_CALLBACK(connect_ap_get, connect_ap_set);
JSONTREE_OBJECT(ap_setting, JSONTREE_PAIR("ssid", &wifi_connect_ap_callback), JSONTREE_PAIR("password", &wifi_connect_ap_callback));
JSONTREE_OBJECT(wifi_tree, JSONTREE_PAIR("ap_details", &ap_setting));
But my problem is that json tree callback never calls the connect_ap_set ( which supposedly extracts the values from json tree to variable which I can then use to print on UART) but calls the connect_ap_get twice.
This is where I have run out of luck and haven't made any further headway.
Any simple solution for using JSON (IoT Demo is too complicated for new users) will be much helpful.
Sending/Receiving JSON via UDP/TCP
-
- Posts: 10
- Joined: Sat May 23, 2015 1:24 pm
-
- Posts: 7
- Joined: Thu Jun 04, 2015 2:59 pm
Re: Sending/Receiving JSON via UDP/TCP
Postby jpenninkhof » Sun Aug 23, 2015 3:25 am
I've built a power strip that currently exchange json data with an MQTT broker. It parses and constructs json using the json functions in the EspressIf SDK. I don't think it's very complicated to comprehend. If you're interested, please have a look at the source code on https://github.com/jpenninkhof/esp_mqtt_switch.
If this doesn't get you started, please do let me know. Perhaps I'll just blog about it.
If this doesn't get you started, please do let me know. Perhaps I'll just blog about it.
Who is online
Users browsing this forum: No registered users and 28 guests
Login
Newbies Start Here
Are you new to ESP8266?
Unsure what to do?
Dunno where to start?
Start right here!
Latest SDK
Documentation
Complete listing of the official ESP8266 related documentation release by ESPRESSIF!
Must read here!
- All times are UTC+08:00
- Top
- Delete all board cookies
About Us
Espressif Systems is a fabless semiconductor company providing cutting-edge low power WiFi SoCs and wireless solutions for wireless communications and Internet of Things applications. We are the manufacturer of ESP8266EX.