Mbed OS Reference
Loading...
Searching...
No Matches
LinkLossService Class Reference

This service defines behavior when a link is lost between two devices. More...

#include <LinkLossService.h>

Inheritance diagram for LinkLossService:
Gap::EventHandler

Public Member Functions

 LinkLossService (BLE &bleIn, callback_t callbackIn, AlertLevel_t levelIn=NO_ALERT)
 
void setCallback (callback_t newCallback)
 Update the callback. More...
 
void setAlertLevel (AlertLevel_t newLevel)
 Update alertness level. More...
 
virtual void onScanRequestReceived (const ScanRequestEvent &event)
 Called when an advertising device receive a scan request. More...
 
virtual void onAdvertisingStart (const AdvertisingStartEvent &event)
 Called when advertising starts. More...
 
virtual void onAdvertisingEnd (const AdvertisingEndEvent &event)
 Called when advertising ends. More...
 
virtual void onAdvertisingReport (const AdvertisingReportEvent &event)
 Called when a scanner receives an advertising or a scan response packet. More...
 
virtual void onScanTimeout (const ScanTimeoutEvent &event)
 Called when scan times out. More...
 
virtual void onPeriodicAdvertisingSyncEstablished (const PeriodicAdvertisingSyncEstablishedEvent &event)
 Called when first advertising packet in periodic advertising is received. More...
 
virtual void onPeriodicAdvertisingReport (const PeriodicAdvertisingReportEvent &event)
 Called when a periodic advertising packet is received. More...
 
virtual void onPeriodicAdvertisingSyncLoss (const PeriodicAdvertisingSyncLoss &event)
 Called when a periodic advertising sync has been lost. More...
 
virtual void onConnectionComplete (const ConnectionCompleteEvent &event)
 Called when connection attempt ends. More...
 
virtual void onUpdateConnectionParametersRequest (const UpdateConnectionParametersRequestEvent &event)
 Called when the peer request connection parameters updates. More...
 
virtual void onConnectionParametersUpdateComplete (const ConnectionParametersUpdateCompleteEvent &event)
 Called when connection parameters have been updated. More...
 
virtual void onReadPhy (ble_error_t status, connection_handle_t connectionHandle, phy_t txPhy, phy_t rxPhy)
 Function invoked when the current transmitter and receiver PHY have been read for a given connection. More...
 
virtual void onPhyUpdateComplete (ble_error_t status, connection_handle_t connectionHandle, phy_t txPhy, phy_t rxPhy)
 Function invoked when the update process of the PHY has been completed. More...
 
virtual void onDataLengthChange (connection_handle_t connectionHandle, uint16_t txSize, uint16_t rxSize)
 Function invoked when the connections changes the maximum number of octets that can be sent or received by the controller in a single packet. More...
 
virtual void onPrivacyEnabled ()
 Function invoked when the privacy subsystem has been enabled and is ready to be used. More...
 

Protected Member Functions

virtual void onDataWritten (const GattWriteCallbackParams *params)
 This callback allows receiving updates to the AlertLevel characteristic. More...
 
void onDisconnectionComplete (const ble::DisconnectionCompleteEvent &) override
 Called when a connection has been disconnected. More...
 

Detailed Description

Constructor & Destructor Documentation

◆ LinkLossService()

LinkLossService ( BLE bleIn,
callback_t  callbackIn,
AlertLevel_t  levelIn = NO_ALERT 
)
Parameters
bleInBLE object for the underlying controller.
callbackInCallback invoked upon disconnection.
levelInAlert level.

Definition at line 54 of file LinkLossService.h.

Member Function Documentation

◆ setCallback()

void setCallback ( callback_t  newCallback)

Update the callback.

Definition at line 77 of file LinkLossService.h.

◆ setAlertLevel()

void setAlertLevel ( AlertLevel_t  newLevel)

Update alertness level.

Definition at line 84 of file LinkLossService.h.

◆ onDataWritten()

