Skip to content
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

[OTA EFR32] Add chip-shell to the EFR32 ota-requestor-app, move OTA initialization to AppTask #13894

Merged
merged 4 commits into from
Jan 25, 2022
Merged
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
7 changes: 3 additions & 4 deletions examples/ota-requestor-app/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ efr32_sdk("sdk") {
"${chip_root}/src/platform/EFR32",
"${efr32_project_dir}/include",
"${examples_plat_dir}",
"${chip_root}/src/lib",
]

defines = [
Expand All @@ -81,6 +82,8 @@ efr32_sdk("sdk") {

efr32_executable("ota_requestor_app") {
output_name = "chip-efr32-ota-requestor-example.out"
include_dirs = [ "include" ]
defines = []
selissia marked this conversation as resolved.
Show resolved Hide resolved

sources = [
"${examples_plat_dir}/LEDWidget.cpp",
Expand Down Expand Up @@ -116,10 +119,6 @@ efr32_executable("ota_requestor_app") {
]
}

include_dirs = [ "include" ]

defines = []

if (show_qr_code) {
sources += [ "${examples_plat_dir}/display/lcd.c" ]
defines += [ "DISPLAY_ENABLED" ]
Expand Down
1 change: 1 addition & 0 deletions examples/ota-requestor-app/efr32/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ chip_openthread_ftd = false

declare_args() {
chip_enable_ota_requestor = true
chip_build_libshell = true
}
2 changes: 2 additions & 0 deletions examples/ota-requestor-app/efr32/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class AppTask

void DispatchEvent(AppEvent * event);

void InitOTARequestor();

static void FunctionTimerEventHandler(AppEvent * aEvent);
static void FunctionHandler(AppEvent * aEvent);
static void LightActionEventHandler(AppEvent * aEvent);
Expand Down
35 changes: 35 additions & 0 deletions examples/ota-requestor-app/efr32/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
#include <app/server/Server.h>
#include <app/util/attribute-storage.h>

#include "app/clusters/ota-requestor/BDXDownloader.h"
#include "app/clusters/ota-requestor/OTARequestor.h"
#include "platform/EFR32/OTAImageProcessorImpl.h"
#include "platform/GenericOTARequestorDriver.h"

#include <assert.h>

#include <credentials/DeviceAttestationCredsProvider.h>
Expand Down Expand Up @@ -86,10 +91,17 @@ StaticTask_t appTaskStruct;

} // namespace

using namespace chip;
using namespace chip::TLV;
using namespace ::chip::Credentials;
using namespace ::chip::DeviceLayer;

// Global OTA objects
OTARequestor gRequestorCore;
DeviceLayer::GenericOTARequestorDriver gRequestorUser;
BDXDownloader gDownloader;
OTAImageProcessorImpl gImageProcessor;

AppTask AppTask::sAppTask;

CHIP_ERROR AppTask::StartAppTask()
Expand Down Expand Up @@ -164,6 +176,9 @@ CHIP_ERROR AppTask::Init()
PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE));
#endif

// Initialize OTA components
InitOTARequestor();

return err;
}

Expand Down Expand Up @@ -511,3 +526,23 @@ void AppTask::DispatchEvent(AppEvent * aEvent)
}

void AppTask::UpdateClusterState(void) {}

void AppTask::InitOTARequestor()
{

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

gRequestorCore.Init(&(chip::Server::GetInstance()), &gRequestorUser, &gDownloader);
selissia marked this conversation as resolved.
Show resolved Hide resolved

gRequestorUser.Init(&gRequestorCore, &gImageProcessor);

OTAImageProcessorParams ipParams;
ipParams.imageFile = CharSpan("test.txt");
selissia marked this conversation as resolved.
Show resolved Hide resolved
gImageProcessor.SetOTAImageProcessorParams(ipParams);
gImageProcessor.SetOTADownloader(&gDownloader);

// Connect the Downloader and Image Processor objects
gDownloader.SetImageProcessorDelegate(&gImageProcessor);
// Initialize and interconnect the Requestor and Image Processor objects -- END
}
29 changes: 1 addition & 28 deletions examples/ota-requestor-app/efr32/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@
#include "sl_system_kernel.h"
#include <app/server/Server.h>

#include "app/clusters/ota-requestor/BDXDownloader.h"
#include "app/clusters/ota-requestor/OTARequestor.h"
#include "platform/EFR32/OTAImageProcessorImpl.h"
#include "platform/GenericOTARequestorDriver.h"

#ifdef HEAP_MONITORING
#include "MemMonitoring.h"
#endif
Expand Down Expand Up @@ -81,12 +76,6 @@ using namespace ::chip::DeviceLayer;

#define UNUSED_PARAMETER(a) (a = a)

// Global OTA objects
OTARequestor gRequestorCore;
DeviceLayer::GenericOTARequestorDriver gRequestorUser;
BDXDownloader gDownloader;
OTAImageProcessorImpl gImageProcessor;

volatile int apperror_cnt;

#include "platform/bootloader/api/application_properties.h"
Expand Down Expand Up @@ -117,7 +106,7 @@ __attribute__((used)) ApplicationProperties_t sl_app_properties = {

/// Bitfield representing type of application
/// e.g. @ref APPLICATION_TYPE_BLUETOOTH_APP
.type = APPLICATION_TYPE_ZIGBEE,
.type = APPLICATION_TYPE_THREAD,
selissia marked this conversation as resolved.
Show resolved Hide resolved

/// Version number for this application
.version = APP_PROPERTIES_VERSION,
Expand Down Expand Up @@ -211,22 +200,6 @@ int main(void)
}
#endif // CHIP_ENABLE_OPENTHREAD

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

gRequestorCore.Init(&(chip::Server::GetInstance()), &gRequestorUser, &gDownloader);

gRequestorUser.Init(&gRequestorCore, &gImageProcessor);

OTAImageProcessorParams ipParams;
ipParams.imageFile = CharSpan("test.txt");
gImageProcessor.SetOTAImageProcessorParams(ipParams);
gImageProcessor.SetOTADownloader(&gDownloader);

// Connect the Downloader and Image Processor objects
gDownloader.SetImageProcessorDelegate(&gImageProcessor);
// Initialize and interconnect the Requestor and Image Processor objects -- END

EFR32_LOG("Starting Platform Manager Event Loop");
ret = PlatformMgr().StartEventLoopTask();
if (ret != CHIP_NO_ERROR)
Expand Down
4 changes: 3 additions & 1 deletion src/lib/shell/MainLoopEFR32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ int TokenizeLine(char * buffer, char ** tokens, int max_tokens)
else if (IsSeparator(buffer[i]))
{
buffer[i] = 0;
if (!IsSeparator(buffer[i + 1]))
// Don't treat the previous character as a separator if this one is 0
// otherwise the trailing space will become a token
if (!IsSeparator(buffer[i + 1]) && buffer[i + 1] != 0)
selissia marked this conversation as resolved.
Show resolved Hide resolved
{
tokens[cursor++] = &buffer[i + 1];
}
Expand Down