Skip to content

Commit 2da7436

Browse files
authored
Merge pull request #10581 from pan-/cordio-tx-path
BLE - Management of Tx path on Cordio.
2 parents 0560ecc + cb97b3c commit 2da7436

File tree

6 files changed

+64
-8
lines changed

6 files changed

+64
-8
lines changed

features/FEATURE_BLE/ble/GattServer.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,12 @@ class GattServer {
693693
confirmationReceivedCallback(attributeHandle);
694694
}
695695
break;
696+
697+
case GattServerEvents::GATT_EVENT_DATA_SENT:
698+
// Called every time a notification or indication has been sent
699+
handleDataSentEvent(1);
700+
break;
701+
696702
default:
697703
break;
698704
}

features/FEATURE_BLE/ble/generic/GenericGattClient.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,15 @@ class GenericGattClient :
147147
uint16_t att_mtu_size
148148
);
149149

150+
/**
151+
* @see pal::GattClient::EventHandler::on_write_command_sent
152+
*/
153+
void on_write_command_sent_(
154+
ble::connection_handle_t connection_handle,
155+
ble::attribute_handle_t attribute_handle,
156+
uint8_t status
157+
);
158+
150159
private:
151160
struct ProcedureControlBlock;
152161
struct DiscoveryControlBlock;

features/FEATURE_BLE/ble/pal/PalGattClient.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,26 @@ struct GattClientEventHandler : StaticInterface<Impl, GattClientEventHandler> {
5252
) {
5353
impl()->on_att_mtu_change_(connection_handle, att_mtu_size);
5454
}
55+
56+
/**
57+
* Function invoked when a write command has been sent out of the stack
58+
* (either to the controller or over the air).
59+
*
60+
* @param connection_handle Connection targeted by the write command
61+
* @param attribute_handle Attribute written
62+
* @param status HCI status of the operation.
63+
*/
64+
void on_write_command_sent(
65+
ble::connection_handle_t connection_handle,
66+
ble::attribute_handle_t attribute_handle,
67+
uint8_t status
68+
) {
69+
impl()->on_write_command_sent_(
70+
connection_handle,
71+
attribute_handle,
72+
status
73+
);
74+
}
5575
};
5676

5777

features/FEATURE_BLE/source/generic/GenericGattClient.tpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,7 @@ GenericGattClient<TPalGattClient, SigningMonitorEventHandler>::GenericGattClient
966966
_pal_client->when_transaction_timeout(
967967
mbed::callback(this, &GenericGattClient::on_transaction_timeout)
968968
);
969+
_pal_client->set_event_handler(this);
969970
}
970971

971972
template<template<class> class TPalGattClient, class SigningMonitorEventHandler>
@@ -1338,6 +1339,24 @@ void GenericGattClient<TPalGattClient, SigningMonitorEventHandler>::on_att_mtu_c
13381339
}
13391340
}
13401341

1342+
template<template<class> class TPalGattClient, class SigningMonitorEventHandler>
1343+
void GenericGattClient<TPalGattClient, SigningMonitorEventHandler>::on_write_command_sent_(
1344+
ble::connection_handle_t connection_handle,
1345+
ble::attribute_handle_t attribute_handle,
1346+
uint8_t status
1347+
) {
1348+
GattWriteCallbackParams response = {
1349+
connection_handle,
1350+
attribute_handle,
1351+
GattWriteCallbackParams::OP_WRITE_CMD,
1352+
BLE_ERROR_NONE,
1353+
status
1354+
};
1355+
1356+
this->processWriteResponse(&response);
1357+
}
1358+
1359+
13411360
template<template<class> class TPalGattClient, class SigningMonitorEventHandler>
13421361
void GenericGattClient<TPalGattClient, SigningMonitorEventHandler>::on_termination(connection_handle_t connection_handle) {
13431362
if (_termination_callback) {

features/FEATURE_BLE/targets/TARGET_CORDIO/source/CordioGattServer.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -695,10 +695,6 @@ ble_error_t GattServer::write_(
695695
}
696696
#endif // BLE_FEATURE_SECURITY
697697

698-
if (updates_sent) {
699-
handleDataSentEvent(updates_sent);
700-
}
701-
702698
return BLE_ERROR_NONE;
703699
}
704700

@@ -749,10 +745,6 @@ ble_error_t GattServer::write_(
749745
}
750746
#endif // BLE_FEATURE_SECURITY
751747

752-
if (updates_sent) {
753-
handleDataSentEvent(updates_sent);
754-
}
755-
756748
return BLE_ERROR_NONE;
757749
}
758750

features/FEATURE_BLE/targets/TARGET_CORDIO/source/CordioPalAttClient.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ void CordioAttClient::att_client_handler(const attEvt_t* event)
3232
if (handler) {
3333
handler->on_att_mtu_change(event->hdr.param, event->mtu);
3434
}
35+
} else if (event->hdr.event == ATTC_WRITE_CMD_RSP) {
36+
ble::vendor::cordio::BLE& ble = ble::vendor::cordio::BLE::deviceInstance();
37+
impl::PalGattClientImpl::EventHandler *handler = ble.getPalGattClient().get_event_handler();
38+
if (handler) {
39+
handler->on_write_command_sent(
40+
event->hdr.param,
41+
event->handle,
42+
event->hdr.status
43+
);
44+
}
3545
} else {
3646
// all handlers are stored in a static array
3747
static const event_handler_t handlers[] = {

0 commit comments

Comments
 (0)