|
试了一下。下载了blinker-js,然后改了一下example
会把{"btn-light":"on"}改成"light-slide":{"val":0}
JS Code:
import { BlinkerDevice } from '../lib/blinker';
import { ButtonWidget, NumberWidget } from '../lib/widget';
let device = new BlinkerDevice("BUTTON-DEVICE-NAME", {
sourceCheck: false
});
device.ready().then(() => {
let message = {"btn-light" : "on"}
let toDevice = 'SWITCH-DEVICE-NAME' // 目标设备的识别码
device.sendMessage(message, toDevice)
});
have strange issue as below log in 8266 SWITCH Device side:
13:46:05.573 -> [713713] Got: {"fromDevice":"BUTTONID","data":{"btn-light":"on"}}
13:46:05.606 -> [713714] data: {"btn-light":"on"}
13:46:05.606 -> [713714] fromDevice: BUTTONID
13:46:05.606 -> [713717] _sharerCount: 0
13:46:05.606 -> [713719] ERROR: No authority&share uuid found, check is from bridge/share device, data: {"btn-light":"on"}
13:46:05.639 -> [713748] available: 1
13:46:05.639 -> [713748] checkAvail: 1
13:46:05.639 -> [713749] parse data: {"fromDevice":"BUTTONID","data":{"btn-light":"on"}}
13:46:05.639 -> [713749] defined BLINKER_ARDUINOJSON
13:46:05.639 -> [713753] autoManager begin: 0 0
13:46:05.639 -> [713755] get_key: null
13:46:05.639 -> [713758] checkNum count: 1
13:46:05.639 -> [713760] checkNum count: 1
13:46:05.639 -> [713762] Blinker readString: {"fromDevice":"BUTTONID","data":{"btn-light":"on"}}
13:46:05.639 -> [713771] autoFormatData key: light-slide, json: "light-slide":{"val":0}
13:46:05.673 -> [713777] new.
13:46:05.673 -> [713778] flush
13:46:05.673 -> [713780] needFreshShare
13:46:05.673 -> [713782] message: /share/device?deviceName=SWICHID&key=SWICHKEY
13:46:05.673 -> [713790] blinker server begin
13:46:05.673 -> [713792] Freeheap: 32664
13:46:05.851 -> [713960] HTTPS begin: http://iot.diandeng.tech/api/v1/user/device/share/device?deviceName=SWICHID&key=SWICHKEY
13:46:05.851 -> [713960] HTTPS payload: /share/device?deviceName=SWICHID&key=SWICHKEY
13:46:05.851 -> [713968] [HTTP] status... code: 200
13:46:05.851 -> [713972] {"detail": {"users": []}, "message": 1000}
13:46:05.851 -> [713977] _type: 16
13:46:05.851 -> [713978] payload: {"users":[]}
13:46:05.851 -> [713982] sharers data: {"users":[]}
13:46:05.885 -> [713984] print: {"light-slide":{"val":0}}
13:46:05.885 -> [713988] Proto print...
13:46:05.885 -> [713990] Freeheap: 32568
13:46:05.885 -> [713992] isJson: {"data":{"light-slide":{"val":0}},"fromDevice":"SWICHID","toDevice":"APPDEVICEID","deviceType":"OwnApp"}
13:46:05.885 -> [714006] MQTT Publish...
13:46:05.885 -> [714008] Freeheap: 32568
13:46:05.885 -> [714010] _print_times: 1
13:46:05.885 -> [714013] {"data":{"light-slide":{"val":0}},"fromDevice":"SWICHID","toDevice":"APPDEVICEID","deviceType":"OwnApp"}
13:46:05.918 -> [714025] ...OK!
13:46:05.918 -> [714026] Freeheap: 31896
13:46:05.918 -> [714028] Freeheap: 32928
13:46:35.922 -> [744043] MQTT Ping!
13:46:35.922 -> [744043] Freeheap: 33968
|
|