Skip to content

Commit

Permalink
Wrap usages of src/ble/... with CONFIG_NETWORK_LAYER_BLE (#16414)
Browse files Browse the repository at this point in the history
* Wrap usages of src/ble/BleLayer with CONFIG_NETWORK_LAYER_BLE

* Restyle Server.cpp

* Restyle CHIPDeviceControllerFactory

* Restyle CASEServer.cpp

* Update Server.cpp

* Restyle change

* Restyle change

* Restyle

* Restyle

* Restyle

* Remove whitespace
  • Loading branch information
wendythewan authored and pull[bot] committed Oct 14, 2023
1 parent 10d9b46 commit 1031536
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 10 deletions.
9 changes: 8 additions & 1 deletion src/app/server/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
#include <app/server/EchoHandler.h>
#include <app/util/DataModelHandler.h>

#if CONFIG_NETWORK_LAYER_BLE
#include <ble/BLEEndPoint.h>
#endif
#include <inet/IPAddress.h>
#include <inet/InetError.h>
#include <lib/core/CHIPPersistentStorageDelegate.h>
Expand All @@ -51,7 +53,9 @@ using chip::kMinValidFabricIndex;
using chip::RendezvousInformationFlag;
using chip::DeviceLayer::PersistedStorage::KeyValueStoreMgr;
using chip::Inet::IPAddressType;
#if CONFIG_NETWORK_LAYER_BLE
using chip::Transport::BleListenParameters;
#endif
using chip::Transport::PeerAddress;
using chip::Transport::UdpListenParameters;

Expand Down Expand Up @@ -239,7 +243,10 @@ CHIP_ERROR Server::Init(AppDelegate * delegate, uint16_t secureServicePort, uint
app::DnssdServer::Instance().StartServer();
#endif

err = mCASEServer.ListenForSessionEstablishment(&mExchangeMgr, &mTransports, chip::DeviceLayer::ConnectivityMgr().GetBleLayer(),
err = mCASEServer.ListenForSessionEstablishment(&mExchangeMgr, &mTransports,
#if CONFIG_NETWORK_LAYER_BLE
chip::DeviceLayer::ConnectivityMgr().GetBleLayer(),
#endif
&mSessions, &mFabrics);
SuccessOrExit(err);

Expand Down
8 changes: 6 additions & 2 deletions src/controller/CHIPDeviceControllerFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,12 @@ CHIP_ERROR DeviceControllerFactory::InitSystemState(FactoryInitParams params)
// We pass in a nullptr for the BLELayer since we're not permitting usage of BLE in this server modality for the controller,
// especially since it will interrupt other potential usages of BLE by the controller acting in a commissioning capacity.
//
ReturnErrorOnFailure(stateParams.caseServer->ListenForSessionEstablishment(
stateParams.exchangeMgr, stateParams.transportMgr, nullptr, stateParams.sessionMgr, stateParams.fabricTable));
ReturnErrorOnFailure(
stateParams.caseServer->ListenForSessionEstablishment(stateParams.exchangeMgr, stateParams.transportMgr,
#if CONFIG_NETWORK_LAYER_BLE
nullptr,
#endif
stateParams.sessionMgr, stateParams.fabricTable));

//
// We need to advertise the port that we're listening to for unsolicited messages over UDP. However, we have both a IPv4
Expand Down
1 change: 0 additions & 1 deletion src/include/platform/CHIPDeviceLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

#if !CHIP_DEVICE_LAYER_NONE

#include <ble/BleLayer.h>
#include <lib/core/CHIPCore.h>
#include <platform/CHIPDeviceError.h>
#include <platform/ConfigurationManager.h>
Expand Down
2 changes: 2 additions & 0 deletions src/include/platform/internal/BLEManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ inline CHIP_ERROR BLEManager::Init()

inline CHIP_ERROR BLEManager::Shutdown()
{
#if CONFIG_NETWORK_LAYER_BLE
ReturnErrorOnFailure(GetBleLayer()->Shutdown());
#endif
return static_cast<ImplClass *>(this)->_Shutdown();
}

Expand Down
10 changes: 7 additions & 3 deletions src/protocols/secure_channel/CASEServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,19 @@ using namespace ::chip::Credentials;
namespace chip {

CHIP_ERROR CASEServer::ListenForSessionEstablishment(Messaging::ExchangeManager * exchangeManager, TransportMgrBase * transportMgr,
Ble::BleLayer * bleLayer, SessionManager * sessionManager,
FabricTable * fabrics)
#if CONFIG_NETWORK_LAYER_BLE
Ble::BleLayer * bleLayer,
#endif
SessionManager * sessionManager, FabricTable * fabrics)
{
VerifyOrReturnError(transportMgr != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
VerifyOrReturnError(exchangeManager != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
VerifyOrReturnError(sessionManager != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
VerifyOrReturnError(fabrics != nullptr, CHIP_ERROR_INVALID_ARGUMENT);

mBleLayer = bleLayer;
#if CONFIG_NETWORK_LAYER_BLE
mBleLayer = bleLayer;
#endif
mSessionManager = sessionManager;
mFabrics = fabrics;
mExchangeManager = exchangeManager;
Expand Down
11 changes: 9 additions & 2 deletions src/protocols/secure_channel/CASEServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@

#pragma once

#if CONFIG_NETWORK_LAYER_BLE
#include <ble/BleLayer.h>
#endif
#include <messaging/ExchangeDelegate.h>
#include <messaging/ExchangeMgr.h>
#include <protocols/secure_channel/CASESession.h>
Expand All @@ -38,7 +40,10 @@ class CASEServer : public SessionEstablishmentDelegate, public Messaging::Exchan
}

CHIP_ERROR ListenForSessionEstablishment(Messaging::ExchangeManager * exchangeManager, TransportMgrBase * transportMgr,
Ble::BleLayer * bleLayer, SessionManager * sessionManager, FabricTable * fabrics);
#if CONFIG_NETWORK_LAYER_BLE
Ble::BleLayer * bleLayer,
#endif
SessionManager * sessionManager, FabricTable * fabrics);

//////////// SessionEstablishmentDelegate Implementation ///////////////
void OnSessionEstablishmentError(CHIP_ERROR error) override;
Expand All @@ -58,7 +63,9 @@ class CASEServer : public SessionEstablishmentDelegate, public Messaging::Exchan
CASESession mPairingSession;
uint16_t mSessionKeyId = 0;
SessionManager * mSessionManager = nullptr;
Ble::BleLayer * mBleLayer = nullptr;
#if CONFIG_NETWORK_LAYER_BLE
Ble::BleLayer * mBleLayer = nullptr;
#endif

FabricTable * mFabrics = nullptr;
SessionIDAllocator mSessionIDAllocator;
Expand Down
5 changes: 4 additions & 1 deletion src/protocols/secure_channel/tests/TestCASESession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,10 @@ void CASE_SecurePairingHandshakeServerTest(nlTestSuite * inSuite, void * inConte
gLoopback.mSentMessageCount = 0;

NL_TEST_ASSERT(inSuite,
gPairingServer.ListenForSessionEstablishment(&ctx.GetExchangeManager(), &ctx.GetTransportMgr(), nullptr,
gPairingServer.ListenForSessionEstablishment(&ctx.GetExchangeManager(), &ctx.GetTransportMgr(),
#if CONFIG_NETWORK_LAYER_BLE
nullptr,
#endif
&ctx.GetSecureSessionManager(), &gDeviceFabrics) == CHIP_NO_ERROR);

ExchangeContext * contextCommissioner = ctx.NewUnauthenticatedExchangeToBob(pairingCommissioner);
Expand Down

0 comments on commit 1031536

Please sign in to comment.