This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

how to add user description to characteristic

Hi

I am implementing my custom service, and started from the led/button example. I am using the LightBlue app on my iphone to connect to my device under test. I can see the characteristics for the LED and button, but would like to add some kind of human readable description string as the label of a characteristic. I though I could do this by replacing the char_md.pa_char_user_desc = NULL by a pointer to a static string in the adding of the LED characteristic, but no luck:

...

//char_md.p_char_user_desc  = NULL;

static char user_desc[] = "LED";
char_md.p_char_user_desc  = (uint8_t *) user_desc;
char_md.char_user_desc_size = strlen(user_desc);
char_md.char_user_desc_max_size = strlen(user_desc);	

...

Any ideas? Do I need to assign something to char_md.p_user_desc_md? And how can I add a characteristic descriptor in general?

  • That is how I do it, here is my code:

    if (description && *description != '\0')
    {
        char_md.p_char_user_desc = (uint8_t*) description; // discards const 
        char_md.char_user_desc_size = strlen(description);  
        char_md.char_user_desc_max_size = char_md.char_user_desc_size;
    }
    

    I also played around with setting the char_pf stuff, but lightblue ignored it. Having the description text is useful for debug, not sure if I will leave it in the production firmware.

  • Hi Wim,

    I don't see any problem with your code, it worked on my side. Could you double check ? You can just leave char_md.p_user_desc_md = NULL;

    Which error do you have when running your code ?

  • Hi Hung Bui,

    In fact, the Lightblue app did not update the device profile after I uploaded my new code. When I removed my device and stopped the app, and then started again, the characteristic was showing with the user description So problem solved!

Related