Skip to content

Commit

Permalink
Merge branch 'master' of github.com:selissia/connectedhomeip into ota…
Browse files Browse the repository at this point in the history
…_cancel_download
  • Loading branch information
selissia committed Jan 24, 2022
2 parents 014a079 + e25a501 commit d75a1b5
Show file tree
Hide file tree
Showing 204 changed files with 9,483 additions and 4,246 deletions.
7 changes: 7 additions & 0 deletions config/ameba/chip.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,20 @@ string(APPEND CHIP_GN_ARGS "ameba_cxx = \"arm-none-eabi-c++\"\n")
string(APPEND CHIP_GN_ARGS "ameba_cpu = \"ameba\"\n")

# Build RPC
if (matter_enable_rpc)
#string(APPEND CHIP_GN_ARGS "remove_default_configs = [\"//third_party/connectedhomeip/third_party/pigweed/repo/pw_build:cpp17\"]\n")
string(APPEND CHIP_GN_ARGS "chip_build_pw_rpc_lib = true\n")
string(APPEND CHIP_GN_ARGS "pw_log_BACKEND = \"//third_party/connectedhomeip/third_party/pigweed/repo/pw_log_basic\"\n")
string(APPEND CHIP_GN_ARGS "pw_assert_BACKEND = \"//third_party/connectedhomeip/third_party/pigweed/repo/pw_assert_log\"\n")
string(APPEND CHIP_GN_ARGS "pw_sys_io_BACKEND = \"//third_party/connectedhomeip/examples/platform/ameba/pw_sys_io:pw_sys_io_ameba\"\n")
string(APPEND CHIP_GN_ARGS "dir_pw_third_party_nanopb = \"//third_party/connectedhomeip/third_party/nanopb/repo\"\n")
string(APPEND CHIP_GN_ARGS "pw_build_LINK_DEPS = [\"//third_party/connectedhomeip/third_party/pigweed/repo/pw_assert:impl\", \"//third_party/connectedhomeip/third_party/pigweed/repo/pw_log:impl\"]\n")
endif (matter_enable_rpc)

# Build ota-requestor
if (matter_enable_ota_requestor)
string(APPEND CHIP_GN_ARGS "chip_enable_ota_requestor = true\n")
endif (matter_enable_ota_requestor)

file(GENERATE OUTPUT ${CHIP_OUTPUT}/args.gn CONTENT ${CHIP_GN_ARGS})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1689,6 +1689,7 @@ server cluster LevelControl = 8 {
server cluster LocalizationConfiguration = 43 {
attribute char_string<35> activeLocale = 1;
readonly attribute CHAR_STRING supportedLocales[] = 2;
readonly global attribute int16u clusterRevision = 65533;
}

server cluster LowPower = 1288 {
Expand Down Expand Up @@ -2534,6 +2535,10 @@ server cluster TestCluster = 1295 {
double h = 7;
}

struct TestFabricScoped {
fabric_idx fabricIndex = 0;
}

struct NestedStructList {
INT8U a = 0;
BOOLEAN b = 1;
Expand Down Expand Up @@ -2602,6 +2607,7 @@ server cluster TestCluster = 1295 {
attribute int16u rangeRestrictedInt16u = 40;
attribute int16s rangeRestrictedInt16s = 41;
readonly attribute LONG_OCTET_STRING listLongOctetString[] = 42;
readonly attribute TestFabricScoped listFabricScoped[] = 43;
attribute boolean timedWriteBoolean = 48;
attribute boolean nullableBoolean = 32768;
attribute bitmap8 nullableBitmap8 = 32769;
Expand Down Expand Up @@ -3107,7 +3113,6 @@ endpoint 1 {
server cluster IlluminanceMeasurement;
server cluster KeypadInput;
server cluster LevelControl;
server cluster LocalizationConfiguration;
server cluster LowPower;
server cluster MediaInput;
server cluster MediaPlayback;
Expand Down
115 changes: 62 additions & 53 deletions examples/all-clusters-app/all-clusters-common/all-clusters-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -1651,10 +1651,10 @@
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "RAM",
"storageOption": "NVM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"defaultValue": "en-US",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand All @@ -1674,6 +1674,21 @@
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "ClusterRevision",
"code": 65533,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "1",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
}
]
},
Expand Down Expand Up @@ -9149,57 +9164,6 @@
}
]
},
{
"name": "Localization Configuration",
"code": 43,
"mfgCode": null,
"define": "LOCALIZATION_CONFIGURATION_CLUSTER",
"side": "client",
"enabled": 0,
"commands": [],
"attributes": []
},
{
"name": "Localization Configuration",
"code": 43,
"mfgCode": null,
"define": "LOCALIZATION_CONFIGURATION_CLUSTER",
"side": "server",
"enabled": 1,
"commands": [],
"attributes": [
{
"name": "ActiveLocale",
"code": 1,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "SupportedLocales",
"code": 2,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "0",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
}
]
},
{
"name": "Power Source",
"code": 47,
Expand Down Expand Up @@ -16453,6 +16417,21 @@
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "list_fabric_scoped",
"code": 43,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "timed_write_boolean",
"code": 48,
Expand Down Expand Up @@ -16978,6 +16957,36 @@
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "AttributeList",
"code": 65531,
"mfgCode": null,
"side": "server",
"included": 0,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 0,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "FeatureMap",
"code": 65532,
"mfgCode": null,
"side": "server",
"included": 0,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0",
"reportable": 0,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "ClusterRevision",
"code": 65533,
Expand Down
18 changes: 18 additions & 0 deletions examples/all-clusters-app/ameba/chip_main.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,16 @@ list(
)
endif (matter_enable_rpc)

if (matter_enable_ota_requestor)
list(
APPEND ${list_chip_main_sources}
#OTARequestor
${chip_dir}/src/app/clusters/ota-requestor/BDXDownloader.cpp
${chip_dir}/src/app/clusters/ota-requestor/OTARequestor.cpp
${chip_dir}/src/app/clusters/ota-requestor/ota-requestor-server.cpp
)
endif (matter_enable_ota_requestor)

list(
APPEND ${list_chip_main_sources}

Expand Down Expand Up @@ -229,6 +239,14 @@ list(
)
endif (matter_enable_rpc)

if (matter_enable_ota_requestor)
list(
APPEND chip_main_flags

-DCONFIG_ENABLE_OTA_REQUESTOR=1
)
endif (matter_enable_ota_requestor)

list(
APPEND chip_main_cpp_flags

Expand Down
61 changes: 59 additions & 2 deletions examples/all-clusters-app/ameba/main/chipinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@
#include <setup_payload/QRCodeSetupPayloadGenerator.h>
#include <support/CHIPMem.h>

#if CONFIG_ENABLE_OTA_REQUESTOR
#include "app/clusters/ota-requestor/BDXDownloader.h"
#include "app/clusters/ota-requestor/OTARequestor.h"
#include "platform/Ameba/AmebaOTAImageProcessor.h"
#include "platform/GenericOTARequestorDriver.h"
#endif

#if CONFIG_ENABLE_PW_RPC
#include "Rpc.h"
#endif
Expand All @@ -44,6 +51,7 @@ using namespace ::chip;
using namespace ::chip::Credentials;
using namespace ::chip::DeviceManager;
using namespace ::chip::DeviceLayer;
using namespace ::chip::System;

Identify gIdentify0 = {
chip::EndpointId{ 0 },
Expand Down Expand Up @@ -72,6 +80,13 @@ Identify gIdentify1 = {

static DeviceCallbacks EchoCallbacks;

#if CONFIG_ENABLE_OTA_REQUESTOR
OTARequestor gRequestorCore;
GenericOTARequestorDriver gRequestorUser;
BDXDownloader gDownloader;
AmebaOTAImageProcessor gImageProcessor;
#endif

void GetGatewayIP(char * ip_buf, size_t ip_len)
{
uint8_t * gateway = LwIP_GetGW(&xnetif[0]);
Expand Down Expand Up @@ -185,6 +200,47 @@ std::string createSetupPayload()
return result;
};

#if CONFIG_ENABLE_OTA_REQUESTOR
extern "C" void amebaQueryImageCmdHandler(uint32_t nodeId, uint32_t fabricId)
{
ChipLogProgress(DeviceLayer, "Calling amebaQueryImageCmdHandler");
// In this mode Provider node ID and fabric idx must be supplied explicitly from ATS$ cmd
gRequestorCore.TestModeSetProviderParameters(nodeId, fabricId, chip::kRootEndpointId);

static_cast<OTARequestor *>(GetRequestorInstance())->TriggerImmediateQuery();
}

extern "C" void amebaApplyUpdateCmdHandler()
{
ChipLogProgress(DeviceLayer, "Calling amebaApplyUpdateCmdHandler");

static_cast<OTARequestor *>(GetRequestorInstance())->ApplyUpdate();
}

static void InitOTARequestor(void)
{
// Initialize and interconnect the Requestor and Image Processor objects -- START
SetRequestorInstance(&gRequestorCore);

// Set server instance used for session establishment
gRequestorCore.Init(&(chip::Server::GetInstance()), &gRequestorUser, &gDownloader);

// WARNING: this is probably not realistic to know such details of the image or to even have an OTADownloader instantiated at
// the beginning of program execution. We're using hardcoded values here for now since this is a reference application.
// TODO: instatiate and initialize these values when QueryImageResponse tells us an image is available
// TODO: add API for OTARequestor to pass QueryImageResponse info to the application to use for OTADownloader init
OTAImageProcessorParams ipParams;
gImageProcessor.SetOTAImageProcessorParams(ipParams);
gImageProcessor.SetOTADownloader(&gDownloader);

// Connect the Downloader and Image Processor objects
gDownloader.SetImageProcessorDelegate(&gImageProcessor);
gRequestorUser.Init(&gRequestorCore, &gImageProcessor);

// Initialize and interconnect the Requestor and Image Processor objects -- END
}
#endif // CONFIG_ENABLE_OTA_REQUESTOR

extern "C" void ChipTest(void)
{
ChipLogProgress(DeviceLayer, "All Clusters Demo!");
Expand Down Expand Up @@ -229,8 +285,9 @@ extern "C" void ChipTest(void)

statusLED1.Init(STATUS_LED_GPIO_NUM);

while (true)
vTaskDelay(pdMS_TO_TICKS(50));
#if CONFIG_ENABLE_OTA_REQUESTOR
InitOTARequestor();
#endif
}

bool lowPowerClusterSleep()
Expand Down
Loading

0 comments on commit d75a1b5

Please sign in to comment.