ESP8266学习笔记4:ESP8266的SmartConfig(转)
版权**:本文为博主原创文章,未经博主允许不得转载。目录(?)[+]
今天花了将近一天的时间来研究ESP8266的SmartConfig功能,这个应该算是wifi云产品的标配。这篇文章先把SmartConfig操作一遍,我还写了另一篇文章梳理了物理层的具体协议,点击这里可以看到。
转载请注明:http://blog.csdn.net/sadshen/
一、准备
http://img.blog.csdn.net/20150714204340262?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center
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
http://img.blog.csdn.net/20150714204408297?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center
如下是ESP8266在ESP-TOUCH时的打印信息:
view plain copy
[*]<Time:2015-07-14 19:01:13:078 Len:0099>:?
[*]SDK ver: 1.2.0 compiled @ Jul3 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
http://img.blog.csdn.net/20150714204424021?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center
如下是ESP8266在AirKiss时的打印信息:
view plain copy
[*]<Time:2015-07-14 19:20:00:968 Len:0159>:?
[*]SDK ver: 1.2.0 compiled @ Jul3 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,经测试,效果良好。
页:
[1]