Bluefruit LE app interface

The Adafruit Bluefruit LE Connect app is an application made by Adafruit that makes it easy to use your phone or tablet to control Adafruit Bluetooth LE devices.

While the app is designed for Adafruit's Bluefruit LE series of boards, most of the functionality uses the standard 'Nordic UART' Bluetooth characteristics, which Espruino also uses for communication with the IDE.

Controller Mode

Connect to your Bluetooth Espruino device and upload the following code:

var fruit = require("BluefruitLE").connect();

The fruit variable will then emit the following events:

For instance if you want to turn an LED on or off based on button 1 in the 'Controller' section of the app, just do:

var fruit = require("BluefruitLE").connect();
fruit.on('button',function(e) {
  if (e.button==1) LED.write(e.state);
});

The BluefruitLE module will detect whether the IDE or Bluefruit app is connecting and will only enable itself if the app is connecting, so you can still connect as normal with the IDE.

Once you've uploaded your code:

UART Mode

The Bluefruit app also supports UART mode, which will communicate directly with Espruino's REPL without needing the BluefruitLE module.

So you can just enter JavaScript commands directly and they will be executed.

If you want to interpret the commands yourself you can do:

// when a device first connects, move the REPL out the way
NRF.on('connect', function(addr) {
LoopbackA.setConsole();
});
// Handle data from Bluetooth
Bluetooth.on('data', function(d) {
  if (d=="\x03") {
    // probably a Ctrl-C sent by the IDE - move the console back
    Bluetooth.setConsole();
    return;
  }

  // Handle the command here
});

Other modes

Other Bluefruit LE modes could be used as most of them still rely on the UART, but the BluefruitLE module doesn't support them.

This page is auto-generated from GitHub. If you see any mistakes or have suggestions, please let us know.