BLE Peripheral UART Streaming Assertion Failure

I am currently modifying the BLE UART peripheral tutorial example ( to send a data stream to the NRF UART v2.0 Android app. My current firmware sends 10 bytes every 100ms via the Timer class & callback. It always connects and works the first time the argon/ app pair after power-on; however I get an assertion failure (SOS + 10 blinks) after successive ‘disconnects’ and ‘pairs’ between the two. The number of successive pairs it takes to get the assertion failure varies each time.

What causes an assertion failure…? If needed I can post code, but I am really not doing much more than adding a timer to the built-in example Particle provided.

Can you post your code. Software Timers have limited stack size and may be part of the problem.

#include "Particle.h"

// This example does not require the cloud so you can run it in manual mode or
// normal cloud-connected mode

const size_t UART_TX_BUF_SIZE = 20;

void onDataReceived(const uint8_t* data, size_t len, const BlePeerDevice& peer, void* context);

// These UUIDs were defined by Nordic Semiconductor and are now the defacto standard for
// UART-like services over BLE. Many apps support the UUIDs now, like the Adafruit Bluefruit app.
const BleUuid serviceUuid("6E400001-B5A3-F393-E0A9-E50E24DCCA9E");
const BleUuid rxUuid("6E400002-B5A3-F393-E0A9-E50E24DCCA9E");
const BleUuid txUuid("6E400003-B5A3-F393-E0A9-E50E24DCCA9E");

BleCharacteristic txCharacteristic("tx", BleCharacteristicProperty::NOTIFY, txUuid, serviceUuid);
BleCharacteristic rxCharacteristic("rx", BleCharacteristicProperty::WRITE_WO_RSP, rxUuid, serviceUuid, onDataReceived, NULL);

//My Timer Addition to the Particle Example App
void Timer100msCallback();
Timer Timer100ms(100, Timer100msCallback);
bool Timer100msSend = false;

//Resume Particle Example App
void onDataReceived(const uint8_t* data, size_t len, const BlePeerDevice& peer, void* context) {
    // Log.trace("Received data from: %02X:%02X:%02X:%02X:%02X:%02X:", peer.address()[0], peer.address()[1], peer.address()[2], peer.address()[3], peer.address()[4], peer.address()[5]);

    for (size_t ii = 0; ii < len; ii++) {

void Timer100msCallback(){
    Timer100msSend = true;

void setup() {


    BleAdvertisingData data;

void loop() {
    if (BLE.connected()) 
        uint8_t txBuf[UART_TX_BUF_SIZE];
        size_t txLen = 0;

        while(Serial.available() && txLen < UART_TX_BUF_SIZE) {
            txBuf[txLen++] =;
            Serial.write(txBuf[txLen - 1]);
        for(int i = 0; i < 10; i++) txBuf[i] = 65+i;
        txLen = 10;
           if (txLen > 0) txCharacteristic.setValue(txBuf, txLen);
           Timer100msSend = false;    

@peekay123 Any idea what’s going on here? Perhaps this is more of a question for @rickkas7?

I’m testing @rickkas7 latest BLE Serial UART library and it works great until the connected BLE device looses connection by going out of range which causes a disconnection and usually this causes the Argon to go into SOS :sos: red flash and the code and counter to reset back to zero.

If you are in range and hit the disconnect button on the Serial Terminal app then the Argon does not crash. If you disconnect by going out of range then you will usually see the Argon SOS and restart from scratch.

I’m sending data every second. I’m connecting via the Adafruit Bluefruit app and a Chrome Web Browser BLE Serial Terminal.

We need to figure out a way to prevent the BLE disconnect due to going out of range from crashing the Gen3 device.

@RWB We may be having seperate issues here. My problem is definitely disconnect related however it’s not caused by the argon going out of range. All the firmware I’ve tested has been with the argon within arms reach. I’ve tested on 2 seperate argons running the same firmware, both with the same results. No issues on first connection, however argon will crash after successive ‘disconnects’ and ‘pairs’ of varying amounts.

Actually, if I’m in good range and I connect and disconnect enough the Argon will SOS as shown in the screenshot below where the counter resets.

Seems like disconnecting from BLE can cause this SOS failure for some reason.

@peekay123 @rickkas7 @ScruffR @RWB Has anyone made any progress on this issue?

Not that I have seen.

I’m trying to do this test against this branch with many fixes:

Will post the result here.

1 Like

Hi there,

There is a fix for this issue: I’ve tested it using an Argon on my side. Could you also help verify if it works?


So you were also seeing the Gen3 Devices SOS after the connected BLE Device went out of range? I’m hoping your fix works if so. I’ll test it.

Actually both of the SOS behaviors you mentioned above is caused by the same bug. The disconnection caused by going out of range is easier to produce the issue. Initiatively disconnecting the connection will invalid the connection handle immediately so that next data transmission attempts will be prevented. But there is still a little chance that the disconnection is happening during a on-going data transmission, which will result a SOS assertion. While disconnecting by going out of range, the connection handle is remaining valid but the connection is actually lost, until a delayed disconnection event raised. That’s why going out of range is easier to produce the issue.

Nice to see you have this issues figured out and fixed!

I use Workbench but have no idea how to compile that altered code so I’ll have to wait until it’s merged with the next firmware release.