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.

CCS/CC2640R2F: Problem with GGS

Part Number: CC2640R2F
Other Parts Discussed in Thread: BLE-STACK, CC2640

Tool/software: Code Composer Studio

Hi all,

I am trying to learn BLE stack with CC2640R2F. I took simple_peripheral example as a starting point. My task init function looks like this:

static void App_init( void ) {
    ICall_registerApp(&selfEntity, &syncEvent);

    Queue_construct(&appMsgQueue, NULL);
    appMsgQueueHandle = Queue_handle(&appMsgQueue);

    Util_constructClock(&clkPeriodic, App_clockHandler, 1000, 0, false, 0);

    GAP_SetParamValue(GAP_PARAM_LINK_UPDATE_DECISION, GAP_UPDATE_REQ_ACCEPT_ALL);

    GGS_SetParameter(GGS_DEVICE_NAME_ATT, GAP_DEVICE_NAME_LEN, appDeviceName);

    GASS_AddService();
    GGS_AddService(GATT_ALL_SERVICES);           
    GATTServApp_AddService(GATT_ALL_SERVICES);   

    DevInfo_AddService();
    BAT_AddService();

    GAP_RegisterForMsgs(selfEntity);
    GATT_RegisterForMsgs(selfEntity);

    GATT_InitClient();

    GAP_DeviceInit(GAP_PROFILE_PERIPHERAL, selfEntity, ADDRMODE_PUBLIC, NULL);
}

I've added my custom battery service (which works fine), but when I am connecting to my board with android with BLE scanning app, I see that GENERIC ACCESS properties are write only (see screenshot).

I've tried to manually set the permissions:

uint8 devNamePermission = GATT_PERMIT_READ;
GGS_SetParameter(GGS_W_PERMIT_DEVICE_NAME_ATT, sizeof(uint8_t), &devNamePermission);
GGS_SetParameter(GGS_W_PERMIT_APPEARANCE_ATT, sizeof(uint8_t), &devNamePermission);

It doesn't work. Also I've even tried to write my own generic access profile:

#include "icall_ble_api.h"



static uint8 devNameProps = GATT_PROP_READ;
static uint8 appearanceProps = GATT_PROP_READ;

static CONST gattAttrType_t gapService = { ATT_BT_UUID_SIZE, gapServiceUUID };

static uint8_t devName[GAP_DEVICE_NAME_LEN] = "TestDev";
static uint8_t appearance[] = {0};


static gattAttribute_t gapAttrTbl[] =
{
  // Device Information Service
  {
    { ATT_BT_UUID_SIZE, gapServiceUUID }, /* type */
    GATT_PERMIT_READ,                         /* permissions */
    0,                                        /* handle */
    (uint8 *)&gapService                  /* pValue */
  },
    {
      { ATT_BT_UUID_SIZE, characterUUID },
      GATT_PERMIT_READ,
      0,
      &devNameProps
    },

    // Dev name value
    {
      { ATT_BT_UUID_SIZE, deviceNameUUID },
      GATT_PERMIT_READ,
      0,
      (uint8 *) devName
    },
    // Declaration
    {
      { ATT_BT_UUID_SIZE, characterUUID },
      GATT_PERMIT_READ,
      0,
      &appearanceProps
    },
    // Appearance value
    {
      { ATT_BT_UUID_SIZE, appearanceUUID },
      GATT_PERMIT_READ,
      0,
      (uint8 *) &appearance
    },

};

static bStatus_t GACC_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
                                     uint8 *pValue, uint16 *pLen, uint16 offset,
                                     uint16 maxLen, uint8 method );



CONST gattServiceCBs_t gapCBs = {
    GACC_ReadAttrCB, // Read callback function pointer
    NULL,               // Write callback function pointer
    NULL                // Authorization callback function pointer
};

bStatus_t GASS_AddService( void ) {
    return GATTServApp_RegisterService( gapAttrTbl, GATT_NUM_ATTRS( gapAttrTbl ), GATT_MAX_ENCRYPT_KEY_SIZE, &gapCBs );
}

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

    bStatus_t status = SUCCESS;

    if ( offset > 0 ) {  return ( ATT_ERR_ATTR_NOT_LONG );  }

    if ( pAttr->type.len == ATT_BT_UUID_SIZE ) {

        uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
        switch ( uuid ) {


        case DEVICE_NAME_UUID:
            *pLen = 6;
            memcpy( pValue, pAttr->pValue, *pLen );
            break;

        case APPEARANCE_UUID:
            *pLen = 1;
            pValue[0] = *pAttr->pValue;
            break;

        default:
            *pLen = 0;
            status = ATT_ERR_ATTR_NOT_FOUND;
            break;

        }
    } else {
        *pLen = 0;
        status = ATT_ERR_INVALID_HANDLE;
    }
    return ( status );
}

It doesn't work either. The function GATTServApp_RegisterService returns 2 (invalid arg). 

I compiled my project with two versions of compiler (16.9.4 and 20.2.1).

I was trying to load different examples (project zero and simple_peripheral with minimal changes due to custom board).

Please tell me where is the problem and how to solve it. And why can't I create my own generic access profile.

Thank you!

  • Hi,

    I have assigned an expert to comment.

    Also, which BLE stack and SDK version are you using for your application?

    Regards,
    Michael

  • Hi Nick,

    1) What version of the SimpleLink CC2640R2 SDK are you basing your code on?

    2) Can you call GGS_SetParameter() after GGS_AddService().

    3) GGS is a part of the BLE-Stack library so making your own version wont work.

    4) Regarding GGS_SetParameter() with the permissions I think the GAPGATTServer  may be overwriting the parameters. Let me check this.

  • Hi,

    1) I am using SDK version 4.10.01.00

    2) It didn't help

  • I am still trying to figure out the reason. I've tried different compiler versions, different sdk versions. Different examples. Ble5 and ble stack. All the same.

    I am working with CCS 10.1.0.00010. I compiled projects on two different PCs (win and Linux).

    It looks like some kind of data alignment error (wrong bytes are fetched within stack or something like that).

    I am using custom board (basically HM-19 chinese module with 4x4 package). I've made changes in board files (created and included my own board file, remapped pins according to my configuration).

    May be I am missing some config due to different package?

    And almost all the time when I start debug session, Cc2640 hangs on addr 0x1001b986 (some internal library loop). Hardware resetting the device brings everything to normal.

    I am using segger jlink debugger.