詳解2b espiot democn v0免責和公告_第1頁
詳解2b espiot democn v0免責和公告_第2頁
詳解2b espiot democn v0免責和公告_第3頁
詳解2b espiot democn v0免責和公告_第4頁
詳解2b espiot democn v0免責和公告_第5頁
已閱讀5頁,還剩10頁未讀 繼續免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

智能插座、智能燈、傳感器,并且通過服務器,實現了對設備的反向控制以及數據。在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. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論