CC2340R5: custom uuid 128

Part Number: CC2340R5

Tool/software:

Hi i am using cc2340 development board for developing a custom service of 128 bit , i have made all the changes required to do.
but in my mobile app i am seeing F0000 XXXX 0451 b000 000000000000 as the service uuid. and xxxx are only the bytes which are from my custom uuid, as i searched on net it shows that F0000 XXXX 0451 b000 000000000000 is the base 128 bit ti uuid.

so i am not getting why this is happening as i have created my .c and .h file where i have declared it as 128 bit , and i have also taken reference from  ti site-  https://software-dl.ti.com/lprf/simplelink_academy/modules/ble_01_custom_profile/ble_01_custom_profile.html#example-service-generator   for developing 128 bit uuid and i have selected 128 bit for uuid generator as for service and characteristic still it is taking 

/// @brief TI Base 128-bit UUID: F000XXXX-0451-4000-B000-000000000000
#define TI_BASE_UUID_128( uuid ) 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xB0, \
0x00, 0x40, 0x51, 0x04, LO_UINT16( uuid ), HI_UINT16( uuid ), 0x00, 0xF0
this as base uuid from bcomdef.h file
although i have changed there also for checking it is still taking that value

can you suggest me how to change to my custom uuid.

i am using sdk 8_10_00_23 eng sdk and using example code basic ble as peripheral.


