nl:: Ble:: BleLayer
#include <src/ble/BleLayer.h>
This class provides an interface for a single thread to drive data either up the stack via the BleLayer platform interface functions, or down the stack via a WeaveConnection object associated with a BLEEndPoint.
Summary
There are two ways to associate a WeaveConnection (defined by the WeaveMessageLayer) with a BLE connection:
First, the application can passively receive an incoming BLE connection and hand the platform-specific BLE_CONNECTION_OBJECT that this receipt generates to BleLayer via the corresponding platform interface function. This causes BleLayer to wrap the BLE_CONNECTION_OBJECT in a BLEEndPoint, and notify WeaveMessageLayer that a new BLE conneciotn has been received. The message layer then wraps the new BLEEndPoint object in a WeaveConnection, and hands this object to the application via the message layer's OnConnectionReceived callback.
Second, the application can actively form an outgoing BLE connection, e.g., by connecting to a BLE peripheral. It then creates a new WeaveConnection via the WeaveMessageLayer, assigns an authentication type to this connection, and binds it to the BLE_CONNECTION_OBJECT for the new BLE connection via WeaveConnection::ConnectBle. This function then establishes the secure session type specified by the WeaveConnection's authentication type member variable.
Inheritance
Direct Known Subclasses:nl::Weave::DeviceLayer::Internal::BLEManagerImpl
nl::Weave::DeviceLayer::Internal::BLEManagerImpl
nl::Weave::DeviceLayer::Internal::BLEManagerImpl
Constructors and Destructors |
|
---|---|
BleLayer(void)
|
Public types |
|
---|---|
@14
|
enum |
BleConnectionReceivedFunct)(BLEEndPoint *newEndPoint)
|
typedefvoid(*
|
Public attributes |
|
---|---|
OnWeaveBleConnectReceived
|
BleConnectionReceivedFunct
|
mAppState
|
void *
|
mState
|
enum nl::Ble::BleLayer::@14
[READ-ONLY] Current state
|
Public functions |
|
---|---|
HandleConnectionError(BLE_CONNECTION_OBJECT connObj, BLE_ERROR err)
|
void
|
HandleIndicationConfirmation(BLE_CONNECTION_OBJECT connObj, const WeaveBleUUID *svcId, const WeaveBleUUID *charId)
|
bool
Call when an oustanding GATT indication receives a positive receipt confirmation.
|
HandleIndicationReceived(BLE_CONNECTION_OBJECT connObj, const WeaveBleUUID *svcId, const WeaveBleUUID *charId, PacketBuffer *pBuf)
|
bool
Call when a GATT indication is received.
|
HandleReadReceived(BLE_CONNECTION_OBJECT connObj, BLE_READ_REQUEST_CONTEXT requestContext, const WeaveBleUUID *svcId, const WeaveBleUUID *charId)
|
bool
Call when a GATT read request is received.
|
HandleSubscribeComplete(BLE_CONNECTION_OBJECT connObj, const WeaveBleUUID *svcId, const WeaveBleUUID *charId)
|
bool
Call when a GATT subscribe request succeeds.
|
HandleSubscribeReceived(BLE_CONNECTION_OBJECT connObj, const WeaveBleUUID *svcId, const WeaveBleUUID *charId)
|
bool
|
HandleUnsubscribeComplete(BLE_CONNECTION_OBJECT connObj, const WeaveBleUUID *svcId, const WeaveBleUUID *charId)
|
bool
Call when a GATT unsubscribe request succeeds.
|
HandleUnsubscribeReceived(BLE_CONNECTION_OBJECT connObj, const WeaveBleUUID *svcId, const WeaveBleUUID *charId)
|
bool
|
HandleWriteConfirmation(BLE_CONNECTION_OBJECT connObj, const WeaveBleUUID *svcId, const WeaveBleUUID *charId)
|
bool
Call when an outstanding GATT write request receives a positive receipt confirmation.
|
HandleWriteReceived(BLE_CONNECTION_OBJECT connObj, const WeaveBleUUID *svcId, const WeaveBleUUID *charId, PacketBuffer *pBuf)
|
bool
Call when a GATT write request is received.
|
Init(BlePlatformDelegate *platformDelegate, BleApplicationDelegate *appDelegate, Weave::System::Layer *systemLayer)
|
|
NewBleEndPoint(BLEEndPoint **retEndPoint, BLE_CONNECTION_OBJECT connObj, BleRole role, bool autoClose)
|
|
ScheduleWork(nl::Weave::System::Layer::TimerCompleteFunct aComplete, void *aAppState)
|
nl::Weave::System::Error
Platform interface functions:
|
Shutdown(void)
|
Public types
@14
@14
BleConnectionReceivedFunct
void(* BleConnectionReceivedFunct)(BLEEndPoint *newEndPoint)
Public attributes
OnWeaveBleConnectReceived
BleConnectionReceivedFunct OnWeaveBleConnectReceived
mAppState
void * mAppState
mState
enum nl::Ble::BleLayer::@14 mState
[READ-ONLY] Current state
Public functions
BleLayer
BleLayer( void )
HandleConnectionError
void HandleConnectionError( BLE_CONNECTION_OBJECT connObj, BLE_ERROR err )
HandleIndicationConfirmation
bool HandleIndicationConfirmation( BLE_CONNECTION_OBJECT connObj, const WeaveBleUUID *svcId, const WeaveBleUUID *charId )
Call when an oustanding GATT indication receives a positive receipt confirmation.
HandleIndicationReceived
bool HandleIndicationReceived( BLE_CONNECTION_OBJECT connObj, const WeaveBleUUID *svcId, const WeaveBleUUID *charId, PacketBuffer *pBuf )
Call when a GATT indication is received.
HandleReadReceived
bool HandleReadReceived( BLE_CONNECTION_OBJECT connObj, BLE_READ_REQUEST_CONTEXT requestContext, const WeaveBleUUID *svcId, const WeaveBleUUID *charId )
Call when a GATT read request is received.
Platform must call this function when any previous operation undertaken by the BleLayer via BleAdapter fails, such as a characteristic write request or subscribe attempt, or when a BLE connection is closed.
In most cases, this will prompt Weave to close the associated WeaveConnection and notify that platform that it has abandoned the underlying BLE connection.
NOTE: if the application explicitly closes a BLE connection with an associated WeaveConnection such that the BLE connection close will not generate an upcall to Weave, HandleConnectionError must be called with err = BLE_ERROR_APP_CLOSED_CONNECTION to prevent the leak of this WeaveConnection and its end point object.
HandleSubscribeComplete
bool HandleSubscribeComplete( BLE_CONNECTION_OBJECT connObj, const WeaveBleUUID *svcId, const WeaveBleUUID *charId )
Call when a GATT subscribe request succeeds.
Platform must call this function when a GATT unsubscribe is requested on any Weave service charateristic, that is, when an existing GATT subscription on a Weave service characteristic is canceled.
HandleSubscribeReceived
bool HandleSubscribeReceived( BLE_CONNECTION_OBJECT connObj, const WeaveBleUUID *svcId, const WeaveBleUUID *charId )
HandleUnsubscribeComplete
bool HandleUnsubscribeComplete( BLE_CONNECTION_OBJECT connObj, const WeaveBleUUID *svcId, const WeaveBleUUID *charId )
Call when a GATT unsubscribe request succeeds.
HandleUnsubscribeReceived
bool HandleUnsubscribeReceived( BLE_CONNECTION_OBJECT connObj, const WeaveBleUUID *svcId, const WeaveBleUUID *charId )
HandleWriteConfirmation
bool HandleWriteConfirmation( BLE_CONNECTION_OBJECT connObj, const WeaveBleUUID *svcId, const WeaveBleUUID *charId )
Call when an outstanding GATT write request receives a positive receipt confirmation.
HandleWriteReceived
bool HandleWriteReceived( BLE_CONNECTION_OBJECT connObj, const WeaveBleUUID *svcId, const WeaveBleUUID *charId, PacketBuffer *pBuf )
Call when a GATT write request is received.
Init
BLE_ERROR Init( BlePlatformDelegate *platformDelegate, BleApplicationDelegate *appDelegate, Weave::System::Layer *systemLayer )
NewBleEndPoint
BLE_ERROR NewBleEndPoint( BLEEndPoint **retEndPoint, BLE_CONNECTION_OBJECT connObj, BleRole role, bool autoClose )
ScheduleWork
nl::Weave::System::Error ScheduleWork( nl::Weave::System::Layer::TimerCompleteFunct aComplete, void *aAppState )
Platform interface functions:
Calling conventions: Weave takes ownership of PacketBuffers received through these functions, and will free them or pass ownership up the stack.
Beyond each call, no guarantees are provided as to the lifetime of UUID arguments.
A 'true' return value means the Weave stack successfully handled the corresponding message or state indication. 'false' means the Weave stack either failed or chose not to handle this. In case of 'false,' the Weave stack will not have freed or taken ownership of any PacketBuffer arguments. This contract allows the platform to pass BLE events to Weave without needing to know which characteristics Weave cares about.
Platform must call this function when a GATT subscription has been established to any Weave service charateristic.
If this function returns true, Weave has accepted the BLE connection and wrapped it in a WeaveConnection object. If Weave accepts a BLE connection, the platform MUST notify Weave if the subscription is canceled or the underlying BLE connection is closed, or the associated WeaveConnection will never be closed or freed.
Shutdown
BLE_ERROR Shutdown( void )