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

Returning a notification (master to peripheral) Modified ble_app_hrs_c example

Hi again!

I'm trying to send/receive data between an nRF51(master) and a AVR/HM-11(serial/BLE module)(peripheral)

After following this visualgdb.com/.../  tutorial based on the SDK 10 - ble_app_hrs_c example, I am able to receive my data/notification from the AVR(peripheral), now I need to send back a notification/data telling the AVR/peripheral) that the data was received.
Could you point me towards a tutorial or example that shows sending a notification from central to peripheral, using SDK 10 and the ble_app_hrs_c modified as in the tutorial?.
I tried adding this code to the "btnsrv_on_ble_evt" ("btnsrv_on_ble_evt" was added during the tutorial).

uint8_t buf[2];
buf[0] = 0x02;
buf[1] = 0xF0;

const ble_gattc_write_params_t write_params = {
.write_op = BLE_GATT_OP_WRITE_REQ,
.flags = BLE_GATT_EXEC_WRITE_FLAG_PREPARED_WRITE,
.handle = m_conn_handle,
.offset = 0,
.len = sizeof(buf),
.p_value = buf};


err_code = sd_ble_gattc_write(m_conn_handle, &write_params);

Now I'm surprised this code does anything! (it returns error code 0, but does not send a notification) as I don't understand what connection handles I should be using!!! Is this the correct approach? if so what values should I be using for the write_params?

Many thanks,

PaulP

Parents Reply Children
No Data
Related