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

Central-Peripheral combo example using indication?

Hi, do you have a central peripheral combo example which illustrates indication (not notification)? Alternatively, if you could list the steps to change from notification to indication - esp in the central side, that would be great. I have done the following: peripheral end:

static uint32_t rx_char_add_debug(ble_nus_t * p_nus, const ble_nus_init_t * p_nus_init)
{
    /**@snippet [Adding proprietary characteristic to S110 SoftDevice] */
    ble_gatts_char_md_t char_md;
    ble_gatts_attr_md_t cccd_md;
    ble_gatts_attr_t    attr_char_value;
    ble_uuid_t          ble_uuid;
    ble_gatts_attr_md_t attr_md;

    memset(&cccd_md, 0, sizeof(cccd_md));

    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm);
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.write_perm);

    cccd_md.vloc = BLE_GATTS_VLOC_STACK;

    memset(&char_md, 0, sizeof(char_md));

    //char_md.char_props.notify = 1;
		char_md.char_props.indicate = 1;
	
    char_md.p_char_user_desc  = NULL;
    char_md.p_char_pf         = NULL;
    char_md.p_user_desc_md    = NULL;
    char_md.p_cccd_md         = &cccd_md;
    char_md.p_sccd_md         = NULL;

    ble_uuid.type = p_nus->uuid_type;
    ble_uuid.uuid = BLE_UUID_NUS_RX_DEBUG_CHARACTERISTIC;

    memset(&attr_md, 0, sizeof(attr_md));

    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.read_perm);
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.write_perm);

    attr_md.vloc    = BLE_GATTS_VLOC_STACK;
    attr_md.rd_auth = 0;
    attr_md.wr_auth = 0;
    attr_md.vlen    = 1;

    memset(&attr_char_value, 0, sizeof(attr_char_value));

    attr_char_value.p_uuid    = &ble_uuid;
    attr_char_value.p_attr_md = &attr_md;
    attr_char_value.init_len  = sizeof(uint8_t);
    attr_char_value.init_offs = 0;
    attr_char_value.max_len   = BLE_NUS_MAX_RX_CHAR_LEN;

    return sd_ble_gatts_characteristic_add(p_nus->service_handle,
                                           &char_md,
                                           &attr_char_value,
                                           &p_nus->rx_handles_debug);




central end:cccd_configure:     buf[0] = enable ? BLE_GATT_HVX_INDICATION : 0;

I never get an event : BLE_GATTS_EVT_HVC at the peripheral, I get BLE_EVT_TX_COMPLETE at peripheral at corrrect times. What else do I need to do so that peripheral gets an event when the data sent by peripheral has been read by the central successfully?

Parents
  • I don't think we have that. The steps would be something like:

    1. Configure the characteristic to support the indication property (which you have done)
    2. The client must write 0x0002 to the CCCD of the characteristic to enable indication.
    3. To send a indication the server should call sd_ble_gatts_hvx() with indication as type, more info here.
    4. The client will receive a BLE_GATTC_EVT_HVX event, and has to reply with sd_ble_gattc_hv_confirm(), more info here.
    5. The server will receive a BLE_GATTS_EVT_HVC event.
Reply
  • I don't think we have that. The steps would be something like:

    1. Configure the characteristic to support the indication property (which you have done)
    2. The client must write 0x0002 to the CCCD of the characteristic to enable indication.
    3. To send a indication the server should call sd_ble_gatts_hvx() with indication as type, more info here.
    4. The client will receive a BLE_GATTC_EVT_HVX event, and has to reply with sd_ble_gattc_hv_confirm(), more info here.
    5. The server will receive a BLE_GATTS_EVT_HVC event.
Children
No Data
Related