Hello,
I am running a nRF51822 rev G0 with Soft Device 6.0.0 & SDK 5.2.0. My device implements a custom service with 4 characteristics. One of those characteristics is a command/response characteristic so it is set up as write & notify. This works great.
I recently added a characteristic to let us stream binary bootloading data for a second micro-controller on our board OTA. Initially this was a write without response characteristic. However that turned out to be troublesome because the protocol on the UART between the nRF51822 has been designed as a synchronous command/response protocol and the write w/o response has some non-synchronous behaviors and multiple packets could arrive faster than they could be processed. Given that we are late in the project I didn't want to build a queuing or scheduling solution to deal with this.
So, we decided to make the data transfer characteristic write and notify just like the command characteristic. We did that and it looks like it is working from the MCP, I can write binary data and get a response back on the new characteristic. However, I was watching the transactions in a Frontline BPA sniffer and noticed something odd. The sniffer shows that when a command or binary data is sent to the device there are two notifications returned.
I don't know if this is an artifact of the sniffer, or if there really are two notifications coming back. I only see one in the MCP. Is it possible that having two notification characteristics in my service could trigger two notifications? That would be very weird if that were the case. Both notifications show the same handle in the sniffer BTW.
Below is my code that prepares the hvx structure for the notification sending. I'll also attach my sniffer trace, just look for transactions on handle 30 near the end of the ATT frames.
Thanks, John
if (p_onset->conn_handle != BLE_CONN_HANDLE_INVALID)
{
len = MAX_ONSET_DATA_LEN;
hvx_len = MAX_ONSET_DATA_LEN;
memset(&hvx_params, 0, sizeof(hvx_params));
if ((uart_control.sensor_pic_state == BL_STATE) &&
(onset_data[0] == PROGRAM_DEVICE))
{
hvx_params.handle = p_onset->pic_bootload_data_handle.value_handle;
}
else
{
hvx_params.handle = p_onset->command_handle.value_handle;
}
hvx_params.type = BLE_GATT_HVX_NOTIFICATION;
hvx_params.offset = 0;
hvx_params.p_len = &hvx_len;
hvx_params.p_data = onset_data;
err_code = sd_ble_gatts_hvx(p_onset->conn_handle, &hvx_params);
if ((err_code == NRF_SUCCESS) && (hvx_len != len))
{
err_code = NRF_ERROR_DATA_SIZE;
ASSERT(false);
}
}