I currently have a custom service emulating the batterey service. I have added an extra characteristic to recieve data from the central in the same way as ble_app_uart. the problem is they both use handlers with different formats, for ble_app_uart
typedef void (*ble_uart_data_handler_t) (ble_tx_t * p_nus, uint8_t * p_data, uint16_t length);
and for batterey service
typedef void (*ble_tx_handler_t) (ble_tx_t * p_tx, ble_tx_evt_t*p_evt );
Can the service use both of these handlers together? The application works untill i also add the uart data handler to the service init
p_tx->evt_handler = p_tx_init->evt_handler;
p_tx->data_handler = p_tx_init->data_handler;
after that once data is written to the char (via MCP) the other char stops transmitting data and only 1 character is logged onto UART, it wont change, is the application not returning somewhere?
any ideas would be great. below is my on write, thanks!
static void on_write(ble_tx_t * p_tx, ble_evt_t * p_ble_evt)
{
ble_gatts_evt_write_t * p_evt_write = &p_ble_evt->evt.gatts_evt.params.write;
if (
(p_evt_write->handle == p_tx->tx_char_handles.cccd_handle)
&&
(p_evt_write->len == 2)
)
{
ble_tx_evt_t evt;
if (ble_srv_is_notification_enabled(p_evt_write->data))
{
evt.evt_type = BLE_TX_EVT_NOTIFICATION_ENABLED;
}
else
{
evt.evt_type = BLE_TX_EVT_NOTIFICATION_DISABLED;
}
}
else if (
(p_evt_write->handle == p_tx->rx_char_handles.value_handle)
&&
(p_tx->data_handler != NULL)
)
{
p_tx->data_handler(p_tx, p_evt_write->data, p_evt_write->len);
}
}