7 years, 2 months ago.

UARTService RXCharacteristic Update Limit?

Hey y'all,

I'm pretty new to using BLE in general, but I'm hoping my question isn't too naive. Maybe I'm not using the right keywords, but I haven't found an answer to my problem.

I'm using the nRF51822 for a project, and here's an outline of what I'm trying to do:

  1. This micro is hooked up to a heart rate sensor and a potentiometer
  2. The micro keeps track of time using an RTC library that someone made and published
  3. Every time an external interrupt is triggered (button press), the micro reads the sensors and the current time and stores this data into flash memory (pstorage)
  4. At some point when a user with a custom app connects, the connection will initiate a data transfer where all the data will be read from flash (one byte at a time) and sent over BLE to the app

While I try and build up each part of this project, I'm currently using the UARTService for debugging purposes. I also planned on using this for the data synchronization mentioned in (4).

For part of this debugging, I currently send off a bunch of data to my phone when the phone sends a certain prompt. The issue I'm experiencing is that when I try and update the RxCharacteristic back to back, it appears to stop sending data after the 4th update. When I resend the command, it will still only execute 4 updates and seemingly ignore the rest.

Updating Rx

#define MAX_UART_PACKET_LEN 20

// Assume ble object exists and is initialized

void dataWrittenCallback(const GattWriteCallbackParams *params)
{
    bool isUartInitialized = (uartService != NULL);
    bool wasTxCharacteristicWrittenTo = (params->handle == uartService->getTXCharacteristicHandle());

    if (isUartInitialized && wasTxCharacteristicWrittenTo)
    {
        if (0 == strcmp((char *)params->data, "ps")) 
        {
            initializePStorage();
        }
        else 
        {
            sendDataOverBLE("Unknown command");
        }            
    }
}

void sendDataOverBLE(const char* format, ...)
{

    uint8_t buffer[MAX_UART_PACKET_LEN];
    int len;

    va_list args;
    va_start (args, format);
    len = vsnprintf((char *)buffer, MAX_UART_PACKET_LEN, format, args);

    ble.updateCharacteristicValue(uartService->getRXCharacteristicHandle(), buffer, len);

    va_end (args);
}

Calling the send function

#include "pstorage.h"

void debugPStorageInfo()
{
    sendDataOverBLE("PageSize: 0x%x", PSTORAGE_FLASH_PAGE_SIZE);
    sendDataOverBLE("Boot: 0x%x", BOOTLOADER_ADDRESS);
    sendDataOverBLE("Swap: 0x%x", PSTORAGE_SWAP_ADDR);
    sendDataOverBLE("Start: 0x%x", PSTORAGE_DATA_START_ADDR);

    // This data does not get sent!
    sendDataOverBLE("End: 0x%x", PSTORAGE_DATA_END_ADDR);
}

Does anyone have any ideas or tips?

Question relating to:

Bluetooth Low Energy (a.k.a Bluetooth LE, BTLE, Bluetooth Smart)

1 Answer

6 years, 12 months ago.

I am having the same problem!