Skip to content

Commit

Permalink
[Infineon][SVE] Initialize CYW30739 OTA requestor after re-attaching …
Browse files Browse the repository at this point in the history
…to Thread network. (project-chip#21781)
  • Loading branch information
hsusid authored and isiu-apple committed Sep 16, 2022
1 parent 90b6b97 commit c51f171
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 34 deletions.
17 changes: 0 additions & 17 deletions examples/lighting-app/cyw30739/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ using namespace ::chip::Shell;

static chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider;
static void InitApp(intptr_t args);
static void EventHandler(const ChipDeviceEvent * event, intptr_t arg);
static void HandleThreadStateChangeEvent(const ChipDeviceEvent * event);
static void LightManagerCallback(LightingManager::Actor_t actor, LightingManager::Action_t action, uint8_t value);

static wiced_led_config_t chip_lighting_led_config = {
Expand Down Expand Up @@ -148,7 +146,6 @@ void InitApp(intptr_t args)
{
ConfigurationMgr().LogDeviceConfig();

PlatformMgrImpl().AddEventHandler(EventHandler, 0);
// Print QR Code URL
PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE));
/* Start CHIP datamodel server */
Expand All @@ -174,20 +171,6 @@ void InitApp(intptr_t args)
#endif
}

void EventHandler(const ChipDeviceEvent * event, intptr_t arg)
{
switch (event->Type)
{
case DeviceEventType::kThreadStateChange:
HandleThreadStateChangeEvent(event);
break;
default:
break;
}
}

void HandleThreadStateChangeEvent(const ChipDeviceEvent * event) {}

void LightManagerCallback(LightingManager::Actor_t actor, LightingManager::Action_t action, uint8_t level)
{
if (action == LightingManager::ON_ACTION)
Expand Down
17 changes: 0 additions & 17 deletions examples/lock-app/cyw30739/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ wiced_bool_t syncClusterToButtonAction = false;

static chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider;
static void InitApp(intptr_t args);
static void EventHandler(const ChipDeviceEvent * event, intptr_t arg);
static void HandleThreadStateChangeEvent(const ChipDeviceEvent * event);
static void ActionInitiated(LockManager::Action_t aAction, int32_t aActor);
static void ActionCompleted(LockManager::Action_t aAction);
static void WriteClusterState(uint8_t value);
Expand Down Expand Up @@ -173,7 +171,6 @@ APPLICATION_START()
void InitApp(intptr_t args)
{
CHIP_ERROR err = CHIP_NO_ERROR;
PlatformMgrImpl().AddEventHandler(EventHandler, 0);
// Print QR Code URL
PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE));
/* Start CHIP datamodel server */
Expand Down Expand Up @@ -267,20 +264,6 @@ void InitApp(intptr_t args)
#endif
}

void EventHandler(const ChipDeviceEvent * event, intptr_t arg)
{
switch (event->Type)
{
case DeviceEventType::kThreadStateChange:
HandleThreadStateChangeEvent(event);
break;
default:
break;
}
}

void HandleThreadStateChangeEvent(const ChipDeviceEvent * event) {}

void ActionInitiated(LockManager::Action_t aAction, int32_t aActor)
{
// If the action has been initiated by the lock, update the bolt lock trait
Expand Down
31 changes: 31 additions & 0 deletions examples/platform/cyw30739/OTAConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,48 @@
#include <app/server/Server.h>
#include <platform/CYW30739/OTAImageProcessorImpl.h>

using namespace ::chip;
using namespace ::chip::DeviceLayer;

namespace OTAConfig {

constexpr uint32_t kInitOTARequestorDelaySec = 3;

// Global OTA objects
chip::DefaultOTARequestor gRequestorCore;
chip::DefaultOTARequestorStorage gRequestorStorage;
chip::DeviceLayer::DefaultOTARequestorDriver gRequestorUser;
chip::BDXDownloader gDownloader;
chip::OTAImageProcessorImpl gImageProcessor;

static void PlatformEventHandler(const ChipDeviceEvent * event, intptr_t arg);
static void InitRequestor(System::Layer * systemLayer, void * appState);

void Init()
{
PlatformMgrImpl().AddEventHandler(PlatformEventHandler, 0);
}

void PlatformEventHandler(const ChipDeviceEvent * event, intptr_t arg)
{
switch (event->Type)
{
case DeviceEventType::kThreadConnectivityChange:
if (event->ThreadConnectivityChange.Result == kConnectivity_Established)
SystemLayer().StartTimer(System::Clock::Seconds32(kInitOTARequestorDelaySec), InitRequestor, nullptr);
break;
default:
break;
}
}

void InitRequestor(System::Layer * systemLayer, void * appState)
{
if (GetRequestorInstance() != nullptr)
return;

ChipLogProgress(SoftwareUpdate, "Initializing requestor");

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

Expand Down

0 comments on commit c51f171

Please sign in to comment.