Skip to content

Commit

Permalink
Generalize name of BtpEngine module in BleLayer. (#293)
Browse files Browse the repository at this point in the history
* Generalize name of BtpEngine module in BleLayer.

* Resolution of comments from BroderickCarlin@
  • Loading branch information
turon authored Apr 16, 2020
1 parent c42bf2e commit 7a8a93f
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 125 deletions.
8 changes: 4 additions & 4 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -821,13 +821,13 @@ AC_ARG_ENABLE(chipoble-test,
],
[enable_chipoble_test=no])
AC_MSG_RESULT(${enable_chipoble_test})
AM_CONDITIONAL([CHIP_ENABLE_BTP_CODEC_TEST], [test "${enable_chipoble_test}" = "yes"])
AM_CONDITIONAL([CHIP_ENABLE_CHIPOBLE_TEST], [test "${enable_chipoble_test}" = "yes"])
if test "${enable_chipoble_test}" = "yes"; then
CHIP_ENABLE_BTP_CODEC_TEST=1
CHIP_ENABLE_CHIPOBLE_TEST=1
else
CHIP_ENABLE_BTP_CODEC_TEST=0
CHIP_ENABLE_CHIPOBLE_TEST=0
fi
AC_DEFINE_UNQUOTED([CHIP_ENABLE_BTP_CODEC_TEST],[${CHIP_ENABLE_BTP_CODEC_TEST}],[Define to 1 if you want to enable CHIPoBle Control Path and Throughput Test.])
AC_DEFINE_UNQUOTED([CHIP_ENABLE_CHIPOBLE_TEST],[${CHIP_ENABLE_CHIPOBLE_TEST}],[Define to 1 if you want to enable CHIPoBle Control Path and Throughput Test.])
#
# Documentation
#
Expand Down
132 changes: 66 additions & 66 deletions src/ble/BLEEndPoint.cpp

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions src/ble/BLEEndPoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
#include <system/SystemMutex.h>

#include <ble/BleLayer.h>
#include <ble/CHIPoBle.h>
#include <ble/BtpEngine.h>
#if CHIP_ENABLE_CHIPOBLE_TEST
#include <ble/CHIPoBleTest.h>
#include <ble/BtpEngineTest.h>
#endif

