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

sending different notification

Hi,

I'm developing a hid keyboard + lbs(led button) application, in my design there're several primary services and each with different characteristic(with read/write notification), when the button is pressed, a notify of the button status is sent. Now my question is, since i have more than one primary service, when the button is pressed, how do i know which service/characteristic(notification) is sent? and how do i control to send different notification? any suggestion will be appreciated..

Thanks,

  • You choose which services to use and on which characteristic the notification is sent, since you have a structure for each service you use and a handle for each characteristic.

    For example if you have the following 2 services:

    static ble_nus_t m_nus;
    static ble_hids_t m_hids;
    

    Then when your button is pressed:

    // Sends data on an Boot Keyboard Input Report characteristic
    ble_hids_boot_kb_inp_rep_send(p_hids, INPUT_REPORT_KEYS_MAX_LEN, data);
    
    // Sends data on an Input Report characteristic.
    ble_hids_inp_rep_send(p_hids, INPUT_REPORT_KEYS_INDEX, INPUT_REPORT_KEYS_MAX_LEN, data);
    
    // Sends a notification on the RX characteristic.
    ble_nus_string_send(&m_nus, data_array, index);
    

    You can also take a look at the ble_app_hids_keyboard example in the SDK.

Related