noble interface should be hardened.
jeremydk opened this issue · comments
I had a client device (ios) disconnect and reconnect while Gymnasticon was actively sending bike data.
Feb 20 02:19:31 gymnasticon gymnasticon[1625]: [2021-02-20T07:19:31.578Z] received stats from bike [power=62W cadence=85rpm]
Feb 20 02:19:31 gymnasticon gymnasticon[1625]: noble warning: unknown handle 64 disconnected!
Feb 20 02:19:31 gymnasticon gymnasticon[1625]: noble: unknown peripheral 742558933534 connected!
Feb 20 02:19:31 gymnasticon gymnasticon[1625]: [2021-02-20T07:19:31.761Z] received stats from bike [power=62W cadence=85rpm]
Feb 20 02:19:31 gymnasticon gymnasticon[1625]: [2021-02-20T07:19:31.861Z] received stats from bike [power=62W cadence=85rpm]
Feb 20 02:19:32 gymnasticon gymnasticon[1625]: /home/pi/workspace/gymnasticon/node_modules/@abandonware/noble/lib/noble.js:564
Feb 20 02:19:32 gymnasticon gymnasticon[1625]: peripheral.mtu = mtu;
Feb 20 02:19:32 gymnasticon gymnasticon[1625]: ^
Feb 20 02:19:32 gymnasticon gymnasticon[1625]: TypeError: Cannot set property 'mtu' of undefined
Feb 20 02:19:32 gymnasticon gymnasticon[1625]: at Noble.onMtu (/home/pi/workspace/gymnasticon/node_modules/@abandonware/noble/lib/noble.js:564:18)
Feb 20 02:19:32 gymnasticon gymnasticon[1625]: at NobleBindings.emit (events.js:314:20)
Feb 20 02:19:32 gymnasticon gymnasticon[1625]: at NobleBindings.onMtu (/home/pi/workspace/gymnasticon/node_modules/@abandonware/noble/lib/hci-socket/bindings.js:277:8)
Feb 20 02:19:32 gymnasticon gymnasticon[1625]: at Gatt.emit (events.js:314:20)
Feb 20 02:19:32 gymnasticon gymnasticon[1625]: at Object.callback (/home/pi/workspace/gymnasticon/node_modules/@abandonware/noble/lib/hci-socket/gatt.js:329:10)
Feb 20 02:19:32 gymnasticon gymnasticon[1625]: at Gatt.onAclStreamData (/home/pi/workspace/gymnasticon/node_modules/@abandonware/noble/lib/hci-socket/gatt.js:133:26)
Feb 20 02:19:32 gymnasticon gymnasticon[1625]: at AclStream.emit (events.js:326:22)
Feb 20 02:19:32 gymnasticon gymnasticon[1625]: at AclStream.push (/home/pi/workspace/gymnasticon/node_modules/@abandonware/noble/lib/hci-socket/acl-stream.js:33:10)
Feb 20 02:19:32 gymnasticon gymnasticon[1625]: at NobleBindings.onAclDataPkt (/home/pi/workspace/gymnasticon/node_modules/@abandonware/noble/lib/hci-socket/bindings.js:288:15)
Feb 20 02:19:32 gymnasticon gymnasticon[1625]: at Hci.emit (events.js:314:20)
We should considering catching / retrying the bluetooth setup (assuming we have visibility at our scope) to become more durable to this. Systemd did restart the process, so this isn't a terminal case for folks.
Interesting! It looks like a race in noble where it tries to operate on a peripheral that is not in its internal list of peripherals. There is an open PR on noble abandonware/noble#165 which looks like it will prevent the TypeError from occurring.
I will keep an eye on that PR and update noble once they merge it.