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

How to notify several characteristics in central

Hi, I am using ble_app_hrs_c as the base for central. I have included 5 characteristics in the peripheral and central side. How to make ble_nus_c_rx_notif_enable() to notify when any of the 5 characteristics is updated? At the moment, ble_nus_c_rx_notif_enable has only this: return cccd_configure(p_ble_nus_c->conn_handle,p_ble_nus_c->handles.nus_rx_cccd_handle, true);

How do I change it so that I get notification even when nus_rx_wheel_status_handle also receives a notification? My ble_nus_c_handles_t looks like this:

typedef struct {
    uint16_t                nus_rx_wheel_control_handle;      

    uint16_t                nus_rx_wheel_control_cccd_handle; /**< Handle of the CCCD of the NUS RX characteristic as provided by a discovery. */
    uint16_t                nus_rx_wheel_status_handle;	
    uint16_t                nus_rx_wheel_status_cccd_handle;	
    uint16_t                nus_rx_wheel_battery_handle;	
    uint16_t                nus_rx_wheel_battery_cccd_handle;		
    uint16_t                nus_rx_wheel_information_handle;	
    uint16_t                nus_rx_wheel_information_cccd_handle;		
    uint16_t                nus_rx_wheel_debug_handle;	
    uint16_t                nus_rx_wheel_debug_cccd_handle;		
    uint16_t                nus_tx_handle_wheel_control;      /**< Handle of the NUS TX characteristic as provided by a discovery. */
    uint16_t                nus_tx_handle_wheel_status;	
    uint16_t                nus_tx_handle_wheel_battery;	
    uint16_t                nus_tx_handle_wheel_information;		
    uint16_t                nus_tx_handle_wheel_debug;		
} ble_nus_c_handles_t;

The code works fine when I enable notification for one character at a time.

Parents
  • If you are using write request you have to enable one notification at the time, because you can only do one write request at the time, you have to wait for the response before you send a new one.

    And I think you must use write request to write to descriptors. You could of course try to use write command instead.

  • The logic that I mentioned in the previous post did not work because, I was not able to sync between central and peripheral (meaning, peripheral transmits too soon and central misses some). The problem becomes worse when the number of peripherals increase. Please let me know if the following logic is correct:

    I have 1 central and 2 peripherals, each having 4 characteristic. My aim is to send data from each of the 4 characteristics from both the peripherals to central and vice versa. But, since the central can have only one characteristic to be notified at a time, I have come up with the following logic - so that I dont have to change the enable notification from one characteristic to another at the central end.

    1. Peripheral and central have 4 characteristics - the uuids of the characteristics match between central and peripheral.
    2. central has notification enabled only for charcteristic 4. In peripheral the first 3 characteristics have write without response and 4th characteristic has notification enabled.
    3. When I want to transmit data in one of the characteristic from peripheral to central, I write respective (different) data to all 4 characteristics. As soon as characteristic 4 is written in peripheral, central gets notified. Now, central reads the characteristic 4 in ble_nus_c_evt and first 3 characteristics using sd_ble_gattc_read. By this way, all 4 characteristics from both the peripherals would not be missed by the central.
Reply
  • The logic that I mentioned in the previous post did not work because, I was not able to sync between central and peripheral (meaning, peripheral transmits too soon and central misses some). The problem becomes worse when the number of peripherals increase. Please let me know if the following logic is correct:

    I have 1 central and 2 peripherals, each having 4 characteristic. My aim is to send data from each of the 4 characteristics from both the peripherals to central and vice versa. But, since the central can have only one characteristic to be notified at a time, I have come up with the following logic - so that I dont have to change the enable notification from one characteristic to another at the central end.

    1. Peripheral and central have 4 characteristics - the uuids of the characteristics match between central and peripheral.
    2. central has notification enabled only for charcteristic 4. In peripheral the first 3 characteristics have write without response and 4th characteristic has notification enabled.
    3. When I want to transmit data in one of the characteristic from peripheral to central, I write respective (different) data to all 4 characteristics. As soon as characteristic 4 is written in peripheral, central gets notified. Now, central reads the characteristic 4 in ble_nus_c_evt and first 3 characteristics using sd_ble_gattc_read. By this way, all 4 characteristics from both the peripherals would not be missed by the central.
Children
No Data
Related