Skip to content

Commit

Permalink
[BL602] cherry-pick from master:a2db7c387bbb03ad462603ae5a84fd03bbb1c…
Browse files Browse the repository at this point in the history
  • Loading branch information
jczhang777 authored Jun 23, 2022
1 parent 5e451a2 commit 2032aae
Show file tree
Hide file tree
Showing 18 changed files with 1,028 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,38 @@
* TODO: 3R
*/
//#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0xF001
#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8005
#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8001

/**
* CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION
*
* The hardware version number assigned to device or product by the device vendor. This
* number is scoped to the device product id, and typically corresponds to a revision of the
* physical device, a change to its packaging, and/or a change to its marketing presentation.
* This value is generally *not* incremented for device software versions.
*/
#define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 1

/**
* CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING
*
* A string identifying the software version running on the device.
* CHIP service currently expects the software version to be in the format
* {MAJOR_VERSION}.0d{MINOR_VERSION}
*/
#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "0.1ALPHA"

/**
* CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION
*
* A uint32_t identifying the software version running on the device.
*/
/* The SoftwareVersion attribute of the Basic cluster. */
#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION 0x0001
#endif
#endif

/**
* CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_REVISION
Expand Down
18 changes: 17 additions & 1 deletion examples/lighting-app/bouffalolab/bl602/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
#include <app-common/zap-generated/attribute-type.h>
#include <app-common/zap-generated/cluster-id.h>
#include <app/clusters/network-commissioning/network-commissioning.h>
#include <app/clusters/ota-requestor/BDXDownloader.h>
#include <app/clusters/ota-requestor/DefaultOTARequestor.h>
#include <app/clusters/ota-requestor/DefaultOTARequestorDriver.h>
#include <app/clusters/ota-requestor/DefaultOTARequestorStorage.h>
#include <app/server/OnboardingCodesUtil.h>
#include <app/server/Server.h>
#include <app/util/af-enums.h>
Expand All @@ -34,6 +38,7 @@
#include <lib/support/CodeUtils.h>
#include <platform/CHIPDeviceLayer.h>
#include <platform/bouffalolab/BL602/NetworkCommissioningDriver.h>
#include <platform/bouffalolab/BL602/OTAImageProcessorImpl.h>
#include <platform/internal/CHIPDeviceLayerInternal.h>

#include <bl_sys_ota.h>
Expand Down Expand Up @@ -72,6 +77,12 @@ chip::app::Clusters::NetworkCommissioning::Instance

using namespace ::chip::System;

DefaultOTARequestor gRequestorCore;
DefaultOTARequestorStorage gRequestorStorage;
DefaultOTARequestorDriver gRequestorUser;
BDXDownloader gDownloader;
OTAImageProcessorImpl gImageProcessor;

AppTask AppTask::sAppTask;
static DeviceCallbacks EchoCallbacks;

Expand Down Expand Up @@ -121,7 +132,12 @@ CHIP_ERROR AppTask::Init()

LightMgr().SetCallbacks(ActionInitiated, ActionCompleted);

UpdateClusterState();
SetRequestorInstance(&gRequestorCore);
gRequestorStorage.Init(chip::Server::GetInstance().GetPersistentStorage());
gRequestorCore.Init(chip::Server::GetInstance(), gRequestorStorage, gRequestorUser, gDownloader);
gImageProcessor.SetOTADownloader(&gDownloader);
gDownloader.SetImageProcessorDelegate(&gImageProcessor);
gRequestorUser.Init(&gRequestorCore, &gImageProcessor);

ConfigurationMgr().LogDeviceConfig();

Expand Down
36 changes: 36 additions & 0 deletions examples/lighting-app/bouffalolab/bl602/src/DeviceCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <app-common/zap-generated/attribute-id.h>
#include <app-common/zap-generated/cluster-id.h>
#include <app/CommandHandler.h>
#include <app/clusters/identify-server/identify-server.h>
#include <app/server/Dnssd.h>
#include <app/util/basic-types.h>
#include <app/util/util.h>
Expand Down Expand Up @@ -250,3 +251,38 @@ bool emberAfBasicClusterMfgSpecificPingCallback(chip::app::CommandHandler * comm
emberAfSendDefaultResponse(emberAfCurrentCommand(), EMBER_ZCL_STATUS_SUCCESS);
return true;
}

void OnIdentifyStart(Identify *)
{
ChipLogProgress(Zcl, "OnIdentifyStart");
}

void OnIdentifyStop(Identify *)
{
ChipLogProgress(Zcl, "OnIdentifyStop");
}

void OnTriggerEffect(Identify * identify)
{
switch (identify->mCurrentEffectIdentifier)
{
case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK:
ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK");
break;
case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE:
ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE");
break;
case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY:
ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY");
break;
case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE:
break;
default:
ChipLogProgress(Zcl, "No identifier effect");
return;
}
}

static Identify gIdentify1 = {
chip::EndpointId{ 1 }, OnIdentifyStart, OnIdentifyStop, EMBER_ZCL_IDENTIFY_IDENTIFY_TYPE_VISIBLE_LED, OnTriggerEffect,
};
9 changes: 7 additions & 2 deletions src/platform/bouffalolab/BL602/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,25 @@ static_library("BL602") {
"ConfigurationManagerImpl.h",
"ConnectivityManagerImpl.cpp",
"ConnectivityManagerImpl.h",
"DeviceInfoProviderImpl.cpp",
"DeviceInfoProviderImpl.h",
"DeviceNetworkProvisioningDelegateImpl.cpp",
"DeviceNetworkProvisioningDelegateImpl.h",
"DiagnosticDataProviderImpl.cpp",
"DiagnosticDataProviderImpl.h",
"DnssdImpl.cpp",
"InetPlatformConfig.h",
"Logging.cpp",
"NetworkCommissioningDriver.cpp",
"OTAImageProcessorImpl.cpp",
"PlatformManagerImpl.cpp",
"PlatformManagerImpl.h",
"SystemPlatformConfig.h",
]

deps = [ "${chip_root}/src/lib/dnssd:platform_header" ]
deps = [
"${chip_root}/src/lib/dnssd:platform_header",
"${chip_root}/src/setup_payload",
]

public_deps = [ "${chip_root}/src/platform:platform_base" ]

Expand Down
Loading

0 comments on commit 2032aae

Please sign in to comment.