Skip to content

Commit

Permalink
Ensure the stack is using a single ExchangeManager
Browse files Browse the repository at this point in the history
  • Loading branch information
vivien-apple committed Apr 30, 2021
1 parent 6df63b4 commit 91fd43a
Show file tree
Hide file tree
Showing 33 changed files with 69 additions and 167 deletions.
1 change: 1 addition & 0 deletions examples/all-clusters-app/all-clusters-common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ chip_data_model("all-clusters-common") {
zap_file = "all-clusters-app.zap"

zap_pregenerated_dir = "gen"
is_server = true
}
1 change: 1 addition & 0 deletions examples/bridge-app/bridge-common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ chip_data_model("bridge-common") {
zap_file = "bridge-app.zap"

zap_pregenerated_dir = "gen"
is_server = true
}
1 change: 0 additions & 1 deletion examples/chip-tool/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ executable("chip-tool") {

deps = [
":data_model",
"${chip_root}/src/app/server",
"${chip_root}/src/lib",
"${chip_root}/src/platform",
"${chip_root}/third_party/inipp",
Expand Down
1 change: 0 additions & 1 deletion examples/chip-tool/commands/common/Command.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

#pragma once

#include <app/server/DataModelHandler.h>
#include <controller/CHIPDeviceController.h>
#include <inet/InetInterface.h>
#include <support/logging/CHIPLogging.h>
Expand Down
13 changes: 0 additions & 13 deletions examples/chip-tool/commands/reporting/ReportingCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ CHIP_ERROR ReportingCommand::Run(PersistentStorage & storage, NodeId localId, No
err = mCommissioner.GetDevice(remoteId, &mDevice);
VerifyOrExit(err == CHIP_NO_ERROR, ChipLogError(chipTool, "Init failure! No pairing for device: %" PRIu64, localId));

mDevice->SetDelegate(this);

AddReportCallbacks(mEndPointId);

cluster.Associate(mDevice, mEndPointId);
Expand All @@ -64,14 +62,3 @@ CHIP_ERROR ReportingCommand::Run(PersistentStorage & storage, NodeId localId, No
mCommissioner.Shutdown();
return err;
}

void ReportingCommand::OnMessage(PacketBufferHandle buffer)
{
ChipLogDetail(chipTool, "%" PRIu64 ": Received %zu bytes", mDevice->GetDeviceId(), buffer->DataLength());
HandleDataModelMessage(mDevice->GetDeviceId(), std::move(buffer));
}

void ReportingCommand::OnStatusChange(void)
{
ChipLogDetail(chipTool, "DeviceStatusDelegate::OnStatusChange");
}
6 changes: 1 addition & 5 deletions examples/chip-tool/commands/reporting/ReportingCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#define CHIP_ZCL_ENDPOINT_MIN 0x00
#define CHIP_ZCL_ENDPOINT_MAX 0xF0

class ReportingCommand : public Command, public chip::Controller::DeviceStatusDelegate
class ReportingCommand : public Command
{
public:
ReportingCommand(const char * commandName) : Command(commandName)
Expand All @@ -36,10 +36,6 @@ class ReportingCommand : public Command, public chip::Controller::DeviceStatusDe
/////////// Command Interface /////////
CHIP_ERROR Run(PersistentStorage & storage, NodeId localId, NodeId remoteId) override;

/////////// DeviceStatusDelegate Interface /////////
void OnMessage(PacketBufferHandle buffer) override;
void OnStatusChange(void) override;

virtual void AddReportCallbacks(uint8_t endPointId) = 0;

private:
Expand Down
2 changes: 0 additions & 2 deletions examples/chip-tool/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
// ================================================================================
int main(int argc, char * argv[])
{
InitDataModelHandler();

Commands commands;
registerCommandsDiscover(commands);
registerCommandsPayload(commands);
Expand Down
1 change: 0 additions & 1 deletion examples/lighting-app/efr32/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include "gen/cluster-id.h"
#include "lcd.h"
#include "qrcodegen.h"
#include <app/server/DataModelHandler.h>
#include <app/server/OnboardingCodesUtil.h>
#include <app/server/Server.h>
#include <app/util/attribute-storage.h>
Expand Down
1 change: 0 additions & 1 deletion examples/lighting-app/efr32/src/ZclCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

#include "AppConfig.h"
#include "LightingManager.h"
#include <app/server/DataModelHandler.h>

#include "gen/attribute-id.h"
#include "gen/cluster-id.h"
Expand Down
1 change: 0 additions & 1 deletion examples/lighting-app/efr32/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@

#include "AppConfig.h"
#include "init_efrPlatform.h"
#include <app/server/DataModelHandler.h>
#include <app/server/Server.h>

#ifdef HEAP_MONITORING
Expand Down
1 change: 1 addition & 0 deletions examples/lighting-app/lighting-common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ chip_data_model("lighting-common") {
zap_file = "lighting-app.zap"

zap_pregenerated_dir = "gen"
is_server = true
}
8 changes: 8 additions & 0 deletions examples/lighting-app/nrfconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
cmake_minimum_required(VERSION 3.13.1)

get_filename_component(CHIP_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/third_party/connectedhomeip REALPATH)
get_filename_component(NLIO_ROOT ${CHIP_ROOT}/third_party/nlio/repo/include REALPATH)
get_filename_component(NRFCONNECT_COMMON ${CHIP_ROOT}/examples/platform/nrfconnect REALPATH)
get_filename_component(LIGHTING_COMMON ${CHIP_ROOT}/examples/lighting-app/lighting-common REALPATH)

Expand All @@ -38,6 +39,7 @@ target_compile_options(app PRIVATE -Werror)
target_include_directories(app PRIVATE
main/include
${LIGHTING_COMMON}
${NLIO_ROOT}
${NRFCONNECT_COMMON}/util/include
${NRFCONNECT_COMMON}/app/include)

Expand Down Expand Up @@ -68,6 +70,12 @@ target_sources(app PRIVATE
${CHIP_ROOT}/src/app/util/process-cluster-message.cpp
${CHIP_ROOT}/src/app/util/process-global-message.cpp
${CHIP_ROOT}/src/app/util/util.cpp
${CHIP_ROOT}/src/app/server/EchoHandler.cpp
${CHIP_ROOT}/src/app/server/Mdns.cpp
${CHIP_ROOT}/src/app/server/OnboardingCodesUtil.cpp
${CHIP_ROOT}/src/app/server/RendezvousServer.cpp
${CHIP_ROOT}/src/app/server/Server.cpp
${CHIP_ROOT}/src/app/server/StorablePeerConnection.cpp
${CHIP_ROOT}/src/app/clusters/basic/basic.cpp
${CHIP_ROOT}/src/app/clusters/bindings/bindings.cpp
${CHIP_ROOT}/src/app/clusters/general-commissioning-server/general-commissioning-server.cpp
Expand Down
1 change: 0 additions & 1 deletion examples/lock-app/efr32/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include "gen/cluster-id.h"
#include "lcd.h"
#include "qrcodegen.h"
#include <app/server/DataModelHandler.h>
#include <app/server/OnboardingCodesUtil.h>
#include <app/server/Server.h>
#include <app/util/attribute-storage.h>
Expand Down
1 change: 0 additions & 1 deletion examples/lock-app/efr32/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@

#include "AppConfig.h"
#include "init_efrPlatform.h"
#include <app/server/DataModelHandler.h>
#include <app/server/Server.h>

#if DISPLAY_ENABLED
Expand Down
1 change: 1 addition & 0 deletions examples/lock-app/lock-common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ chip_data_model("lock-common") {
zap_file = "lock-app.zap"

zap_pregenerated_dir = "gen"
is_server = true
}
8 changes: 8 additions & 0 deletions examples/lock-app/nrfconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
cmake_minimum_required(VERSION 3.13.1)

get_filename_component(CHIP_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/third_party/connectedhomeip REALPATH)
get_filename_component(NLIO_ROOT ${CHIP_ROOT}/third_party/nlio/repo/include REALPATH)
get_filename_component(NRFCONNECT_COMMON ${CHIP_ROOT}/examples/platform/nrfconnect REALPATH)
get_filename_component(LOCK_COMMON ${CHIP_ROOT}/examples/lock-app/lock-common REALPATH)

Expand All @@ -38,6 +39,7 @@ project(chip-nrfconnect-lock-example)
target_include_directories(app PRIVATE
main/include
${LOCK_COMMON}
${NLIO_ROOT}
${NRFCONNECT_COMMON}/util/include
${NRFCONNECT_COMMON}/app/include)

Expand Down Expand Up @@ -68,6 +70,12 @@ target_sources(app PRIVATE
${CHIP_ROOT}/src/app/util/process-cluster-message.cpp
${CHIP_ROOT}/src/app/util/process-global-message.cpp
${CHIP_ROOT}/src/app/util/util.cpp
${CHIP_ROOT}/src/app/server/EchoHandler.cpp
${CHIP_ROOT}/src/app/server/Mdns.cpp
${CHIP_ROOT}/src/app/server/OnboardingCodesUtil.cpp
${CHIP_ROOT}/src/app/server/RendezvousServer.cpp
${CHIP_ROOT}/src/app/server/Server.cpp
${CHIP_ROOT}/src/app/server/StorablePeerConnection.cpp
${CHIP_ROOT}/src/app/clusters/basic/basic.cpp
${CHIP_ROOT}/src/app/clusters/bindings/bindings.cpp
${CHIP_ROOT}/src/app/clusters/general-commissioning-server/general-commissioning-server.cpp
Expand Down
5 changes: 4 additions & 1 deletion examples/platform/linux/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ source_set("app-main") {
defines = [ "PW_RPC_ENABLED" ]
}

public_deps = [ "${chip_root}/src/lib" ]
public_deps = [
"${chip_root}/src/app/server",
"${chip_root}/src/lib",
]

public_configs = [ ":app-main-config" ]
}
1 change: 1 addition & 0 deletions examples/window-app/common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ chip_data_model("window-common") {
zap_file = "window-app.zap"

zap_pregenerated_dir = "gen"
is_server = true
}
1 change: 0 additions & 1 deletion examples/window-app/efr32/src/ZclCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <AppConfig.h>
#include <AppTask.h>
#include <app/Command.h>
#include <app/server/DataModelHandler.h>
#include <app/util/af-types.h>
#include <gen/attribute-id.h>
#include <gen/cluster-id.h>
Expand Down
1 change: 0 additions & 1 deletion examples/window-app/efr32/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@

#include "AppConfig.h"
#include "init_efrPlatform.h"
#include <app/server/DataModelHandler.h>
#include <app/server/Server.h>

#if DISPLAY_ENABLED
Expand Down
5 changes: 5 additions & 0 deletions src/app/chip_data_model.gni
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ template("chip_data_model") {
"cluster_sources",
"zap_file",
"use_default_client_callbacks",
"is_server",
])

if (!defined(sources)) {
Expand Down Expand Up @@ -170,6 +171,10 @@ template("chip_data_model") {
"${chip_root}/src/protocols/secure_channel",
]

if (defined(invoker.is_server)) {
public_deps += [ "${chip_root}/src/app/server" ]
}

if (!defined(public_configs)) {
public_configs = []
}
Expand Down
100 changes: 0 additions & 100 deletions src/app/server/DataModelHandler.cpp

This file was deleted.

14 changes: 2 additions & 12 deletions src/app/server/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
#include <app/server/Server.h>

#include <app/InteractionModelEngine.h>
#include <app/server/DataModelHandler.h>
#include <app/server/EchoHandler.h>
#include <app/server/RendezvousServer.h>
#include <app/server/StorablePeerConnection.h>
#include <app/util/DataModelHandler.h>

#include <ble/BLEEndPoint.h>
#include <core/CHIPPersistentStorageDelegate.h>
Expand Down Expand Up @@ -407,16 +407,6 @@ SecurePairingUsingTestSecret gTestPairing;

} // namespace

SecureSessionMgr & chip::SessionManager()
{
return gSessions;
}

Messaging::ExchangeManager & chip::ExchangeManager()
{
return gExchangeMgr;
}

CHIP_ERROR OpenDefaultPairingWindow(ResetAdmins resetAdmins, chip::PairingWindowAdvertisement advertisementMode)
{
// TODO(cecille): If this is re-called when the window is already open, what should happen?
Expand Down Expand Up @@ -489,7 +479,7 @@ void InitServer(AppDelegate * delegate)

chip::Platform::MemoryInit();

InitDataModelHandler();
InitDataModelHandler(&gExchangeMgr);
gCallbacks.SetDelegate(delegate);

#if CHIP_DEVICE_LAYER_TARGET_DARWIN
Expand Down
4 changes: 0 additions & 4 deletions src/app/server/Server.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ enum class PairingWindowAdvertisement
kBle,
kMdns,
};

SecureSessionMgr & SessionManager();
Messaging::ExchangeManager & ExchangeManager();

} // namespace chip

/**
Expand Down
Loading

0 comments on commit 91fd43a

Please sign in to comment.