Skip to content

Commit 487351b

Browse files
Fix fallback mode (revert to stream after success or fail)
1 parent 5edf3b4 commit 487351b

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

src/Context.h

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ namespace sua {
5454
std::shared_ptr<IBundleChecker> bundleChecker;
5555
std::string updatesDirectory = "/data/selfupdates";
5656
bool downloadMode = true;
57+
bool fallbackMode = false;
5758

5859
DesiredState desiredState;
5960
CurrentState currentState;

src/FSM/States/Installing.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ namespace sua {
5858
if(result == TechCode::OK) {
5959
Logger::info("Installation completed");
6060
send(ctx, IMqttProcessor::TOPIC_FEEDBACK, "installed");
61+
62+
if(ctx.fallbackMode) {
63+
ctx.downloadMode = false;
64+
ctx.fallbackMode = false;
65+
}
66+
6167
return FotaEvent::InstallCompleted;
6268
}
6369

@@ -67,13 +73,20 @@ namespace sua {
6773
// for download mode transit to fail state
6874
if (true == ctx.downloadMode) {
6975
send(ctx, IMqttProcessor::TOPIC_FEEDBACK, "installFailed", lastError);
76+
77+
if(ctx.fallbackMode) {
78+
ctx.downloadMode = false;
79+
ctx.fallbackMode = false;
80+
}
81+
7082
return FotaEvent::InstallFailed;
7183
}
7284

7385
// for stream mode start again in download mode
7486
Logger::info("Trying normal download mode as fallback");
7587
send(ctx, IMqttProcessor::TOPIC_FEEDBACK, "installFailedFallback", lastError);
7688
ctx.downloadMode = true;
89+
ctx.fallbackMode = true;
7790
return FotaEvent::InstallFailedFallback;
7891
}
7992

utest/TestMqttMessagingProtocolJSON.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -723,8 +723,6 @@ namespace {
723723

724724
TEST_F(TestMessagingProtocolJSON, createMessage_installFailedFallback)
725725
{
726-
d.installProgressPercentage = 66;
727-
728726
const std::string result = ProtocolJSON().createMessage(ctx, "installFailedFallback");
729727

730728
// clang-format off

0 commit comments

Comments
 (0)