or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing
xxxxxxxxxx
物聯網 Lab5
物聯網目錄:
遠端燈泡同步控制
前備知識
打開 NSCL 與 GSCL 後,在 GSCL 部分打入
ss
出現如下視窗,再輸入start 25
開始燈泡模擬ipu.sample
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →達成目標
基本功能:
額外功能:
Switch
,且配合狀態同步顯示版面設計
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →一樣需注意元件初始值
send
:Url
填入http://電腦的 IPv4:1880/LAMP
recv
:Url
填入http://電腦的 IPv4:1880/STATUS
Clock1
:TimeInterval
填入 700 毫秒程式設計
這次主要因為
Switch
同步的關係,在程式上需要考慮的點會比較多recv
主要是進行定期同步,根據 OM2M 紀錄更新 APP 狀態,同時也更新Switch
lamp0
與lamp1
為紀錄下一輪同步前的狀態Switch
一起改變,而切換又會造成事件觸發,所以需要比較同步前的狀態是否有更動,如果不同就表示是 APP 主動切換燈泡Switch
目前狀況,不同就表示主動控制全部control
為主要關鍵字Node-RED 部分拉出以下所示
/LAMP
接收 APP 的控制訊息,根據數字執行對應的 OM2M 操作/STATUS
接收 APP 的同步訊息,先依序獲取燈泡最新狀態,再擷取對應的 true/false,最終合併傳回CONTROL
這邊使用status
變數作為switch
判斷,且使payload
為空,以此傳送空指令這邊的路徑與 OM2M 上的捷徑一致,ALL 的部分與其他的稍為不同
http://localhost:8181/om2m/gscl/applications/LAMP_0/lamps/true
http://localhost:8181/om2m/gscl/applications/LAMP_0/lamps/false
http://localhost:8181/om2m/gscl/applications/LAMP_1/lamps/true
http://localhost:8181/om2m/gscl/applications/LAMP_1/lamps/false
http://localhost:8181/om2m/gscl/groups/ON_ALL/membersContent
http://localhost:8181/om2m/gscl/groups/OFF_ALL/membersContent
http://localhost:8181/om2m/gscl/applications/LAMP_0/containers/DATA/contentInstances/latest/content
http://localhost:8181/om2m/gscl/applications/LAMP_1/containers/DATA/contentInstances/latest/content
EXTRACT
是一樣的function
,主要為了取得燈泡最新狀態的 true/falsejoin
這邊使用,
分隔,且設定接受到兩個訊息後自動合併實際畫面