8000 [Ameba] Update Ameba platform by pankore · Pull Request #39982 · project-chip/connectedhomeip · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[Ameba] Update Ameba platform #39982

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 26 additions & 19 deletions examples/air-purifier-app/ameba/main/chipinterface.cpp
100644 → 100755
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,36 @@
* limitations under the License.
*/

#include <chip_porting.h>
#include <platform_stdlib.h>

#include "AmebaObserver.h"
#include "CHIPDeviceManager.h"
#include "DeviceCallbacks.h"
#include "Server.h"
#include <DeviceInfoProviderImpl.h>

#include "chip_porting.h"
#include <platform/CHIPDeviceLayer.h>
#include <support/CHIPMem.h>
#include <AmebaObserver.h>
#include <CHIPDeviceManager.h>
#include <DeviceCallbacks.h>

#include <air-purifier-manager.h>
#include <app/clusters/identify-server/identify-server.h>
#include <app/clusters/network-commissioning/network-commissioning.h>
#include <app/server/Server.h>
#if CHIP_ENABLE_AMEBA_TERMS_AND_CONDITION
#include <app/server/TermsAndConditionsManager.h>
#endif
#include <app/util/endpoint-config-api.h>
#include <data-model-providers/codegen/Instance.h>
#include <lib/core/ErrorStr.h>
#include <platform/Ameba/AmebaConfig.h>
#include <platform/Ameba/DeviceInfoProviderImpl.h>
#include <platform/Ameba/NetworkCommissioningDriver.h>
#if CONFIG_ENABLE_AMEBA_CRYPTO
#include <platform/Ameba/crypto/AmebaPersistentStorageOperationalKeystore.h>
#endif
#include <platform/CHIPDeviceLayer.h>
#include <setup_payload/ManualSetupPayloadGenerator.h>
#include <setup_payload/OnboardingCodesUtil.h>
#include <setup_payload/QRCodeSetupPayloadGenerator.h>
#if CONFIG_ENABLE_AMEBA_CRYPTO
#include <platform/Ameba/crypto/AmebaPersistentStorageOperationalKeystore.h>
#endif

#include <lwip_netconf.h>

#include <support/CHIPMem.h>
#if CONFIG_ENABLE_PW_RPC
#include "Rpc.h"
#include <Rpc.h>
#endif

#define AIR_PURIFIER_ENDPOINT 1
Expand All @@ -61,6 +59,9 @@ using namespace ::chip::DeviceManager;
using namespace ::chip::DeviceLayer;
using namespace ::chip::System;

static DeviceCallbacks EchoCallbacks;
chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider;

namespace { // Network Commissioning
constexpr EndpointId kNetworkCommissioningEndpointMain = 0;
constexpr EndpointId kNetworkCommissioningEndpointSecondary = 0xFFFE;
Expand All @@ -78,9 +79,6 @@ void NetWorkCommissioningInstInit()
emberAfEndpointEnableDisable(kNetworkCommissioningEndpointSecondary, false);
}

static DeviceCallbacks EchoCallbacks;
chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider;

