Tessel Bluetooth


Allows your tesselation to work as a Bluetooth LE master or slave device.

Connect to your phone, FitBit, or other low-powered device.

  • Compatible with iOS 5+, Android 4.3+
  • Supports master mode to connect to other BLE devices and Tessels

For more info visit here.

How To Connect

Cylon.robot({
  connections: {
    tessel: { adaptor: 'tessel', port: 'A' }
  },

  devices: {
    ble: { driver: 'ble-ble113a' }
  },

});

How To Use

Example using a Direct Pin.

var Cylon = require('cylon');

Cylon.robot({
  connections: {
    tessel: { adaptor: 'tessel', port: 'A' }
  },

  devices: {
    ble: { driver: 'ble-ble113a' }
  },

  work: function(my) {
    my.ble.on('error', function (err) {
      console.log(err)
    });

    my.ble.on('discover', function(peripheral) {
      console.log("Discovered peripheral!", peripheral.toString());
    });

    after((2).seconds, function() {
      console.log("scanning...");
      my.ble.startScanning();
    });
  }
}).start();

Commands

Master Commands

bluetooth.startScanning( [options], callback(err))

Start searching for BLE peripherals.

bluetooth.stopScanning( callback(err) )

Stop Searching for BLE peripherals.

bluetooth.connect( peripheral, callback(err) )

bluetooth.disconnect( peripheral, callback(err )

bluetooth.discoverServices( peripheral, [serviceUUIDs], callback(err, services) )

Search for specific Services by passing in array of uuids. Returns array of Service objects.

bluetooth.discoverAllServices( peripheral, callback(err, services) )

Search for all Services of a peripheral. Returns array of Service objects.

bluetooth.discoverIncludedServices( periphreal, serviceUUID, callback(err, includedServices))

Find what services are included in this service, if any (pretty rare).

bluetooth.discoverCharacteristics( peripheral, [characteristicsUUIDs], callback(err, characteristics) )

Search for specific Characteristics by passing in array of uuids. Returns array of Characteristic objects.

bluetooth.discoverAllCharacteristics( peripheral, callback(err, characteristics) )

Search for all Characteristics of a peripheral. Returns array of Characteristic objects.

bluetooth.discoverAllServicesAndCharacteristics( peripheral, callback(err, results) )

Return all services and characteristics of a peripheral.

bluetooth.discoverCharacteristicsOfService( service, [characteristicUUIDs], callback(err, characteristics) )

Discover specific UUIDs of a service.

bluetooth.discoverAllCharacteristicsOfService( service, callback(err, characteristics) )

Discover the characteristics of a specific service.

bluetooth.discoverDescriptorsOfCharacteristic( characteristic, callback(err, descriptors) )

Discover the descriptors of a specific service.

bluetooth.discoverAllAttributes( peripheral, callback(err, attributes) )

Read all the services, characteristics, and descriptors of a peripheral.

bluetooth.read( characteristic, callback(err, value) )

Get the value of a remote characteristic.

bluetooth.write( characteristic, value, callback(err) )

Write the value of a remote characteristic. Value should be a buffer.

bluetooth.readDescriptor( descriptor, callback(err, value) )

Get the value of a remote descriptor.

bluetooth.writeDescriptor( descriptor, value callback(err) )

Get the value of a remote descriptor.

bluetooth.startNotifications( characteristic, callback(err) )

Subscribe to remote characteristic updates without having to indicate it was received.

bluetooth.stopNotifications( characteristic, callback(err) )

Stop being notified about remote characteristic updates.

bluetooth.startIndications( characteristic, callback(err) )

Subscribe to remote characteristic updates and indicate it was received.

bluetooth.stopIndications( characteristic, callback(err) )

Stop receiving remote characteristic updates and indicate it was received.

bluetooth.updateRSSI( peripheral, callback(err, rssi) )

Get signal strength of peripheral that we're connected to.

bluetooth.reset( callback(err))

Reset the module (useful in case of unexpected state ).

Slave Commands

bluetooth.startAdvertising(callback(err))

Begin advertising to master devices.

bluetooth.stopAdvertising( callback(err) )

Stop advertising.

bluetooth.setAdvertisingData( data, callback(err) )

Set the data the master receives in advertising packet.

bluetooth.writeLocalValue( index, data, callback(err) )

Write a local value to be read by a master.

bluetooth.readLocalValue( index, offset, callback(err, value))

Read local values that have been written. Offset is how many bytes in to read (reads in 32 byte chunks max ).

bluetooth.sendReadResponse( connection, errorCode, value, callback(err) )

If a master device requests to read a "user" attribute, you'll need to manually send it to them. This should be called after the "remoteReadRequest" event. If errorCode is zero, it will send the value, else it will send the error code back.

bluetooth.maxNumValues( callback(err, maxNumValues))

Get max number of values (V1.0.1 is 12 ).

Security Commands

bluetooth.setBondable( peripheral, bondable, callback(err))

Set whether a peripheral can be bonded to (not sure if this pertains to master mode as well ).

bluetooth.getBonds( callback(err, bonds) )

Get bonds with current devices.

bluetooth.deleteBonds( peripheral, callback(err) )

Delete any bonds with devices.

bluetooth.startEncryption( peripheral, callback(err) )

Start the encryption process.

bluetooth.enterPasskey( peripheral, callback(err) )

When a remote requests a passkey, you'll need to enter it.

bluetooth.setEncryptionKeySize( keysize, callback(err) )

Set the size of the encryption key.

bluetooth.setOOBData( data, callback(err) )

Set the out of band data.

bluetooth.enableMITMProtection( enable, callback(err) )

Choose whether to enable or disable MITM protection.

System Commands

bluetooth.getBluetoothAddress( callback(err, address) )

Get the current address of the device.

bluetooth.getMaxConnections( callback(err, maxConnections))

Get how many connections are supported by the module (currently at 4 ).

bluetooth.reset( callback(err) )

Reset the module.

Events

Master Events

'error'

'scanStart'

'scanStop'

'discover'

'connect'

'disconnect'

'servicesDiscover'

'characteristicsDiscover'

'descriptorsDiscover'

'characteristicRead'

'characteristicWrite'

'descriptorRead'

'descriptorWrite'

'notification'

'indication'

'rssiUpdate'

Slave Events

'startAdvertising'

'stopAdvertising'

'connect'

'disconnect'

'remoteWrite'

'remoteReadRequest'

'remoteNotification'

'remoteIndication'

'remoteUpdateStop'

'indicated'

Compatibility