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.

cc2540 adding new attributes UUID

Other Parts Discussed in Thread: CC2540

Hi,

I am using the cc2540 and the Mini DK.
I am trying to add a second accelerometer with the same part number as the one that is onboard and read from it using the other USART and some pins that are not used for anything else.

My first try was to read separately from the external accelerometer. And that is working fine.
Now what I want to do is add another enable for the second accelerometer and be able to read and control both.

Is there any simple way to do this?
Please could anybody tell me the main steps to achieve my goal?

What I have done until now is

1. Change cma3000d to include acc2init(), acc2ReadAcc(), acc2ReadReg() and acc2Write().
I am able to use these functions to configure the second usart and read from the other pins.
(working)

2. I have added  

// Profile UUIDs
#define ACCEL2_ENABLER_UUID            0xFFA6
#define ACCEL2_RANGE_UUID              0xFFA7
#define ACCEL2_X_UUID                  0xFFA8
#define ACCEL2_Y_UUID                  0xFFA9
#define ACCEL2_Z_UUID                  0xFFAA
 
// Accelerometer Service UUID
#define ACCEL2_SERVICE_UUID           

With the idea of being able to access them with Btool.

3. In keyfobdemo.h/.c I have add accel2Read() and accel2EnableChangeCB() because they were calling acc2init, acc2ReadAcc.

I have added a new event to allow me to control both accelerometers separately.

#define KFD_START_DEVICE_EVT                              0x0001
#define KFD_BATTERY_CHECK_EVT                             0x0002
#define KFD_ACCEL_READ_EVT                                0x0004
#define KFD_TOGGLE_BUZZER_EVT                             0x0008
#define KFD_ADV_IN_CONNECTION_EVT                         0x0010

#define KFD_ACCEL2_READ_EVT                                0x0020 

As I will have a second enable attribute on my profile I have added

// Accelerometer Profile Callbacks
static accelCBs_t keyFob_Accel2CBs =
{
  accel2EnablerChangeCB,          // Called when Enabler attribute changes
};

and do the following calls from keyfobdemo.c

// Start the Accelerometer Profile
               VOID Accel_RegisterAppCBs( &keyFob_AccelCBs );
   
// Start the Accelerometer2 Profile
    VOID Accel2_RegisterAppCBs( &keyFob_Accel2CBs );

4. In the accelerometer profile (accelerometer.c/.h) I have included the new attributes UUID on the attributes table and declare new 

static profile Attributes variables.

  // If an attribute changed then callback function to notify application of change
  if ( (notify != 0xFF) && accel2_AppCBs && accel2_AppCBs->pfnAccelEnabler )
    accel2_AppCBs->pfnAccelEnabler(); 

When I use BTool to access ACCEL2_ENABLER_UUID (0xFFA6) I am getting "success" as a response but anything else. 

I am also confused with the utility of the services..  is that useful in the case of two accelerometers?

Any help will be greatly appreciated.

 

  • can you provide what you have done to change the profile attribute table:

    /*********************************************************************
    * Profile Attributes - Table
    */
    static gattAttribute_t accelAttrTbl[SERVAPP_NUM_ATTR_SUPPORTED] =
    {
  • Thank you for your fast reply, 
    
    
    I have included them at the end and declared new static variables for the pValue
    
    
    #define SERVAPP_NUM_ATTR_SUPPORTED        24
    
    
    /*********************************************************************
    * Profile Attributes - Table
    */
    static gattAttribute_t accelAttrTbl[SERVAPP_NUM_ATTR_SUPPORTED] =
    {
    // Accelerometer Service
    {
    { ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */
    GATT_PERMIT_READ, /* permissions */
    0, /* handle */
    (uint8 *)&accelService /* pValue */
    },

    // Accel Enabler Characteristic Declaration
    {
    { ATT_BT_UUID_SIZE, characterUUID },
    GATT_PERMIT_READ,
    0,
    &accelEnabledCharProps
    },

    // Accelerometer Enable Characteristic Value
    {
    { ATT_BT_UUID_SIZE, accEnablerUUID },
    GATT_PERMIT_READ | GATT_PERMIT_WRITE,
    0,
    &accelEnabled
    },

    // Accelerometer Enable User Description
    {
    { ATT_BT_UUID_SIZE, charUserDescUUID },
    GATT_PERMIT_READ,
    0,
    (uint8*)&accelEnabledUserDesc
    },

    // Accel Range Characteristic Declaration
    {
    { ATT_BT_UUID_SIZE, characterUUID },
    GATT_PERMIT_READ,
    0,
    &accelRangeCharProps
    },

    // Accelerometer Range Char Value
    {
    { ATT_BT_UUID_SIZE, rangeUUID },
    GATT_PERMIT_READ,
    0,
    (uint8*)&accelRange
    },

    // Accelerometer Range User Description
    {
    { ATT_BT_UUID_SIZE, charUserDescUUID },
    GATT_PERMIT_READ,
    0,
    accelRangeUserDesc
    },

    // X-Coordinate Characteristic Declaration
    {
    { ATT_BT_UUID_SIZE, characterUUID },
    GATT_PERMIT_READ,
    0,
    &accelXCharProps
    },

    // X-Coordinate Characteristic Value
    {
    { ATT_BT_UUID_SIZE, xUUID },
    0,
    0,
    (uint8*) &accelCoordinates[0]
    },

    // X-Coordinate Characteristic configuration
    {
    { ATT_BT_UUID_SIZE, clientCharCfgUUID },
    GATT_PERMIT_READ | GATT_PERMIT_WRITE,
    0,
    (uint8 *)&accelConfigCoordinates[0]
    },

    // X-Coordinate Characteristic User Description
    {
    { ATT_BT_UUID_SIZE, charUserDescUUID },
    GATT_PERMIT_READ,
    0,
    accelXCharUserDesc
    },

    // Y-Coordinate Characteristic Declaration
    {
    { ATT_BT_UUID_SIZE, characterUUID },
    GATT_PERMIT_READ,
    0,
    &accelYCharProps
    },

    // Y-Coordinate Characteristic Value
    {
    { ATT_BT_UUID_SIZE, yUUID },
    0,
    0,
    (uint8*) &accelCoordinates[1]
    },

    // Y-Coordinate Characteristic configuration
    {
    { ATT_BT_UUID_SIZE, clientCharCfgUUID },
    GATT_PERMIT_READ | GATT_PERMIT_WRITE,
    0,
    (uint8 *)&accelConfigCoordinates[1]
    },

    // Y-Coordinate Characteristic User Description
    {
    { ATT_BT_UUID_SIZE, charUserDescUUID },
    GATT_PERMIT_READ,
    0,
    accelYCharUserDesc
    },

    // Z-Coordinate Characteristic Declaration
    {
    { ATT_BT_UUID_SIZE, characterUUID },
    GATT_PERMIT_READ,
    0,
    &accelZCharProps
    },

    // Z-Coordinate Characteristic Value
    {
    { ATT_BT_UUID_SIZE, zUUID },
    0,
    0,
    (uint8*) &accelCoordinates[2]
    },

    // Z-Coordinate Characteristic configuration
    {
    { ATT_BT_UUID_SIZE, clientCharCfgUUID },
    GATT_PERMIT_READ | GATT_PERMIT_WRITE,
    0,
    (uint8 *)&accelConfigCoordinates[2]
    },

    // Z-Coordinate Characteristic User Description
    {
    { ATT_BT_UUID_SIZE, charUserDescUUID },
    GATT_PERMIT_READ,
    0,
    accelZCharUserDesc
    },

    // Accelerometer Service----------------------------------------
    {
    { ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */
    GATT_PERMIT_READ, /* permissions */
    0, /* handle */
    (uint8 *)&accel2Service /* pValue */
    },
    // Accelerometer Enable Characteristic Value----------------
    {
    { ATT_BT_UUID_SIZE, acc2EnablerUUID },
    GATT_PERMIT_READ | GATT_PERMIT_WRITE,
    0,
    &accel2Enabled
    },

    // X-Coordinate Characteristic Value--------------------------------
    {
    { ATT_BT_UUID_SIZE, x2UUID },
    0,
    0,
    (uint8*) &accel2Coordinates[0]
    },

    // Y-Coordinate Characteristic Value------------------------------
    {
    { ATT_BT_UUID_SIZE, y2UUID },
    0,
    0,
    (uint8*) &accel2Coordinates[1]
    },

    //
    // Z-Coordinate Characteristic Value------------------------------
    {
    { ATT_BT_UUID_SIZE, z2UUID },
    0,
    0,
    (uint8*) &accel2Coordinates[2]
    },
    };
  • Hi!

    Sorry for my bad english. I'm a newbie to digital electronic and BLE.

    I'm interested in your  work. I'd like to connect  an external accelerometer to the keyfob as in your project.

    Could you explain me your hardware configuration ?

    Have you used the USART 0 in the first location or the USART 1 ?

    Which Pin have you used ? The debug/ flash pin or the additional Testpins ?

    Which changes have you made to the keyfobdemo project ?

    thank you in advance and best regards

  • 1、there is a wrong configuration on your defined UUID,you can config it like demo,the structure is :

    static gattAttribute_t userDefAttrTbl[]

    {

        // user defined primary service
        { 
          {ATT_BT_UUID_SIZE, primaryServiceUUID },     /* type */
          GATT_PERMIT_READ,                                        /* permissions */
          0,                                                                           /* handle */
          (uint8 *)&userDefService                                           /* pValue */
        },


        // Characteristic Declaration for Set_dev_name UUID
        {
          { ATT_BT_UUID_SIZE, characterUUID },
          GATT_PERMIT_READ,
          0,
          &userdefUUID01CharProps
        },
       
        // Characteristic  value
        {
          { ATT_UUID_SIZE, userDefUUID01 },
          GATT_PERMIT_READ|GATT_PERMIT_WRITE ,
          0,
          (uint8 *)&userDefUUID01val
        },

       ...

           // Characteristic Declaration for Set_dev_name UUID
        {
          { ATT_BT_UUID_SIZE, characterUUID },
          GATT_PERMIT_READ,
          0,
          &userdefUUIDnCharProps
        },
       
        // Characteristic  value
        {
          { ATT_UUID_SIZE, userDefUUIDn },
          GATT_PERMIT_READ|GATT_PERMIT_WRITE ,
          0,
          (uint8 *)&userDefUUIDnval
        },

    }

    the character feature can be modify by yourself

    sorry for my poor English ,you can send message by QQ(2912615383) for detail,thank you!