void OnIdentifyStart(Identify *)
{
ChipLogProgress(Zcl, "OnIdentifyStart");
Expand Down Expand Up @@ -136,12 +134,14 @@ static void InitServer(intptr_t context)
static chip::CommonCaseDeviceServerInitParams initParams;
(void) initParams.InitializeStaticResourcesBeforeServerInit();
initParams.dataModelProvider = CodegenDataModelProviderInstance(initParams.persistentStorageDelegate);

#if CONFIG_ENABLE_AMEBA_CRYPTO
ChipLogProgress(DeviceLayer, "platform crypto enabled!");
static chip::AmebaPersistentStorageOperationalKeystore sAmebaPersistentStorageOpKeystore;
VerifyOrDie((sAmebaPersistentStorageOpKeystore.Init(initParams.persistentStorageDelegate)) == CHIP_NO_ERROR);
initParams.operationalKeystore = &sAmebaPersistentStorageOpKeystore;
#endif

static AmebaObserver sAmebaObserver;
initParams.appDelegate = &sAmebaObserver;
chip::Server::GetInstance().Init(initParams);
Expand All @@ -150,6 +150,13 @@ static void InitServer(intptr_t context)

NetWorkCommissioningInstInit();

#if CHIP_ENABLE_AMEBA_TERMS_AND_CONDITION
const Optional<app::TermsAndConditions> termsAndConditions = Optional<app::TermsAndConditions>(
app::TermsAndConditions(CHIP_AMEBA_TC_REQUIRED_ACKNOWLEDGEMENTS, CHIP_AMEBA_TC_MIN_REQUIRED_VERSION));
PersistentStorageDelegate & persistentStorageDelegate = Server::GetInstance().GetPersistentStorage();
chip::app::TermsAndConditionsManager::GetInstance()->Init(&persistentStorageDelegate, termsAndConditions);
#endif

if (RTW_SUCCESS != wifi_is_connected_to_ap())
{
// QR code will be used with CHIP Tool
Expand Down
15 changes: 14 additions & 1 deletion examples/all-clusters-app/ameba/main/CHIPDeviceManager.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@

#include <stdlib.h>

#include "CHIPDeviceManager.h"
#if CONFIG_ENABLE_AMEBA_ATTRIBUTE_CALLBACK
#include <ameba_matter_attribute_callbacks.h>
#endif
#include <CHIPDeviceManager.h>
#include <app/ConcreteAttributePath.h>
#include <app/util/basic-types.h>
#include <core/ErrorStr.h>
Expand All @@ -36,6 +39,8 @@
#include <support/CodeUtils.h>

using namespace ::chip;
using namespace ::chip::app;
using namespace ::chip::app::Clusters;
using namespace ::chip::Credentials;

namespace chip {
Expand Down Expand Up @@ -103,10 +108,18 @@ void CHIPDeviceManager::Shutdown()

void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & path, uint8_t type, uint16_t size, uint8_t * value)
{
#if CONFIG_ENABLE_AMEBA_ATTRIBUTE_CALLBACK
if (AmebaDeviceManager::GetInstance() != nullptr)
{
AmebaDeviceManager::GetInstance()->AmebaPostAttributeChangeCallback(path.mEndpointId, path.mClusterId, path.mAttributeId,
type, size, value);
}
#else
chip::DeviceManager::CHIPDeviceManagerCallbacks * cb =
chip::DeviceManager::CHIPDeviceManager::GetInstance().GetCHIPDeviceManagerCallbacks();
if (cb != nullptr)
{
cb->PostAttributeChangeCallback(path.mEndpointId, path.mClusterId, path.mAttributeId, type, size, value);
}
#endif
}
79 changes: 44 additions & 35 deletions examples/all-clusters-app/ameba/main/chipinterface.cpp
100644 → 100755
10677
Original file line number Diff line number Diff line change
Expand Up @@ -15,48 +15,55 @@
* limitations under the License.
*/

#include <chip_porting.h>
#include <platform_stdlib.h>

#include "AmebaObserver.h"
#include "BindingHandler.h"
#include "CHIPDeviceManager.h"
#include "DeviceCallbacks.h"
#include "Globals.h"
#include "LEDWidget.h"
#include "chip_porting.h"
#if CHIP_AMEBA_APP_TASK
#include "ameba_main_task.h"
#if CONFIG_ENABLE_AMEBA_APP_TASK
#include <ameba_main_task.h>
#endif
#include <DeviceInfoProviderImpl.h>

#include <AmebaObserver.h>
#include <BindingHandler.h>
#include <CHIPDeviceManager.h>
#include <DeviceCallbacks.h>
#include <Globals.h>
#include <LEDWidget.h>

#include <app/clusters/identify-server/identify-server.h>
#include <app/clusters/network-commissioning/network-commissioning.h>
#include <app/server/Server.h>
#if CHIP_ENABLE_AMEBA_TERMS_AND_CONDITION
#include <app/server/TermsAndConditionsManager.h>
#endif
#include <app/util/endpoint-config-api.h>
#include <data-model-providers/codegen/Instance.h>
#include <lib/core/ErrorStr.h>
#include <setup_payload/OnboardingCodesUtil.h>

#include <platform/Ameba/AmebaConfig.h>
#include <platform/Ameba/DeviceInfoProviderImpl.h>
#include <platform/Ameba/NetworkCommissioningDriver.h>
#if CONFIG_ENABLE_AMEBA_CRYPTO
#include <platform/Ameba/crypto/AmebaPersistentStorageOperationalKeystore.h>
#endif
#include <platform/CHIPDeviceLayer.h>
#include <setup_payload/ManualSetupPayloadGenerator.h>
#include <setup_payload/OnboardingCodesUtil.h>
#include <setup_payload/QRCodeSetupPayloadGenerator.h>
#include <support/CHIPMem.h>

#if CONFIG_ENABLE_AMEBA_TEST_EVENT_TRIGGER
#include <test_event_trigger/AmebaTestEventTriggerDelegate.h>
#endif

#if CONFIG_ENABLE_CHIP_SHELL
#include <shell/launch_shell.h>
#endif
#if CONFIG_ENABLE_PW_RPC
#include <Rpc.h>
#endif

#if CONFIG_ENABLE_CHIP_SHELL
#include <shell/launch_shell.h>
#ifdef CONFIG_PLATFORM_8721D
#define STATUS_LED_GPIO_NUM PB_5
#elif defined(CONFIG_PLATFORM_8710C)
#define STATUS_LED_GPIO_NUM PA_20
#else
#define STATUS_LED_GPIO_NUM NC
#endif

using namespace ::chip;
Expand All @@ -65,6 +72,14 @@ using namespace ::chip::DeviceManager;
using namespace ::chip::DeviceLayer;
using namespace ::chip::System;

static DeviceCallbacks EchoCallbacks;
chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider;

#if CONFIG_ENABLE_AMEBA_TEST_EVENT_TRIGGER
uint8_t sTestEventTriggerEnableKey[TestEventTriggerDelegate::kEnableKeyLength] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff };
#endif

namespace { // Network Commissioning
constexpr EndpointId kNetworkCommissioningEndpointMain = 0;
constexpr EndpointId kNetworkCommissioningEndpointSecondary = 0xFFFE;
Expand Down Expand Up @@ -121,22 +136,6 @@ Identify gIdentify1 = {
OnIdentifyTriggerEffect,
};

#ifdef CONFIG_PLATFORM_8721D
#define STATUS_LED_GPIO_NUM PB_5
#elif defined(CONFIG_PLATFORM_8710C)
#define STATUS_LED_GPIO_NUM PA_20
#else
#define STATUS_LED_GPIO_NUM NC
#endif

static DeviceCallbacks EchoCallbacks;
chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider;

#if CONFIG_ENABLE_AMEBA_TEST_EVENT_TRIGGER
uint8_t sTestEventTriggerEnableKey[TestEventTriggerDelegate::kEnableKeyLength] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff };
#endif

static void InitServer(intptr_t context)
{
// Init ZCL Data Model and CHIP App Server
Expand All @@ -146,6 +145,7 @@ static void InitServer(intptr_t context)
static AmebaTestEventTriggerDelegate sTestEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) };
initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate;
#endif

