Skip to content
This repository has been archived by the owner on Jun 28, 2019. It is now read-only.

user_plug, how to send data to APP #7

Open
ericchan16 opened this issue Dec 9, 2016 · 3 comments
Open

user_plug, how to send data to APP #7

ericchan16 opened this issue Dec 9, 2016 · 3 comments

Comments

@ericchan16
Copy link

Hi All,

I'm using the user_plug example in ESP8266_IOT_PLATFORM.
Everything works well, APP can control the plug, and request the plug status.
But when I press the key to make plug turns on or turns off, it will not send plug status to APP.
So I add below code:
`

if(key_pressed_flag == 1)
{
	key_pressed_flag = 0;
	
	char *pbuf = NULL;
	int nonce = 0;

	pbuf = (char *)zalloc(packet_size);

	if (pbuf != NULL) {
		sprintf(pbuf, RESPONSE_FRAME, user_plug_get_status(), nonce);
		printf("%s\n", pbuf);
		write(client_param.sock_fd, pbuf, strlen(pbuf));
		free(pbuf);
		pbuf = NULL;
	}
}

`

But when execute these code, it will return below error.
Does anyone know why? Or is there any method to upload the plug status to APP?
Thanks!

[2016-12-09 16:16:48.712 R]read application data
user_esp_platform_data_process {"status": 500, "result": "failed", "message": "Internal Server Error"}
, 72

@tzxespressio
Copy link

I think if plug change its status,the status just upload to server,but server won't push the message to app right now,just when app want to get the status of plug,and it send request to server,server will response plug status to app,but if use it in LAN environment ,use the webserver control the plug,it‘s easy to update the status to APP

@Clairehou111
Copy link

I got the same doubt here, especially via local network,the apps which keep connection with ESP are supposed to get the ESP's latest data, my question is how to implement this . Should the ESP send the data straightforward to apps or apps keep requesting data from the ESP? If it's former, unicast or broadcast should be used? Thanks a lot in advance.

@Clairehou111
Copy link

but if use it in LAN environment ,use the webserver control the plug,it‘s easy to update the status to APP

@tzxespressio , could you give more details about the method please ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants