mirror of https://github.com/ARMmbed/mbed-os.git
add status to start and stop events
parent
e99741dd3d
commit
8dedd43e7c
|
|
@ -341,18 +341,6 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when an asynchronous advertising command fails.
|
|
||||||
*
|
|
||||||
* @param event Advertising command failed event.
|
|
||||||
*
|
|
||||||
* @see startAdvertising()
|
|
||||||
* @see stopAdvertising()
|
|
||||||
*/
|
|
||||||
virtual void onAdvertisingCommandFailed(const AdvertisingCommandFailedEvent &event)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a scanner receives an advertising or a scan response packet.
|
* Called when a scanner receives an advertising or a scan response packet.
|
||||||
*
|
*
|
||||||
|
|
@ -761,7 +749,7 @@ public:
|
||||||
* @param maxEvents Max number of events produced during advertising - 0 means no limit.
|
* @param maxEvents Max number of events produced during advertising - 0 means no limit.
|
||||||
* @return BLE_ERROR_NONE on success. This does not guarantee the set has started if
|
* @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
|
* extended advertising is enabled. Register an event handler and wait for onAdvertisingStart
|
||||||
* event. An (unlikely) failed start will emit an onAdvertisingCommandFailed instead.
|
* event. An (unlikely) failed start the status of the event will contain an error.
|
||||||
*
|
*
|
||||||
* @see EventHandler::onAdvertisingStart when the advertising starts.
|
* @see EventHandler::onAdvertisingStart when the advertising starts.
|
||||||
* @see EventHandler::onScanRequestReceived when a scan request is received.
|
* @see EventHandler::onScanRequestReceived when a scan request is received.
|
||||||
|
|
@ -781,7 +769,7 @@ public:
|
||||||
* @param handle Advertising set handle.
|
* @param handle Advertising set handle.
|
||||||
* @return BLE_ERROR_NONE on success. For extented advertising this does not guarantee
|
* @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.
|
* the set is stopped if. Register an event handler and wait for onAdvertisingEnd event.
|
||||||
* An (unlikely) failed stop will emit an onAdvertisingCommandFailed instead.
|
* An (unlikely) failed stop the event status will contain the error code.
|
||||||
*/
|
*/
|
||||||
ble_error_t stopAdvertising(advertising_handle_t handle);
|
ble_error_t stopAdvertising(advertising_handle_t handle);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -586,9 +586,10 @@ struct AdvertisingStartEvent {
|
||||||
/** Create an advertising start event.
|
/** Create an advertising start event.
|
||||||
*
|
*
|
||||||
* @param advHandle Advertising set handle.
|
* @param advHandle Advertising set handle.
|
||||||
|
* @param status Advertising set start command status.
|
||||||
*/
|
*/
|
||||||
AdvertisingStartEvent(advertising_handle_t advHandle) :
|
AdvertisingStartEvent(advertising_handle_t advHandle, ble_error_t status = BLE_ERROR_NONE) :
|
||||||
advHandle(advHandle)
|
advHandle(advHandle), status(status)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -600,43 +601,12 @@ struct AdvertisingStartEvent {
|
||||||
return advHandle;
|
return advHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
/** Get status of operation. */
|
||||||
advertising_handle_t advHandle;
|
ble_error_t getStatus() const
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Event produced when an async advertising command fails.
|
|
||||||
*
|
|
||||||
* @see ble::Gap::EventHandler::onAdvertisingCommandFailed().
|
|
||||||
*/
|
|
||||||
struct AdvertisingCommandFailedEvent {
|
|
||||||
#if !defined(DOXYGEN_ONLY)
|
|
||||||
/** Create an extended advertising command failed event.
|
|
||||||
*
|
|
||||||
* @param advHandle Advertising set handle.
|
|
||||||
* @param status Error code.
|
|
||||||
*/
|
|
||||||
AdvertisingCommandFailedEvent(
|
|
||||||
advertising_handle_t advHandle,
|
|
||||||
ble_error_t status
|
|
||||||
) :
|
|
||||||
advHandle(advHandle),
|
|
||||||
status(status)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
/** Get advertising handle. */
|
|
||||||
advertising_handle_t getAdvHandle() const
|
|
||||||
{
|
|
||||||
return advHandle;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Error code that caused the event. */
|
|
||||||
uint8_t getStatus() const
|
|
||||||
{
|
{
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
advertising_handle_t advHandle;
|
advertising_handle_t advHandle;
|
||||||
ble_error_t status;
|
ble_error_t status;
|
||||||
|
|
@ -648,7 +618,8 @@ private:
|
||||||
* @see ble::Gap::EventHandler::onAdvertisingEnd().
|
* @see ble::Gap::EventHandler::onAdvertisingEnd().
|
||||||
*
|
*
|
||||||
* @note The connection handle, connected flag and completed_event fields are
|
* @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 {
|
struct AdvertisingEndEvent {
|
||||||
#if !defined(DOXYGEN_ONLY)
|
#if !defined(DOXYGEN_ONLY)
|
||||||
|
|
@ -659,18 +630,21 @@ struct AdvertisingEndEvent {
|
||||||
* @param connection Connection handle.
|
* @param connection Connection handle.
|
||||||
* @param completed_events Number of events created during before advertising end.
|
* @param completed_events Number of events created during before advertising end.
|
||||||
* @param connected True if connection has been established.
|
* @param connected True if connection has been established.
|
||||||
|
* @param status Error code if stop command failed.
|
||||||
*/
|
*/
|
||||||
AdvertisingEndEvent(
|
AdvertisingEndEvent(
|
||||||
advertising_handle_t advHandle,
|
advertising_handle_t advHandle,
|
||||||
connection_handle_t connection,
|
connection_handle_t connection,
|
||||||
uint8_t completed_events,
|
uint8_t completed_events,
|
||||||
bool connected
|
bool connected,
|
||||||
|
ble_error_t status = BLE_ERROR_NONE
|
||||||
) :
|
) :
|
||||||
advHandle(advHandle),
|
advHandle(advHandle),
|
||||||
connection(connection),
|
connection(connection),
|
||||||
completed_events(completed_events),
|
completed_events(completed_events),
|
||||||
connected(connected),
|
connected(connected),
|
||||||
legacy(false)
|
legacy(false),
|
||||||
|
status(status)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -681,7 +655,8 @@ struct AdvertisingEndEvent {
|
||||||
connection(),
|
connection(),
|
||||||
completed_events(0),
|
completed_events(0),
|
||||||
connected(false),
|
connected(false),
|
||||||
legacy(true)
|
legacy(true),
|
||||||
|
status(BLE_ERROR_NONE)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -721,12 +696,20 @@ struct AdvertisingEndEvent {
|
||||||
return legacy;
|
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:
|
private:
|
||||||
advertising_handle_t advHandle;
|
advertising_handle_t advHandle;
|
||||||
connection_handle_t connection;
|
connection_handle_t connection;
|
||||||
uint8_t completed_events;
|
uint8_t completed_events;
|
||||||
bool connected;
|
bool connected;
|
||||||
bool legacy;
|
bool legacy;
|
||||||
|
ble_error_t status;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue