8266在和路由器失联后,如何通过SDK CALLBACK获取?

grantgao
Posts: 36
Joined: Tue Apr 14, 2015 5:20 pm

8266在和路由器失联后,如何通过SDK CALLBACK获取?

Postby grantgao » Thu Apr 16, 2015 4:04 pm

你好,请问,在8266已经连上路由器,并和服务器建立tcp连接,如果中途路由器重启,过段时间,8266和路由器再次取得连接并重新分配了IP地址,此时8266的SDK是否能提供API通过callback的形式通知user程序,从而可以让user程序清理旧的tcp连接,再和服务器建立新tcp连接?
你可以看下我附图中,8266的底层打印表明,路由器在重新scan done后,获取了IP地址和网关。我需要一个API能在此时主动通过callback的形式通知user程序
Attachments
路由器失连.png
路由器失连.png (29.64 KiB) Viewed 12392 times

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: 8266在和路由器失联后,如何通过SDK CALLBACK获取?

Postby ESP_Faye » Thu Apr 16, 2015 4:13 pm

您好,

非常抱歉,目前没有相关 callback,您可以通过 timer 查询是否连接上路由,请参考 IOT_Demo 中的 user_esp_platform_check_ip

您的意见十分宝贵,我们将安排评估这一需求。

感谢您对 ESP8266 的关注 !

jackon
Posts: 28
Joined: Thu Oct 23, 2014 9:05 am

Re: 8266在和路由器失联后,如何通过SDK CALLBACK获取?

Postby jackon » Fri Apr 17, 2015 10:09 am

hi, grantgao
i add the function you required last night, now you can register a callback in user_init, and handle connect/disconnect/got_ip event in your callback function.
please follow readme.txt in the attached zip file, test this new function and give me feedback asap.
thx
Attachments
1.0.1_b2_wifi_event_callback.zip
(511.74 KiB) Downloaded 849 times

grantgao
Posts: 36
Joined: Tue Apr 14, 2015 5:20 pm

Re: 8266在和路由器失联后,如何通过SDK CALLBACK获取?

Postby grantgao » Fri Apr 17, 2015 10:42 am

jackon wrote:hi, grantgao
i add the function you required last night, now you can register a callback in user_init, and handle connect/disconnect/got_ip event in your callback function.
please follow readme.txt in the attached zip file, test this new function and give me feedback asap.
thx


wonderful!i will try and feedback,thanks very much!

grantgao
Posts: 36
Joined: Tue Apr 14, 2015 5:20 pm

Re: 8266在和路由器失联后,如何通过SDK CALLBACK获取?

Postby grantgao » Fri Apr 17, 2015 4:51 pm

jackon wrote:hi, grantgao
i add the function you required last night, now you can register a callback in user_init, and handle connect/disconnect/got_ip event in your callback function.
please follow readme.txt in the attached zip file, test this new function and give me feedback asap.
thx


i have tried it ,and it is very useful feature!i power off my router and wait several seconds ,then power on the router again,the callback handle can note me wifi have reconnected ,so at this time i can make sure that currect tcp socket need to be cleared and recreate!
thanks espressif team!

grantgao
Posts: 36
Joined: Tue Apr 14, 2015 5:20 pm

Re: 8266在和路由器失联后,如何通过SDK CALLBACK获取?

Postby grantgao » Fri Apr 17, 2015 5:07 pm

grantgao wrote:
jackon wrote:hi, grantgao
i add the function you required last night, now you can register a callback in user_init, and handle connect/disconnect/got_ip event in your callback function.
please follow readme.txt in the attached zip file, test this new function and give me feedback asap.
thx


i have tried it ,and it is very useful feature!i power off my router and wait several seconds ,then power on the router again,the callback handle can note me wifi have reconnected ,so at this time i can make sure that currect tcp socket need to be cleared and recreate!
thanks espressif team!


but i found one new issue,when i shut down my local TCP server ,and then boot esp8266,esp8266 can not connect with local server ofcourse,but the wifi event handle always note me with string "event 2 ip:192.168.0.103,mask:255.255.255.0,gw:192.168.0.1" every 5-8min,if i start local server and let esp8266 connect successful,and tranport a keepalive packet every minitue,esp8266 never note me the string "event 2ip:192.168.0.103,mask:255.255.255.0,gw:192.168.0.1" again,

my question is ,if no trasport task on esp8266 wifi ,will esp8266 enter idle or sleep mode automatic? if not,why it note me with the string "event 2 ip:192.168.0.103,mask:255.255.255.0,gw:192.168.0.1" every 5-8min?

jackon
Posts: 28
Joined: Thu Oct 23, 2014 9:05 am

Re: 8266在和路由器失联后,如何通过SDK CALLBACK获取?

Postby jackon » Mon Apr 20, 2015 6:05 pm

any other event received? connect/disconnect.
do your tcp client reconnect to your server after fail? or only connect once when you power up.
it seems that your ap kicks out esp8266, but i'm not sure now. if station does not transfer any data to ap, ap will kick out this station, the time depend on the config of ap.
so please ping your device from pc, check again.

Who is online

Users browsing this forum: No registered users and 40 guests