diff --git a/README.md b/README.md index 3e35f5c5..c5455f04 100644 --- a/README.md +++ b/README.md @@ -51,18 +51,6 @@ There are two methods that you can use to install this BSP. We highly recommend - [SiLabs CP2104 driver](http://www.silabs.com/products/mcu/pages/usbtouartbridgevcpdrivers.aspx) is required for USB to Serial when using with Feather nRF52832 -## Arduino BLE Application Support - -This Arduino core contains basic BLE peripheral mode helper classes and an initial peripheral mode -API. These helper classes and APIs aim to make it easier to work with the Nordic SoftDevice that -contains Nordic's official Bluetooth Low Energy stack. You are also free to use the Nordic SDK to -generate your own example code, since all of the SoftDevice header files are included in your -projects by default. - -To see a list of example sketches that make use of these helper classes, select the appropriate -board from the `Tools > Board` menu item, and then in the `Examples` menu look for the list of -examples sketched for the selected board. - ## Bootloader Support ### Upgrade existing Bootloader @@ -111,36 +99,6 @@ $ nrfjprog --program feather_nrf52832_bootloader.hex -f nrf52 $ nrfjprog --reset -f nrf52 ``` -## Misc Notes - -#### nRF52DK Jlink Issue on macOS - -If developing with the nRF52DK on macOS, there is a bug where only 64 bytes can be sent -over the USB CDC interface, which will prevent you from using the serial bootloader from -the Arduino IDE with an error like this: - -``` -Upgrading target on /dev/cu.usbmodem1421 with DFU package /private/var/folders/86/hb2vp14n5_5_yvdz_z8w9x_c0000gn/T/arduino_build_267869/nRF51Blinky.ino.zip. Flow control is disabled. - - -Timed out waiting for acknowledgement from device. - -Failed to upgrade target. Error is: No data received on serial port. Not able to proceed. - -Possible causes: -- bootloader, SoftDevice or application on target does not match the requirements in the DFU package. -- baud rate or flow control is not the same as in the target bootloader. -- target is not in DFU mode. If using the SDK examples, press Button 4 and RESET and release both to enter DFU mode. -``` - -To resolve this and enable 512 byte packets over USB serial, you must disable the -Mass Storage Device interface on the JLink-OB, which will free up two of the 512 byte -USB end points. (For details see [this article](https://wiki.segger.com/index.php?title=J-Link-OB_SAM3U).) - -You can do so by running `JLinkExe` from the command line, and then entering the -`MSDDisable` command, and power cycling your nRF52DK. To re-enable MSD support, do the same -but enter the `MSDEnable` command. - ## Credits This core is based on [Arduino-nRF5](https://github.com/sandeepmistry/arduino-nRF5) by Sandeep Mistry, diff --git a/changelog.md b/changelog.md index 965ff30e..2bcef2da 100644 --- a/changelog.md +++ b/changelog.md @@ -6,10 +6,10 @@ - Fixed pulseIn() compile issue: implement countPulseASM() using C instead of ASM - Update bootloader to 0.2.9 which fixed OTA issue with latest BLE5 central such as iPhone X - Added Metro nRF52840 Board support -- Added enableOTA(bool) to disable/enable OTA service (default is enable) - Fixed various warnings, thanks @brijohn - Added ARDUINO_NRF52832_FEATHER for feather 832, ARDUINO_NRF52840_FEATHER for feather 840, ARDUINO_NRF52_FEATHER for both - Fixed an memory leak with LFS, also extend to allow it to be used with SPI flash on other boards. Thanks @jeremypoulter +- Seperate OTA DFU service from Bluefruit.begin(), sketch must explicit add it if needed. - Introduce BLEPeriph class (Bluefruit.Periph) to mange peripheral role's connection - setConnInterval(), setConnIntervalMS(), setConnSupervisionTimeout(), setConnSupervisionTimeoutMS() - setConnectCallback(), setDisconnectCallback() diff --git a/libraries/Bluefruit52Lib/examples/DualRoles/dual_bleuart/dual_bleuart.ino b/libraries/Bluefruit52Lib/examples/DualRoles/dual_bleuart/dual_bleuart.ino index 6c16322a..68c1512a 100644 --- a/libraries/Bluefruit52Lib/examples/DualRoles/dual_bleuart/dual_bleuart.ino +++ b/libraries/Bluefruit52Lib/examples/DualRoles/dual_bleuart/dual_bleuart.ino @@ -21,6 +21,9 @@ */ #include +// OTA DFU service +BLEDfu bledfu; + // Peripheral uart service BLEUart bleuart; @@ -50,6 +53,9 @@ void setup() Bluefruit.Central.setConnectCallback(cent_connect_callback); Bluefruit.Central.setDisconnectCallback(cent_disconnect_callback); + // To be consistent OTA DFU should be added first if it exists + bledfu.begin(); + // Configure and Start BLE Uart Service bleuart.begin(); bleuart.setRxCallback(prph_bleuart_rx_callback); diff --git a/libraries/Bluefruit52Lib/examples/Peripheral/adv_advanced/adv_advanced.ino b/libraries/Bluefruit52Lib/examples/Peripheral/adv_advanced/adv_advanced.ino index 7332a2db..8f633761 100644 --- a/libraries/Bluefruit52Lib/examples/Peripheral/adv_advanced/adv_advanced.ino +++ b/libraries/Bluefruit52Lib/examples/Peripheral/adv_advanced/adv_advanced.ino @@ -12,7 +12,7 @@ any redistribution *********************************************************************/ -/* This sketches demontrates the Bluefruit.Advertising API(). When powered up, +/* This sketch demonstrates the Bluefruit.Advertising API(). When powered up, * the Bluefruit module will start advertising for ADV_TIMEOUT seconds (by * default 30 seconds in fast mode, the remaining time slow mode) and then * stop advertising completely. The module will start advertising again if diff --git a/libraries/Bluefruit52Lib/examples/Peripheral/bleuart/bleuart.ino b/libraries/Bluefruit52Lib/examples/Peripheral/bleuart/bleuart.ino index ab671049..19371adf 100644 --- a/libraries/Bluefruit52Lib/examples/Peripheral/bleuart/bleuart.ino +++ b/libraries/Bluefruit52Lib/examples/Peripheral/bleuart/bleuart.ino @@ -14,6 +14,7 @@ #include // BLE Service +BLEDfu bledfu; // OTA DFU service BLEDis bledis; // device information BLEUart bleuart; // uart over ble BLEBas blebas; // battery @@ -44,6 +45,9 @@ void setup() Bluefruit.Periph.setConnectCallback(connect_callback); Bluefruit.Periph.setDisconnectCallback(disconnect_callback); + // To be consistent OTA DFU should be added first if it exists + bledfu.begin(); + // Configure and Start Device Information Service bledis.setManufacturer("Adafruit Industries"); bledis.setModel("Bluefruit Feather52"); diff --git a/libraries/Bluefruit52Lib/examples/Peripheral/blinky_ota/blinky_ota.ino b/libraries/Bluefruit52Lib/examples/Peripheral/blinky_ota/blinky_ota.ino index 85cd5f0d..530983be 100644 --- a/libraries/Bluefruit52Lib/examples/Peripheral/blinky_ota/blinky_ota.ino +++ b/libraries/Bluefruit52Lib/examples/Peripheral/blinky_ota/blinky_ota.ino @@ -14,6 +14,9 @@ #include +// OTA DFU service +BLEDfu bledfu; + void setup() { Serial.begin(115200); @@ -27,6 +30,9 @@ void setup() Bluefruit.setTxPower(4); Bluefruit.setName("Bluefruit52"); + // To be consistent OTA DFU should be added first if it exists + bledfu.begin(); + // Set up and start advertising startAdv(); } diff --git a/libraries/Bluefruit52Lib/examples/Peripheral/controller/controller.ino b/libraries/Bluefruit52Lib/examples/Peripheral/controller/controller.ino index 5db66960..993303a6 100644 --- a/libraries/Bluefruit52Lib/examples/Peripheral/controller/controller.ino +++ b/libraries/Bluefruit52Lib/examples/Peripheral/controller/controller.ino @@ -14,6 +14,10 @@ #include +// OTA DFU service +BLEDfu bledfu; + +// Uart over BLE service BLEUart bleuart; // Function prototypes for packetparser.cpp @@ -37,6 +41,9 @@ void setup(void) Bluefruit.setTxPower(4); Bluefruit.setName("Bluefruit52"); + // To be consistent OTA DFU should be added first if it exists + bledfu.begin(); + // Configure and start the BLE Uart service bleuart.begin(); diff --git a/libraries/Bluefruit52Lib/examples/Peripheral/neopixel/neopixel.ino b/libraries/Bluefruit52Lib/examples/Peripheral/neopixel/neopixel.ino index af1d204a..660db21a 100644 --- a/libraries/Bluefruit52Lib/examples/Peripheral/neopixel/neopixel.ino +++ b/libraries/Bluefruit52Lib/examples/Peripheral/neopixel/neopixel.ino @@ -43,6 +43,7 @@ uint8_t components = 3; // only 3 and 4 are valid values Adafruit_NeoPixel neopixel = Adafruit_NeoPixel(); // BLE Service +BLEDfu bledfu; BLEDis bledis; BLEUart bleuart; @@ -67,6 +68,9 @@ void setup() Bluefruit.setName("Bluefruit52"); Bluefruit.Periph.setConnectCallback(connect_callback); + // To be consistent OTA DFU should be added first if it exists + bledfu.begin(); + // Configure and Start Device Information Service bledis.setManufacturer("Adafruit Industries"); bledis.setModel("Bluefruit Feather52"); diff --git a/libraries/Bluefruit52Lib/src/bluefruit.cpp b/libraries/Bluefruit52Lib/src/bluefruit.cpp index 1c3717b8..69a2ce6a 100644 --- a/libraries/Bluefruit52Lib/src/bluefruit.cpp +++ b/libraries/Bluefruit52Lib/src/bluefruit.cpp @@ -107,9 +107,7 @@ static void nrf_error_cb(uint32_t id, uint32_t pc, uint32_t info) #endif } -/** - * Constructor - */ +// Constructor AdafruitBluefruit::AdafruitBluefruit(void) { /*------------------------------------------------------------------*/ @@ -149,8 +147,6 @@ AdafruitBluefruit::AdafruitBluefruit(void) _led_blink_th = NULL; _led_conn = true; - _ota_en = true; - _tx_power = CFG_BLE_TX_POWER_LEVEL; _conn_hdl = BLE_CONN_HANDLE_INVALID; @@ -268,11 +264,6 @@ void AdafruitBluefruit::configCentralBandwidth(uint8_t bw) } } -void AdafruitBluefruit::enableOTA(bool en) -{ - _ota_en = en; -} - bool AdafruitBluefruit::begin(uint8_t prph_count, uint8_t central_count) { _prph_count = prph_count; @@ -455,9 +446,6 @@ bool AdafruitBluefruit::begin(uint8_t prph_count, uint8_t central_count) sd_power_usbremoved_enable(true); #endif - // Add DFU OTA service if enabled - if ( _ota_en ) _dfu_svc.begin(); - // Init Central role if (_central_count) Central.begin(); diff --git a/libraries/Bluefruit52Lib/src/bluefruit.h b/libraries/Bluefruit52Lib/src/bluefruit.h index 152e02aa..081903d3 100644 --- a/libraries/Bluefruit52Lib/src/bluefruit.h +++ b/libraries/Bluefruit52Lib/src/bluefruit.h @@ -135,8 +135,6 @@ class AdafruitBluefruit void configPrphBandwidth (uint8_t bw); void configCentralBandwidth(uint8_t bw); - void enableOTA(bool en); - bool begin(uint8_t prph_count = 1, uint8_t central_count = 0); /*------------------------------------------------------------------*/ @@ -231,9 +229,6 @@ class AdafruitBluefruit TimerHandle_t _led_blink_th; bool _led_conn; - bool _ota_en; - BLEDfu _dfu_svc; - uint16_t _conn_hdl; BLEConnection* _connection[BLE_MAX_CONNECTION];