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.

Added Characteristic to simpleBLEProfile not showing up in Android/BLE Monitor

Hi,

I tried adding a characteristic and for some reason it won't show up to the Android app and appears weird when using the BLE Device Monitor. In Android, the characteristic does not show up at all, and in BLE Dev Mon, the item will show up but will not have descriptions, which I'm guessing is related to the same issue.  Am I missing some init step? Code is below the images.

in simpleGATTprofile.c:

init global variables:


// Characteristic 6 UUID: 0xFFF6
CONST uint8 simpleProfilechar6UUID[ATT_BT_UUID_SIZE] =
{
LO_UINT16(SIMPLEPROFILE_CHAR6_UUID), HI_UINT16(SIMPLEPROFILE_CHAR6_UUID)
};

...

Create the Profile attribute variables:


// Simple Profile Characteristic 6 Properties
static uint8 simpleProfileChar6Props = GATT_PROP_READ | GATT_PROP_WRITE;

// Characteristic 6 Value
static uint8 simpleProfileChar6[SIMPLEPROFILE_CHAR6_LEN] = { 0 };

// Simple Profile Characteristic 6 User Description
static uint8 simpleProfileChar6UserDesp[] = "Characteristic 6\0";

...

Update the profile attributes table:


// Characteristic 6 Declaration
{
{ ATT_BT_UUID_SIZE, characterUUID },
GATT_PERMIT_READ,
0,
&simpleProfileChar6Props
},

// Characteristic Value 6
{
{ ATT_BT_UUID_SIZE, simpleProfilechar6UUID },
GATT_PERMIT_READ | GATT_PERMIT_WRITE,
0,
simpleProfileChar6
},

// Characteristic 6 User Description
{
{ ATT_BT_UUID_SIZE, charUserDescUUID },
GATT_PERMIT_READ,
0,
simpleProfileChar6UserDesp
},

...

In SimpleProfile_SetParameter:


case SIMPLEPROFILE_CHAR6:
if ( len <= SIMPLEPROFILE_CHAR6_LEN )
{
VOID osal_memcpy( simpleProfileChar6, value, SIMPLEPROFILE_CHAR6_LEN );
}
else
{
ret = bleInvalidRange;
}
break;

...

In SimpleProfile_GetParameter:


case SIMPLEPROFILE_CHAR6:
VOID osal_memcpy( value, simpleProfileChar6, SIMPLEPROFILE_CHAR6_LEN );
break;

...

In simpleProfile_ReadAttrCB:


case SIMPLEPROFILE_CHAR6_UUID:
*pLen = SIMPLEPROFILE_CHAR6_LEN;
VOID osal_memcpy( pValue, pAttr->pValue, SIMPLEPROFILE_CHAR6_LEN );
break;

...

In simpleProfile_WriteAttrCB:


case SIMPLEPROFILE_CHAR6_UUID:
//Validate the value
// Make sure it's not too long

if ( len >= SIMPLEPROFILE_CHAR6_LEN )
{
status = ATT_ERR_INVALID_VALUE_SIZE;
}

//Write the value
if ( status == SUCCESS )
{
uint8 *pCurValue = (uint8 *)pAttr->pValue;
osal_memcpy(pCurValue+offset, pValue, len);
notifyApp = SIMPLEPROFILE_CHAR6;
}

break;

In simpleGATTprofile.h:

#define SIMPLEPROFILE_CHAR6 5 // RW uint8 - Profile Characteristic 6 value

#define SIMPLEPROFILE_CHAR6_UUID 0xFFF6

#define SIMPLEPROFILE_CHAR6_LEN 10

In simpleBLEPeripheral.c: it is initialized in SimpleBLEPeripheral_Init


uint8 charValue6[SIMPLEPROFILE_CHAR6_LEN] = { 0 };

SimpleProfile_SetParameter( SIMPLEPROFILE_CHAR6, SIMPLEPROFILE_CHAR6_LEN, charValue6 );

  • Hi Danny,

    Are you adding a NULL terminator to your Char 6 user description: "Characteristic 6\0";?
    Also, what is the behavior that you observe with CC debugger during a read/write? Any errors?

    Best wishes
  • Hi JXS,

    Yes, the Char 6 user description is defined as "Characteristic 6\0";. When I read/write from the BLE Dev Mon, I don't see any errors AFAIK. I have a callback that updates the advertisement data with the write to Char 6, and that updates correctly. I still can't see the characteristic from the Android, however. Do I have to register the added characteristic somewhere for when available services are queried?
  • Hi Danny,

    If you see the Char correctly in Dev Monitor and/or BTool, then it's likely working correctly.

    I've been told that Android doesn't like it when a specific paired/bonded device changes it's GATT database table. Maybe try removing the history of the device from the phone and try to re-connect.

    Best wishes
  • Hi JXS,

    The Char doesn't show correctly in the BLE Dev Mon, unfortunately. It shows up as in the first image I attached, with blank descriptions. Also, do you have a reference for how to remove the device history from the Android device? Is it just deleting the app?

  • Hello. Usually turning bluetooth off/on removes the device history. Note that there is a step-by-step guide describing how to add characteristics / profiles:

    processors.wiki.ti.com/.../Tutorial:_How_to_Create_a_Custom_Bluetooth_Smart_Embedded_Application_with_the_CC2650DK
  • I agree with Tim and would like to add that on iOS it is a known and common issue that the OS is caching device characteristics and a reboot of the iOS is often the only way to see the updated GATT. I am not familiar with Android but would not be surprised if the situation is similar there.

    This of course only applies to a changing service database as we commonly do during development, not the actual values of the characteristics which are not caches in that was and therefore don't have the issue. Once you have established how your profile should look like, this often becomes a non-issue but can indeed be quite annoying during development.

    As a general practice we typically reboot the mobile devices anytime we add or remove a service from GATT.

    Hope that helps.