Skip to content

BLE - Management of Tx path on Cordio. #10581

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions features/FEATURE_BLE/ble/GattServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,12 @@ class GattServer {
confirmationReceivedCallback(attributeHandle);
}
break;

case GattServerEvents::GATT_EVENT_DATA_SENT:
// Called every time a notification or indication has been sent
handleDataSentEvent(1);
break;

default:
break;
}
Expand Down
9 changes: 9 additions & 0 deletions features/FEATURE_BLE/ble/generic/GenericGattClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,15 @@ class GenericGattClient :
uint16_t att_mtu_size
);

/**
* @see pal::GattClient::EventHandler::on_write_command_sent
*/
void on_write_command_sent_(
ble::connection_handle_t connection_handle,
ble::attribute_handle_t attribute_handle,
uint8_t status
);

private:
struct ProcedureControlBlock;
struct DiscoveryControlBlock;
Expand Down
20 changes: 20 additions & 0 deletions features/FEATURE_BLE/ble/pal/PalGattClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,26 @@ struct GattClientEventHandler : StaticInterface<Impl, GattClientEventHandler> {
) {
impl()->on_att_mtu_change_(connection_handle, att_mtu_size);
}

/**
* Function invoked when a write command has been sent out of the stack
* (either to the controller or over the air).
*
* @param connection_handle Connection targeted by the write command
* @param attribute_handle Attribute written
* @param status HCI status of the operation.
*/
void on_write_command_sent(
ble::connection_handle_t connection_handle,
ble::attribute_handle_t attribute_handle,
uint8_t status
) {
impl()->on_write_command_sent_(
connection_handle,
attribute_handle,
status
);
}
};


Expand Down
19 changes: 19 additions & 0 deletions features/FEATURE_BLE/source/generic/GenericGattClient.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,7 @@ GenericGattClient<TPalGattClient, SigningMonitorEventHandler>::GenericGattClient
_pal_client->when_transaction_timeout(
mbed::callback(this, &GenericGattClient::on_transaction_timeout)
);
_pal_client->set_event_handler(this);
}

template<template<class> class TPalGattClient, class SigningMonitorEventHandler>
Expand Down Expand Up @@ -1338,6 +1339,24 @@ void GenericGattClient<TPalGattClient, SigningMonitorEventHandler>::on_att_mtu_c
}
}

template<template<class> class TPalGattClient, class SigningMonitorEventHandler>
void GenericGattClient<TPalGattClient, SigningMonitorEventHandler>::on_write_command_sent_(
ble::connection_handle_t connection_handle,
ble::attribute_handle_t attribute_handle,
uint8_t status
) {
GattWriteCallbackParams response = {
connection_handle,
attribute_handle,
GattWriteCallbackParams::OP_WRITE_CMD,
BLE_ERROR_NONE,
status
};

this->processWriteResponse(&response);
}


template<template<class> class TPalGattClient, class SigningMonitorEventHandler>
void GenericGattClient<TPalGattClient, SigningMonitorEventHandler>::on_termination(connection_handle_t connection_handle) {
if (_termination_callback) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -695,10 +695,6 @@ ble_error_t GattServer::write_(
}
#endif // BLE_FEATURE_SECURITY

if (updates_sent) {
handleDataSentEvent(updates_sent);
}

return BLE_ERROR_NONE;
}

Expand Down Expand Up @@ -749,10 +745,6 @@ ble_error_t GattServer::write_(
}
#endif // BLE_FEATURE_SECURITY

if (updates_sent) {
handleDataSentEvent(updates_sent);
}

return BLE_ERROR_NONE;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ void CordioAttClient::att_client_handler(const attEvt_t* event)
if (handler) {
handler->on_att_mtu_change(event->hdr.param, event->mtu);
}
} else if (event->hdr.event == ATTC_WRITE_CMD_RSP) {
ble::vendor::cordio::BLE& ble = ble::vendor::cordio::BLE::deviceInstance();
impl::PalGattClientImpl::EventHandler *handler = ble.getPalGattClient().get_event_handler();
if (handler) {
handler->on_write_command_sent(
event->hdr.param,
event->handle,
event->hdr.status
);
}
} else {
// all handlers are stored in a static array
static const event_handler_t handlers[] = {
Expand Down