-
Notifications
You must be signed in to change notification settings - Fork 72
Scratch micro:bit extension与Scratch Link通信的细节
wwj718 edited this page Jul 12, 2019
·
6 revisions
在Scratch中选择microbit extension,前端发送发现硬件消息:
{"jsonrpc":"2.0","method":"discover","params":{"filters":[{"services":[61445]}]},"id":0}
Scratch Link回复:{"id":0,jsonrpc":"2.0","result":null}
, 之后不断回复:
{"params":{"name":"BBC micro:bit [gazat]","rssi":-32,"peripheralId":"89FC6234-54E4-4E68-8EE0-C947ECF9A292"},"method":"didDiscoverPeripheral","jsonrpc":"2.0"}
点击连接,前端发送消息:
{"jsonrpc":"2.0","method":"connect","params":{"peripheralId":"89FC6234-54E4-4E68-8EE0-C947ECF9A292"},"id":1}
Scratch Link回复:
{"id":1,"result":null,"jsonrpc":"2.0"}
前端发送消息:
{"jsonrpc":"2.0","method":"read","params":{"serviceId":61445,"characteristicId":"5261da01-fa7e-42ab-850b-7c80220097cc","startNotifications":true},"id":2}
之后Scratch Link回复
{"id":2,"result":{"encoding":"base64","message":""},"jsonrpc":"2.0"}
{"params":{"encoding":"base64","message":""},"method":"characteristicDidChange","jsonrpc":"2.0"}
{"params":{"encoding":"base64","message":"\/8oCygAAAAAAAAAAAAAAAAAAAAA="},"method":"characteristicDidChange","jsonrpc":"2.0"}
前端发送
{"jsonrpc":"2.0","method":"write","params":{"serviceId":61445,"characteristicId":"5261da02-fa7e-42ab-850b-7c80220097cc","message":"ggoVEQoE","encoding":"base64","withResponse":true},"id":3}
link回复
{"id":3,"jsonrpc":"2.0","result":6}
没有发送通信
猜测是直接断掉wss,link知道之后 自动清理
新开了wss
...