andersonshatch / soma-ctrl

Node util for controlling SOMA smart shade via MQTT or HTTP
MIT License
21 stars 6 forks source link

TypeError: Cannot read property 'valueHandle' of undefined #74

Closed aaronpk closed 5 years ago

aaronpk commented 5 years ago

Describe the bug After some amount of time has passed, it appears it lost the connection to the device and is unable to see or control it.

To Reproduce Steps to reproduce the behavior:

Screenshots / Logs

Aug 21 06:21:15 hassbian soma.sh[15398]: /home/homeassistant/.nvm/versions/node/v9.11.2/lib/node_modules/soma-ctrl/node_modules/noble/lib/hci-socket/gatt.js:535
Aug 21 06:21:15 hassbian soma.sh[15398]:     this._queueCommand(this.writeRequest(characteristic.valueHandle, data, false), function(data) {
Aug 21 06:21:15 hassbian soma.sh[15398]:                                                         ^
Aug 21 06:21:15 hassbian soma.sh[15398]: TypeError: Cannot read property 'valueHandle' of undefined
Aug 21 06:21:15 hassbian soma.sh[15398]:     at Gatt.write (/home/homeassistant/.nvm/versions/node/v9.11.2/lib/node_modules/soma-ctrl/node_modules/noble/lib/hci-socket/gatt.js:535:57)
Aug 21 06:21:15 hassbian soma.sh[15398]:     at NobleBindings.write (/home/homeassistant/.nvm/versions/node/v9.11.2/lib/node_modules/soma-ctrl/node_modules/noble/lib/hci-socket/bindings.js:364:10)
Aug 21 06:21:15 hassbian soma.sh[15398]:     at Noble.write (/home/homeassistant/.nvm/versions/node/v9.11.2/lib/node_modules/soma-ctrl/node_modules/noble/lib/noble.js:325:19)
Aug 21 06:21:15 hassbian soma.sh[15398]:     at Characteristic.write (/home/homeassistant/.nvm/versions/node/v9.11.2/lib/node_modules/soma-ctrl/node_modules/noble/lib/characteristic.js:74:15)
Aug 21 06:21:15 hassbian soma.sh[15398]:     at SomaShade.stop (/home/homeassistant/.nvm/versions/node/v9.11.2/lib/node_modules/soma-ctrl/src/SomaShade.js:104:34)
Aug 21 06:21:15 hassbian soma.sh[15398]:     at MqttClient.MQTTConnector.mqttClient.on (/home/homeassistant/.nvm/versions/node/v9.11.2/lib/node_modules/soma-ctrl/src/MQTTConnector.js:24:28)
Aug 21 06:21:15 hassbian soma.sh[15398]:     at MqttClient.emit (events.js:180:13)
Aug 21 06:21:15 hassbian soma.sh[15398]:     at MqttClient._handlePublish (/home/homeassistant/.nvm/versions/node/v9.11.2/lib/node_modules/soma-ctrl/node_modules/mqtt/lib/client.js:987:12)
Aug 21 06:21:15 hassbian soma.sh[15398]:     at MqttClient._handlePacket (/home/homeassistant/.nvm/versions/node/v9.11.2/lib/node_modules/soma-ctrl/node_modules/mqtt/lib/client.js:336:12)
Aug 21 06:21:15 hassbian soma.sh[15398]:     at work (/home/homeassistant/.nvm/versions/node/v9.11.2/lib/node_modules/soma-ctrl/node_modules/mqtt/lib/client.js:292:12)
Aug 21 06:21:15 hassbian systemd[1]: soma.service: Main process exited, code=exited, status=1/FAILURE

Versions

andersonshatch commented 5 years ago

Is this a regular occurrence? Have yet to encounter it myself, and looks like an issue deep into noble bindings from first glance.

aaronpk commented 5 years ago

Yes, it was happening 100% of the time after about an hour of initializing.

I forgot I had submitted this bug, and kept on digging into the issue. It looks like it's actually a problem with the bluetooth stack on the raspberry pi. I disabled the internal bluetooth of the raspberry pi and switched to a USB dongle and it looks like the problem has gone away.

andersonshatch commented 5 years ago

Ah, well that's good to hear. Sounds like it's something that should be abstracted away by noble if anything, so I'll close this out.