static AmebaObserver sAmebaObserver;
initParams.appDelegate = &sAmebaObserver;

Expand All @@ -164,6 +164,13 @@ static void InitServer(intptr_t context)
// TODO: Use our own DeviceInfoProvider
chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider);

#if CHIP_ENABLE_AMEBA_TERMS_AND_CONDITION
const Optional<app::TermsAndConditions> termsAndConditions = Optional<app::TermsAndConditions>(
app::TermsAndConditions(CHIP_AMEBA_TC_REQUIRED_ACKNOWLEDGEMENTS, CHIP_AMEBA_TC_MIN_REQUIRED_VERSION));
PersistentStorageDelegate & persistentStorageDelegate = Server::GetInstance().GetPersistentStorage();
chip::app::TermsAndConditionsManager::GetInstance()->Init(&persistentStorageDelegate, termsAndConditions);
#endif

NetWorkCommissioningInstInit();

if (RTW_SUCCESS != wifi_is_connected_to_ap())
Expand All @@ -175,9 +182,11 @@ static void InitServer(intptr_t context)
#if CONFIG_ENABLE_CHIP_SHELL
InitBindingHandler();
#endif
#if CHIP_AMEBA_APP_TASK

#if CONFIG_ENABLE_AMEBA_APP_TASK
AppTaskInit();
#endif

chip::Server::GetInstance().GetFabricTable().AddFabricDelegate(&sAmebaObserver);
}

Expand Down Expand Up @@ -216,7 +225,7 @@ extern "C" void ChipTestShutdown(void)
deviceMgr.Shutdown();
}

bool lowPowerClusterSleep()
bool lowPowerClusterSleep(void)
{
return true;
}
Loading
Loading
0