Skip to content
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

Import generic implementation of connection manager #52

Merged
merged 7 commits into from
Mar 13, 2020
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
174 changes: 87 additions & 87 deletions src/ble/BLEEndPoint.cpp

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions src/ble/BLEEndPoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* @file
* This file defines a Bluetooth Low Energy (BLE) connection
* endpoint abstraction for the byte-streaming,
* connection-oriented chip over Bluetooth Low Energy (WoBLE)
* connection-oriented chip over Bluetooth Low Energy (CHIPoBLE)
* Bluetooth Transport Protocol (BTP).
*
*/
Expand All @@ -30,9 +30,9 @@
#include <system/SystemMutex.h>

#include <ble/BleLayer.h>
#include <ble/WoBle.h>
#if CHIP_ENABLE_WOBLE_TEST
#include <ble/WoBleTest.h>
#include <ble/CHIPoBle.h>
#if CHIP_ENABLE_CHIPOBLE_TEST
#include <ble/CHIPoBleTest.h>
#endif

namespace chip {
Expand All @@ -49,16 +49,16 @@ enum
// Forward declarations
class BleLayer;
class BleEndPointPool;
#if CHIP_ENABLE_WOBLE_TEST
class WoBleTest;
#if CHIP_ENABLE_CHIPOBLE_TEST
class CHIPoBleTest;
#endif

class DLL_EXPORT BLEEndPoint : public BleLayerObject
{
friend class BleLayer;
friend class BleEndPointPool;
#if CHIP_ENABLE_WOBLE_TEST
friend class WoBleTest;
#if CHIP_ENABLE_CHIPOBLE_TEST
friend class CHIPoBleTest;
#endif

public:
Expand Down Expand Up @@ -86,11 +86,11 @@ class DLL_EXPORT BLEEndPoint : public BleLayerObject
typedef void (*OnConnectionClosedFunct)(BLEEndPoint * endPoint, BLE_ERROR err);
OnConnectionClosedFunct OnConnectionClosed;

#if CHIP_ENABLE_WOBLE_TEST
#if CHIP_ENABLE_CHIPOBLE_TEST
typedef void (*OnCommandReceivedFunct)(BLEEndPoint * endPoint, PacketBuffer * msg);
OnCommandReceivedFunct OnCommandReceived;
inline void SetOnCommandReceivedCB(OnCommandReceivedFunct cb) { OnCommandReceived = cb; };
WoBleTest mWoBleTest;
CHIPoBleTest mCHIPoBleTest;
inline void SetTxWindowSize(uint8_t size) { mRemoteReceiveWindowSize = size; };
inline void SetRxWindowSize(uint8_t size) { mReceiveWindowMaxSize = size; };
#endif
Expand Down Expand Up @@ -125,7 +125,7 @@ class DLL_EXPORT BLEEndPoint : public BleLayerObject
kTimerState_AckReceivedTimerRunning = 0x04, // Ack received timer running due to unacked sent fragment.
kTimerState_SendAckTimerRunning = 0x08, // Send ack timer running; indicates pending ack to send.
kTimerState_UnsubscribeTimerRunning = 0x10, // Unsubscribe completion timer running.
#if CHIP_ENABLE_WOBLE_TEST
#if CHIP_ENABLE_CHIPOBLE_TEST
kTimerState_UnderTestTimerRunnung = 0x80 // running throughput Tx test
#endif
};
Expand All @@ -135,7 +135,7 @@ class DLL_EXPORT BLEEndPoint : public BleLayerObject
// modify the state of the underlying BLE connection.
BLE_CONNECTION_OBJECT mConnObj;

// Queue of outgoing messages to send when current WoBle transmission completes.
// Queue of outgoing messages to send when current CHIPoBle transmission completes.
//
// Re-used during connection setup to cache capabilities request and response payloads; payloads are freed when
// connection is established.
Expand All @@ -145,14 +145,14 @@ class DLL_EXPORT BLEEndPoint : public BleLayerObject
// progress.
PacketBuffer * mAckToSend;

WoBle mWoBle;
CHIPoBle mCHIPoBle;
BleRole mRole;
uint8_t mConnStateFlags;
uint8_t mTimerStateFlags;
SequenceNumber_t mLocalReceiveWindowSize;
SequenceNumber_t mRemoteReceiveWindowSize;
SequenceNumber_t mReceiveWindowMaxSize;
#if CHIP_ENABLE_WOBLE_TEST
#if CHIP_ENABLE_CHIPOBLE_TEST
chip::System::Mutex mTxQueueMutex; // For MT-safe Tx queuing
#endif

Expand Down Expand Up @@ -215,10 +215,10 @@ class DLL_EXPORT BLEEndPoint : public BleLayerObject
void FinalizeClose(uint8_t state, uint8_t flags, BLE_ERROR err);
void ReleaseBleConnection(void);
void Free(void);
void FreeWoBle(void);
void FreeCHIPoBle(void);

// Mutex lock on Tx queue. Used only in WoBle test build for now.
#if CHIP_ENABLE_WOBLE_TEST
// Mutex lock on Tx queue. Used only in CHIPoBle test build for now.
#if CHIP_ENABLE_CHIPOBLE_TEST
inline void QueueTxLock() { mTxQueueMutex.Lock(); };
inline void QueueTxUnlock() { mTxQueueMutex.Unlock(); };
#else
Expand Down
2 changes: 1 addition & 1 deletion src/ble/Ble.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include <ble/BleLayer.h>
#include <ble/BlePlatformDelegate.h>
#include <ble/BleUUID.h>
#include <ble/WoBle.h>
#include <ble/CHIPoBle.h>

/**
* @namespace Ble
Expand Down
2 changes: 1 addition & 1 deletion src/ble/BleError.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ bool FormatBleLayerError(char * buf, uint16_t bufSize, int32_t err)
case BLE_ERROR_NOT_IMPLEMENTED:
desc = "Not implemented";
break;
case BLE_ERROR_WOBLE_PROTOCOL_ABORT:
case BLE_ERROR_CHIPOBLE_PROTOCOL_ABORT:
desc = "BLE transport protocol fired abort";
break;
case BLE_ERROR_REMOTE_DEVICE_DISCONNECTED:
Expand Down
4 changes: 2 additions & 2 deletions src/ble/BleError.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,13 @@ typedef BLE_CONFIG_ERROR_TYPE BLE_ERROR;
*/

/**
* @def BLE_ERROR_WOBLE_PROTOCOL_ABORT
* @def BLE_ERROR_CHIPOBLE_PROTOCOL_ABORT
*
* @brief
* A BLE Transport Protocol (BTP) error was encountered.
*
*/
#define BLE_ERROR_WOBLE_PROTOCOL_ABORT _BLE_ERROR(11)
#define BLE_ERROR_CHIPOBLE_PROTOCOL_ABORT _BLE_ERROR(11)

/**
* @def BLE_ERROR_REMOTE_DEVICE_DISCONNECTED
Expand Down
4 changes: 2 additions & 2 deletions src/ble/BleLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ BLE_ERROR BleLayer::Init(BlePlatformDelegate * platformDelegate, BleApplicationD

mState = kState_Initialized;

#if CHIP_ENABLE_WOBLE_TEST
#if CHIP_ENABLE_CHIPOBLE_TEST
mTestBleEndPoint = NULL;
#endif

Expand Down Expand Up @@ -382,7 +382,7 @@ BLE_ERROR BleLayer::NewBleEndPoint(BLEEndPoint ** retEndPoint, BLE_CONNECTION_OB

(*retEndPoint)->Init(this, connObj, role, autoClose);

#if CHIP_ENABLE_WOBLE_TEST
#if CHIP_ENABLE_CHIPOBLE_TEST
mTestBleEndPoint = *retEndPoint;
#endif

Expand Down
12 changes: 6 additions & 6 deletions src/ble/BleLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ typedef enum
typedef enum
{
kBleTransportProtocolVersion_None = 0,
kBleTransportProtocolVersion_V1 = 1, // Prototype WoBLe version without ACKs or flow-control.
kBleTransportProtocolVersion_V2 = 2, // First WoBLE version with ACKs and flow-control.
kBleTransportProtocolVersion_V3 = 3 // First WoBLE version with asymetric fragement sizes.
kBleTransportProtocolVersion_V1 = 1, // Prototype CHIPoBle version without ACKs or flow-control.
kBleTransportProtocolVersion_V2 = 2, // First CHIPoBLE version with ACKs and flow-control.
kBleTransportProtocolVersion_V3 = 3 // First CHIPoBLE version with asymetric fragement sizes.
} BleTransportProtocolVersion;

class BleLayerObject
Expand Down Expand Up @@ -229,8 +229,8 @@ class BleTransportCapabilitiesResponseMessage
class DLL_EXPORT BleLayer
{
friend class BLEEndPoint;
#if CHIP_ENABLE_WOBLE_TEST
friend class WoBleTest;
#if CHIP_ENABLE_CHIPOBLE_TEST
friend class CHIPoBleTest;
#endif

public:
Expand Down Expand Up @@ -330,7 +330,7 @@ class DLL_EXPORT BleLayer
* err = BLE_ERROR_APP_CLOSED_CONNECTION to prevent the leak of this chipConnection and its end point object. */
void HandleConnectionError(BLE_CONNECTION_OBJECT connObj, BLE_ERROR err);

#if CHIP_ENABLE_WOBLE_TEST
#if CHIP_ENABLE_CHIPOBLE_TEST
BLEEndPoint * mTestBleEndPoint;
#endif

Expand Down
Loading