This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

alert notification - field "category" shall have variable size

Hello, Ble spec says that "new alert" characteristic - field: "category ID" can have 1 or 2 bytes. here

But it seems in your struct you let it have only 1B.

typedef struct
{
    uint8_t   alert_category;                                 /**< Alert category to which this alert belongs.*/
    uint8_t   alert_category_count;                           /**< Number of alerts in the category. */
    uint32_t  alert_msg_length;                               /**< Length of optional text message send by the server. */
    uint8_t * p_alert_msg_buf;                                /**< Pointer to buffer containing the optional text message. */
} ble_ans_alert_notification_t;

And when you assign ANS client data during notification event you expect fixed size 1B:

p_alert->alert_category_count = p_notification->data[1];                       //lint !e415

it might be actually bug because server might use 2B for "category" - thus offset for "count" can be 2. Right? I'm new to BLE so I'm not sure...

  • Hi,

    Right you are. There's another optional 1 byte bitmask in the "alert_category", which we have not added to the profile. I'll report this internally as a feature-request.

    And when you assign ANS client data during notification event you expect fixed size 1B:

    p_alert->alert_category_count = p_notification->data[1];
    //lint !e415

    it might be actually bug because server might use 2B for "category" - thus offset for "count" can be 2. Right? I'm new to BLE so I'm not sure...

    This shall point to the correct member of the struct. I'll classify this as an improvement internally.

    Thanks for reporting this to us! It's highly appreciated that you help us improve the SDK.

    Cheers, Håkon

Related