diff --git a/examples/ota-requestor-app/efr32/BUILD.gn b/examples/ota-requestor-app/efr32/BUILD.gn index aba10e91819dc6..ae18d2e517b0a8 100644 --- a/examples/ota-requestor-app/efr32/BUILD.gn +++ b/examples/ota-requestor-app/efr32/BUILD.gn @@ -63,6 +63,7 @@ efr32_sdk("sdk") { "${chip_root}/src/platform/EFR32", "${efr32_project_dir}/include", "${examples_plat_dir}", + "${chip_root}/src/lib", ] defines = [ @@ -81,6 +82,8 @@ efr32_sdk("sdk") { efr32_executable("ota_requestor_app") { output_name = "chip-efr32-ota-requestor-example.out" + include_dirs = [ "include" ] + defines = [] sources = [ "${examples_plat_dir}/LEDWidget.cpp", @@ -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" ] diff --git a/examples/ota-requestor-app/efr32/args.gni b/examples/ota-requestor-app/efr32/args.gni index e0bc6e99507b2d..354ee1b214a371 100644 --- a/examples/ota-requestor-app/efr32/args.gni +++ b/examples/ota-requestor-app/efr32/args.gni @@ -25,4 +25,5 @@ chip_openthread_ftd = false declare_args() { chip_enable_ota_requestor = true + chip_build_libshell = true } diff --git a/examples/ota-requestor-app/efr32/include/AppTask.h b/examples/ota-requestor-app/efr32/include/AppTask.h index 8c43d3a0a2c828..8dacfd4bd2ca79 100644 --- a/examples/ota-requestor-app/efr32/include/AppTask.h +++ b/examples/ota-requestor-app/efr32/include/AppTask.h @@ -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); diff --git a/examples/ota-requestor-app/efr32/src/AppTask.cpp b/examples/ota-requestor-app/efr32/src/AppTask.cpp index 2b6d5e39bd2c2c..d2acbba1a8850d 100644 --- a/examples/ota-requestor-app/efr32/src/AppTask.cpp +++ b/examples/ota-requestor-app/efr32/src/AppTask.cpp @@ -32,6 +32,11 @@ #include #include +#include "app/clusters/ota-requestor/BDXDownloader.h" +#include "app/clusters/ota-requestor/OTARequestor.h" +#include "platform/EFR32/OTAImageProcessorImpl.h" +#include "platform/GenericOTARequestorDriver.h" + #include #include @@ -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() @@ -164,6 +176,9 @@ CHIP_ERROR AppTask::Init() PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE)); #endif + // Initialize OTA components + InitOTARequestor(); + return err; } @@ -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); + + 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 +} diff --git a/examples/ota-requestor-app/efr32/src/main.cpp b/examples/ota-requestor-app/efr32/src/main.cpp index 3f5a5bca94c47d..c268cdd94ca56b 100644 --- a/examples/ota-requestor-app/efr32/src/main.cpp +++ b/examples/ota-requestor-app/efr32/src/main.cpp @@ -40,11 +40,6 @@ #include "sl_system_kernel.h" #include -#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 @@ -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" @@ -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, /// Version number for this application .version = APP_PROPERTIES_VERSION, @@ -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) diff --git a/src/lib/shell/MainLoopEFR32.cpp b/src/lib/shell/MainLoopEFR32.cpp index 3b1f298d5cfb55..6b32d04bdd5ab1 100644 --- a/src/lib/shell/MainLoopEFR32.cpp +++ b/src/lib/shell/MainLoopEFR32.cpp @@ -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) { tokens[cursor++] = &buffer[i + 1]; }