Thanks

  • Hi,

    Thank you for reaching out. It looks like you are using the TI 128-bit UUID macro.

    To define your own custom UUID, you must not use the macro and instead define the entire 128-bit manually.

    Best Regards,

    Jan

  • i have one more question that i want to send data of 20 bytes and i am using

    bool BLEAppUtil_gattwrite(uint8_t *data, uint8_t length)

    {
    bStatus_t status;
    attWriteReq_t req3;
    uint8_t scConnHandle = 0;

    req3.pValue = GATT_bm_alloc(scConnHandle, ATT_WRITE_REQ, length, NULL);

    req3.handle =37;
    req3.len = 1;
    // req3.pValue[0] = '1';//harVal_own;

    req3.sig = 0;
    req3.cmd = 0;

    memcpy(req3.pValue, data, length);
    status = GATT_WriteCharValue( scConnHandle, &req3, BLEAppUtilSelfEntity);

    if(status != SUCCESS)
    {
    GATT_bm_free((gattMsg_t *)&req3, ATT_WRITE_REQ);
    }

    }

    why i am not able to send
    and i have called this function BLEAppUtil_gattwrite from

    this function
    void write_data_own3(void)
    {
    BLEAppUtil_invokeFunctionNoData((InvokeFromBLEAppUtilContext_t) BLEAppUtil_gattwrite(dataSet2.bytes, 20));
    }

    and this void write_data_own3(void) is called from

    this function


    fillDataSet(&dataSet4);
    for(int i=0;i<20;i++)
    {
    status = BLEAppUtil_invokeFunctionNoData((InvokeFromBLEAppUtilContext_t)write_data_own2);
    }
    vTaskDelay(pdMS_TO_TICKS(250));


    i am not able to send more than 20 bytes could you guide me to solve my issue

  • Hi,

    Can you confirm that the length of the characteristic is larger than 20 on the GATT server side? Have you increased the data length on the GATT client side?

    Best Regards,

    Jan

  • no i dont know about that
    can you guide me to how to do that
    in which file i need to do that change
    As i have declared my characteristic length as 20 in my.h file were i declared my characteristic length 

  • #define char1_len  20
    #define char2_len  20

    like this

  • Hi,

    The characteristic length defined by the GATT server must be larger than 20 to be able to send more than 20 bytes to the characteristic. Is the GATT write code on the peripheral or the central device?

    Best Regards,

    Jan

  • on peripheral device....
    so i need to increase the characteristic length more than 20, ok i will try it and no need to change the the code i provided you in above snip is it ok?



  • #include"gatt_profile.h"

    #include <string.h>
    #include <icall.h>
    /* This Header file contains all BLE API and icall structure definition */
    #include "icall_ble_api.h"
    #include"hal_defs.h"
    #include <ti/bleapp/profiles/simple_gatt/simple_gatt_profile.h>
    #include <ti/bleapp/ble_app_util/inc/bleapputil_api.h>


    void SimpleGattProfile_callback( uint8 paramID );
    void SimpleGattProfile_invokeFromFWContext( char *pData );

    GATT_BT_UUID(simpleGattProfile_ServUUID, GATTPROFILE_SERV_UUID);


    GATT_BT_UUID(simpleGattProfile_char1UUID, GATTPROFILE_CHAR1_UUID);


    GATT_BT_UUID(simpleGattProfile_char2UUID, GATTPROFILE_CHAR2_UUID);

    static simpleGattProfile_CBs_t *simpleGattProfile_appCBs = NULL;


    // Simple GATT Profile Service attribute
    static CONST gattAttrType_t simpleGattProfile_Service = { ATT_BT_UUID_SIZE, simpleGattProfile_ServUUID };


    // Simple GATT Profile Characteristic 1 Properties
    static uint8 simpleGattProfile_Char1Props = GATT_PROP_READ | GATT_PROP_NOTIFY;

    // Characteristic 1 Value
    static uint8 simpleGattProfile_Char1 = 0;

    // Simple GATT Profile Characteristic 1 User Description
    static uint8 simpleGattProfile_Char1UserDesp[17] = "Characteristic 1";


    // Simple GATT Profile Characteristic 2 Properties
    static uint8 simpleGattProfile_Char2Props = GATT_PROP_WRITE;

    // Characteristic 2 Value
    static uint8 simpleGattProfile_Char2 = 0;

    // Simple Profile Characteristic 2 User Description
    static uint8 simpleGattProfile_Char2UserDesp[17] = "Characteristic 2";

    static gattCharCfg_t *simpleGattProfile_Char4Config;

    /*********************************************************************
    * Profile Attributes - Table
    */

    static gattAttribute_t simpleGattProfile_attrTbl[] =
    {
    /*------------------type-----------------*/ /*-----------permissions-----------*/ /*-----------------pValue----------------*/
    // Simple Profile Service
    GATT_BT_ATT( primaryServiceUUID, GATT_PERMIT_READ, (uint8 *) &simpleGattProfile_Service ),

    // Characteristic 1 Declaration
    GATT_BT_ATT( characterUUID, GATT_PERMIT_READ, &simpleGattProfile_Char1Props ),
    // Characteristic Value 1
    GATT_BT_ATT( simpleGattProfile_char1UUID, GATT_PERMIT_READ | GATT_PERMIT_WRITE, &simpleGattProfile_Char1 ),
    // Characteristic 1 User Description
    GATT_BT_ATT( charUserDescUUID, GATT_PERMIT_READ, simpleGattProfile_Char1UserDesp ),

    // Characteristic 2 Declaration
    GATT_BT_ATT( characterUUID, GATT_PERMIT_READ, &simpleGattProfile_Char2Props ),
    // Characteristic Value 2
    GATT_BT_ATT( simpleGattProfile_char2UUID, GATT_PERMIT_READ|GATT_PERMIT_WRITE, &simpleGattProfile_Char2 ),
    // Characteristic 2 User Description
    GATT_BT_ATT( charUserDescUUID, GATT_PERMIT_READ, simpleGattProfile_Char2UserDesp ),
    };
    /*********************************************************************
    * LOCAL FUNCTIONS
    */
    bStatus_t simpleGattProfile_readAttrCB( uint16_t connHandle,
    gattAttribute_t *pAttr,
    uint8_t *pValue, uint16_t *pLen,
    uint16_t offset, uint16_t maxLen,
    uint8_t method );
    bStatus_t simpleGattProfile_writeAttrCB( uint16_t connHandle,
    gattAttribute_t *pAttr,
    uint8_t *pValue, uint16_t len,
    uint16_t offset, uint8_t method );


    CONST gattServiceCBs_t simpleGattProfile_CBs =
    {
    simpleGattProfile_readAttrCB, // Read callback function pointer
    simpleGattProfile_writeAttrCB, // Write callback function pointer
    NULL // Authorization callback function pointer
    };


    bStatus_t simpleGattProfile_addService( void )
    {
    uint8 status = SUCCESS;

    // Allocate Client Characteristic Configuration table
    simpleGattProfile_Char4Config = (gattCharCfg_t *)ICall_malloc( sizeof( gattCharCfg_t ) *
    MAX_NUM_BLE_CONNS );
    if ( simpleGattProfile_Char4Config == NULL )
    {
    return ( bleMemAllocError );
    }

    // Initialize Client Characteristic Configuration attributes
    GATTServApp_InitCharCfg( LINKDB_CONNHANDLE_INVALID, simpleGattProfile_Char4Config );


    // Register GATT attribute list and CBs with GATT Server App
    status = GATTServApp_RegisterService( simpleGattProfile_attrTbl,
    GATT_NUM_ATTRS( simpleGattProfile_attrTbl ),
    GATT_MAX_ENCRYPT_KEY_SIZE,
    &simpleGattProfile_CBs );

    // Return status value
    return ( status );
    }


    bStatus_t simpleGattProfile_registerAppCBs( simpleGattProfile_CBs_t *appCallbacks )
    {
    if ( appCallbacks )
    {
    simpleGattProfile_appCBs = appCallbacks;

    return ( SUCCESS );
    }
    else
    {
    return ( bleAlreadyInRequestedMode );
    }
    }


    bStatus_t simpleGattProfile_setParameter( uint8 param, uint8 len, void *value )
    {
    bStatus_t status = SUCCESS;

    switch ( param )
    {
    case simpleGattProfile_CHAR1:
    if ( len == sizeof ( uint8 ) )
    {
    simpleGattProfile_Char1 = *((uint8*)value);
    }
    else
    {
    status = bleInvalidRange;
    }
    break;

    case simpleGattProfile_CHAR2:
    if ( len == sizeof ( uint8 ) )
    {
    simpleGattProfile_Char2 = *((uint8*)value);
    }
    else
    {
    status = bleInvalidRange;
    }
    break;

    default:
    status = INVALIDPARAMETER;
    break;
    }

    // Return status value
    return ( status );
    }


    bStatus_t simpleGattProfile_getParameter( uint8 param, void *value )
    {
    bStatus_t status = SUCCESS;
    switch ( param )
    {
    case simpleGattProfile_CHAR1:
    *((uint8*)value) = simpleGattProfile_Char1;
    break;

    case simpleGattProfile_CHAR2:
    *((uint8*)value) = simpleGattProfile_Char2;
    break;

    default:
    status = INVALIDPARAMETER;
    break;
    }

    // Return status value
    return ( status );
    }


    bStatus_t simpleGattProfile_readAttrCB(uint16_t connHandle,
    gattAttribute_t *pAttr,
    uint8_t *pValue, uint16_t *pLen,
    uint16_t offset, uint16_t maxLen,
    uint8_t method)
    {
    bStatus_t status = SUCCESS;

    // Make sure it's not a blob operation (no attributes in the profile are long)
    if ( offset > 0 )
    {
    return ( ATT_ERR_ATTR_NOT_LONG );
    }

    if ( pAttr->type.len == ATT_BT_UUID_SIZE )
    {
    // 16-bit UUID
    uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
    switch ( uuid )
    {
    // No need for "GATT_SERVICE_UUID" or "GATT_CLIENT_CHAR_CFG_UUID" cases;
    // gattserverapp handles those reads

    // characteristics 1 and 2 have read permissions
    // characteritisc 3 does not have read permissions; therefore it is not
    // included here
    // characteristic 4 does not have read permissions, but because it
    // can be sent as a notification, it is included here
    case GATTPROFILE_CHAR1_UUID:
    case GATTPROFILE_CHAR2_UUID:
    case SIMPLEGATTPROFILE_CHAR4_UUID:
    *pLen = 1;
    pValue[0] = *pAttr->pValue;
    break;

    default:
    // Should never get here! (characteristics 3 and 4 do not have read permissions)
    *pLen = 0;
    status = ATT_ERR_ATTR_NOT_FOUND;
    break;
    }
    }
    else
    {
    // 128-bit UUID
    *pLen = 0;
    status = ATT_ERR_INVALID_HANDLE;
    }

    // Return status value
    return ( status );
    }


    bStatus_t simpleGattProfile_writeAttrCB( uint16_t connHandle,
    gattAttribute_t *pAttr,
    uint8_t *pValue, uint16_t len,
    uint16_t offset, uint8_t method )
    {
    bStatus_t status = SUCCESS;
    uint8 notifyApp = 0xFF;

    if ( pAttr->type.len == ATT_BT_UUID_SIZE )
    {
    // 16-bit UUID
    uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
    switch ( uuid )
    {
    case GATTPROFILE_CHAR2_UUID:
    {
    //Validate the value
    // Make sure it's not a blob oper
    if ( offset == 0 )
    {
    if ( len != 1 )
    {
    status = ATT_ERR_INVALID_VALUE_SIZE;
    }
    }
    else
    {
    status = ATT_ERR_ATTR_NOT_LONG;
    }

    //Write the value
    if ( status == SUCCESS )
    {
    uint8 *pCurValue = (uint8 *)pAttr->pValue;
    *pCurValue = pValue[0];

    if( pAttr->pValue == &simpleGattProfile_Char1 )
    {
    notifyApp = simpleGattProfile_CHAR2;
    }
    else
    {
    notifyApp = simpleGattProfile_CHAR1;
    }
    }
    }
    break;

    case GATT_CLIENT_CHAR_CFG_UUID:
    status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
    offset, GATT_CLIENT_CFG_NOTIFY );
    //notify the App that a change has occurred in Char 4
    notifyApp = simpleGattProfile_CHAR2;
    break;

    default:
    // Should never get here! (characteristics 2 and 4 do not have write permissions)
    status = ATT_ERR_ATTR_NOT_FOUND;
    break;
    }
    }
    else
    {
    // 128-bit UUID
    status = ATT_ERR_INVALID_HANDLE;
    }

    // If a characteristic value changed then callback function to notify application of change
    if ((notifyApp != 0xFF ) && simpleGattProfile_appCBs && simpleGattProfile_appCBs->pfnsimpleGattProfile_Change)
    {
    simpleGattProfile_callback( notifyApp );
    }

    // Return status value
    return ( status );
    }

    void simpleGattProfile_callback( uint8 paramID )
    {
    char *pData = ICall_malloc(sizeof(char));

    if(pData == NULL)
    {
    return;
    }

    pData[0] = paramID;

    BLEAppUtil_invokeFunction(simpleGattProfile_invokeFromFWContext, pData);
    }


    void simpleGattProfile_invokeFromFWContext( char *pData )
    {
    simpleGattProfile_appCBs->pfnsimpleGattProfile_Change(pData[0]);
    }

  • Hi,

    I am a bit confused. Can you clarify what the goal of the GATT write call is? Are you connected to another device and attempting to write to a characteristic that belongs to the other device?

    Best Regards,

    Jan

  • And one more question sir i am sending notify of 20 bytes but it is going in 1-1 byte i want to send it all in single shot 
    i have tried all the methods 
    please describe the solution in details for my understanding.

    All the above issues are solved but i have been stucked in this notify process of sending all data in single time.
      thanku

  • Hi,

    I am glad to hear the other issues were resolved! Can you share the latest snippet of code that shows how the notification payload is being prepared and then sent?

    Best Regards,

    Jan