Skip to content

Instantly share code, notes, and snippets.

@loginov-rocks
Created August 27, 2018 00:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loginov-rocks/b39e4e5c6d0c95b404172ad04baf8b28 to your computer and use it in GitHub Desktop.
Save loginov-rocks/b39e4e5c6d0c95b404172ad04baf8b28 to your computer and use it in GitHub Desktop.
How to make a web app for your own Bluetooth Low Energy device? Step 11
function disconnect() {
if (deviceCache) {
log('Disconnecting from "' + deviceCache.name + '" bluetooth device...');
deviceCache.removeEventListener('gattserverdisconnected',
handleDisconnection);
if (deviceCache.gatt.connected) {
deviceCache.gatt.disconnect();
log('"' + deviceCache.name + '" bluetooth device disconnected');
}
else {
log('"' + deviceCache.name +
'" bluetooth device is already disconnected');
}
}
characteristicCache = null;
deviceCache = null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment