Created
August 27, 2018 00:42
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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