8266在和路由器失联后,如何通过SDK CALLBACK获取?
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程序
你可以看下我附图中,8266的底层打印表明,路由器在重新scan done后,获取了IP地址和网关。我需要一个API能在此时主动通过callback的形式通知user程序
- Attachments
-
- 路由器失连.png (29.64 KiB) Viewed 12391 times
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
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
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!
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!
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?
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.
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 151 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.