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

Add ble UART TX characteristic to s120 ble_app_multilink_central

Hello,

I have implemented the ble UART service in the s120 example : ble_app_multilink_central. I can receive messages that are sent from a ble UART peripheral in the "on_evt_hvx" function of the ble_app_multilink_central (on the ble UART RX characteristic 0x0003) but I can't send a feedback from my central to the ble uart peripheral (on ble UART TX characteristic 0x0002).

Could someone help me ?

best regard,

Stoffels Kévin

EDIT : No one can help me to send a notification from a central nRF51822 to a peripheral nRF51822 ?

client_handling.c

Parents
  • Hey guys,

    I hope you have already figured out the answer to this question.

    Here's my solution:

    Add this function to Stoffels Kevin's client_handling.c file

    uint32_t client_send_string(uint8_t * string, uint16_t length){
    
    ble_gattc_write_params_t write_params;
    	
    write_params.write_op = BLE_GATT_OP_WRITE_CMD;
    write_params.handle   = m_client[0].srv_db.services[0].charateristics[1].characteristic.handle_value;
    write_params.flags = BLE_GATT_EXEC_WRITE_FLAG_PREPARED_WRITE;
    write_params.offset   = 0;
    write_params.len      = length;
    write_params.p_value  = string;
    
    APPL_LOG("[APPL]: In client_send_string: handle=%d, data=%s\r\n",write_params.handle,write_params.p_value);
    APPL_LOG("[APPL]: Connection handle = %d\r\n",m_client[0].srv_db.conn_handle);	
    
    return sd_ble_gattc_write(m_client[0].srv_db.conn_handle, &write_params);}
    

    You'll need to declare this in client_handling.h.

    This works as expected for a string of length less than 20 bytes.

    Cheers,

    • Aditya
Reply
  • Hey guys,

    I hope you have already figured out the answer to this question.

    Here's my solution:

    Add this function to Stoffels Kevin's client_handling.c file

    uint32_t client_send_string(uint8_t * string, uint16_t length){
    
    ble_gattc_write_params_t write_params;
    	
    write_params.write_op = BLE_GATT_OP_WRITE_CMD;
    write_params.handle   = m_client[0].srv_db.services[0].charateristics[1].characteristic.handle_value;
    write_params.flags = BLE_GATT_EXEC_WRITE_FLAG_PREPARED_WRITE;
    write_params.offset   = 0;
    write_params.len      = length;
    write_params.p_value  = string;
    
    APPL_LOG("[APPL]: In client_send_string: handle=%d, data=%s\r\n",write_params.handle,write_params.p_value);
    APPL_LOG("[APPL]: Connection handle = %d\r\n",m_client[0].srv_db.conn_handle);	
    
    return sd_ble_gattc_write(m_client[0].srv_db.conn_handle, &write_params);}
    

    You'll need to declare this in client_handling.h.

    This works as expected for a string of length less than 20 bytes.

    Cheers,

    • Aditya
Children
No Data
Related