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

send data to different Characteristic

I have one service two TX Characteristic(not the same name) one RX Characteristic 

than how to send data to different TX Characteristic?

Parents Reply Children
  • Take a look at the tutorial Bluetooth low energy Characteristics, a beginner's tutorial, which gives a good introduction to characteristics in the nRF5 SDK. Be aware that it was written using SDK 15, and there has been some changes in the API since then.

    But let's try to answer your quesiton:

    When you add the characteristics, using characteristic_add(),

    E.g. take a look at SDK\components\ble\ble_services\ble_nus\ble_nus.c-->ble_nus_init()-->characteristic_add(p_nus->service_handle, &add_char_params, &p_nus->tx_handles);

    you're providing the characteristic handles as the third argument. You should create two instances of this type (e.g. ble_gatts_char_handles_t tx_handles_1; ble_gatts_char_handles_t tx_handles_2;). 

    In order to write to the TX characteristic number 1 you should do something like this: sd_ble_gatts_hvx(conn_handle, &tx_handles_1).

    Of course you should set all the fields of the handle before using it. Take a look at the function components\ble\ble_services\ble_nus\ble_nus.c-->ble_nus_data_send()--> sd_ble_gatts_hvx() for guidance how to go about this.

    Best regards,

    Simon

Related