ESP8266学习笔记4:ESP8266的SmartConfig
今天花了将近一天的时间来研究ESP8266的SmartConfig功能,这个应该算是wifi云产品的标配。这篇文章先把SmartConfig操作一遍,我还写了还有一篇文章梳理了物理层的详细协议,点击这里能够看到。
转载请注明:http://blog.csdn.net/sadshen/
一、准备
ESP8266眼下的SDK_v1.2.0支持SmartConfig。将esp_iot_sdk_v1.2.0\examples\smart_config
\文件夹的例程源代码拷贝至app文件夹就可以。
ESP-Touch的APP在乐鑫官网有下载。
微信官方对AirKiss有初步介绍(http://iot.weixin.qq.com/document-7_1.html),这个介绍中提到的库文件误导了我。其实ESP的SDK_v1.2.0已经支持了AirKiss。我们仅仅须要调用SmartConfig接口就能够了。
一个比較大的限制是,微信仅仅将AirKiss的功能权限开放给企业服务号,而个人申请的订阅号则不能申请这个权限。只是微信还是给了DEMO(http://iot.weixin.qq.com/download.html)方便开发人员的调试。
二、ESP-TOUCH
例如以下是ESP8266在ESP-TOUCH时的信息打印:
<Time:2015-07-14 19:01:13:078 Len:0099>:?SDK ver: 1.2.0 compiled @ Jul 3 2015 19:36:17 phy ver: 356, pp ver: 8.7 SDK version:1.2.0 <Time:2015-07-14 19:01:13:218 Len:0045>:mode : sta(18:fe:34:f8:8f:cf) add if0 f 0, <Time:2015-07-14 19:01:15:296 Len:0015>:scandone f 0, <Time:2015-07-14 19:01:17:484 Len:0034>:scandone SC_STATUS_FIND_CHANNEL <Time:2015-07-14 19:02:07:484 Len:0136>: TYPE: ESPTOUCH V2.4 T|PHONE MAC: b4 b 44 1 6 5 T|AP MAC : 0 c4 38 12 0 5e SC_STATUS_GETTING_SSID_PSWD SC_TYPE:SC_TYPE_ESPTOUCH <Time:2015-07-14 19:02:08:531 Len:0030>:T|SCAN SSID: 杩瀢ifi_2.4g鍚?
<Time:2015-07-14 19:02:09:593 Len:0088>:T|pswd: 12345678 T|ssid: 杩瀢ifi_2.4g鍚?
T|bssid: 00 c4 38 12 00 5e SC_STATUS_LINK <Time:2015-07-14 19:02:09:671 Len:0008>:f -240, <Time:2015-07-14 19:02:11:906 Len:0072>:scandone no 杩瀢ifi_2.4g鍚?found, reconnect after 1s reconnect f 0, <Time:2015-07-14 19:02:14:093 Len:0123>:scandone add 0 aid 2 pm open phy_2,type:2 0 0 connected with 杩瀢ifi_2.4g鍚?
channel 3 dhcp client start... cnt <Time:2015-07-1419:02:17:109 Len:0052>:ip:192.168.4.232,mask:255.255.255.0,gw:192.168.4.1 <Time:2015-07-14 19:02:19:937 Len:0046>:SC_STATUS_LINK_OVER Phone ip: 192.168.4.199
三、AirKiss
例如以下是ESP8266在AirKiss时的信息打印:
<Time:2015-07-14 19:20:00:968 Len:0159>:? SDK ver: 1.2.0 compiled @ Jul 3 2015 19:36:17 phy ver: 356, pp ver: 8.7 SDK version:1.2.0 mode : sta(18:fe:34:f8:8f:cf) add if0 f 0, scandone f 0, <Time:2015-07-14 19:20:03:046 Len:0015>:scandone f 0, <Time:2015-07-14 19:20:05:234 Len:0034>:scandone SC_STATUS_FIND_CHANNEL <Time:2015-07-14 19:20:16:421 Len:0185>: TYPE: AIRKISS V2.4 T|sniffer on ch:3 T|PHONE MAC: b4 b 44 1 6 5 T|AP MAC : 0 c4 38 12 0 5e T|Head Len : 66 SC_STATUS_GETTING_SSID_PSWD SC_TYPE:SC_TYPE_AIRKISS T|sync:wait <Time:2015-07-14 19:20:16:812 Len:0052>:T|retain data: 0 T|all data: 24 T|sync:mgc end <Time:2015-07-14 19:20:17:406 Len:0250>:T|ssid len15 T|SSID: 杩瀢ifi_2.4g鍚?T|SCAN CRC SSID: 1 T|index:2, remain:1 T|password len: 8 T|sync:pfx end T|seq:0 T|seq:1 T|seq:2 T|I get it! T|pswd : 12345678 T|ssid : 杩瀢ifi_2.4g鍚? T|bssid: 00 c4 38 12 00 5e SC_STATUS_LINK f 0, <Time:2015-07-14 19:20:19:562 Len:0123>:scandone add 0 aid 2 pm open phy_2,type:2 0 0 connected with 杩瀢ifi_2.4g鍚? channel 3 dhcp client start... cnt <Time:2015-07-14 19:20:20:343 Len:0052>:ip:192.168.4.232,mask:255.255.255.0,gw:192.168.4.1 <Time:2015-07-14 19:20:24:171 Len:0021>:SC_STATUS_LINK_OVER
四、总结
ESP8266在V1.2.0版本号已经兼容ESP-TOUCH和微信AirKiss,经測试,效果良好。