virtual void onDataWritten ( const GattWriteCallbackParams params)
protectedvirtual

This callback allows receiving updates to the AlertLevel characteristic.

Parameters
[in]paramsInformation about the characteristic being updated.

Definition at line 95 of file LinkLossService.h.

◆ onDisconnectionComplete()

void onDisconnectionComplete ( const ble::DisconnectionCompleteEvent event)
overrideprotectedvirtual

Called when a connection has been disconnected.

Parameters
eventDetails of the event.
See also
disconnect()

Reimplemented from Gap::EventHandler.

Definition at line 101 of file LinkLossService.h.

◆ onScanRequestReceived()

virtual void onScanRequestReceived ( const ScanRequestEvent event)
virtualinherited

Called when an advertising device receive a scan request.

Parameters
eventScan request event.
Version
: 5+.
See also
AdvertisingParameters::setScanRequestNotification().

Reimplemented in ChainableGapEventHandler.

Definition at line 313 of file Gap.h.

◆ onAdvertisingStart()

virtual void onAdvertisingStart ( const AdvertisingStartEvent event)
virtualinherited

Called when advertising starts.

Parameters
eventAdvertising start event.
Note
Check event.getStatus() to see if advertising started successfully
See also
startAdvertising()

Reimplemented in ChainableGapEventHandler.

Definition at line 326 of file Gap.h.

◆ onAdvertisingEnd()

virtual void onAdvertisingEnd ( const AdvertisingEndEvent event)
virtualinherited

Called when advertising ends.

Advertising ends when the process timeout or if it is stopped by the application or if the local device accepts a connection request.

Parameters
eventAdvertising end event.
Note
Check event.getStatus() to see if advertising ended successfully
See also
stopAdvertising()
onConnectionComplete()

Reimplemented in ChainableGapEventHandler.

Definition at line 343 of file Gap.h.

◆ onAdvertisingReport()

virtual void onAdvertisingReport ( const AdvertisingReportEvent event)
virtualinherited

Called when a scanner receives an advertising or a scan response packet.

Parameters
eventAdvertising report.
See also
startScan()

Reimplemented in ChainableGapEventHandler.

Definition at line 354 of file Gap.h.

◆ onScanTimeout()

virtual void onScanTimeout ( const ScanTimeoutEvent event)
virtualinherited

Called when scan times out.

Parameters
eventAssociated event.
See also
startScan()

Reimplemented in ChainableGapEventHandler.

Definition at line 365 of file Gap.h.

◆ onPeriodicAdvertisingSyncEstablished()

virtual void onPeriodicAdvertisingSyncEstablished ( const PeriodicAdvertisingSyncEstablishedEvent event)
virtualinherited

Called when first advertising packet in periodic advertising is received.

Parameters
eventPeriodic advertising sync event.
Version
: 5+.
See also
createSync()

Reimplemented in ChainableGapEventHandler.

Definition at line 378 of file Gap.h.

◆ onPeriodicAdvertisingReport()

virtual void onPeriodicAdvertisingReport ( const PeriodicAdvertisingReportEvent event)
virtualinherited

Called when a periodic advertising packet is received.

Parameters
eventPeriodic advertisement event.
Version
: 5+.
See also
createSync()

Reimplemented in ChainableGapEventHandler.

Definition at line 393 of file Gap.h.

◆ onPeriodicAdvertisingSyncLoss()

virtual void onPeriodicAdvertisingSyncLoss ( const PeriodicAdvertisingSyncLoss event)
virtualinherited

Called when a periodic advertising sync has been lost.

Parameters
eventDetails of the event.
Version
: 5+.
See also
createSync()

Reimplemented in ChainableGapEventHandler.

Definition at line 408 of file Gap.h.

◆ onConnectionComplete()

virtual void onConnectionComplete ( const ConnectionCompleteEvent event)
virtualinherited

Called when connection attempt ends.

Check event.getStatus() to see if connection was established. If this device is the peripheral and it was advertising this will end the advertising set which will also create the onAdvertisingEnd event.

