版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
智能插座、智能灯、传感器,并且通过服务器,实现了对设备的反向控制以及数据。在user_ma voiduser_init(void)是上层程序的函数,给用户提供一个初始化接口,用户可在该函数esp_iot_sdkexampleIOT_Demo,AT,smart_config三种应用示例,实际上,也可以在IOT_Demosmart_configAPI,SDKAPI上层应用均可调用。 user_devicefind.c—UDP传输功能的示例,提供ESP8266设备查找功能; tform.c—与Espressif云端服务器通信的示例;user_plug.c—智能插座的功能示例代码;user_light.c— 下为应用程序相关头文件,需要注意的是"user_config.h文件,在该头文件中可 整,flashmap详见文档“2A-ESP8266IOT_SDK_User_” tform.h#defineESP_PARAM_START_SEC0x3Cuser_light.h#definePRIV_PARAM_START_SEC0x3Cuser_plug.h#definePRIV_PARAM_START_SEC0x3C IoTDemouser_esp_tform_initsotfAP+station共存的模式,用户连入ESP8266softAP接口的局域网,发指令让ESP8266station接口连接可入的路由(AP),Espressifuser_esp_tform_check_ip。连接服务/ /Demo设备进行通讯时,可采用curl命令。可在()进行指定版本的,后文中的curl指令请参照“Windowscurl”的示例。若使用Linuxcurl或者Cygw url,后文中的curl指令请参照“Linux/Cygw url”的示例。IOT_DEMO中#defineSOFTAP_ENCRYPT定义softAP需要进行连接(用户如果无需,则可将宏#defineSOFTAP_ENCRYPT关闭),格式为:ESP8266_softAPMAC_PASSWORD,开发者可自行修改esp_iot_sdk\app\lude\user_config.h中宏定义#definePASSWORD,配置。curlcurl-X响应{"Version":"Device":"manufacture","Espressif}}述),通过PC发送curl指令设置。curlcurl-XPOST-H"Content-Type:application/json"-d?curlcurl-XPOST-H"Content-Type:application/json"-d?
tokenEspressifCloudtokenEspressifCloud申请该设备的控制权限。因此,随机token与ESP8266设备是一一对应的关系,不能与其他设备共用。 curlcurl-XPOST-HContent-Type:application/json-d?curlcurl-XPOST-H"Content-Type:application/json"-d\",\"token\":7890\”}}}}"curlcurl-X返回status说明如下curlcurl-Xcurl-Xcurl-Xcurlcurl-XPOST-H"Content-Type:application/json"-d{"Connect_Softap":{"authmode":"OPEN","channel":6," curlcurl-XPOST-H"Content-Type:application/json"-d authmode支持:OPEN,PSK,2PSK,PSK/2PSK.password必须多于8bytes. 以查询station的连接状态。 station模式。此时可以重新从步骤2进行连接。由宏定义#defineAP_CACHE控制此功能开关。“AreYouEspressifIOTSmartDevice?”,ESP82661025UDP广播包进行响应响应I’mI’mI’mxx:xx:xx:xx:xx:xxMAC地址,yyy.yyy.yyy.yyyIP地址。curlcurl-X{"Response":{"Response":"status":}}curlcurl-XPOST-H"Content-Type:application/json"-dcurlcurl-XPOST-H"Content-Type:application/json"-dcurlcurl-X{{"rgb":{"red":"green":"blue":}}其中,freq取值范围为1~500;red、green、blue取值范围为0~255curlcurl-XPOST-H"Content-Type:application/json"-d'{"freq":100,"rgb":{"red":200,"green":0,"blue":0}}'curlcurl-XPOST-H"Content-Type:application/json"-d"{\"freq\":100,\"rgb\":{\"red\":其中,freq取值范围为1~500;red、green、blue取值范围为0~255ESP8266设备凭借它作为认证,享受EspressifCloud提供的云端服务,master-device-key.bin需要向EspressifCloud申请,烧录到SPIflash。 {"path":{"path":"/v1/device/activate/","method":"POST","meta":{"Authorization":"tokenHERE_IS_THE_MASTER_DEVICE_KEY"},"body":{"encrypt_method":" ":"18:fe:34:70:12:00","token": {"status":{"status":200,"device":{device},"key":{key},"token":curlcurl-XPOST-H"Authorization:tokenc8922638bb6ec4c18fcf3e44ce9955f19fa3ba12"-d'{"token":"7890"}'curlcurl-XPOST-H"Authorization:tokenc8922638bb6ec4c18fcf3e44ce9955f19fa3ba12"-d"{\"token\":\"7890\"}"{"status":200,{"status":200,"key":{"updated":"2014-05-1221:22:03","user_id":1,"product_id":0,"name":"deviceactivatesharetoken","created":"2014-05-1221:22:03","source_ip":"*","visibly":1,"id":149,"datastream_tmpl_id":0,"token":"e474bba4b8e11b97b91019e61b7a018cdbaa3246","access_methods":"*","is_owner_key":1,"scope":3, "device_id":29,"activate_status":1,"datastream_id":0,"expired_at":"2288-02-22c8922638bb6ec4c18fcf3e44ce9955f19fa3ba12为userkey(用户ID)的举例,需填入用户实际的userkey值,在EspressifCloud用户时获得。步骤如下:e474bba4b8e11b97b91019e61b7a018cdbaa3246ownerkeyPCownerkey对设备进行控制。{"nonce":{"nonce":560192812,"path":"/v1/device/identify","method":"GET",{"Authorization":"tokenEspressifCloud都需要向服务器发送这样一包数据。其中“nonce”是一组随机整数,token后面是设备的master-device-key。EspressifCloudmaster-device-key后,会向设备回复一个{"device":{"device":{"productbatch_id":0,"last_active":"2014-06-1910:06:58","ptype":12335,"activate_status":1,"serial":"334a8481","id":130,"b ":"18:fe:34:97:d5:33","last_pull":"2014-06-1910:06:58","last_push":"2014-06-10:06:58","location":"","metadata":"18:fe:34:97:d5:33temperature","status":2,"updated":"2014-06-1910:06:58","description":"device-description-79eba060","activated_at":"2014-06-1910:06:58","visibly":1,"is_private":"product_id":1,"name":"device-name-79eba060","created":"2014-05-28"is_frozen":0,"key_id":387},"nonce":560192812,"message":identified","status":EspressifCloud(IP地址8,端口8000TCP{"path":{"path":/","method":"POST","meta":{"Authorization":{"status":{"status":200,"message":"nonce":success","datetime":"2014-06-19服务器发给设备的GET命令格式如下所示:{"body":{},{"body":{},"nonce":33377242,"is_query_device":true,"get":{},"token":"e474bba4b8e11b97b91019e61b7a018cdbaa3246","meta":{"Authorization":"tokene474bba4b8e11b97b91019e61b7a018cdbaa3246"},"path":"/v1/datastreams/plug-status/datapoint/","post":{},"method":"GET"}{"status":{"status":200,"datapoint":{"x":0},"nonce":33377242,"is_query_device":数据包实现对应的控制动作,例如,打开智能插座开关令:{"body":{"body":{"datapoint":{"x":1}},"nonce":620580862,"is_query_device":true,"get":{},"token":"e474bba4b8e11b97b91019e61b7a018cdbaa3246","meta":{"Authorization":"tokene474bba4b8e11b97b91019e61b7a018cdbaa3246"},"path":"/v1/datastreams/plug-status/datapoint/","post":{},"method":"POST","deliver_to_device":true}noncenonce值一致,以表示每次控制和响应相互对{"status":{"status":200,"datapoint":{"x":1},"nonce":620580862,"deliver_to_device":curlcurl-XGET-H"Content-Type:application/json"-H"Authorization:token{"status":200,"nonce":11432809,"datapoint":{"x":1},"deliver_to_device":{"status":200,"nonce":11432809,"datapoint":{"x":1},"deliver_to_device":curl-XPOST-H"Content-Type:application/json"-H"Authorization:tokencurl-XPOST-H"Content-Type:application/json"-H"Authorization:tokene474bba4b8e11b97b91019e61b7a018cdbaa3246"–d'{"datapoint":{"x":1}}'http://curl-XPOST-H"Content-Type:application/json"-H"Authorization:tokencurl-XPOST-H"Content-Type:application/json"-H"Authorization:tokene474bba4b8e11b97b91019e61b7a018cdbaa3246"–d"{\"datapoint\":{\"x\":1}}"http://{"status":{"status":200,"nonce":11432809,"datapoint":{"x":1},"deliver_to_device":服务器发给设备的GET命令格式如下所示:{"body":{"body":{},"nonce":8968711,"is_query_device":true,"get":{},"token":"e474bba4b8e11b97b91019e61b7a018cdbaa3246","meta":{"Authorization":"tokene474bba4b8e11b97b91019e61b7a018cdbaa3246"},"path":"/v1/datastreams/light/datapoint/","post":{},"method":"GET"}{"nonce":{"nonce":5619936,"datapoint":{"x":100,"y":200,"z":0,"k":0,"l":"deliver_to_device":数据包实现对应的控制动作,例如,设置智能灯光调色令:{"body":{"body":{"datapoint":{"y":200,"x":100,"k":0,"z":0,"l":50}},"nonce":5619936,"is_query_device":true,"get":{},"token":"e474bba4b8e11b97b91019e61b7a018cdbaa3246","meta":{"Authorization":"tokene474bba4b8e11b97b91019e61b7a018cdbaa3246"},"path":"/v1/datastreams/light/datapoint/","post":{},"method":"POST"{"nonce":{"nonce":5619936,"datapoint":{"x":100,"y":200,"z":0,"k":0,"l":"deliver_to_device":其中,X1~500;Yred),Z(green),K(blue)调节智能灯的颜色,取值范围0~255;L为保留参数。curlcurl-XGET-H"Content-Type:application/json"-H"Authorization:token{"nonce":{"nonce":5619936,"datapoint":{"x":100,"y":200,"z":0,"k":0,"l":"deliver_to_device":curl-XPOST-H"Content-Type:application/json"-H"Authorization:tokencurl-XPOST-H"Content-Type:application/json"-H"Authorization:tokene474bba4b8e11b97b91019e61b7a018cdbaa3246"–d'{"datapoint":{"x":100,"y":200,"z":0,"k":0,"l":50}}curl-XPOST-H"Content-Type:application/json"-H"Authorization:tokencurl-XPOST-H"Content-Type:application/json"-H"Authorization:tokene474bba4b8e11b97b91019e61b7a018cdbaa3246"–d"{\"datapoint\":{\"x\":100,\"y\":200,\"z\":0,\"k\":0,\"l\":50}}"{"nonce":{"nonce":5619936,"datapoint":{"x":100,"y":200,"z":0,"k":0,"l":"deliver_to_device":其中,X1~500;Yred),Z(green),K(blue)调节智能灯的颜色,取值范围0~255;L为保留参数。{"nonce":{"nonce":1,"path":"/v1/datastreams/tem_hum/datapoint/","method":"POST","body":{"datapoint":{"x":35,"y":32}},"meta":{"Authorization":"token
{"status":200,{"status":200,"datapoint":{"updated":"2014-05-1418:
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年度南京二手房交易税费减免政策咨询合同
- 二零二五年度农田租赁与农业金融服务合同样本
- 2025年度瓶装纯净水原水采集与处理合同4篇
- 2025年度门面房屋租赁合同租赁双方信息保密协议4篇
- 2025年度海洋工程技术服务合同协议范本3篇
- 民政局二零二五年度离婚协议书电子模板使用许可4篇
- 二零二五版金融信息服务合同4篇
- 2025年度个人店面租赁合同范本简易版2篇
- 2025年度个人房产买卖合同法律咨询协议2篇
- 2025年度个人网络安全与隐私保护咨询服务合同范本3篇
- 梁湘润《子平基础概要》简体版
- 医院急诊医学小讲课课件:急诊呼吸衰竭的处理
- 肠梗阻导管在临床中的使用及护理课件
- 调料厂工作管理制度
- 2023年MRI技术操作规范
- 小学英语单词汇总大全打印
- 卫生健康系统安全生产隐患全面排查
- GB/T 15114-2023铝合金压铸件
- 三相分离器原理及操作
- 货物验收单表格模板
- 600字A4标准作文纸
评论
0/150
提交评论