A wrapper for BLE APIs in FxOS. It help developers handle BLE things easier.
- Declare bluetooth-helper as dependency module in
bower.json
. Please check bower.json. - Download the module:
bower install
. - Import the module in
<head>
in HTML file.html<script src="bower_components/bluetooth-helper/lib/bluetooth_helper.js"></script>
- Done.
var ble = Bluetooth.connect('BT_NAME', 'e4:a9:35:a4:e:10');
ble.on('connected', function() {
// You need to send one byte or more data in HEX format at one time.
ble.send('EE');
});
ble.startNotifications();
ble.on('data', function(evt) {
console.log('data: ' + JSON.stringify(evt));
});
ble.disconnected();
ble.on('disconnected', function() {
ble.connect();
})
- Design and implement API: https://gist.github.com/evanxd/e23c805724cda59b8469