文稿2b espiot democn v免责和公告_第1页
文稿2b espiot democn v免责和公告_第2页
文稿2b espiot democn v免责和公告_第3页
文稿2b espiot democn v免责和公告_第4页
文稿2b espiot democn v免责和公告_第5页
已阅读5页,还剩10页未读 继续免费阅读

付费下载

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

在user_main.c中实现。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_Manual” tform.h#defineESP_PARAM_START_SEC0x3Cuser_light.h#definePRIV_PARAM_START_SEC0x3Cuser_plug.h#definePRIV_PARAM_START_SEC0x3CIoTDemouser_esp_tform_initsotfAP+station共存的模式,用户连入ESP8266softAP接口的局域网,发指令让ESP8266station接口连接可入的路由(AP),Espressifuser_esp_tform_check_ip。连接服务/ 2/Demo设备进行通讯时,可采用curl命令。可在()进行指定版本的,后文中的curl指令请参照“Windowscurl”的示例。LinuxcurlCygwincurlcurl“Linux/Cygwincurl的示例。curl指令的工具(Linux/CygwinorWindows)则可将宏#defineSOFTAP_ENCRYPT关闭),格式为:ESP8266_softAPMAC_PASSWORD,开发例如curlcurl-XGET {"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-XGET返回status说明如下curlcurl-XPOST curl-XPOST curl-XPOST curlcurl-XPOST-H"Content-Type:application/json"-d{"Connect_Softap":{"authmode":"OPEN","channel":6," "password":""}}}}'. curlcurl-XPOST-H"Content-Type:application/json"-d \",\"password\":\"\"}}}}" 注意authmode支持:OPEN,PSK,2PSK,PSK/2PSK.password必须多于8bytes.查询station的连接状态。station模式。此时可以重新从步骤2进行连接。由宏定义#defineAP_CACHE控制此功能开关。PC1025UDPESP8266设备的查找,发送广播“AreYouEspressifIOTSmartDevice?”,ESP82661025UDP广播包进行响应响应I’mI’mI’mxx:xx:xx:xx:xx:xxMAC地址,yyy.yyy.yyy.yyyIP地址。curlcurl-XGET {"Response":{"Response":"status":}}curlcurl-XPOST-H"Content-Type:application/json"-d'{"Response":{"status":1}}' curlcurl-XPOST-H"Content-Type:application/json"-d"{\"Response\":{\"status\":1}}" curlcurl-XGET 响应{{"freq":100,"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}}'ht curlcurl-XPOST-H"Content-Type:application/json"-d"{\"freq\":100,\"rgb\":{\"red\":200,\"green\":0,\"blue\":0}}"ht 其中,freq取值范围为1~500;red、green、blue取值范围为0~255注意要向EspressifCloud申请,烧录到SPIflash。EspressifCloud{"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":EspressifCloudcurlcurl-XPOST-H"Authorization:tokenc'{"token":"bb6ec4c18fcf3e44ce9955f19fa3ba12"-7890"}'curlcurl-XPOST-H"Authorization:tokenc"{\"token\":\"bb6ec4c18fcf3e44ce9955f19fa3ba12"-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-22 bb6ec4c18fcf3e44ce9955f19fa3ba12为userkey(用户ID)的举例,需填入用户实际的userkey值,在EspressifCloud用户时获得。步骤如下: 并登陆EspressifCloud e474bba4b8e11b97b91019e61b7a018cdbaa3246ownerkeyPCownerkey对设备进行控制。,"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, ":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-2817:43:29","is_frozen":0,"key_id":387},"nonce": ,"message":"deviceidentified","status":200}EspressifCloudIP地址8,端口8000TCP{"path":{"path":/","method":"POST","meta":{"Authorization":响应{"status":{"status":200,"message":success","datetime":"2014-06-19 服务器发给设备的GET命令格式如下所示:{"body":{"body":{},,"is_query_device":true,"get":{},"e474bba4b8e11b97b91019e61b7a018cdbaa3246","meta":{"Authorization":"tokene474bba4b8e11b97b91019e61b7a018cdbaa3246"},"path":"/v1/datastreams/plug-status/datapoint/","post":{},"method":响应{"status":{"status":200,"datapoint":{"x":0},,{"body":{"body":{"datapoint":{"x":1}},,"is_query_device":"get":{},"token":"e474bba4b8e11b97b91019e61b7a018cdbaa3246",{"Authorization":"tokene474bba4b8e11b97b91019e61b7a018cdbaa3246"},"path":"/v1/datastreams/plug-status/datapoint/","post":{},"method":"POST","deliver_to_device":ESP8266智能插座完成控制动作后,向服务器发送一个更新状态成功的响应,格式如下,响应回noncenonce值一致,以表示每次控制和响应相互对响应{"status":{"status":200,"datapoint":{"x":1},,curl-XGET-H"Content-Type:application/json"-H"Authorization:tokene474bba4b8e11b97b91019e61b7a018cdbaa3246curl-XGET-H"Content-Type:application/json"-H"Authorization:tokene474bba4b8e11b97b91019e61b7a018cdbaa3246"http:/ 响应{"status":{"status":200,,"datapoint":{"x":1},curl-XPOST-H"Content-Type:application/json"-H"Authorization:tokencurl-XPOST-H"Content-Type:application/json"-H"Authorization:tokene474bba4b8e11b97b91019e61b7a018cdbaa3246"–d'{"datapoint":{"x":1}}'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,,"datapoint":{"x":1},服务器发给设备的GET命令格式如下所示:{"body":{"body":{},,"is_query_device":true,"get":{},"e474bba4b8e11b97b91019e61b7a018cdbaa3246","meta":{"Authorization":"tokene474bba4b8e11b97b91019e61b7a018cdbaa3246"},"path":"/v1/datastreams/light/datapoint/","post":{},"method":响应,"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}},,"is_query_device":true,"get":{},"token":"e474bba4b8e11b97b91019e61b7a018cdbaa3246","meta":{"Authorization":"tokene474bba4b8e11b97b91019e61b7a018cdbaa3246"},"path":"/v1/datastreams/light/datapoint/","post":{},"method":"POST"响应,"datapoint":{"x":100,"y":200,"z":0,"k":0,"l":"deliver_to_device":其中,X1~500;Yred),Zgreen),Kblue调节智能灯的颜色,取值范围0~255;L为保留参数。curl-XGET-H"Content-Type:application/json"-H"Authorization:tokene474bba4b8e11b97b91019e61b7a018cdbaa3246curl-XGET-H"Content-Type:application/json"-H"Authorization:tokene474bba4b8e11b97b91019e61b7a018cdbaa3246"http:/ 响应,"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}}'http:/ 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}}"http:/ 响应,"datapoint":{"x":100,"y":200,"z":0,"k":0,"l":"deliver_to_device":其中,X1~500;Yred),Zgreen),Kblue调节智能灯的颜色,取值范围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:42:54","2014-05-1418:42:54","visibly":1,"datastream_id":16,"at":"2014-05-18:42:54","y":32,"x":35,"id":ownerkey查询数据curl-XGET-H"Content-Type:application/json"-H"Authorization:tokencurl-XGET-H"Content-Type:application/json"-H"Authorization:tokene474bba4b8e11b97b91019e61b7a018cdbaa3246"http:/ 注意

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论