Skip to content

Commit

Permalink
More compilation fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
arkq committed May 8, 2024
1 parent 5a0bc36 commit 55d7dcc
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions src/ble/tests/TestBleLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <cstdint>
#include <memory>
#include <numeric>
#include <type_traits>

#include <gtest/gtest.h>

Expand Down Expand Up @@ -47,12 +48,6 @@ constexpr ChipBleUUID uuidChar2 = { { 0x18, 0xEE, 0x2E, 0xF5, 0x26, 0x3D, 0x45,
constexpr ChipBleUUID uuidChar3 = { { 0x64, 0x63, 0x02, 0x38, 0x87, 0x72, 0x45, 0xF2, 0xB8, 0x7D, 0x74, 0x8A, 0x83, 0x21, 0x8F,
0x04 } };

BLE_CONNECTION_OBJECT GetConnectionObject()
{
static auto connObj = reinterpret_cast<BLE_CONNECTION_OBJECT>(0x1234);
return ++connObj;
}

}; // namespace

class TestBleLayer : public BleLayer,
Expand Down Expand Up @@ -86,6 +81,25 @@ class TestBleLayer : public BleLayer,
Shutdown();
}

// Return unique BLE connection object for each call.
template <typename T = BLE_CONNECTION_OBJECT>
BLE_CONNECTION_OBJECT GetConnectionObject()
{
T conn = BLE_CONNECTION_UNINITIALIZED;

if constexpr (std::is_pointer_v<T>)
{
conn = reinterpret_cast<T>(&mNumConnection + mNumConnection);
}
else
{
conn = static_cast<T>(mNumConnection);
}

mNumConnection++;
return conn;
}

// Passing capabilities request message to HandleWriteReceived should create
// new BLE endpoint which later can be used to receive more data.
bool HandleWriteReceivedCapabilitiesRequest(BLE_CONNECTION_OBJECT connObj)
Expand Down Expand Up @@ -144,6 +158,9 @@ class TestBleLayer : public BleLayer,
{
return true;
}

private:
unsigned int mNumConnection = 0;
};

TEST_F(TestBleLayer, CheckBleTransportCapabilitiesRequestMessage)
Expand Down

0 comments on commit 55d7dcc

Please sign in to comment.