namespace chip {
Expand All @@ -51,15 +51,15 @@ enum
class BleLayer;
class BleEndPointPool;
#if CHIP_ENABLE_CHIPOBLE_TEST
class CHIPoBleTest;
class BtpEngineTest;
#endif

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

public:
Expand Down Expand Up @@ -91,7 +91,7 @@ class DLL_EXPORT BLEEndPoint : public BleLayerObject
typedef void (*OnCommandReceivedFunct)(BLEEndPoint * endPoint, PacketBuffer * msg);
OnCommandReceivedFunct OnCommandReceived;
inline void SetOnCommandReceivedCB(OnCommandReceivedFunct cb) { OnCommandReceived = cb; };
CHIPoBleTest mCHIPoBleTest;
BtpEngineTest mBtpEngineTest;
inline void SetTxWindowSize(uint8_t size) { mRemoteReceiveWindowSize = size; };
inline void SetRxWindowSize(uint8_t size) { mReceiveWindowMaxSize = size; };
#endif
Expand Down Expand Up @@ -136,7 +136,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 CHIPoBle transmission completes.
// Queue of outgoing messages to send when current BtpEngine transmission completes.
//
// Re-used during connection setup to cache capabilities request and response payloads; payloads are freed when
// connection is established.
Expand All @@ -146,7 +146,7 @@ class DLL_EXPORT BLEEndPoint : public BleLayerObject
// progress.
PacketBuffer * mAckToSend;

CHIPoBle mCHIPoBle;
BtpEngine mBtpEngine;
BleRole mRole;
uint8_t mConnStateFlags;
uint8_t mTimerStateFlags;
Expand Down Expand Up @@ -216,9 +216,9 @@ class DLL_EXPORT BLEEndPoint : public BleLayerObject
void FinalizeClose(uint8_t state, uint8_t flags, BLE_ERROR err);
void ReleaseBleConnection(void);
void Free(void);
void FreeCHIPoBle(void);
void FreeBtpEngine(void);

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

/**
* @namespace Ble
Expand Down
4 changes: 2 additions & 2 deletions src/ble/BleLayer.am
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ CHIP_BUILD_BLE_LAYER_SOURCE_FILES = \
@top_builddir@/src/ble/BleLayer.cpp \
@top_builddir@/src/ble/BleUUID.cpp \
@top_builddir@/src/ble/BLEEndPoint.cpp \
@top_builddir@/src/ble/CHIPoBle.cpp \
@top_builddir@/src/ble/BtpEngine.cpp \
$(NULL)

CHIP_BUILD_BLE_LAYER_HEADER_FILES = \
Expand All @@ -42,5 +42,5 @@ CHIP_BUILD_BLE_LAYER_HEADER_FILES = \
BleLayer.h \
BlePlatformDelegate.h \
BleUUID.h \
CHIPoBle.h \
BtpEngine.h \
$(NULL)
8 changes: 4 additions & 4 deletions src/ble/BleLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ typedef enum
typedef enum
{
kBleTransportProtocolVersion_None = 0,
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.
kBleTransportProtocolVersion_V1 = 1, // Prototype BTP version without ACKs or flow-control.
kBleTransportProtocolVersion_V2 = 2, // First BTP version with ACKs and flow-control.
kBleTransportProtocolVersion_V3 = 3 // First BTP version with asymetric fragement sizes.
} BleTransportProtocolVersion;

class BleLayerObject
Expand Down Expand Up @@ -231,7 +231,7 @@ class DLL_EXPORT BleLayer
{
friend class BLEEndPoint;
#if CHIP_ENABLE_CHIPOBLE_TEST
friend class CHIPoBleTest;
friend class BtpEngineTest;
#endif

public:
Expand Down
62 changes: 31 additions & 31 deletions src/ble/CHIPoBle.cpp → src/ble/BtpEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@

/**
* @file
* This file implements types and an object for the chip over
* Bluetooth Low Energy (CHIPoBLE) byte-stream, connection-oriented
* adaptation of chip for point-to-point Bluetooth Low Energy
* (BLE) links.
* This module implements encode, decode, fragmentation and reassembly of
* Bluetooth Transport Layer (BTP) packet types for transport of a
* CHIP-over-Bluetooth Low Energy (CHIPoBLE) byte-stream over point-to-point
* Bluetooth Low Energy (BLE) links.
*
*/

#include <ble/BleConfig.h>

#if CONFIG_NETWORK_LAYER_BLE

#include <ble/CHIPoBle.h>
#include <ble/BtpEngine.h>
#if CHIP_ENABLE_CHIPOBLE_TEST
#include <ble/CHIPoBleTest.h>
#include <ble/BtpEngineTest.h>
#endif

#include <support/logging/CHIPLogging.h>
Expand Down Expand Up @@ -73,8 +73,8 @@ static inline void IncSeqNum(SequenceNumber_t & a_seq_num)

static inline bool DidReceiveData(uint8_t rx_flags)
{
return (GetFlag(rx_flags, CHIPoBle::kHeaderFlag_StartMessage) || GetFlag(rx_flags, CHIPoBle::kHeaderFlag_ContinueMessage) ||
GetFlag(rx_flags, CHIPoBle::kHeaderFlag_EndMessage));
return (GetFlag(rx_flags, BtpEngine::kHeaderFlag_StartMessage) || GetFlag(rx_flags, BtpEngine::kHeaderFlag_ContinueMessage) ||
GetFlag(rx_flags, BtpEngine::kHeaderFlag_EndMessage));
}

static void PrintBufDebug(PacketBuffer * buf)
Expand All @@ -89,10 +89,10 @@ static void PrintBufDebug(PacketBuffer * buf)
#endif
}

const uint16_t CHIPoBle::sDefaultFragmentSize = 20; // 23-byte minimum ATT_MTU - 3 bytes for ATT operation header
const uint16_t CHIPoBle::sMaxFragmentSize = 128; // Size of write and indication characteristics
const uint16_t BtpEngine::sDefaultFragmentSize = 20; // 23-byte minimum ATT_MTU - 3 bytes for ATT operation header
const uint16_t BtpEngine::sMaxFragmentSize = 128; // Size of write and indication characteristics

