diff --git a/libraries/Bluefruit52Lib/examples/Peripheral/arduino_science_journal/.cluenrf52840.test.only b/libraries/Bluefruit52Lib/examples/Peripheral/arduino_science_journal/.cluenrf52840.test.only new file mode 100644 index 00000000..e69de29b diff --git a/libraries/Bluefruit52Lib/examples/Peripheral/arduino_science_journal/.cplaynrf52840.test.only b/libraries/Bluefruit52Lib/examples/Peripheral/arduino_science_journal/.cplaynrf52840.test.only new file mode 100644 index 00000000..e69de29b diff --git a/libraries/Bluefruit52Lib/examples/Peripheral/arduino_science_journal/.feather52840sense.test.only b/libraries/Bluefruit52Lib/examples/Peripheral/arduino_science_journal/.feather52840sense.test.only new file mode 100644 index 00000000..e69de29b diff --git a/libraries/Bluefruit52Lib/examples/Peripheral/arduino_science_journal/arduino_science_journal.ino b/libraries/Bluefruit52Lib/examples/Peripheral/arduino_science_journal/arduino_science_journal.ino new file mode 100644 index 00000000..3d1026db --- /dev/null +++ b/libraries/Bluefruit52Lib/examples/Peripheral/arduino_science_journal/arduino_science_journal.ino @@ -0,0 +1,396 @@ +/********************************************************************* + This is an example for our nRF52 based Bluefruit LE modules + + Pick one up today in the adafruit shop! + + Adafruit invests time and resources providing this open source code, + please support Adafruit and open-source hardware by purchasing + products from Adafruit! + + MIT license, check LICENSE for more information + All text above, and the splash screen below must be included in + any redistribution +*********************************************************************/ + +/* This sketch implement Arduino Science Journal firmware using Adafruit Bluefruit library + * https://www.arduino.cc/education/science-journal. + * Supported boards are: + * - Circuit Playground Bluefruit : https://www.adafruit.com/product/4333 + * - CLUE nRF52840 : https://www.adafruit.com/product/4500 + * - Feather Sense : https://www.adafruit.com/product/4516 + */ + +#include +#include + +const int VERSION = 0x00000001; +const float TEMPERATURE_CALIBRATION = -5.0; + +// 555a0002-val-467a-9538-01f0652c74e8" +#define SCIENCE_KIT_UUID(val) \ + (const uint8_t[]) { \ + 0xe8, 0x74, 0x2c, 0x65, 0xf0, 0x01, 0x38, 0x95, \ + 0x7a, 0x46, (uint8_t) (val & 0xff), (uint8_t) (val >> 8), 0x02, 0x00, 0x5a, 0x55 \ + } + +BLEService service (SCIENCE_KIT_UUID(0x0000)); +BLECharacteristic versionCharacteristic (SCIENCE_KIT_UUID(0x0001)); +BLECharacteristic accelerationCharacteristic (SCIENCE_KIT_UUID(0x0011)); +BLECharacteristic gyroscopeCharacteristic (SCIENCE_KIT_UUID(0x0012)); +BLECharacteristic magneticFieldCharacteristic(SCIENCE_KIT_UUID(0x0013)); +BLECharacteristic temperatureCharacteristic (SCIENCE_KIT_UUID(0x0014)); +BLECharacteristic pressureCharacteristic (SCIENCE_KIT_UUID(0x0015)); +BLECharacteristic humidityCharacteristic (SCIENCE_KIT_UUID(0x0016)); +BLECharacteristic proximityCharacteristic (SCIENCE_KIT_UUID(0x0017)); +BLECharacteristic colorCharacteristic (SCIENCE_KIT_UUID(0x0018)); +BLECharacteristic soundPressureCharacteristic(SCIENCE_KIT_UUID(0x0019)); + + +#if defined(ARDUINO_NRF52840_CIRCUITPLAY) + +#include + +#elif defined(ARDUINO_NRF52840_CLUE) || defined(ARDUINO_NRF52840_FEATHER_SENSE) + +#include +#include +#include +#include +#include + +Adafruit_LSM6DS33 lsm6ds33; // Gyro and Accel +Adafruit_LIS3MDL lis3mdl; // Magnetometer +Adafruit_APDS9960 apds9960; // Proximity, Light, Gesture, Color +Adafruit_BMP280 bmp280; // Temperature, Barometric +Adafruit_SHT31 sht30; // Humid + +#else + +#error "Board is not supported" + +#endif + +Adafruit_Sensor* accel_sensor; + +short soundSampleBuffer[256]; + +void onPDMdata() { + // query the number of bytes available + int bytesAvailable = PDM.available(); + + // read into the sample buffer + PDM.read(soundSampleBuffer, bytesAvailable); +} + +uint16_t getSoundAverage() { + uint32_t avg = 0; + for (int i = 0; i < sizeof(soundSampleBuffer)/sizeof(soundSampleBuffer[0]); i++) { + avg += soundSampleBuffer[i]*soundSampleBuffer[i]; + } + return sqrt(avg); +} + +void setupSensors(void) +{ +#if defined ARDUINO_NRF52840_CIRCUITPLAY + CircuitPlayground.begin(); + accel_sensor = &CircuitPlayground.lis; + +#elif defined(ARDUINO_NRF52840_CLUE) || defined(ARDUINO_NRF52840_FEATHER_SENSE) + + #ifdef ARDUINO_NRF52840_CLUE + // White LEDs for color sensing + pinMode(PIN_LED2, OUTPUT); + digitalWrite(PIN_LED2, LOW); + #endif + + apds9960.begin(); + bmp280.begin(); + sht30.begin(0x44); + lsm6ds33.begin_I2C(); + lis3mdl.begin_I2C(); + + // set lowest range + lsm6ds33.setAccelRange(LSM6DS_ACCEL_RANGE_2_G); + lsm6ds33.setGyroRange(LSM6DS_GYRO_RANGE_250_DPS); + lis3mdl.setRange(LIS3MDL_RANGE_4_GAUSS); + + // set slightly above refresh rate + lsm6ds33.setAccelDataRate(LSM6DS_RATE_104_HZ); + lsm6ds33.setGyroDataRate(LSM6DS_RATE_104_HZ); + lis3mdl.setDataRate(LIS3MDL_DATARATE_1000_HZ); + lis3mdl.setPerformanceMode(LIS3MDL_MEDIUMMODE); + lis3mdl.setOperationMode(LIS3MDL_CONTINUOUSMODE); + + // Increase I2C speed to 400 Khz + Wire.setClock(400000); + + accel_sensor = lsm6ds33.getAccelerometerSensor(); +#endif + + // 1 channel (mono mode) with 16 kHz sample rate + PDM.onReceive(onPDMdata); + PDM.begin(1, 16000); +} + +void setupBLEScience(void) +{ + service.begin(); + + versionCharacteristic.setProperties(CHR_PROPS_READ); + versionCharacteristic.setPermission(SECMODE_OPEN, SECMODE_NO_ACCESS); + versionCharacteristic.setFixedLen(4); + versionCharacteristic.begin(); + versionCharacteristic.write32(VERSION); + + accelerationCharacteristic.setProperties(CHR_PROPS_NOTIFY); + accelerationCharacteristic.setPermission(SECMODE_OPEN, SECMODE_NO_ACCESS); + accelerationCharacteristic.setFixedLen(3 * sizeof(float)); + accelerationCharacteristic.begin(); + +#if defined(ARDUINO_NRF52840_CLUE) || defined(ARDUINO_NRF52840_FEATHER_SENSE) + gyroscopeCharacteristic.setProperties(CHR_PROPS_NOTIFY); + gyroscopeCharacteristic.setPermission(SECMODE_OPEN, SECMODE_NO_ACCESS); + gyroscopeCharacteristic.setFixedLen(3 * sizeof(float)); + gyroscopeCharacteristic.begin(); + + magneticFieldCharacteristic.setProperties(CHR_PROPS_NOTIFY); + magneticFieldCharacteristic.setPermission(SECMODE_OPEN, SECMODE_NO_ACCESS); + magneticFieldCharacteristic.setFixedLen(3 * sizeof(float)); + magneticFieldCharacteristic.begin(); + + pressureCharacteristic.setProperties(CHR_PROPS_NOTIFY); + pressureCharacteristic.setPermission(SECMODE_OPEN, SECMODE_NO_ACCESS); + pressureCharacteristic.setFixedLen(sizeof(float)); + pressureCharacteristic.begin(); + + humidityCharacteristic.setProperties(CHR_PROPS_NOTIFY); + humidityCharacteristic.setPermission(SECMODE_OPEN, SECMODE_NO_ACCESS); + humidityCharacteristic.setFixedLen(sizeof(float)); + humidityCharacteristic.begin(); + + proximityCharacteristic.setProperties(CHR_PROPS_NOTIFY); + proximityCharacteristic.setPermission(SECMODE_OPEN, SECMODE_NO_ACCESS); + proximityCharacteristic.setFixedLen(sizeof(unsigned int)); + proximityCharacteristic.setCccdWriteCallback(science_notify_callback); + proximityCharacteristic.begin(); +#endif + + temperatureCharacteristic.setProperties(CHR_PROPS_NOTIFY); + temperatureCharacteristic.setPermission(SECMODE_OPEN, SECMODE_NO_ACCESS); + temperatureCharacteristic.setFixedLen(sizeof(float)); + temperatureCharacteristic.begin(); + + colorCharacteristic.setProperties(CHR_PROPS_NOTIFY); + colorCharacteristic.setPermission(SECMODE_OPEN, SECMODE_NO_ACCESS); + colorCharacteristic.setFixedLen(4 * sizeof(int)); + colorCharacteristic.setCccdWriteCallback(science_notify_callback); + colorCharacteristic.begin(); + + soundPressureCharacteristic.setProperties(CHR_PROPS_NOTIFY); + soundPressureCharacteristic.setPermission(SECMODE_OPEN, SECMODE_NO_ACCESS); + soundPressureCharacteristic.setFixedLen(sizeof(unsigned short)); + soundPressureCharacteristic.begin(); +} + +void setup() +{ + Serial.begin(115200); + Serial.println("Bluefruit Science Journal Example"); + Serial.println("---------------------------------\n"); + + setupSensors(); + + // Config the peripheral connection with maximum bandwidth + // more SRAM required by SoftDevice + // Note: All config***() function must be called before begin() + Bluefruit.configPrphBandwidth(BANDWIDTH_MAX); + Bluefruit.configUuid128Count(15); + + Bluefruit.begin(); + Bluefruit.setTxPower(4); // Check bluefruit.h for supported values + Bluefruit.Periph.setConnectCallback(connect_callback); + Bluefruit.Periph.setDisconnectCallback(disconnect_callback); + + setupBLEScience(); + + // Set up and start advertising + startAdv(); +} + +void startAdv(void) +{ + // Advertising packet + Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE); + Bluefruit.Advertising.addTxPower(); + + // Include bleuart 128-bit uuid + Bluefruit.Advertising.addService(service); + + // Secondary Scan Response packet (optional) + // Since there is no room for 'Name' in Advertising packet + Bluefruit.ScanResponse.addName(); + + /* Start Advertising + * - Enable auto advertising if disconnected + * - Interval: fast mode = 20 ms, slow mode = 152.5 ms + * - Timeout for fast mode is 30 seconds + * - Start(timeout) with timeout = 0 will advertise forever (until connected) + * + * For recommended advertising interval + * https://developer.apple.com/library/content/qa/qa1931/_index.html + */ + Bluefruit.Advertising.restartOnDisconnect(true); + Bluefruit.Advertising.setInterval(32, 244); // in unit of 0.625 ms + Bluefruit.Advertising.setFastTimeout(30); // number of seconds in fast mode + Bluefruit.Advertising.start(0); // 0 = Don't stop advertising after n seconds +} + +void loop() +{ + if ( Bluefruit.connected() ) + { + updateSubscribedCharacteristics(); + delay(1000); + } +} + +void updateSubscribedCharacteristics(void) +{ + sensors_event_t event; + + if ( accelerationCharacteristic.notifyEnabled() ) + { + accel_sensor->getEvent(&event); + accelerationCharacteristic.notify(event.data, accelerationCharacteristic.getMaxLen()); + } + +#ifdef ARDUINO_NRF52840_CIRCUITPLAY + if ( temperatureCharacteristic.notifyEnabled() ) + { + float temperature = CircuitPlayground.temperature(); + temperatureCharacteristic.notify32(temperature); + } + + if ( colorCharacteristic.notifyEnabled() ) + { + int color[4] = { 0 }; + color[3] = CircuitPlayground.lightSensor(); + colorCharacteristic.notify(color, colorCharacteristic.getMaxLen()); + } + +#elif defined(ARDUINO_NRF52840_CLUE) || defined(ARDUINO_NRF52840_FEATHER_SENSE) + if ( gyroscopeCharacteristic.notifyEnabled() ) + { + lsm6ds33.getGyroSensor()->getEvent(&event); + + // Convert gyro from Rad/s to Degree/s + event.gyro.x *= SENSORS_RADS_TO_DPS; + event.gyro.y *= SENSORS_RADS_TO_DPS; + event.gyro.z *= SENSORS_RADS_TO_DPS; + + gyroscopeCharacteristic.notify(event.data, gyroscopeCharacteristic.getMaxLen()); + } + + if ( magneticFieldCharacteristic.notifyEnabled() ) + { + lis3mdl.getEvent(&event); + magneticFieldCharacteristic.notify(event.data, magneticFieldCharacteristic.getMaxLen()); + } + + if ( proximityCharacteristic.notifyEnabled() ) + { + uint32_t proximity = 255 - apds9960.readProximity(); + proximityCharacteristic.notify32(proximity); + } + + if ( temperatureCharacteristic.notifyEnabled() || humidityCharacteristic.notifyEnabled() ) + { + float temperature = bmp280.readTemperature(); + float temperatureCalibrated = temperature + TEMPERATURE_CALIBRATION; + + if ( temperatureCharacteristic.notifyEnabled() ) + { + temperatureCharacteristic.notify32(temperatureCalibrated); + } + + if ( humidityCharacteristic.notifyEnabled() ) + { + float humidity = sht30.readHumidity(); + float dp = temperature - ((100.0 - humidity) / 5.0); + float humidityCalibrated = 100.0 - (5.0 * (temperatureCalibrated - dp)); + humidityCharacteristic.notify32(humidityCalibrated); + } + } + + if ( pressureCharacteristic.notifyEnabled() ) + { + float pressure = bmp280.readPressure() / 1000.0; // kilo pascal + pressureCharacteristic.notify32(pressure); + } + + if ( colorCharacteristic.notifyEnabled() ) + { + int color[4] = { 0 }; + apds9960.getColorData((uint16_t*) &color[0], (uint16_t*) &color[1], (uint16_t*) &color[2], (uint16_t*) &color[3]); + colorCharacteristic.notify(color, colorCharacteristic.getMaxLen()); + } +#endif + + if ( soundPressureCharacteristic.notifyEnabled() ) + { + uint16_t sound = getSoundAverage(); + soundPressureCharacteristic.notify16(sound); + } +} + +void science_notify_callback(uint16_t conn_hdl, BLECharacteristic* chr, uint16_t value) +{ + (void) conn_hdl; + + bool enabled = (value == 0x0001); + (void) enabled; + +#if defined(ARDUINO_NRF52840_CLUE) || defined(ARDUINO_NRF52840_FEATHER_SENSE) + if ( chr == &colorCharacteristic ) + { + apds9960.enableColor(enabled); + +#ifdef ARDUINO_NRF52840_CLUE + digitalWrite(PIN_LED2, enabled); +#endif + } + + if ( chr == &proximityCharacteristic) + { + apds9960.enableProximity(enabled); + } +#endif +} + +// callback invoked when central connects +void connect_callback(uint16_t conn_handle) +{ + // Get the reference to current connection + BLEConnection* connection = Bluefruit.Connection(conn_handle); + + char central_name[32] = { 0 }; + connection->getPeerName(central_name, sizeof(central_name)); + + Serial.print("Connected to "); + Serial.println(central_name); +} + +/** + * Callback invoked when a connection is dropped + * @param conn_handle connection where this event happens + * @param reason is a BLE_HCI_STATUS_CODE which can be found in ble_hci.h + */ +void disconnect_callback(uint16_t conn_handle, uint8_t reason) +{ + (void) conn_handle; + (void) reason; + + Serial.println(); + Serial.print("Disconnected, reason = 0x"); Serial.println(reason, HEX); +} diff --git a/libraries/Bluefruit52Lib/examples/Peripheral/bluefruit_playground/bluefruit_playground.ino b/libraries/Bluefruit52Lib/examples/Peripheral/bluefruit_playground/bluefruit_playground.ino index 35dcf622..a771b9ee 100644 --- a/libraries/Bluefruit52Lib/examples/Peripheral/bluefruit_playground/bluefruit_playground.ino +++ b/libraries/Bluefruit52Lib/examples/Peripheral/bluefruit_playground/bluefruit_playground.ino @@ -150,8 +150,6 @@ uint16_t measure_color(uint8_t* buf, uint16_t bufsize) return sizeof(rgb); } - - void gesture_enable_callback(uint16_t conn_hdl, bool enabled) { (void) conn_hdl; diff --git a/libraries/Bluefruit52Lib/examples/Peripheral/nrf_blinky/nrf_blinky.ino b/libraries/Bluefruit52Lib/examples/Peripheral/nrf_blinky/nrf_blinky.ino index 00c1805a..a7fc2559 100644 --- a/libraries/Bluefruit52Lib/examples/Peripheral/nrf_blinky/nrf_blinky.ino +++ b/libraries/Bluefruit52Lib/examples/Peripheral/nrf_blinky/nrf_blinky.ino @@ -19,41 +19,34 @@ */ #include +#include // max concurrent connections supported by this example #define MAX_PRPH_CONNECTION 2 uint8_t connection_count = 0; -/* HRM Service Definitions - * Heart Rate Monitor Service: 0x180D - * Heart Rate Measurement Char: 0x2A37 - * Body Sensor Location Char: 0x2A38 - */ -BLEService hrms = BLEService(UUID16_SVC_HEART_RATE); -BLECharacteristic hrmc = BLECharacteristic(UUID16_CHR_HEART_RATE_MEASUREMENT); -BLECharacteristic bslc = BLECharacteristic(UUID16_CHR_BODY_SENSOR_LOCATION); - -/* LBS Service: 00001523-1212-EFDE-1523-785FEABCD123 +/* Nordic Led-Button Service (LBS) + * LBS Service: 00001523-1212-EFDE-1523-785FEABCD123 * LBS Button : 00001524-1212-EFDE-1523-785FEABCD123 * LBS LED : 00001525-1212-EFDE-1523-785FEABCD123 */ const uint8_t LBS_UUID_SERVICE[] = { - 0x23, 0xD1, 0xBC, 0xEA, 0x5F, 0x78, 0x23, 0x15, - 0xDE, 0xEF, 0x12, 0x12, 0x23, 0x15, 0x00, 0x00 + 0x23, 0xD1, 0xBC, 0xEA, 0x5F, 0x78, 0x23, 0x15, + 0xDE, 0xEF, 0x12, 0x12, 0x23, 0x15, 0x00, 0x00 }; const uint8_t LBS_UUID_CHR_BUTTON[] = { - 0x23, 0xD1, 0xBC, 0xEA, 0x5F, 0x78, 0x23, 0x15, - 0xDE, 0xEF, 0x12, 0x12, 0x24, 0x15, 0x00, 0x00 + 0x23, 0xD1, 0xBC, 0xEA, 0x5F, 0x78, 0x23, 0x15, + 0xDE, 0xEF, 0x12, 0x12, 0x24, 0x15, 0x00, 0x00 }; const uint8_t LBS_UUID_CHR_LED[] = { - 0x23, 0xD1, 0xBC, 0xEA, 0x5F, 0x78, 0x23, 0x15, - 0xDE, 0xEF, 0x12, 0x12, 0x25, 0x15, 0x00, 0x00 + 0x23, 0xD1, 0xBC, 0xEA, 0x5F, 0x78, 0x23, 0x15, + 0xDE, 0xEF, 0x12, 0x12, 0x25, 0x15, 0x00, 0x00 }; BLEService lbs(LBS_UUID_SERVICE); @@ -67,15 +60,36 @@ BLECharacteristic lsbLED(LBS_UUID_CHR_LED); uint8_t button = A0; #endif +// CPB button active state is HIGH, all other is low +#ifdef ARDUINO_NRF52840_CIRCUITPLAY + #define BUTTON_ACTIVE HIGH +#else + #define BUTTON_ACTIVE LOW +#endif + uint8_t buttonState; +#ifdef PIN_NEOPIXEL + +#ifndef NEOPIXEL_NUM +#define NEOPIXEL_NUM 1 +#endif + +Adafruit_NeoPixel neopixel = Adafruit_NeoPixel(NEOPIXEL_NUM, PIN_NEOPIXEL, NEO_GRB + NEO_KHZ800); + +#endif + void setup() { + pinMode(button, BUTTON_ACTIVE ? INPUT_PULLDOWN : INPUT_PULLUP); + buttonState = (BUTTON_ACTIVE == digitalRead(button)); + pinMode(LED_BUILTIN, OUTPUT); digitalWrite(LED_BUILTIN, 1-LED_STATE_ON); // led off - pinMode(button, INPUT_PULLUP); - buttonState = (uint8_t) (1-digitalRead(button)); // button is active LOW +#ifdef PIN_NEOPIXEL + neopixel.begin(); +#endif Serial.begin(115200); //while ( !Serial ) delay(10); // for nrf52840 with native usb @@ -162,15 +176,21 @@ void led_write_callback(uint16_t conn_hdl, BLECharacteristic* chr, uint8_t* data // data = 1 -> LED = On // data = 0 -> LED = Off digitalWrite(LED_BUILTIN, data[0] ? LED_STATE_ON : (1-LED_STATE_ON)); + +#ifdef PIN_NEOPIXEL + uint32_t c = neopixel.Color(0x00, 0x00, data[0] ? 0x20 : 0x00); + neopixel.fill(c, 0, NEOPIXEL_NUM); + neopixel.show(); +#endif } void loop() { delay(10); // poll button every 10 ms - uint8_t newState = (uint8_t) (1-digitalRead(button)); // button is active LOW + uint8_t newState = (BUTTON_ACTIVE == digitalRead(button)); - // only notify if button state chagnes + // only notify if button state changes if ( newState != buttonState) { buttonState = newState; diff --git a/libraries/Bluefruit52Lib/src/BLECharacteristic.cpp b/libraries/Bluefruit52Lib/src/BLECharacteristic.cpp index d3a42108..46dc152f 100644 --- a/libraries/Bluefruit52Lib/src/BLECharacteristic.cpp +++ b/libraries/Bluefruit52Lib/src/BLECharacteristic.cpp @@ -751,6 +751,11 @@ bool BLECharacteristic::notify32(uint16_t conn_hdl, int num) return notify(conn_hdl, (uint8_t*) &num, sizeof(num)); } +bool BLECharacteristic::notify32(uint16_t conn_hdl, float num) +{ + return notify(conn_hdl, (uint8_t*) &num, sizeof(num)); +} + //--------------------------------------------------------------------+ // Notify with single connection //--------------------------------------------------------------------+ @@ -784,6 +789,10 @@ bool BLECharacteristic::notify32(int num) return notify32(BLE_CONN_HANDLE_INVALID, num); } +bool BLECharacteristic::notify32(float num) +{ + return notify32(BLE_CONN_HANDLE_INVALID, num); +} /*------------------------------------------------------------------*/ /* INDICATE multiple connections @@ -874,6 +883,11 @@ bool BLECharacteristic::indicate32(uint16_t conn_hdl, int num) return indicate32(conn_hdl, (uint32_t) num); } +bool BLECharacteristic::indicate32(uint16_t conn_hdl, float num) +{ + return indicate(conn_hdl, (uint8_t*) &num, sizeof(num)); +} + /*------------------------------------------------------------------*/ /* INDICATE single connections *------------------------------------------------------------------*/ @@ -906,3 +920,8 @@ bool BLECharacteristic::indicate32(int num) { return indicate32(BLE_CONN_HANDLE_INVALID, num); } + +bool BLECharacteristic::indicate32(float num) +{ + return indicate32(BLE_CONN_HANDLE_INVALID, num); +} diff --git a/libraries/Bluefruit52Lib/src/BLECharacteristic.h b/libraries/Bluefruit52Lib/src/BLECharacteristic.h index acd17531..b0decf52 100644 --- a/libraries/Bluefruit52Lib/src/BLECharacteristic.h +++ b/libraries/Bluefruit52Lib/src/BLECharacteristic.h @@ -134,6 +134,7 @@ class BLECharacteristic bool notify16 (uint16_t num); bool notify32 (uint32_t num); bool notify32 (int num); + bool notify32 (float fnum); /*------------- Notify multiple connections -------------*/ // bool notify (uint16_t conn_hdl); @@ -144,6 +145,7 @@ class BLECharacteristic bool notify16 (uint16_t conn_hdl, uint16_t num); bool notify32 (uint16_t conn_hdl, uint32_t num); bool notify32 (uint16_t conn_hdl, int num); + bool notify32 (uint16_t conn_hdl, float num); /*------------- Indicate -------------*/ bool indicateEnabled(void); @@ -156,6 +158,7 @@ class BLECharacteristic bool indicate16 (uint16_t num); bool indicate32 (uint32_t num); bool indicate32 (int num); + bool indicate32 (float num); /*------------- Indicate multiple connections -------------*/ bool indicate (uint16_t conn_hdl, const void* data, uint16_t len); @@ -165,6 +168,7 @@ class BLECharacteristic bool indicate16 (uint16_t conn_hdl, uint16_t num); bool indicate32 (uint16_t conn_hdl, uint32_t num); bool indicate32 (uint16_t conn_hdl, int num); + bool indicate32 (uint16_t conn_hdl, float num); /*------------- Internal Functions -------------*/ virtual void _eventHandler(ble_evt_t* event); diff --git a/libraries/Bluefruit52Lib/src/bluefruit.cpp b/libraries/Bluefruit52Lib/src/bluefruit.cpp index 62549455..a7ddcc11 100644 --- a/libraries/Bluefruit52Lib/src/bluefruit.cpp +++ b/libraries/Bluefruit52Lib/src/bluefruit.cpp @@ -41,12 +41,6 @@ #define CFG_BLE_TX_POWER_LEVEL 0 #endif -#ifdef USB_PRODUCT - #define CFG_DEFAULT_NAME USB_PRODUCT -#else - #define CFG_DEFAULT_NAME "Feather nRF52832" -#endif - #ifndef CFG_BLE_TASK_STACKSIZE #define CFG_BLE_TASK_STACKSIZE (256*5) #endif @@ -55,6 +49,12 @@ #define CFG_SOC_TASK_STACKSIZE (200) #endif +#ifdef USB_PRODUCT + #define CFG_DEFAULT_NAME USB_PRODUCT +#else + #define CFG_DEFAULT_NAME "Feather nRF52832" +#endif + #ifdef USE_TINYUSB #include "nrfx_power.h" @@ -195,7 +195,7 @@ void AdafruitBluefruit::configServiceChanged(bool changed) _sd_cfg.service_changed = (changed ? 1 : 0); } -void AdafruitBluefruit::configUuid128Count(uint8_t uuid128_max) +void AdafruitBluefruit::configUuid128Count(uint8_t uuid128_max) { _sd_cfg.uuid128_max = uuid128_max; } diff --git a/variants/circuitplayground_nrf52840/variant.h b/variants/circuitplayground_nrf52840/variant.h index 2bbadeb0..5624a59b 100644 --- a/variants/circuitplayground_nrf52840/variant.h +++ b/variants/circuitplayground_nrf52840/variant.h @@ -45,6 +45,7 @@ extern "C" // LEDs #define PIN_LED1 (13) #define PIN_NEOPIXEL (8) +#define NEOPIXEL_NUM 10 #define LED_BUILTIN PIN_LED1 diff --git a/variants/clue_nrf52840/variant.h b/variants/clue_nrf52840/variant.h index 7924b3ba..de6db9d6 100644 --- a/variants/clue_nrf52840/variant.h +++ b/variants/clue_nrf52840/variant.h @@ -44,6 +44,7 @@ extern "C" #define PIN_LED1 (17) #define PIN_LED2 (43) // dual white LEDs #define PIN_NEOPIXEL (18) +#define NEOPIXEL_NUM 1 #define LED_BUILTIN PIN_LED1 diff --git a/variants/feather_nrf52840_express/variant.h b/variants/feather_nrf52840_express/variant.h index c64a3728..c4d3d947 100644 --- a/variants/feather_nrf52840_express/variant.h +++ b/variants/feather_nrf52840_express/variant.h @@ -46,6 +46,7 @@ extern "C" #define PIN_LED1 (3) #define PIN_LED2 (4) #define PIN_NEOPIXEL (8) +#define NEOPIXEL_NUM 1 #define LED_BUILTIN PIN_LED1 #define LED_CONN PIN_LED2 diff --git a/variants/feather_nrf52840_sense/variant.h b/variants/feather_nrf52840_sense/variant.h index 18d1782d..210f09a3 100644 --- a/variants/feather_nrf52840_sense/variant.h +++ b/variants/feather_nrf52840_sense/variant.h @@ -45,6 +45,7 @@ extern "C" #define PIN_LED1 (13) #define PIN_LED2 (4) #define PIN_NEOPIXEL (8) +#define NEOPIXEL_NUM 1 #define LED_BUILTIN PIN_LED1 #define LED_CONN PIN_LED2 diff --git a/variants/metro_nrf52840_express/variant.h b/variants/metro_nrf52840_express/variant.h index 852a147c..76904a36 100644 --- a/variants/metro_nrf52840_express/variant.h +++ b/variants/metro_nrf52840_express/variant.h @@ -46,6 +46,7 @@ extern "C" #define PIN_LED1 (33) #define PIN_LED2 (34) #define PIN_NEOPIXEL (35) +#define NEOPIXEL_NUM 1 #define LED_BUILTIN PIN_LED1 #define LED_CONN PIN_LED2