




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
智能插座、智能燈、傳感器,并且通過服務(wù)器,實現(xiàn)了對設(shè)備的反向控制以及數(shù)據(jù)。在user_ma voiduser_init(void)是上層程序的函數(shù),給用戶提供一個初始化接口,用戶可在該函數(shù)esp_iot_sdkexampleIOT_Demo,AT,smart_config三種應(yīng)用示例,實際上,也可以在IOT_Demosmart_configAPI,SDKAPI上層應(yīng)用均可調(diào)用。 user_devicefind.c—UDP傳輸功能的示例,提供ESP8266設(shè)備查找功能; tform.c—與Espressif云端服務(wù)器通信的示例;user_plug.c—智能插座的功能示例代碼;user_light.c— 下為應(yīng)用程序相關(guān)頭文件,需要注意的是"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接口的局域網(wǎng),發(fā)指令讓ESP8266station接口連接可入的路由(AP),Espressifuser_esp_tform_check_ip。連接服務(wù)/ /Demo設(shè)備進行通訊時,可采用curl命令??稍冢ǎ┻M行指定版本的,后文中的curl指令請參照“Windowscurl”的示例。若使用Linuxcurl或者Cygw url,后文中的curl指令請參照“Linux/Cygw url”的示例。IOT_DEMO中#defineSOFTAP_ENCRYPT定義softAP需要進行連接(用戶如果無需,則可將宏#defineSOFTAP_ENCRYPT關(guān)閉),格式為:ESP8266_softAPMAC_PASSWORD,開發(fā)者可自行修改esp_iot_sdk\app\lude\user_config.h中宏定義#definePASSWORD,配置。curlcurl-X響應(yīng){"Version":"Device":"manufacture","Espressif}}述),通過PC發(fā)送curl指令設(shè)置。curlcurl-XPOST-H"Content-Type:application/json"-d?curlcurl-XPOST-H"Content-Type:application/json"-d?
tokenEspressifCloudtokenEspressifCloud申請該設(shè)備的控制權(quán)限。因此,隨機token與ESP8266設(shè)備是一一對應(yīng)的關(guān)系,不能與其他設(shè)備共用。 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的連接狀態(tài)。 station模式。此時可以重新從步驟2進行連接。由宏定義#defineAP_CACHE控制此功能開關(guān)?!癆reYouEspressifIOTSmartDevice?”,ESP82661025UDP廣播包進行響應(yīng)響應(yīng)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設(shè)備憑借它作為認證,享受EspressifCloud提供的云端服務(wù),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對設(shè)備進行控制。{"nonce":{"nonce":560192812,"path":"/v1/device/identify","method":"GET",{"Authorization":"tokenEspressifCloud都需要向服務(wù)器發(fā)送這樣一包數(shù)據(jù)。其中“nonce”是一組隨機整數(shù),token后面是設(shè)備的master-device-key。EspressifCloudmaster-device-key后,會向設(shè)備回復(fù)一個{"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服務(wù)器發(fā)給設(shè)備的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":數(shù)據(jù)包實現(xiàn)對應(yīng)的控制動作,例如,打開智能插座開關(guān)令:{"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值一致,以表示每次控制和響應(yīng)相互對{"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":服務(wù)器發(fā)給設(shè)備的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":數(shù)據(jù)包實現(xiàn)對應(yīng)的控制動作,例如,設(shè)置智能燈光調(diào)色令:{"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)調(diào)節(jié)智能燈的顏色,取值范圍0~255;L為保留參數(shù)。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)調(diào)節(jié)智能燈的顏色,取值范圍0~255;L為保留參數(shù)。{"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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 家具廠質(zhì)量管理制度
- 應(yīng)急處置室管理制度
- 強電室安全管理制度
- 律師兩結(jié)合管理制度
- 微生物培訓(xùn)管理制度
- 心電圖質(zhì)量管理制度
- 急診科被褥管理制度
- 總承包投資管理制度
- 患標本安全管理制度
- 成品倉收貨管理制度
- 基本藥物政策培訓(xùn)
- 安徽省宣城市皖東南初中六校2024-2025學(xué)年上學(xué)期七年級期中考試數(shù)學(xué)試卷
- 古鎮(zhèn)旅游活動策劃方案
- 清遠市突發(fā)事件總體應(yīng)急預(yù)案
- 通風(fēng)與防排煙系統(tǒng)的施工方案
- 滬教版英語小學(xué)四年級上學(xué)期試卷與參考答案(2024-2025學(xué)年)
- 人工智能訓(xùn)練師理論知識考核要素細目表二級
- 2024年人教版一年級數(shù)學(xué)(下冊)期末試卷及答案(各版本)
- 《卒中患者吞咽障礙護理規(guī)范》
- DL∕T 698.45-2017 電能信息采集與管理系統(tǒng) 第4-5部分:通信協(xié)議-面向?qū)ο蟮臄?shù)據(jù)交換協(xié)議
- 2024版房屋租賃合同范本房屋租賃合同
評論
0/150
提交評論