From 89ba0b1aac7784a6c53fb5a65b736997f47cba93 Mon Sep 17 00:00:00 2001 From: Petr Nejedly Date: Sat, 1 Sep 2018 11:54:58 -0700 Subject: [PATCH 1/2] Fix upstream issue #173 - lost UART packets. In case the application is sending more notifications back-to-back and the framework has no free buffer slots error code was returned instead of false, which was interpreted as success. Return false in such a case, in line with SD buffer overflow handling below. --- libraries/Bluefruit52Lib/src/BLECharacteristic.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/Bluefruit52Lib/src/BLECharacteristic.cpp b/libraries/Bluefruit52Lib/src/BLECharacteristic.cpp index 3f85b4169..91c2d09a0 100644 --- a/libraries/Bluefruit52Lib/src/BLECharacteristic.cpp +++ b/libraries/Bluefruit52Lib/src/BLECharacteristic.cpp @@ -539,7 +539,8 @@ bool BLECharacteristic::notify(const void* data, uint16_t len) while ( remaining ) { // TODO multiple connection support - if ( !Bluefruit.Gap.getHvnPacket( Bluefruit.connHandle() ) ) return NRF_ERROR_RESOURCES; //BLE_ERROR_NO_TX_PACKETS; + // With no free buffers, give the app a channce to retry gracefully + if ( !Bluefruit.Gap.getHvnPacket( Bluefruit.connHandle() ) ) return false; uint16_t packet_len = min16(max_payload, remaining); From 50a0a9ec437fcc3bc49a8816993ce999c7383071 Mon Sep 17 00:00:00 2001 From: Petr Nejedly Date: Sat, 1 Sep 2018 12:37:39 -0700 Subject: [PATCH 2/2] Fix upstream issue #171: Better choice of pin interrupt priority Nordic SoftDevice needs to have control over lowest priority interrupts for reliable, timing sensitive operation. If user code tries to use such a low priority level, SoftDevice refuses to start. One way to overcome this limitation is to start the SoftDevice before attaching pin change interrupts, though in such a case, SD will cap the effective priority of the user interrupt anyway and it is a common mistake API users do. This change simply changes the priority to 2, which is legal (for fast interrupt handlers anyway) under SoftDevice, no matter if attached before of after SD start. --- cores/nRF5/WInterrupts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/nRF5/WInterrupts.c b/cores/nRF5/WInterrupts.c index b3c6c357a..ffb45cf62 100644 --- a/cores/nRF5/WInterrupts.c +++ b/cores/nRF5/WInterrupts.c @@ -42,7 +42,7 @@ static void __initialize() NVIC_DisableIRQ(GPIOTE_IRQn); NVIC_ClearPendingIRQ(GPIOTE_IRQn); - NVIC_SetPriority(GPIOTE_IRQn, 1); + NVIC_SetPriority(GPIOTE_IRQn, 2); NVIC_EnableIRQ(GPIOTE_IRQn); }