student project

FRDM-K64F實作的通訊協定

04 Jul 2016

目前FRDM-K64F 可傳送的資料如下,利用"GET" 可以取得下面兩種資料 目前payload 都是json格式

按鈕: 每按一下,button counter 會加一

{
    "async-response-id": "867560668#b963e35d-2f14-4142-a556-1e0e45cf0efc@ede09176-f03b-481c-875d-5b44c4c3c2e7/digital_inp/0/button_1"
}
Waiting for asynchronous response...
Asynchronous response received in the notification channel ...
{
    "id": "867560668#b963e35d-2f14-4142-a556-1e0e45cf0efc@ede09176-f03b-481c-875d-5b44c4c3c2e7/digital_inp/0/button_1",
    "status": 200,
    "payload": "eyJidXR0b25fMSI6W3siY291bnRlciI6MTB9XX0=",
    "ct": "text/plain",
    "max-age": 0
}
Base64 decoded payload:  {"button_1":[{"counter":10}]}

姿態偵測:只要稍微更動板子角度,讀取的資料就會變化

{
    "async-response-id": "867560670#b963e35d-2f14-4142-a556-1e0e45cf0efc@ede09176-f03b-481c-875d-5b44c4c3c2e7/analog_sensor/0/axis_sensor"
}
Waiting for asynchronous response...
Asynchronous response received in the notification channel ...
{
    "id": "867560670#b963e35d-2f14-4142-a556-1e0e45cf0efc@ede09176-f03b-481c-875d-5b44c4c3c2e7/analog_sensor/0/axis_sensor",
    "status": 200,
    "payload": "eyJheGlzX3NlbnNvciI6W3siWCI6LTE4OTQsIlkiOi00MDMsIloiOi0xODk0fV19",
    "ct": "text/plain",
    "max-age": 0
}
Base64 decoded payload: {"axis_sensor":[{"X":-1894,"Y":-403,"Z":-1894}]}

接收 POST :目前只有接收事件後,LED燈閃爍4下

{
    "async-response-id": "867560672#b963e35d-2f14-4142-a556-1e0e45cf0efc@ede09176-f03b-481c-875d-5b44c4c3c2e7/led_blink/0/blinker"
}
Waiting for asynchronous response...
Asynchronous response received in the notification channel ...
{
    "id": "867560672#b963e35d-2f14-4142-a556-1e0e45cf0efc@ede09176-f03b-481c-875d-5b44c4c3c2e7/led_blink/0/blinker",
    "status": 200,
    "payload": "",
    "max-age": 60
}
05 Jul 2016

good~

這部份在Pi上也將實現類似的結果, 其中server 送出POST後, 帶不同payload(command) 在板子讀出payload 後, 進行字串解析, 做不同command 的處理

server 送出HTTP GET 要能傳回BME280 溫溼度 /BME280/0/temp /BME280/0/humility /BME280/0/pressure

server 送出HTTP POST 要能控制GPIO, 如 "GPIO/0/on" "GPIO/0/off" "GPIO/22/on" "GPIO/22/off"