1 /*==================================================================================================
4 * If you are using an Arduino 101, you do not need to make any changes to this file (unless you
5 * need a unique ble local name (see below). If you are using another supported BLE board or shield,
6 * follow the instructions for the specific board or shield below.
8 * Make sure you have the Intel Curie Boards package v2.0.2 or higher installed via the Arduino
11 * Supported boards and shields:
12 * - Arduino 101 (recommended)
13 * - RedBearLab BLE Shield (v2) ** to be verified **
14 * - RedBearLab BLE Nano ** works with modifications **
15 * - Adafruit Feather M0 Bluefruit LE
17 *================================================================================================*/
19 // change this to a unique name per board if running StandardFirmataBLE on multiple boards
20 // within the same physical space
21 #define FIRMATA_BLE_LOCAL_NAME "FIRMATA"
26 * Make sure you have the Intel Curie Boards package v2.0.2 or higher installed via the Arduino
29 * Test script: https://gist.github.com/soundanalogous/927360b797574ed50e27
31 #ifdef _VARIANT_ARDUINO_101_X_
32 // After conversion to units of 1.25ms, both values must be between
33 // 0x0006 (7.5ms) and 0x0c80 (4s)
34 #define FIRMATA_BLE_MIN_INTERVAL 8 // ( 8 * 1000) / 1250 == 0x06 -> 7.5ms
35 #define FIRMATA_BLE_MAX_INTERVAL 30 // (30 * 1000) / 1250 == 0x18 -> 30ms
40 * RedBearLab BLE Shield
42 * If you are using a RedBearLab BLE shield, uncomment the define below.
43 * Also, change the define for BLE_RST if you have the jumper set to pin 7 rather than pin 4.
45 * You will need to use the shield with an Arduino Zero, Due, Mega, or other board with sufficient
46 * Flash and RAM. Arduino Uno, Leonardo and other ATmega328p and Atmega32u4 boards to not have
47 * enough memory to run StandardFirmataBLE.
49 * TODO: verify if this works and with which boards it works.
51 * Test script: https://gist.github.com/soundanalogous/927360b797574ed50e27
53 //#define REDBEAR_BLE_SHIELD
55 #ifdef REDBEAR_BLE_SHIELD
58 #define BLE_RST 4 // 4 or 7 via jumper on shield
63 * Adafruit Feather M0 Bluefruit LE
65 * If you are using an Adafruit Feather M0 Bluefruit LE, uncomment the define below.
66 * This configuration should also work with other Bluefruit LE boards/modules that communicate
67 * with the nRF51822 via SPI (e.g. Bluefruit LE SPI Friend, Bluefruit LE Shield), although
68 * you may need to change the values of BLE_SPI_CS, BLE_SPI_IRQ, and/or BLE_SPI_RST below.
70 * You will need to install a lightly-modified version of the Adafruit BluefruitLE nRF51
71 * package, available at:
72 * https://github.com/cstawarz/Adafruit_BluefruitLE_nRF51/archive/firmata_fixes.zip
74 //#define BLUEFRUIT_LE_SPI
76 #ifdef BLUEFRUIT_LE_SPI
77 // Both values must be between 10ms and 4s
78 #define FIRMATA_BLE_MIN_INTERVAL 10 // 10ms
79 #define FIRMATA_BLE_MAX_INTERVAL 20 // 20ms
90 #if !defined(FIRMATA_BLE_MIN_INTERVAL) && !defined(FIRMATA_BLE_MAX_INTERVAL)
91 // These values apply to all devices using the Arduino BLEPeripheral library
92 // with a Nordic nRF8001 or nRF51822. Both values must be between
93 // 0x0006 (7.5ms) and 0x0c80 (4s).
94 #define FIRMATA_BLE_MIN_INTERVAL 0x0006 // 7.5ms (7.5 / 1.25)
95 #define FIRMATA_BLE_MAX_INTERVAL 0x0018 // 30ms (30 / 1.25)
98 #if !defined(FIRMATA_BLE_TXBUFFER_FLUSH_INTERVAL)
99 #define FIRMATA_BLE_TXBUFFER_FLUSH_INTERVAL 30 // 30ms
103 /*==================================================================================================
104 * END BLE CONFIGURATION - you should not need to change anything below this line
105 *================================================================================================*/
107 #ifdef _VARIANT_ARDUINO_101_X_
108 #include "utility/BLEStream.h"
113 #ifdef REDBEAR_BLE_SHIELD
115 #include "utility/BLEStream.h"
116 BLEStream stream(BLE_REQ, BLE_RDY, BLE_RST);
120 #ifdef BLUEFRUIT_LE_SPI
121 #include "utility/BluefruitLE_SPI_Stream.h"
122 BluefruitLE_SPI_Stream stream(BLE_SPI_CS, BLE_SPI_IRQ, BLE_SPI_RST);
127 * RedBearLab BLE Nano (with default switch settings)
129 * Blocked on this issue: https://github.com/RedBearLab/nRF51822-Arduino/issues/46
130 * Works with modifications. See comments at top of the test script referenced below.
131 * When the RBL nRF51822-Arduino library issue is resolved, this should work witout
134 * Test script: https://gist.github.com/soundanalogous/d39bb3eb36333a0906df
136 * Note: If you have changed the solder jumpers on the Nano you may encounter issues since
137 * the pins are currently mapped in Firmata only for the default (factory) jumper settings.
140 // #include "utility/BLEStream.h"
146 * RedBearLab Blend and Blend Micro
148 * StandardFirmataBLE requires too much Flash and RAM to run on the ATmega32u4-based Blend
149 * and Blend Micro boards. It may work with ConfigurableFirmata selecting only analog and/or
152 // #if defined(BLEND_MICRO) || defined(BLEND)
154 // #include "utility/BLEStream.h"
160 // BLEStream stream(BLE_REQ, BLE_RDY, BLE_RST);
164 #if defined(BLE_REQ) && defined(BLE_RDY) && defined(BLE_RST)
165 #define IS_IGNORE_BLE_PINS(p) ((p) == BLE_REQ || (p) == BLE_RDY || (p) == BLE_RST)
166 #elif defined(BLE_SPI_CS) && defined(BLE_SPI_IRQ) && defined(BLE_SPI_RST)
167 #define IS_IGNORE_BLE_PINS(p) ((p) == BLE_SPI_CS || (p) == BLE_SPI_IRQ || (p) == BLE_SPI_RST)