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.

LAUNCHXL-CC2640R2: Reg: Custom service and characteristics

Part Number: LAUNCHXL-CC2640R2

Dear All,

I have added a custom service and characteristics in the "Project zero" sample code. I am following the "Bluetooth low energy custom profile" document for implementing new services and characteristics.

Under "Task 4 - Add API and callback handling" I can send the static data "4" through the new characteristics. I followed the instruction and wrote as showed below, I couldn't get the data as expected.

I know that I did some mistake in understanding. Please let me know where exactly I made the mistake.

-------------program--------

static bStatus_t sunlightService_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;

if (! memcmp(pAttr->type.uuid, sunlightService_SunlightValueUUID, pAttr->type.len))            
{     
*pLen = MIN(maxLen, 4 - offset); 
memcpy(pValue, pAttr->pValue + offset, *pLen);
}

.

.

.

}

-------------------------------

Thank you,

Prakash S

  • Hello Prakash,

    I have a few questions that will help me assist you with your issue. What version of the SDK are you using? What is the value you are reading? What is the value you are expecting. Did you modify the initial value of the characteristic in project_zero.c?

    Regards,

    Jan

  • Dear Jan,

    Thanks for your response.

    I am using simple academy 4.10.01.00.

    Other two questions are kind of unaware to me. I am following the step by step procedures from "BLE Low Energy Custom Profile".

    Now exactly I am  in Task 4 of that document. There I did not see anything related project Zero.c . 

    This is my understanding about the activities which I have done so far.

    Please let me know if any further details required.

    Thank you,

    Prakash S  

  • Hello Prakash,

    Part 4 requires slight modification to the project_zero.c file to be completed. Specifically, the value initialization is performed in the ProjectZero_init() function. Are you able to connect to the modified project_zero project and view the Sunlight characteristic? You should be able to see the characteristic in the characteristic list. Are you using a phone app or BTool to connect to the project?

    Regards,

    Jan

  • Hello Jan,

    I did those modification and I can able to see newly created services and characteristics through my mobile.

    Actually I created the characteristics with read and notification option. This option also I can see through the mobile.

    Thank you

    Prakash S

  • Hello Prakash,

    Are you able to read the characteristic and see expected value? The expected value should be whatever value you selected for the initial value in project_zero.c in the ProjectZero_init() function.

    Regards,

    Jan

  • Hello Jan,

    yeah, I can able see the same value which I have mentioned as initial value in the ProjectZero.c file.

    Thank you

    Prakash S

  • Hello Prakash,

    That is great to hear. If you do not have any further questions, then you may close the thread by selecting the most helpful answer.

    Regards,

    Jan

  • Hello Jan,

    Ok, Now I need to change the value based on some computation. So, Do I need update the initial value declaration in ProjectZero.c every time.

    If suppose any other options are there to update the value as per convenient. Please let me know, this i what exactly I need. 

    Thank you,

    Prakash S

  • Hello Prakash,

    You do not need to change the initial value each time. The initial value is only used to set what the original value of the characteristic should be. If you need to update the value periodically there are a few different ways you could implement this. You could implement a clock that triggers a function every time the clock elapses and within that function you could update the characteristic. You could also update the characteristic within whatever function you are performing the computation by using SunlightService_SetParameter() function.You could also opt to update the characteristics every time one of the buttons is pressed by calling the SunlightService_SetParameter() within the button handling functions.

    Regards,

    Jan