Skip to content

Commit 865ac99

Browse files
committed
Seperate OTA DFU service from Bluefruit.begin()
1 parent 665f4f7 commit 865ac99

File tree

10 files changed

+30
-62
lines changed

10 files changed

+30
-62
lines changed

README.md

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,6 @@ There are two methods that you can use to install this BSP. We highly recommend
5151
5252
- [SiLabs CP2104 driver](http://www.silabs.com/products/mcu/pages/usbtouartbridgevcpdrivers.aspx) is required for USB to Serial when using with Feather nRF52832
5353
54-
## Arduino BLE Application Support
55-
56-
This Arduino core contains basic BLE peripheral mode helper classes and an initial peripheral mode
57-
API. These helper classes and APIs aim to make it easier to work with the Nordic SoftDevice that
58-
contains Nordic's official Bluetooth Low Energy stack. You are also free to use the Nordic SDK to
59-
generate your own example code, since all of the SoftDevice header files are included in your
60-
projects by default.
61-
62-
To see a list of example sketches that make use of these helper classes, select the appropriate
63-
board from the `Tools > Board` menu item, and then in the `Examples` menu look for the list of
64-
examples sketched for the selected board.
65-
6654
## Bootloader Support
6755
6856
### Upgrade existing Bootloader
@@ -111,36 +99,6 @@ $ nrfjprog --program feather_nrf52832_bootloader.hex -f nrf52
11199
$ nrfjprog --reset -f nrf52
112100
```
113101
114-
## Misc Notes
115-
116-
#### nRF52DK Jlink Issue on macOS
117-
118-
If developing with the nRF52DK on macOS, there is a bug where only 64 bytes can be sent
119-
over the USB CDC interface, which will prevent you from using the serial bootloader from
120-
the Arduino IDE with an error like this:
121-
122-
```
123-
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.
124-
125-
126-
Timed out waiting for acknowledgement from device.
127-
128-
Failed to upgrade target. Error is: No data received on serial port. Not able to proceed.
129-
130-
Possible causes:
131-
- bootloader, SoftDevice or application on target does not match the requirements in the DFU package.
132-
- baud rate or flow control is not the same as in the target bootloader.
133-
- target is not in DFU mode. If using the SDK examples, press Button 4 and RESET and release both to enter DFU mode.
134-
```
135-
136-
To resolve this and enable 512 byte packets over USB serial, you must disable the
137-
Mass Storage Device interface on the JLink-OB, which will free up two of the 512 byte
138-
USB end points. (For details see [this article](https://wiki.segger.com/index.php?title=J-Link-OB_SAM3U).)
139-
140-
You can do so by running `JLinkExe` from the command line, and then entering the
141-
`MSDDisable` command, and power cycling your nRF52DK. To re-enable MSD support, do the same
142-
but enter the `MSDEnable` command.
143-
144102
## Credits
145103
146104
This core is based on [Arduino-nRF5](https://github.com/sandeepmistry/arduino-nRF5) by Sandeep Mistry,

changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
- Fixed pulseIn() compile issue: implement countPulseASM() using C instead of ASM
77
- Update bootloader to 0.2.9 which fixed OTA issue with latest BLE5 central such as iPhone X
88
- Added Metro nRF52840 Board support
9-
- Added enableOTA(bool) to disable/enable OTA service (default is enable)
109
- Fixed various warnings, thanks @brijohn
1110
- Added ARDUINO_NRF52832_FEATHER for feather 832, ARDUINO_NRF52840_FEATHER for feather 840, ARDUINO_NRF52_FEATHER for both
1211
- Fixed an memory leak with LFS, also extend to allow it to be used with SPI flash on other boards. Thanks @jeremypoulter
12+
- Seperate OTA DFU service from Bluefruit.begin(), sketch must explicit add it if needed.
1313
- Introduce BLEPeriph class (Bluefruit.Periph) to mange peripheral role's connection
1414
- setConnInterval(), setConnIntervalMS(), setConnSupervisionTimeout(), setConnSupervisionTimeoutMS()
1515
- setConnectCallback(), setDisconnectCallback()

libraries/Bluefruit52Lib/examples/DualRoles/dual_bleuart/dual_bleuart.ino

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
*/
2222
#include <bluefruit.h>
2323

24+
// OTA DFU service
25+
BLEDfu bledfu;
26+
2427
// Peripheral uart service
2528
BLEUart bleuart;
2629

@@ -50,6 +53,9 @@ void setup()
5053
Bluefruit.Central.setConnectCallback(cent_connect_callback);
5154
Bluefruit.Central.setDisconnectCallback(cent_disconnect_callback);
5255

56+
// To be consistent OTA DFU should be added first if it exists
57+
bledfu.begin();
58+
5359
// Configure and Start BLE Uart Service
5460
bleuart.begin();
5561
bleuart.setRxCallback(prph_bleuart_rx_callback);

libraries/Bluefruit52Lib/examples/Peripheral/adv_advanced/adv_advanced.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
any redistribution
1313
*********************************************************************/
1414

15-
/* This sketches demontrates the Bluefruit.Advertising API(). When powered up,
15+
/* This sketch demonstrates the Bluefruit.Advertising API(). When powered up,
1616
* the Bluefruit module will start advertising for ADV_TIMEOUT seconds (by
1717
* default 30 seconds in fast mode, the remaining time slow mode) and then
1818
* stop advertising completely. The module will start advertising again if

libraries/Bluefruit52Lib/examples/Peripheral/bleuart/bleuart.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <bluefruit.h>
1515

1616
// BLE Service
17+
BLEDfu bledfu; // OTA DFU service
1718
BLEDis bledis; // device information
1819
BLEUart bleuart; // uart over ble
1920
BLEBas blebas; // battery
@@ -44,6 +45,9 @@ void setup()
4445
Bluefruit.Periph.setConnectCallback(connect_callback);
4546
Bluefruit.Periph.setDisconnectCallback(disconnect_callback);
4647

48+
// To be consistent OTA DFU should be added first if it exists
49+
bledfu.begin();
50+
4751
// Configure and Start Device Information Service
4852
bledis.setManufacturer("Adafruit Industries");
4953
bledis.setModel("Bluefruit Feather52");

libraries/Bluefruit52Lib/examples/Peripheral/blinky_ota/blinky_ota.ino

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515
#include <bluefruit.h>
1616

17+
// OTA DFU service
18+
BLEDfu bledfu;
19+
1720
void setup()
1821
{
1922
Serial.begin(115200);
@@ -27,6 +30,9 @@ void setup()
2730
Bluefruit.setTxPower(4);
2831
Bluefruit.setName("Bluefruit52");
2932

33+
// To be consistent OTA DFU should be added first if it exists
34+
bledfu.begin();
35+
3036
// Set up and start advertising
3137
startAdv();
3238
}

libraries/Bluefruit52Lib/examples/Peripheral/controller/controller.ino

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414

1515
#include <bluefruit.h>
1616

17+
// OTA DFU service
18+
BLEDfu bledfu;
19+
20+
// Uart over BLE service
1721
BLEUart bleuart;
1822

1923
// Function prototypes for packetparser.cpp
@@ -37,6 +41,9 @@ void setup(void)
3741
Bluefruit.setTxPower(4);
3842
Bluefruit.setName("Bluefruit52");
3943

44+
// To be consistent OTA DFU should be added first if it exists
45+
bledfu.begin();
46+
4047
// Configure and start the BLE Uart service
4148
bleuart.begin();
4249

libraries/Bluefruit52Lib/examples/Peripheral/neopixel/neopixel.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ uint8_t components = 3; // only 3 and 4 are valid values
4343
Adafruit_NeoPixel neopixel = Adafruit_NeoPixel();
4444

4545
// BLE Service
46+
BLEDfu bledfu;
4647
BLEDis bledis;
4748
BLEUart bleuart;
4849

@@ -67,6 +68,9 @@ void setup()
6768
Bluefruit.setName("Bluefruit52");
6869
Bluefruit.Periph.setConnectCallback(connect_callback);
6970

71+
// To be consistent OTA DFU should be added first if it exists
72+
bledfu.begin();
73+
7074
// Configure and Start Device Information Service
7175
bledis.setManufacturer("Adafruit Industries");
7276
bledis.setModel("Bluefruit Feather52");

libraries/Bluefruit52Lib/src/bluefruit.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,7 @@ static void nrf_error_cb(uint32_t id, uint32_t pc, uint32_t info)
107107
#endif
108108
}
109109

110-
/**
111-
* Constructor
112-
*/
110+
// Constructor
113111
AdafruitBluefruit::AdafruitBluefruit(void)
114112
{
115113
/*------------------------------------------------------------------*/
@@ -149,8 +147,6 @@ AdafruitBluefruit::AdafruitBluefruit(void)
149147
_led_blink_th = NULL;
150148
_led_conn = true;
151149

152-
_ota_en = true;
153-
154150
_tx_power = CFG_BLE_TX_POWER_LEVEL;
155151

156152
_conn_hdl = BLE_CONN_HANDLE_INVALID;
@@ -268,11 +264,6 @@ void AdafruitBluefruit::configCentralBandwidth(uint8_t bw)
268264
}
269265
}
270266

271-
void AdafruitBluefruit::enableOTA(bool en)
272-
{
273-
_ota_en = en;
274-
}
275-
276267
bool AdafruitBluefruit::begin(uint8_t prph_count, uint8_t central_count)
277268
{
278269
_prph_count = prph_count;
@@ -455,9 +446,6 @@ bool AdafruitBluefruit::begin(uint8_t prph_count, uint8_t central_count)
455446
sd_power_usbremoved_enable(true);
456447
#endif
457448

458-
// Add DFU OTA service if enabled
459-
if ( _ota_en ) _dfu_svc.begin();
460-
461449
// Init Central role
462450
if (_central_count) Central.begin();
463451

libraries/Bluefruit52Lib/src/bluefruit.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,6 @@ class AdafruitBluefruit
135135
void configPrphBandwidth (uint8_t bw);
136136
void configCentralBandwidth(uint8_t bw);
137137

138-
void enableOTA(bool en);
139-
140138
bool begin(uint8_t prph_count = 1, uint8_t central_count = 0);
141139

142140
/*------------------------------------------------------------------*/
@@ -231,9 +229,6 @@ class AdafruitBluefruit
231229
TimerHandle_t _led_blink_th;
232230
bool _led_conn;
233231

234-
bool _ota_en;
235-
BLEDfu _dfu_svc;
236-
237232
uint16_t _conn_hdl;
238233

239234
BLEConnection* _connection[BLE_MAX_CONNECTION];

0 commit comments

Comments
 (0)