Skip to content

Commit de482e4

Browse files
committed
BLE: Create and handle write_command Event.
This event is raised when a write command has been sent to the controller. It can be used to queue a new write command.
1 parent e814a3c commit de482e4

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,18 @@ struct GattClientEventHandler : StaticInterface<Impl, GattClientEventHandler> {
5252
) {
5353
impl()->on_att_mtu_change_(connection_handle, att_mtu_size);
5454
}
55+
56+
void on_write_command_sent(
57+
ble::connection_handle_t connection_handle,
58+
ble::attribute_handle_t attribute_handle,
59+
uint8_t status
60+
) {
61+
impl()->on_write_command_sent_(
62+
connection_handle,
63+
attribute_handle,
64+
status
65+
);
66+
}
5567
};
5668

5769

features/FEATURE_BLE/source/generic/GenericGattClient.tpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,6 +1339,24 @@ void GenericGattClient<TPalGattClient, SigningMonitorEventHandler>::on_att_mtu_c
13391339
}
13401340
}
13411341

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+
13421360
template<template<class> class TPalGattClient, class SigningMonitorEventHandler>
13431361
void GenericGattClient<TPalGattClient, SigningMonitorEventHandler>::on_termination(connection_handle_t connection_handle) {
13441362
if (_termination_callback) {

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)