Example #1
0
var advertise_new_mfr_data = function (new_mfr_data) {
  new_mfr_data = new Buffer(new_mfr_data);

  if (!tessel_ble_module_ready) {
    console.log('WARNING: Pending opertaion since Tessel BLE module is not ready');
    tessel_ble_module_ready_pending_task = function () { advertise_new_mfr_data(new_mfr_data); };
    return false;
  }

  LED_BLUE.write(1);
  var ad_data = bleadvertise.serialize({
    flags: [0x04],
    mfrData: new_mfr_data,
    completeName: DEVICE_NAME
  });
  tessel_ble_module.stopAdvertising(function () {
    console.log('Tessel BLE module stops advertising itself');
    tessel_ble_module.setAdvertisingData(ad_data, function () {
      console.log('Tessel BLE module updates its advertisement data', new_mfr_data);
      tessel_ble_module.startAdvertising(function () {
        console.log('Tessel BLE module starts advertising itself');
        LED_BLUE.write(0);
      });
    });
  });
  return true;
};
Example #2
0
var ble = bleLib.use(tessel.port['A'], function(){
  console.log('BLE ready');
  var advertisement = bleadvertise.serialize({
    flags: [0x02, 0x04],
    shortName: 'Reach',
    incompleteUUID128: ['d752c5fb13804cd5b0efcac7d72cff20']
  });
  ble.setAdvertisingData(advertisement, function(err){
    if (!err){
      console.log('Advertising data set');
      ble.startAdvertising(function(err){
        if(!err){
          console.log('Advertising started');
        }
      });
    }
  });
});
Example #3
0
var tessel = require('tessel');
var bleLib = require('ble-ble113a');
var bleadvertise = require('bleadvertise');

var packet = {
    flags: [0x02, 0x04], // Connectable, BLE only
    incompleteUUID128 : ['08c8c7a06cc511e3981f0800200c9a66'], // Tessel Firmware Version Service UUID
    shortName : 'Team19'
}

    var ad = bleadvertise.serialize(packet);

var peripheral = bleLib.use(tessel.port['A'], function(){
	peripheral.setAdvertisingData(ad, function(){
		peripheral.startAdvertising();
		console.log('Now advertising');
	    });
    });