Skip to content

Commit

Permalink
Remove BLE from CASEServer and CommissioneeDeviceProxy
Browse files Browse the repository at this point in the history
It's not used at all in CommissioneeDeviceProxy. See issue #16766
for CASEServer.
  • Loading branch information
cecille committed Apr 4, 2022
1 parent 5f84379 commit 7dce782
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 64 deletions.
6 changes: 1 addition & 5 deletions src/app/server/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,7 @@ CHIP_ERROR Server::Init(const ServerInitParams & initParams)
err = mCASESessionManager.Init(&DeviceLayer::SystemLayer(), caseSessionManagerConfig);
SuccessOrExit(err);

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

// This code is necessary to restart listening to existing groups after a reboot
Expand Down
10 changes: 10 additions & 0 deletions src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,16 @@ CommissioneeDeviceProxy * DeviceCommissioner::FindCommissioneeDevice(const Trans

void DeviceCommissioner::ReleaseCommissioneeDevice(CommissioneeDeviceProxy * device)
{
// TODO: Call CloseSession here see #16440 and #16805 (blocking)

#if CONFIG_NETWORK_LAYER_BLE
if (mSystemState->BleLayer() != nullptr && device->GetDeviceTransportType() == Transport::Type::kBle)
{
// We only support one BLE connection, so if this is BLE, close it
ChipLogProgress(Discovery, "Closing all BLE connections");
mSystemState->BleLayer()->CloseAllBleConnections();
}
#endif
mCommissioneeDevicePool.ReleaseObject(device);
// Make sure that there will be no dangling pointer
if (mDeviceInPASEEstablishment == device)
Expand Down
7 changes: 2 additions & 5 deletions src/controller/CHIPDeviceControllerFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,8 @@ CHIP_ERROR DeviceControllerFactory::InitSystemState(FactoryInitParams params)
// 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,
#if CONFIG_NETWORK_LAYER_BLE
nullptr,
#endif
stateParams.sessionMgr, stateParams.fabricTable, stateParams.groupDataProvider));
stateParams.exchangeMgr, stateParams.transportMgr, stateParams.sessionMgr, stateParams.fabricTable,
stateParams.groupDataProvider));

//
// We need to advertise the port that we're listening to for unsolicited messages over UDP. However, we have both a IPv4
Expand Down
5 changes: 1 addition & 4 deletions src/controller/CommissioneeDeviceProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,7 @@ void CommissioneeDeviceProxy::Reset()
mState = ConnectionState::NotConnected;
mSessionManager = nullptr;
mUDPEndPointManager = nullptr;
#if CONFIG_NETWORK_LAYER_BLE
mBleLayer = nullptr;
#endif
mExchangeMgr = nullptr;
mExchangeMgr = nullptr;
}

CHIP_ERROR CommissioneeDeviceProxy::LoadSecureSessionParameters()
Expand Down
17 changes: 1 addition & 16 deletions src/controller/CommissioneeDeviceProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@
#include <transport/raw/MessageHeader.h>
#include <transport/raw/UDP.h>

#if CONFIG_NETWORK_LAYER_BLE
#include <ble/BleLayer.h>
#include <transport/raw/BLE.h>
#endif

namespace chip {

constexpr size_t kAttestationNonceLength = 32;
Expand All @@ -68,10 +63,7 @@ struct ControllerDeviceInitParams
Messaging::ExchangeManager * exchangeMgr = nullptr;
Inet::EndPointManager<Inet::UDPEndPoint> * udpEndPointManager = nullptr;
PersistentStorageDelegate * storageDelegate = nullptr;
#if CONFIG_NETWORK_LAYER_BLE
Ble::BleLayer * bleLayer = nullptr;
#endif
FabricTable * fabricsTable = nullptr;
FabricTable * fabricsTable = nullptr;
};

class CommissioneeDeviceProxy : public DeviceProxy, public SessionReleaseDelegate
Expand Down Expand Up @@ -118,9 +110,6 @@ class CommissioneeDeviceProxy : public DeviceProxy, public SessionReleaseDelegat
mExchangeMgr = params.exchangeMgr;
mUDPEndPointManager = params.udpEndPointManager;
mFabricIndex = fabric;
#if CONFIG_NETWORK_LAYER_BLE
mBleLayer = params.bleLayer;
#endif
}

