ESP8266 SmartConfig
来自Jack's Lab
(版本间的差异)
(→Notes) |
(→Notes) |
||
第153行: | 第153行: | ||
* 开通公众号硬件 JSAPI | * 开通公众号硬件 JSAPI | ||
* 硬件 JSAPI: http://iot.weixin.qq.com/document-3_1.html | * 硬件 JSAPI: http://iot.weixin.qq.com/document-3_1.html | ||
+ | * 微信JS-SDK说明文档:http://mp.weixin.qq.com/wiki/7/1c97470084b73f8e224fe6d9bab1625b.html | ||
* 公众号设置 ---> 功能设置 ---> JS接口安全域名 | * 公众号设置 ---> 功能设置 ---> JS接口安全域名 | ||
2015年11月12日 (四) 19:38的版本
目录 |
1 概述
所谓 SmartConfig 就是乐鑫(ESP8266 芯片厂家)为配置 WiFi SSID 和 Password 提供了一种快速配置技术
原有配置 WiFi 步骤:
- 手机先从无线路由断开,连上设备的 WiFi 热点
- 在 APP / WeChat 里输入设备需要连接的无线路由的 SSID 和 Password
SmartConfig 将其过程简化为无须断连无线路由,直接在 微信/APP 里输入 Password 即可,步骤大大简化,用户体验提升明显
现有的 SmartConfig 支持微信的 AirKiss 和乐鑫自己的 ESP Touch
2 快速尝试
下载 SDK:
# clone the whole sdk $ git clone git://github.com/icamgo/noduino-sdk.git noduino-sdk # fetch the toolchain of esp8266 $ cd noduino-sdk $ git submodule init $ git submodule update $ cd toolchain $ ./gen.py # generate the toolchain (you need Python 2.7)
插上开发板,编译上传一步完成:
$ cd ../example/smart-config $ make flash
打开微信,扫一扫如下二维码,关注公众号:
进入公众号后,点下方菜单: 探索 ---> 添加设备:
点 ”开始配置“ 后:
- WiFi 配置的过程中,开发板的串口输出为:
scandone f r0, scandone SC_STATUS_FIND_CHANNEL TYPE: AIRKISS T|sniffer on ch:8 T|PHONE MAC: 38 48 4c 69 33 75 T|AP MAC : e0 46 9a 8b 34 4e T|Head Len : 74 SC_STATUS_GETTING_SSID_PSWD SC_TYPE:SC_TYPE_AIRKISS T|sync:wait T|retain data: 2 T|all data: 22 T|sync:mgc end T|ssid len 11 T|SSID: GAGA-comcat T|SCAN CRC SSID: 1 T|index:2, remain:3 T|password len: 10 T|sync:pfx end T|seq:0 T|seq:1 T|seq:2 T|pswd : 9510189510 T|ssid : GAGA-comcat SC_STATUS_LINK Store the ssid and password into flash f r0, scandone state: 0 -> 2 (b0) state: 2 -> 3 (0) state: 3 -> 5 (10) add 0 aid 9 connected with GAGA-comcat, channel 8 dhcp client start... cnt ip:192.168.13.62,mask:255.255.255.0,gw:192.168.13.1 SC_STATUS_LINK_OVER free heap size:50496 pm open phy_2,type:2 0 0
3 微信 AirKiss
微信 AirKiss 的原理,参考此文档:http://iot.weixin.qq.com/airkiss_developer_manual.pdf
微信 AirKiss 目前支持的硬件:http://iot.weixin.qq.com/document-0_4.html#rd
4 ESP Touch
乐鑫也实现了类似的功能,并做了 IOS 和 Android 平台的 APP,开源在:
- ESP Touch for Android: https://github.com/EspressifApp/EsptouchForAndroid
- ESP Touch for IOS: https://github.com/EspressifApp/EsptouchForIOS
如需尝试 ESP Touch,可将 noduino-sdk/example/smart-config/ 下 的 user_main.c 打开,找到:
void user_init(void) { uart_init(BIT_RATE_115200, BIT_RATE_115200); os_printf("SDK version:%s\n", system_get_sdk_version()); //SC_TYPE_ESPTOUCH,SC_TYPE_AIRKISS,SC_TYPE_ESPTOUCH_AIRKISS smartconfig_set_type(SC_TYPE_AIRKISS); wifi_set_opmode(STATION_MODE); smartconfig_start(smartconfig_done); }
把 smartconfig_set_type 的参数换为 SC_TYPE_ESPTOUCH 即可
5 Notes
- 开通公众号硬件 JSAPI
- 硬件 JSAPI: http://iot.weixin.qq.com/document-3_1.html
- 微信JS-SDK说明文档:http://mp.weixin.qq.com/wiki/7/1c97470084b73f8e224fe6d9bab1625b.html
- 公众号设置 ---> 功能设置 ---> JS接口安全域名