Skip to content

Rebuild on mbed-os 6.12 #276

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 9 commits into from
Jul 5, 2021
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 6 additions & 2 deletions cores/arduino/mbed/connectivity/FEATURE_BLE/include/ble/Gap.h
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,9 @@ class Gap {
* @param handle Advertising set handle.
* @param maxDuration Max duration for advertising (in units of 10ms) - 0 means no limit.
* @param maxEvents Max number of events produced during advertising - 0 means no limit.
* @return BLE_ERROR_NONE on success.
* @return BLE_ERROR_NONE on success. This does not guarantee the set has started if
* extended advertising is enabled. Register an event handler and wait for onAdvertisingStart
* event. An (unlikely) failed start the status of the event will contain an error.
*
* @see EventHandler::onAdvertisingStart when the advertising starts.
* @see EventHandler::onScanRequestReceived when a scan request is received.
Expand All @@ -765,7 +767,9 @@ class Gap {
* which will not be affected.
*
* @param handle Advertising set handle.
* @return BLE_ERROR_NONE on success.
* @return BLE_ERROR_NONE on success. For extented advertising this does not guarantee
* the set is stopped if. Register an event handler and wait for onAdvertisingEnd event.
* An (unlikely) failed stop the event status will contain the error code.
*/
ble_error_t stopAdvertising(advertising_handle_t handle);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,9 @@ class GattServer {
}

/**
* Function invoked when the server has sent data to a client as
* part of a notification/indication.
* Function invoked when the server has sent data to a client. For
* notifications this is triggered when data is sent, for indications
* it's only triggered when the confirmation has been received.
*
* @note params has a temporary scope and should be copied by the
* application if needed later
Expand Down Expand Up @@ -188,12 +189,13 @@ class GattServer {
}

/**
* Function invoked when an ACK has been received for an
* indication sent to the client.
* Event not used.
*
* @note params has a temporary scope and should be copied by the
* application if needed later
*/
MBED_DEPRECATED_SINCE("mbed-os-6.11.0", "This event is never triggered. Indication triggers onDataSent"
"when confirmation is received.")
virtual void onConfirmationReceived(const GattConfirmationReceivedCallbackParams &params) {
(void)params;
}
Expand Down Expand Up @@ -274,7 +276,7 @@ class GattServer {
* Event handler that handles subscription to characteristic updates,
* unsubscription from characteristic updates and notification confirmation.
*
* @see onUpdatesEnabled() onUpdateDisabled() onConfirmationReceived()
* @see onUpdatesEnabled() onUpdateDisabled()
*/
typedef FunctionPointerWithContext<GattAttribute::Handle_t> EventCallback_t;

Expand Down Expand Up @@ -705,7 +707,8 @@ class GattServer {
* @param[in] callback Event handler being registered.
*/
MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
"been replaced by GattServer::setEventHandler. Use that function instead.")
"been replaced by an event handler. Indication confirmation triggers"
"GattServer::onDataSent event instead.")
void onConfirmationReceived(EventCallback_t callback);

#if !defined(DOXYGEN_ONLY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,50 @@
#ifndef MBED_BLE_ROLES_H__
#define MBED_BLE_ROLES_H__

/* we provide default values if no configuration is present (e.g. in unittests) */
#if !defined(BLE_ROLE_OBSERVER)
#define BLE_ROLE_OBSERVER 1
#endif
#if !defined(BLE_ROLE_BROADCASTER)
#define BLE_ROLE_BROADCASTER 1
#endif
#if !defined(BLE_ROLE_CENTRAL)
#define BLE_ROLE_CENTRAL 1
#endif
#if !defined(BLE_ROLE_PERIPHERAL)
#define BLE_ROLE_PERIPHERAL 1
#endif
#if !defined(BLE_FEATURE_GATT_CLIENT)
#define BLE_FEATURE_GATT_CLIENT 1
#endif
#if !defined(BLE_FEATURE_GATT_SERVER)
#define BLE_FEATURE_GATT_SERVER 1
#endif
#if !defined(BLE_FEATURE_SECURITY)
#define BLE_FEATURE_SECURITY 1
#endif
#if !defined(BLE_FEATURE_SECURE_CONNECTIONS)
#define BLE_FEATURE_SECURE_CONNECTIONS 1
#endif
#if !defined(BLE_FEATURE_SIGNING)
#define BLE_FEATURE_SIGNING 1
#endif
#if !defined(BLE_FEATURE_WHITELIST)
#define BLE_FEATURE_WHITELIST 1
#endif
#if !defined(BLE_FEATURE_PRIVACY)
#define BLE_FEATURE_PRIVACY 1
#endif
#if !defined(BLE_FEATURE_PHY_MANAGEMENT)
#define BLE_FEATURE_PHY_MANAGEMENT 1
#endif
#if !defined(BLE_FEATURE_EXTENDED_ADVERTISING)
#define BLE_FEATURE_EXTENDED_ADVERTISING 1
#endif
#if !defined(BLE_FEATURE_PERIODIC_ADVERTISING)
#define BLE_FEATURE_PERIODIC_ADVERTISING 1
#endif

#if !(BLE_ROLE_OBSERVER) && !(BLE_ROLE_BROADCASTER)
#error "BLE requires at least one role 'BROADCASTER' or 'OBSERVER' to be enabled"
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,17 @@ enum ble_error_t {
/**
* Data not found or there is nothing to return.
*/
BLE_ERROR_NOT_FOUND = 13
BLE_ERROR_NOT_FOUND = 13,

/**
* Specified timeout expired.
*/
BLE_ERROR_TIMEOUT = 14,

/**
* Specified limit expired.
*/
BLE_ERROR_LIMIT_REACHED = 15
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -586,9 +586,10 @@ struct AdvertisingStartEvent {
/** Create an advertising start event.
*
* @param advHandle Advertising set handle.
* @param status Advertising set start command status.
*/
AdvertisingStartEvent(advertising_handle_t advHandle) :
advHandle(advHandle)
AdvertisingStartEvent(advertising_handle_t advHandle, ble_error_t status = BLE_ERROR_NONE) :
advHandle(advHandle), status(status)
{
}

Expand All @@ -600,8 +601,15 @@ struct AdvertisingStartEvent {
return advHandle;
}

/** Get status of operation. */
ble_error_t getStatus() const
{
return status;
}

private:
advertising_handle_t advHandle;
ble_error_t status;
};

/**
Expand All @@ -610,29 +618,38 @@ struct AdvertisingStartEvent {
* @see ble::Gap::EventHandler::onAdvertisingEnd().
*
* @note The connection handle, connected flag and completed_event fields are
* valid if the flag legacy is not set to true.
* valid if the flag legacy is not set to true. If status is different from BLE_ERROR_NONE
* the completed_events field is not valid and the set may still be active.
*/
struct AdvertisingEndEvent {
#if !defined(DOXYGEN_ONLY)

/** Create an extended advertising end event.
*
* @param advHandle Advertising set handle.
* @param connection Connection handle.
* @param completed_events Number of events created during before advertising end.
* @param connection Connection handle - only valid if connected is True.
* @param completed_events Number of events created during before advertising end - only valid
* if advertising end has been caused by BLE_ERROR_LIMIT_REACHED, not the local user.
* Check getStatus().
* @param connected True if connection has been established.
* @param status Error code showing the reason for event. BLE_ERROR_LIMIT_REACHED if set number
* of events have been reached. BLE_ERROR_TIMEOUT if set time has elapsed.
* BLE_ERROR_SUCCESS if connection occurred or user ended the set. Check isConnected()
* to determine which.
*/
AdvertisingEndEvent(
advertising_handle_t advHandle,
connection_handle_t connection,
uint8_t completed_events,
bool connected
bool connected,
ble_error_t status = BLE_ERROR_NONE
) :
advHandle(advHandle),
connection(connection),
completed_events(completed_events),
connected(connected),
legacy(false)
legacy(false),
status(status)
{
}

Expand All @@ -643,7 +660,8 @@ struct AdvertisingEndEvent {
connection(),
completed_events(0),
connected(false),
legacy(true)
legacy(true),
status(BLE_ERROR_NONE)
{
}

Expand Down Expand Up @@ -683,12 +701,20 @@ struct AdvertisingEndEvent {
return legacy;
}

/** Get the result of the stop advertising event. If the status is not BLE_ERROR_NONE the set
* may still be active. */
ble_error_t getStatus() const
{
return status;
}

private:
advertising_handle_t advHandle;
connection_handle_t connection;
uint8_t completed_events;
bool connected;
bool legacy;
ble_error_t status;
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1672,19 +1672,30 @@ class GattCharacteristic {
*
* @attention This function is not meant to be called by user code.
*
* @param[in] params Context of the read-auth request; it contains an
* @param[in,out] params Context of the read-auth request; it contains an
* out-parameter used as a reply and the handler can fill it with outgoing
* data.
* data. The params->data provides a pointer to the data and params->len
* provides the length of this data. params->len is also used to pass the
* maximum size of data that the params->data can contain. If you set the
* params->len to a value larger than the passed in value the read operation
* will fail.
*
* @return A GattAuthCallbackReply_t value indicating whether authorization
* is granted.
*
* @note If the read is approved, the event handler can specify an outgoing
* value directly with the help of the fields params->data and params->len.
*
* @note If the read request is approved and params->data remains nullptr, then
* the current characteristic value is used in the read response payload.
*
* @note If the read is approved, the event handler can specify an outgoing
* value directly with the help of the fields
* GattReadAuthCallbackParams::data and GattReadAuthCallbackParams::len.
* @note The params->len parameter initially contains the maximum length of
* data that can be returned. Set it to the length of your data but it must
* not be larger than the original value.
*
* @note You must also take into account the offset provided in params->offset.
* The params->len you provide must be larger then the offset as the read operation
* will attempt to read at that offset.
*/
GattAuthCallbackReply_t authorizeRead(GattReadAuthCallbackParams *params)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@
#include "source/PalPrivateAddressControllerImpl.h"
#include "source/generic/PrivateAddressController.h"

#include "drivers/Timeout.h"
#ifdef DEVICE_LPTICKER
#include "drivers/LowPowerTimeout.h"
#include "drivers/LowPowerTimer.h"
#else
#include "drivers/Timer.h"
#endif

namespace ble {

Expand All @@ -57,6 +63,14 @@ namespace impl {
* @see BLEInstanceBase
*/
class BLEInstanceBase final : public ble::BLEInstanceBase {
#ifdef DEVICE_LPTICKER
using Timeout = mbed::LowPowerTimeout;
using Timer = mbed::LowPowerTimer;
#else
using Timeout = mbed::Timeout;
using Timer = mbed::Timer;
#endif

friend PalSigningMonitor;

/**
Expand Down Expand Up @@ -200,7 +214,7 @@ class BLEInstanceBase final : public ble::BLEInstanceBase {
} initialization_status;

mutable ble::impl::PalEventQueue _event_queue;
mbed::LowPowerTimer _timer;
Timer _timer;
uint64_t _last_update_us;
};

Expand Down
Loading