/**
Expand Down Expand Up @@ -252,10 +241,6 @@ class CommissioneeDeviceProxy : public DeviceProxy, public SessionReleaseDelegat
bool mActive = false;
ConnectionState mState = ConnectionState::NotConnected;

#if CONFIG_NETWORK_LAYER_BLE
Ble::BleLayer * mBleLayer = nullptr;
#endif

PASESession mPairing;

SessionManager * mSessionManager = nullptr;
Expand Down
22 changes: 0 additions & 22 deletions src/protocols/secure_channel/CASEServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ using namespace ::chip::Credentials;
namespace chip {

CHIP_ERROR CASEServer::ListenForSessionEstablishment(Messaging::ExchangeManager * exchangeManager, TransportMgrBase * transportMgr,
#if CONFIG_NETWORK_LAYER_BLE
Ble::BleLayer * bleLayer,
#endif
SessionManager * sessionManager, FabricTable * fabrics,
Credentials::GroupDataProvider * responderGroupDataProvider)
{
Expand All @@ -42,9 +39,6 @@ CHIP_ERROR CASEServer::ListenForSessionEstablishment(Messaging::ExchangeManager
VerifyOrReturnError(sessionManager != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
VerifyOrReturnError(responderGroupDataProvider != nullptr, CHIP_ERROR_INVALID_ARGUMENT);

#if CONFIG_NETWORK_LAYER_BLE
mBleLayer = bleLayer;
#endif
mSessionManager = sessionManager;
mFabrics = fabrics;
mExchangeManager = exchangeManager;
Expand All @@ -58,22 +52,6 @@ CHIP_ERROR CASEServer::InitCASEHandshake(Messaging::ExchangeContext * ec)
{
ReturnErrorCodeIf(ec == nullptr, CHIP_ERROR_INVALID_ARGUMENT);

// Mark any PASE sessions used for commissioning as stale.
// This is a workaround, as we currently don't have a way to identify
// secure sessions established via PASE protocol.
// TODO - Identify which PASE base secure channel was used
// for commissioning and drop it once commissioning is complete.
mSessionManager->ExpireAllPairings(kUndefinedNodeId, kUndefinedFabricIndex);

#if CONFIG_NETWORK_LAYER_BLE
// Close all BLE connections now since a CASE handshake has been initiated.
if (mBleLayer != nullptr)
{
ChipLogProgress(Discovery, "CASE handshake initiated, closing all BLE Connections");
mBleLayer->CloseAllBleConnections();
}
#endif

// Setup CASE state machine using the credentials for the current fabric.
GetSession().SetGroupDataProvider(mGroupDataProvider);
ReturnErrorOnFailure(GetSession().ListenForSessionEstablishment(
Expand Down
9 changes: 0 additions & 9 deletions src/protocols/secure_channel/CASEServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@

#pragma once

#if CONFIG_NETWORK_LAYER_BLE
#include <ble/BleLayer.h>
#endif
#include <credentials/GroupDataProvider.h>
#include <messaging/ExchangeDelegate.h>
#include <messaging/ExchangeMgr.h>
Expand All @@ -40,9 +37,6 @@ class CASEServer : public SessionEstablishmentDelegate, public Messaging::Exchan
}

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

Expand All @@ -63,9 +57,6 @@ class CASEServer : public SessionEstablishmentDelegate, public Messaging::Exchan

CASESession mPairingSession;
SessionManager * mSessionManager = nullptr;
#if CONFIG_NETWORK_LAYER_BLE
Ble::BleLayer * mBleLayer = nullptr;
#endif

FabricTable * mFabrics = nullptr;
Credentials::GroupDataProvider * mGroupDataProvider = nullptr;
Expand Down
3 changes: 0 additions & 3 deletions src/protocols/secure_channel/tests/TestCASESession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,6 @@ void CASE_SecurePairingHandshakeServerTest(nlTestSuite * inSuite, void * inConte

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

Expand Down

0 comments on commit 7dce782

Please sign in to comment.