BLE_ERROR CHIPoBle::Init(void * an_app_state, bool expect_first_ack)
BLE_ERROR BtpEngine::Init(void * an_app_state, bool expect_first_ack)
{
mAppState = an_app_state;
mRxState = kState_Idle;
Expand All @@ -110,8 +110,8 @@ BLE_ERROR CHIPoBle::Init(void * an_app_state, bool expect_first_ack)
mTxNewestUnackedSeqNum = 0;
mTxOldestUnackedSeqNum = 0;
#if CHIP_ENABLE_CHIPOBLE_TEST
mTxPacketType = kType_Data; // Default CHIPoBle Data packet
mRxPacketType = kType_Data; // Default CHIPoBle Data packet
mTxPacketType = kType_Data; // Default BtpEngine Data packet
mRxPacketType = kType_Data; // Default BtpEngine Data packet
#endif

if (expect_first_ack)
Expand All @@ -130,7 +130,7 @@ BLE_ERROR CHIPoBle::Init(void * an_app_state, bool expect_first_ack)
return BLE_NO_ERROR;
}

SequenceNumber_t CHIPoBle::GetAndIncrementNextTxSeqNum()
SequenceNumber_t BtpEngine::GetAndIncrementNextTxSeqNum()
{
SequenceNumber_t ret = mTxNextSeqNum;

Expand All @@ -150,7 +150,7 @@ SequenceNumber_t CHIPoBle::GetAndIncrementNextTxSeqNum()
return ret;
}

SequenceNumber_t CHIPoBle::GetAndRecordRxAckSeqNum()
SequenceNumber_t BtpEngine::GetAndRecordRxAckSeqNum()
{
SequenceNumber_t ret = mRxNewestUnackedSeqNum;

Expand All @@ -160,12 +160,12 @@ SequenceNumber_t CHIPoBle::GetAndRecordRxAckSeqNum()
return ret;
}

bool CHIPoBle::HasUnackedData() const
bool BtpEngine::HasUnackedData() const
{
return (mRxOldestUnackedSeqNum != mRxNextSeqNum);
}

bool CHIPoBle::IsValidAck(SequenceNumber_t ack_num) const
bool BtpEngine::IsValidAck(SequenceNumber_t ack_num) const
{
ChipLogDebugBtpEngine(Ble, "entered IsValidAck, ack = %u, oldest = %u, newest = %u", ack_num, mTxOldestUnackedSeqNum,
mTxNewestUnackedSeqNum);
Expand All @@ -189,7 +189,7 @@ bool CHIPoBle::IsValidAck(SequenceNumber_t ack_num) const
}
}

