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

fix for missing connection change event #42

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,12 @@ NobleBindings.prototype._onAdvertisementWatcherStopped = function(sender, e) {
};

NobleBindings.prototype._onConnectionStatusChanged = function(sender, e) {
const deviceUuid = sender.bluetoothAddress.toString(16);
// we store the uuid in strings of length 12
// make sure we get the correct length by appending 000...
let deviceUuid = sender.bluetoothAddress.toString(16);
if (deviceUuid.length < 12) {
deviceUuid = Array(12 - deviceUuid.length + 1).join('0') + deviceUuid;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In _onAdvertisementWatcherReceived, the deviceUuid is generated by these two lines of code:

	let address = formatBluetoothAddress(e.bluetoothAddress);
	let deviceUuid = address.replace(/:/g, '');

The result is the same, so it doesn't matter which way it's done, but I'd prefer it to be consistent in the two places. Maybe add a new helper function?

}
const deviceRecord = this._deviceMap[deviceUuid];
if (deviceRecord) {
const connectionStatus = sender.connectionStatus;
Expand Down