Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After a connection I got the error: _TypeError: Cannot read property 'write' of undefined #1

Open
BjarkeVadPedersen opened this issue Nov 16, 2017 · 1 comment

Comments

@BjarkeVadPedersen
Copy link

Hi,

Thank you for a nice script, got the functionality up and running with home assistant.

Just a few notes on what I experienced:
I had to change the name of the expected device from ITAG to iTAG to get the script to do the connection. I guess the devices vary in name.

Also initially after a connection I got the error:
TypeError: Cannot read property 'write' of undefined
at peripheral.discoverAllServicesAndCharacteristics (/home/pi/itag-mqtt-bridge/src/index.js:74:33)
at Peripheral. (/home/pi/node_modules/noble/lib/peripheral.js:101:13)
at Service. (/home/pi/node_modules/noble/lib/service.js:53:7)
at Object.onceWrapper (events.js:293:19)
at emitOne (events.js:96:13)
at Service.emit (events.js:191:7)
at Noble.onCharacteristicsDiscover (/home/pi/node_modules/noble/lib/noble.js:261:13)
at emitThree (events.js:116:13)
at NobleBindings.emit (events.js:197:7)
at NobleBindings.onCharacteristicsDiscovered (/home/pi/node_modules/noble/lib/hci-socket/bindings.js:339:8)

which I solved by uncommenting the relevant lines after line 74:

//linkLossAlertLevelCh.write(new Buffer([itag_characteristic_alertLevel_value_noAlert]), true, (error)=>{
// if(error) log.error(error)
// log.debug(ITAG peripheral id: ${peripheral.id} LinkLoss AlertLevel write success)
// if(beep_on_itag_connect==='true') alertITAGContinous(peripheral.id,200)
// });

I am not sure if this error is only related to my specific installation.

/Bjarke

@tomasgatial
Copy link
Owner

Hi,

Thank you for your looking into the code, and also bringing this up.

Seem that China never disappoints with its diversity. Also when it comes to small BLE trackers. :-)

The reason for the disabling the Link Loss is that my specific device had a LinkLoss feature enabled by default. When the connection was interrupted by turning of the mqtt bridge app, or by simply walking too far from the raspberry, my device would start beeping. Thats not exactly the use case i wanted.

Where did you get your BLE tag, would you mind sharing a reference (link to e-shop)?

Thanks,
Tomas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants