Please enable JavaScript.
Coggle requires JavaScript to display documents.
MQTT - Coggle Diagram
MQTT
shadow
mqtt 在 getValue 時可以取得資料
設備 offline 時可以設定
可以記錄 desired & reported 以及更新時間
設備在第一次 online 時,可以取得最後的設定 apply 在自己身上
第一次 login 如何 sync 到 device 的所有 settings?
在device online 時 shadow 檢查後台是否有資料,若沒有則透過 getAllSettings topic 或 command 來取得
但是這是必要的嗎?
第一次 login 如何取得 device profile?
在device online 時 shadow 檢查後台是否有資料,若沒有則透過 getProfile topic 或 command 來取得
device online 之後如何 sync shadow 上的 settings?
device 應該要能夠 publish 到一個特殊的 shadow topic 或 http api來取得 shadow 上的狀態
shadow 必須根據 device profile 來判斷 request 是否合法, 但有個問題如果 value 有範圍該怎麼辦?
mqtt topic
report
XXX/propertyId
收到 cmd 修改成功後,必須 report 狀態上來
cmd
XXX/propertyId/cmd
欄位格式
一般設備
report:<publicUDID>/<secretId>/<propertyID>
cmd:<publicUDID>/<secretId>/<propertyID>/cmd
gateway
report:<publicUDID>/<secretId>/<nodeId>/<propertyID>
cmd:<publicUDID>/<secretId>/<nodeId>/<propertyID>/cmd
getAllSettings
XXX/getAllSettings
XXX/getAllSettings/req
getProfile
XXX/getProfile
XXX/getProfile/req
shadow
$SYS/<publicUDID>/<secretId>/shadow
$SYS/<publicUDID>/<secretId>/shadow/req
create instance
主將 secretId 帶上,如果重新 create 則原本的 secretId 會失效
設定 shadow 位置? 或是設置是否支持 shadow
online/offline
XXX/online
設備必須設定 last will
online/offline 狀態也會被更新到 shadow 上
Settings
UI profile
UI profile 要能夠使用 property id 來做操作
Device profile
要支持 property id 的表達方式
mqtt 要支持取得 profile 的 topic
mqtt 要支持取得所有目前狀況的 topic
支持 getValue
支持 setValue
Command
nebula 向 gateway server 拿到 bridge server
mqtt 向 gateway server 拿到協議轉換 server
協議轉換 server 收到 client 的 setValue 時,轉換成 publish 到該 property id
Client 發送 command 時必須不加密
協議轉換 server 收到 getValue 時則直接跟 shadow 取值
device 處理完 cmd 時,必須 report 給 mqtt 或是 shadow
App 操作
取得 profile
取得初始值
點取控制發出 command
點取統計歷史資料
Report
透過 mqtt
如何分辨是設備還是 client
根據 username? client id?
透過 http
如何認證是設備?
需夾帶完整 UDID
只能設備發送
最終 report 格式為何?
JSON
必須讓 mqtt topic 容易轉換
可能需要研究該如何從 broker 收取資料並且做轉換
設備如果被 command 改變了,應該也要 report 更新狀態給 server?
有哪些 propertyId 需要 report? 怎麼判斷?
Binding
交換 credential
secret id
在 nebula 是 bridge server 幫助過濾 client
在 mqtt 是讓沒綁過的 client 不知道 topic name
Psk
在 nebula 是保護 data 不讓 server 看到
在 mqtt 則不需要使用 psk
會遇到的問題
Device 沒辦法支持 https
Device 透過 mqtt 來做綁定
Client 端必須有辦法透過 UDID 來連到特殊的 binding server
nebula commad / mqtt topic 轉換
getValue
setValue
單值
{"value":true}
多值
{"temp":12,"hum":90}
getAllSettings
getProfile
device profile with property ids
新增 propertySets 欄位
functionSets 必須有 propertyId
function 必須有 getValue, setValue, 裡面各自描述有的 propertyIds
wifi setting
smart config
TUTK AP mode wifi config
online/offline 狀態
mqtt 會將 online 狀態發至 shadow 上
nebula 則是 bridge server 會將狀態通報給 shadow
Data histories & statistics
只統計 reported 結果
IFTTT
透過 shadow 的 http API cmd 方式來改變
Live view
UI profile with property ids