BLE_ERROR CHIPoBle::HandleAckReceived(SequenceNumber_t ack_num)
BLE_ERROR BtpEngine::HandleAckReceived(SequenceNumber_t ack_num)
{
BLE_ERROR err = BLE_NO_ERROR;

Expand Down Expand Up @@ -218,7 +218,7 @@ BLE_ERROR CHIPoBle::HandleAckReceived(SequenceNumber_t ack_num)

// Calling convention:
// EncodeStandAloneAck may only be called if data arg is commited for immediate, synchronous subsequent transmission.
BLE_ERROR CHIPoBle::EncodeStandAloneAck(PacketBuffer * data)
BLE_ERROR BtpEngine::EncodeStandAloneAck(PacketBuffer * data)
{
BLE_ERROR err = BLE_NO_ERROR;
uint8_t * characteristic;
Expand Down Expand Up @@ -248,9 +248,9 @@ BLE_ERROR CHIPoBle::EncodeStandAloneAck(PacketBuffer * data)
}

// Calling convention:
// CHIPoBle does not retain ownership of reassembled messages, layer above needs to free when done.
// BtpEngine does not retain ownership of reassembled messages, layer above needs to free when done.
//
// CHIPoBle does not reset itself on error. Upper layer should free outbound message and inbound reassembly buffers
// BtpEngine does not reset itself on error. Upper layer should free outbound message and inbound reassembly buffers
// if there is a problem.

// HandleCharacteristicReceived():
Expand All @@ -260,7 +260,7 @@ BLE_ERROR CHIPoBle::EncodeStandAloneAck(PacketBuffer * data)
// function returns.
//
// Upper layer must immediately clean up and reinitialize protocol engine if returned err != BLE_NO_ERROR.
BLE_ERROR CHIPoBle::HandleCharacteristicReceived(PacketBuffer * data, SequenceNumber_t & receivedAck, bool & didReceiveAck)
BLE_ERROR BtpEngine::HandleCharacteristicReceived(PacketBuffer * data, SequenceNumber_t & receivedAck, bool & didReceiveAck)
{
BLE_ERROR err = BLE_NO_ERROR;
uint8_t rx_flags = 0;
Expand Down Expand Up @@ -353,8 +353,8 @@ BLE_ERROR CHIPoBle::HandleCharacteristicReceived(PacketBuffer * data, SequenceNu
mRxBuf->CompactHead(); // will free 'data' and adjust rx buf's end/length
data = NULL;

// For now, limit CHIPoBle message size to max length of 1 pbuf, as we do for chip messages sent via IP.
// TODO add support for CHIPoBle messages longer than 1 pbuf
// For now, limit BtpEngine message size to max length of 1 pbuf, as we do for chip messages sent via IP.
// TODO add support for BtpEngine messages longer than 1 pbuf
VerifyOrExit(mRxBuf->Next() == NULL, err = BLE_ERROR_RECEIVED_MESSAGE_TOO_BIG);
}
else
Expand Down Expand Up @@ -415,12 +415,12 @@ BLE_ERROR CHIPoBle::HandleCharacteristicReceived(PacketBuffer * data, SequenceNu
return err;
}

PacketBuffer * CHIPoBle::RxPacket()
PacketBuffer * BtpEngine::RxPacket()
{
return mRxBuf;
}

bool CHIPoBle::ClearRxPacket()
bool BtpEngine::ClearRxPacket()
{
if (mRxState == kState_Complete)
{
Expand All @@ -436,7 +436,7 @@ bool CHIPoBle::ClearRxPacket()
// Calling convention:
// May only be called if data arg is commited for immediate, synchronous subsequent transmission.
// Returns false on error. Caller must free data arg on error.
bool CHIPoBle::HandleCharacteristicSend(PacketBuffer * data, bool send_ack)
bool BtpEngine::HandleCharacteristicSend(PacketBuffer * data, bool send_ack)
{
uint8_t * characteristic;
mTxCharCount++;
Expand Down Expand Up @@ -577,12 +577,12 @@ bool CHIPoBle::HandleCharacteristicSend(PacketBuffer * data, bool send_ack)
return true;
}

PacketBuffer * CHIPoBle::TxPacket()
PacketBuffer * BtpEngine::TxPacket()
{
return mTxBuf;
}

bool CHIPoBle::ClearTxPacket()
bool BtpEngine::ClearTxPacket()
{
if (mTxState == kState_Complete)
{
Expand All @@ -595,7 +595,7 @@ bool CHIPoBle::ClearTxPacket()
return false;
}

void CHIPoBle::LogState() const
void BtpEngine::LogState() const
{
ChipLogError(Ble, "mAppState: %p", mAppState);

Expand All @@ -618,7 +618,7 @@ void CHIPoBle::LogState() const
ChipLogError(Ble, "mTxPacketCount: %d", mTxPacketCount);
}

void CHIPoBle::LogStateDebug() const
void BtpEngine::LogStateDebug() const
{
#ifdef CHIP_BTP_PROTOCOL_ENGINE_DEBUG_LOGGING_ENABLED
LogState();
Expand Down
16 changes: 8 additions & 8 deletions src/ble/CHIPoBle.h → src/ble/BtpEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
*
*/

#ifndef CHIPOBLE_H_
#define CHIPOBLE_H_
#ifndef BTP_ENGINE_H_
#define BTP_ENGINE_H_

#ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS
Expand All @@ -46,7 +46,7 @@ namespace Ble {

using ::chip::System::PacketBuffer;

typedef uint8_t SequenceNumber_t; // If type changed from uint8_t, adjust assumptions in CHIPoBle::IsValidAck and
typedef uint8_t SequenceNumber_t; // If type changed from uint8_t, adjust assumptions in BtpEngine::IsValidAck and
// BLEEndPoint::AdjustReceiveWindow.

#if CHIP_ENABLE_CHIPOBLE_TEST
Expand All @@ -58,9 +58,9 @@ typedef enum
{
kType_Data = 0, // Default 0 for data
kType_Control = 1,
} PacketType_t; // CHIPoBle packet types
} PacketType_t; // BTP packet types

class CHIPoBle
class BtpEngine
{
#if CHIP_ENABLE_CHIPOBLE_TEST
friend class BLEEndPoint;
Expand Down Expand Up @@ -92,8 +92,8 @@ class CHIPoBle

public:
// Public functions:
CHIPoBle(void){};
~CHIPoBle(void){};
BtpEngine(void){};
~BtpEngine(void){};

BLE_ERROR Init(void * an_app_state, bool expect_first_ack);

Expand Down Expand Up @@ -192,4 +192,4 @@ class CHIPoBle
} /* namespace Ble */
} /* namespace chip */

#endif /* CHIPOBLE_H_ */
#endif /* BTP_ENGINE_H_ */

0 comments on commit 7a8a93f

Please sign in to comment.