AlCalzone / ioBroker.ble

Monitor Bluetooth Low Energy beacons
MIT License
41 stars 15 forks source link

Ruuvi-tag - unhandled promise rejection #20

Closed JonasR- closed 4 years ago

JonasR- commented 6 years ago

Hi,

I get the following error. When I activate the ruuvi-tag plugin

unhandled promise rejection: TypeError: Cannot read property 'startsWith' of undefined

JonasR- commented 6 years ago
2018-03-28 07:05:13.611 - debug: ble.0 discovered peripheral c0:cd:26:xxxxx
--
2018-03-28 07:05:13.611 - debug: ble.0 has advertisement: true
2018-03-28 07:05:13.612 - debug: ble.0 has serviceData: true
2018-03-28 07:05:13.614 - debug: ble.0 serviceData = [{"uuid":"feaa","data":{"type":"Buffer","data":[16,249,3,114,117,117,46,118,105,47,35,66,76,103,67,65,77,73,107,70]}}]
2018-03-28 07:05:13.614 - debug: ble.0 ruuvi-tag >> peripheral {"id":"c0cd266001a0","address":"c0:cd:26:xxxxx","addressType":"random","connectable":false,"advertisement":{"serviceData":[{"uuid":"feaa","data":{"type":"Buffer","data":[16,249,3,114,117,117,46,118,105,47,35,66,76,103,67,65,77,73,107,70]}}],"serviceUuids":["feaa"],"solicitationServiceUuids":[],"serviceSolicitationUuids":[]},"rssi":-91,"state":"disconnected"}
2018-03-28 07:05:13.615 - debug: ble.0 ruuvi-tag >> peripheral.advertisement {"serviceData":[{"uuid":"feaa","data":{"type":"Buffer","data":[16,249,3,114,117,117,46,118,105,47,35,66,76,103,67,65,77,73,107,70]}}],"serviceUuids":["feaa"],"solicitationServiceUuids":[],"serviceSolicitationUuids":[]}
2018-03-28 07:05:13.616 - error: ble.0 unhandled promise rejection: TypeError: Cannot read property 'startsWith' of undefined
AlCalzone commented 6 years ago

I'll check it out, thx!

AlCalzone commented 6 years ago

I can't reproduce it, which node version do you have?

JonasR- commented 6 years ago

Got node 6.13.1

Can it be that line 117 if (!peripheral.advertisement.localName.startsWith("Ruuvi")) is the problem? I dont see 'localName' in 'peripheral.advertisement'

AlCalzone commented 6 years ago

That might be true. The type definitions from noble are pretty bad, so I made my own. So far all devices had that property. Do you know if all Ruuvi tags have a MAC starting with "c0cd26"? I would like some quick check if the plugin should do additional work or not. For Xiaomi devices I can use the mac prefix for that.

Otherwise I need to use another strategy, e.g. try parsing the data on the first invokation of isHandling and remember if that worked.

JonasR- commented 6 years ago

I got four of them and none of them got the same start of the MAC address

c0:cd:26:...
e1:d4:48:...
e4:46:37:...
f4:a7:de:...

What about the service data uuid? Is it not enough?

AlCalzone commented 6 years ago

0xfeaa seems to be the general uuid for eddystone beacons, so most likely no.

AlCalzone commented 6 years ago

Hopefully fixed in v0.5.2

JonasR- commented 6 years ago

Okay, didnt know that. I will see if I can find out something more

v0.5.2 fixed the issue, I get data on my objects. Thanks :)

AlCalzone commented 6 years ago

I get data on my objects. Thanks :)

Great! Can you please send me some log data (ruuvi-tag >> got url: ... or ruuvi-tag >> got data: ...) when you set the adapter loglevel to "debug"? 3 or 4 logs should be enough. Don't forget to set the loglevel back to info afterwards.

JonasR- commented 6 years ago
2018-03-28 11:45:53.911 - debug: ble.0 ruuvi-tag >> got url: �ruu.vi/#BMADAMHAF
2018-03-28 11:45:53.989 - debug: ble.0 ruuvi-tag >> got url: �ruu.vi/#BFAUAMHAl
2018-03-28 11:45:54.063 - debug: ble.0 ruuvi-tag >> got url: �ruu.vi/#BFwSAMHAC
2018-03-28 11:45:54.194 - debug: ble.0 ruuvi-tag >> got url: �ruu.vi/#BFQTAMFcw
JonasR- commented 6 years ago

image