See also
startAdvertising()
connect()
Parameters
eventConnection event.

Reimplemented in ChainableGapEventHandler.

Definition at line 424 of file Gap.h.

◆ onUpdateConnectionParametersRequest()

virtual void onUpdateConnectionParametersRequest ( const UpdateConnectionParametersRequestEvent event)
virtualinherited

Called when the peer request connection parameters updates.

Application must accept the update with acceptConnectionParametersUpdate() or reject it with rejectConnectionParametersUpdate().

Parameters
eventThe connection parameters requested by the peer.
Version
4.1+.
Note
This event will only be produced if manageConnectionParametersUpdateRequest() was called with true. Otherwise the stack will handle the request and no event will be generated.
See also
manageConnectionParametersUpdateRequest()
acceptConnectionParametersUpdate()
rejectConnectionParametersUpdate()

Reimplemented in ChainableGapEventHandler.

Definition at line 445 of file Gap.h.

◆ onConnectionParametersUpdateComplete()

virtual void onConnectionParametersUpdateComplete ( const ConnectionParametersUpdateCompleteEvent event)
virtualinherited

Called when connection parameters have been updated.

Parameters
eventThe new connection parameters.
See also
updateConnectionParameters()
acceptConnectionParametersUpdate()

Reimplemented in ChainableGapEventHandler.

Definition at line 459 of file Gap.h.

◆ onReadPhy()

virtual void onReadPhy ( ble_error_t  status,
connection_handle_t  connectionHandle,
phy_t  txPhy,
phy_t  rxPhy 
)
virtualinherited

Function invoked when the current transmitter and receiver PHY have been read for a given connection.

Parameters
statusStatus of the operation: BLE_ERROR_NONE in case of success or an appropriate error code.
connectionHandleThe handle of the connection for which the PHYs have been read.
txPhyPHY used by the transmitter.
rxPhyPHY used by the receiver.
See also
readPhy().
Version
: 5+.

Reimplemented in ChainableGapEventHandler.

Definition at line 494 of file Gap.h.

◆ onPhyUpdateComplete()

virtual void onPhyUpdateComplete ( ble_error_t  status,
connection_handle_t  connectionHandle,
phy_t  txPhy,
phy_t  rxPhy 
)
virtualinherited

Function invoked when the update process of the PHY has been completed.

The process can be initiated by a call to the function setPhy, the local bluetooth subsystem or the peer.

Parameters
statusStatus of the operation: BLE_ERROR_NONE in case of success or an appropriate error code.
connectionHandleThe handle of the connection on which the operation was made.
txPhyPHY used by the transmitter.
rxPhyPHY used by the receiver.
Note
Success doesn't mean the PHY has been updated it means both ends have negotiated the best PHY according to their configuration and capabilities. The PHY currently used are present in the txPhy and rxPhy parameters.
See also
setPhy()
Version
: 5+.

Reimplemented in ChainableGapEventHandler.

Definition at line 528 of file Gap.h.

◆ onDataLengthChange()

virtual void onDataLengthChange ( connection_handle_t  connectionHandle,
uint16_t  txSize,
uint16_t  rxSize 
)
virtualinherited

Function invoked when the connections changes the maximum number of octets that can be sent or received by the controller in a single packet.

A single L2CAP packet can be fragmented across many such packets.

Note
This only triggers if controller supports data length extension and negotiated data length is longer than the default 23.
Parameters
connectionHandleThe handle of the connection that changed the size.
txSizeNumber of octets we can send on this connection in a single packet.
rxSizeNumber of octets we can receive on this connection in a single packet.

Reimplemented in ChainableGapEventHandler.

Definition at line 549 of file Gap.h.

◆ onPrivacyEnabled()

virtual void onPrivacyEnabled ( )
virtualinherited

Function invoked when the privacy subsystem has been enabled and is ready to be used.

See also
enablePrivacy()

Reimplemented in ChainableGapEventHandler.

Definition at line 563 of file Gap.h.