This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2541 BLE stack 1.4.1 Battery Service issue/question

I'm a little reluctant to post this since, if it was an issue, it would surely have been reported by now. However....

In testing battery service notifications it seems that it only reports when the measured level is less that the previous measured level. This is fine for alkaline batteries etc. but LiPo batteries will never show that they are recharging/have been recharged unless you power-cycle the peripheral.

Looking at battservice.c:

In two places we have:

bStatus_t Batt_MeasLevel( void )
{
  uint8 level;

  level = battMeasure();

  // If level has gone down
  if (level < battLevel)
  {
    // Update level
    battLevel = level;

    // Send a notification
    battNotifyLevel();
  }

  return SUCCESS;

and

static bStatus_t battReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
                                 uint8 *pValue, uint8 *pLen, uint16 offset,
                                 uint8 maxLen, uint8 method )
{
....

  // Measure battery level if reading level
  if ( uuid == BATT_LEVEL_UUID )
  {
    uint8 level;

    level = battMeasure();

    // If level has gone down
    if (level < battLevel)
    {
      // Update level
      battLevel = level;
    }

If you replace the level < battLevel with level != battLevel the service correctly notifies on both decreasing and increasing battery level.

But I guess it's forbidden to change a BT registered service?

Regards,

ac