Open shundroid opened 7 years ago
noble側の問題っぽいですかね。 現在調査中ですが、disconnectした後にconnectした場合、 servicesなどがうまく探索できていないような…?
engine:ws received "42["removeOrb","SK-D215"]" +9s
engine:socket packet +0ms
socket.io-parser decoded 2["removeOrb","SK-D215"] as {"type":2,"nsp":"/","data":["removeOrb","SK-D215"]} +410ms
socket.io:socket got packet {"type":2,"nsp":"/","data":["removeOrb","SK-D215"]} +9s
socket.io:socket emitting event ["removeOrb","SK-D215"] +0ms
socket.io:socket dispatching an event ["removeOrb","SK-D215"] +0ms
removing...
hci disconnect - writing: 01060403010e13 +1ms
hci onSocketData: 040f0400010604 +2ms
hci event type = 4 +0ms
hci sub event type = 15 +0ms
hci status = 0 +0ms
hci cmd = 1030 +0ms
hci onSocketData: 04050400010e16 +8ms
hci event type = 4 +0ms
hci sub event type = 5 +0ms
hci handle = 3585 +0ms
hci reason = 22 +0ms
Now disconnected from Sphero (SK-D215)
socket.io:client writing packet {"type":2,"data":["updateOrbs",[]],"nsp":"/"} +11ms
socket.io-parser encoding packet {"type":2,"data":["updateOrbs",[]],"nsp":"/"} +1ms
socket.io-parser encoded {"type":2,"data":["updateOrbs",[]],"nsp":"/"} as 2["updateOrbs",[]] +0ms
engine:socket sending packet "message" (2["updateOrbs",[]]) +19ms
engine:socket flushing buffer to transport +0ms
engine:ws writing "42["updateOrbs",[]]" +0ms
engine:ws received "2" +8s
engine:socket packet +0ms
engine:socket got ping +0ms
engine:socket sending packet "pong" (undefined) +0ms
engine:socket flushing buffer to transport +0ms
engine:ws writing "3" +0ms
engine:ws received "42["addOrb","SK-D215",""]" +14s
engine:socket packet +0ms
socket.io-parser decoded 2["addOrb","SK-D215",""] as {"type":2,"nsp":"/","data":["addOrb","SK-D215",""]} +22s
socket.io:socket got packet {"type":2,"nsp":"/","data":["addOrb","SK-D215",""]} +22s
socket.io:socket emitting event ["addOrb","SK-D215",""] +0ms
socket.io:socket dispatching an event ["addOrb","SK-D215",""] +0ms
changed! e8b42f8ad215
hci set scan enabled - writing: 010c20020001 +4ms
hci set scan parameters - writing: 010b200701100010000000 +0ms
hci set scan enabled - writing: 010c20020101 +0ms
hci onSocketData: 040e04010c200c +1ms
hci event type = 4 +0ms
hci sub event type = 14 +0ms
hci cmd = 8204 +0ms
hci status = 12 +0ms
hci result = +0ms
hci onSocketData: 040e04010b2000 +1ms
hci event type = 4 +0ms
hci sub event type = 14 +0ms
hci cmd = 8203 +0ms
hci status = 0 +0ms
hci result = +0ms
hci onSocketData: 040e04020c2000 +1ms
hci event type = 4 +0ms
hci sub event type = 14 +0ms
hci cmd = 8204 +0ms
hci status = 0 +0ms
hci result = +0ms
noble scanStart +0ms
hci onSocketData: 043e160201000115d28a2fb4e80a02010603ff3530020af6c8 +55ms
hci event type = 4 +0ms
hci sub event type = 62 +0ms
hci LE meta event type = 2 +0ms
hci LE meta event status = 1 +0ms
hci LE meta event data = 000115d28a2fb4e80a02010603ff3530020af6c8 +0ms
hci type = 0 +0ms
hci address = e8:b4:2f:8a:d2:15 +0ms
hci address type = random +0ms
hci eir = 02010603ff3530020af6 +0ms
hci rssi = -56 +0ms
gap advertisement = {"localName":"SK-D215","txPowerLevel":-10,"manufacturerData":{"type":"Buffer","data":[53,48]},"serviceData":[],"serviceUuids":[],"solicitationServiceUuids":[],"serviceSolicitationUuids":[]} +0ms
hci onSocketData: 043e270201040115d28a2fb4e81b11072753706865726f2d5475a02b6f74bb220809534b2d44323135c8 +1ms
hci event type = 4 +0ms
hci sub event type = 62 +0ms
hci LE meta event type = 2 +0ms
hci LE meta event status = 1 +0ms
hci LE meta event data = 040115d28a2fb4e81b11072753706865726f2d5475a02b6f74bb220809534b2d44323135c8 +0ms
hci type = 4 +0ms
hci address = e8:b4:2f:8a:d2:15 +0ms
hci address type = random +0ms
hci eir = 11072753706865726f2d5475a02b6f74bb220809534b2d44323135 +0ms
hci rssi = -56 +0ms
gap advertisement = {"localName":"SK-D215","txPowerLevel":-10,"manufacturerData":{"type":"Buffer","data":[53,48]},"serviceData":[],"serviceUuids":["22bb746f2ba075542d6f726568705327"],"solicitationServiceUuids":[],"serviceSolicitationUuids":[]} +0ms
name: SK-D215, uuid: e8b42f8ad215
hci set scan enabled - writing: 010c20020001 +1ms
hci create le conn - writing: 010d201960003000000115d28a2fb4e80006000c000000c80004000600 +0ms
hci set scan enabled - writing: 010c20020001 +0ms
hci onSocketData: 040e04020c2000 +3ms
hci event type = 4 +0ms
hci sub event type = 14 +0ms
hci cmd = 8204 +0ms
hci status = 0 +0ms
hci result = +0ms
noble scanStop +0ms
hci onSocketData: 040f0400020d20 +1ms
hci event type = 4 +0ms
hci sub event type = 15 +5ms
hci status = 0 +2ms
hci cmd = 8205 +0ms
hci onSocketData: 040e04010c200c +0ms
hci event type = 4 +0ms
hci sub event type = 14 +0ms
hci cmd = 8204 +0ms
hci status = 12 +1ms
hci result = +0ms
hci onSocketData: 043e130100010e000115d28a2fb4e80c000000c80000 +140ms
hci event type = 4 +0ms
hci sub event type = 62 +0ms
hci LE meta event type = 1 +0ms
hci LE meta event status = 0 +0ms
hci LE meta event data = 010e000115d28a2fb4e80c000000c80000 +0ms
hci handle = 3585 +0ms
hci role = 0 +0ms
hci address type = random +0ms
hci address = e8:b4:2f:8a:d2:15 +0ms
hci interval = 15 +0ms
hci latency = 0 +0ms
hci supervision timeout = 2000 +0ms
hci master clock accuracy = 0 +1ms
att e8:b4:2f:8a:d2:15: write: 020001 +1ms
hci write acl data pkt - writing: 02010e070003000400020001 +0ms
socket.io:client writing packet {"type":2,"data":["log","Catched unknown error: \nTypeError: Cannot read property '22bb746f2bbd75542d6f726568705327' of undefined","error"],"nsp":"/"} +219ms
socket.io-parser encoding packet {"type":2,"data":["log","Catched unknown error: \nTypeError: Cannot read property '22bb746f2bbd75542d6f726568705327' of undefined","error"],"nsp":"/"} +1ms
socket.io-parser encoded {"type":2,"data":["log","Catched unknown error: \nTypeError: Cannot read property '22bb746f2bbd75542d6f726568705327' of undefined","error"],"nsp":"/"} as 2["log","Catched unknown error: \nTypeError: Cannot read property '22bb746f2bbd75542d6f726568705327' of undefined","error"] +0ms
engine:socket sending packet "message" (2["log","Catched unknown error: \nTypeError: Cannot read property '22bb746f2bbd75542d6f726568705327' of undefined","error"]) +220ms
engine:socket flushing buffer to transport +1ms
engine:ws writing "42["log","Catched unknown error: \nTypeError: Cannot read property '22bb746f2bbd75542d6f726568705327' of undefined","error"]" +0ms
TypeError: Cannot read property '22bb746f2bbd75542d6f726568705327' of undefined
ぎょえー、わからないです!
分かったかも〜!
peripheral.disconnect()した後も、peripheral.servicesが保持されてしまっている。 だから、再度peripheral.connect()したときに、実際にはまだ接続されていないのにservicesがあるように見えてしまうっぽい。 https://github.com/sandeepmistry/noble/blob/73a01ea52063cbaa5b2649250fae146be36588dc/lib/peripheral.js#L17
加えて、sphero.jsのconnectにも問題があって、何度もconnectすると問題になる。 https://github.com/comozilla/sphero.js/pull/2
nobleの修正はこちら https://github.com/comozilla/noble/pull/1
テストコード
const sphero = require("sphero"),
orb = sphero("xx:xx:xx:xx:xx:xx"); // change BLE address accordingly
orb.connect().then(() => {
const direction = Math.floor(Math.random() * 360);
orb.roll(100, direction);
setTimeout(() => {
new Promise((resolve, reject) => {
orb.disconnect(() => {
resolve()
});
}).then(() => {
console.log("disconnected");
setTimeout(() => {
console.log("connecting...");
orb.connect().then(() => {
console.log("reconnected");
orb.roll(100, direction);
orb.disconnect(() => {
console.log("disconnected");
});
});
}, 5000);
});
}, 3000);
});
sphero-websocketの依存ですが、この修正どうやって反映させましょうかね?
ありがとうございます。
@Babibubebon
そうですねえ、 comozilla/sphero-websocket
のほうの
sphero モジュールを comozilla のほうのモジュールに
差し替えましょうか
どうでしょう
直しておきますー
と思ったら直っている!
うーん、となると次、onigo-server 側で npm i したら 新しい sphero モジュールのコミットが sphero-websocket を通して入るんですよね
どうだろう、sphero モジュール側でリリースを切って、そこを参照させるようにしましょうか?
取り急ぎ、sphero-websocketのsphero, nobleのdepsを、comozillaのリポジトリを参照するように変更しました。
今は面倒なんでdevelop
ブランチを参照させちゃいましたが、確かにあんまり良くないので、後でどうにかしましょう・・・
ありがとうございます。 わかりました。