|
|
@ -21,6 +21,7 @@ |
|
|
|
} /**< Used vendor specific UUID. */ |
|
|
|
|
|
|
|
static zdatachannel_t *p_datachannel; |
|
|
|
static uint32_t m_last_rx_data_tp; |
|
|
|
// static uint32_t m_mtusize; |
|
|
|
|
|
|
|
static bool notification_enable(uint16_t conn_handle, uint16_t cccd_handle) { |
|
|
@ -48,6 +49,7 @@ static void on_write(zdatachannel_t *p_nus, ble_evt_t const *p_ble_evt) { |
|
|
|
ble_gatts_evt_write_t const *p_evt_write = &p_ble_evt->evt.gatts_evt.params.write; |
|
|
|
|
|
|
|
memset(&evt, 0, sizeof(zdatachannel_evt_t)); |
|
|
|
m_last_rx_data_tp = znordic_getpower_on_s(); |
|
|
|
|
|
|
|
if ((p_evt_write->handle == p_nus->cmd_tx_handles.cccd_handle) && (p_evt_write->len == 2)) { |
|
|
|
if (ble_srv_is_notification_enabled(p_evt_write->data)) { |
|
|
@ -223,3 +225,12 @@ uint32_t zdatachannel_block_data_send(uint8_t *p_data, uint16_t *p_length) { |
|
|
|
|
|
|
|
return sd_ble_gatts_hvx(p_datachannel->conn_handle, &hvx_params); |
|
|
|
} |
|
|
|
|
|
|
|
uint32_t zdatachannel_last_rx_data_haspassed_s() { // |
|
|
|
uint32_t now = znordic_getpower_on_s(); |
|
|
|
if (now > m_last_rx_data_tp) { |
|
|
|
return now - m_last_rx_data_tp; |
|
|
|
} else { |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |