UNPKG

gattacker

Version:
33 lines (25 loc) 703 B
var bleno = require('../..'); var BlenoPrimaryService = bleno.PrimaryService; var EchoCharacteristic = require('./characteristic'); console.log('bleno - echo'); bleno.on('stateChange', function(state) { console.log('on -> stateChange: ' + state); if (state === 'poweredOn') { bleno.startAdvertising('echo', ['ec00']); } else { bleno.stopAdvertising(); } }); bleno.on('advertisingStart', function(error) { console.log('on -> advertisingStart: ' + (error ? 'error ' + error : 'success')); if (!error) { bleno.setServices([ new BlenoPrimaryService({ uuid: 'ec00', characteristics: [ new EchoCharacteristic() ] }) ]); } });