21
21
#include " FSM/States/Idle.h"
22
22
#include " FSM/States/Installed.h"
23
23
#include " FSM/States/Installing.h"
24
+ #include " FSM/States/SendCurrentState.h"
24
25
#include " FSM/States/Uninitialized.h"
25
26
#include " FotaEvent.h"
26
27
#include " Logger.h"
@@ -35,43 +36,48 @@ namespace sua {
35
36
{
36
37
// clang-format off
37
38
auto factory = std::make_shared<StateFactory>();
38
- factory->addStateT <Connected >(" Connected" );
39
- factory->addStateT <Downloading >(" Downloading" );
40
- factory->addStateT <Failed >(" Failed" );
41
- factory->addStateT <Idle >(" Idle" );
42
- factory->addStateT <Installed >(" Installed" );
43
- factory->addStateT <Installing >(" Installing" );
44
- factory->addStateT <Uninitialized>(" Uninitialized" );
39
+ factory->addStateT <Connected >(" Connected" );
40
+ factory->addStateT <Downloading >(" Downloading" );
41
+ factory->addStateT <Failed >(" Failed" );
42
+ factory->addStateT <Idle >(" Idle" );
43
+ factory->addStateT <Installed >(" Installed" );
44
+ factory->addStateT <Installing >(" Installing" );
45
+ factory->addStateT <SendCurrentState>(" SendCurrentState" );
46
+ factory->addStateT <Uninitialized >(" Uninitialized" );
45
47
_context.stateMachine ->setFactory (factory);
46
48
// clang-format-on
47
49
48
50
// clang-format off
49
51
_context.stateMachine ->setTransitions ({
50
52
// from "Uninitialized"
51
- { FotaEvent::ConnectivityEstablished , " Uninitialized" , " Connected" },
53
+ { FotaEvent::ConnectivityEstablished, " Uninitialized" , " Connected" },
52
54
// from "Connected"
53
- { FotaEvent::ConnectivityLost , " Connected" , " Uninitialized" },
54
- { FotaEvent::Start , " Connected" , " Failed" , FotaEvent::BundleVersionUnchanged },
55
- { FotaEvent::Start , " Connected" , " Downloading" , FotaEvent::BundleVersionOK },
55
+ { FotaEvent::ConnectivityLost , " Connected" , " Uninitialized" },
56
+ { FotaEvent::Start , " Connected" , " Failed" , FotaEvent::BundleVersionUnchanged },
57
+ { FotaEvent::Start , " Connected" , " Downloading" , FotaEvent::BundleVersionOK },
58
+ { FotaEvent::GetCurrentState , " Connected" , " SendCurrentState" },
56
59
// from "Failed"
57
- { FotaEvent::ConnectivityLost , " Failed" , " Uninitialized" },
58
- { FotaEvent::Waiting , " Failed" , " Idle" },
60
+ { FotaEvent::ConnectivityLost , " Failed" , " Uninitialized" },
61
+ { FotaEvent::Waiting , " Failed" , " Idle" },
59
62
// from "Downloading"
60
- { FotaEvent::ConnectivityLost , " Downloading" , " Uninitialized" },
61
- { FotaEvent::DownloadStart , " Downloading" , " Installing" , FotaEvent::BundleVersionOK },
62
- { FotaEvent::DownloadStart , " Downloading" , " Failed" , FotaEvent::BundleVersionInconsistent },
63
- { FotaEvent::DownloadStart , " Downloading" , " Failed" , FotaEvent::DownloadFailed },
63
+ { FotaEvent::ConnectivityLost , " Downloading" , " Uninitialized" },
64
+ { FotaEvent::DownloadStart , " Downloading" , " Installing" , FotaEvent::BundleVersionOK },
65
+ { FotaEvent::DownloadStart , " Downloading" , " Failed" , FotaEvent::BundleVersionInconsistent },
66
+ { FotaEvent::DownloadStart , " Downloading" , " Failed" , FotaEvent::DownloadFailed },
64
67
// from "Installing"
65
- { FotaEvent::ConnectivityLost , " Installing" , " Uninitialized" },
66
- { FotaEvent::InstallStart , " Installing" , " Installed" , FotaEvent::InstallCompleted },
67
- { FotaEvent::InstallStart , " Installing" , " Failed" , FotaEvent::InstallFailed },
68
+ { FotaEvent::ConnectivityLost , " Installing" , " Uninitialized" },
69
+ { FotaEvent::InstallStart , " Installing" , " Installed" , FotaEvent::InstallCompleted },
70
+ { FotaEvent::InstallStart , " Installing" , " Failed" , FotaEvent::InstallFailed },
68
71
// from "Installed"
69
- { FotaEvent::ConnectivityLost , " Installed" , " Uninitialized" },
70
- { FotaEvent::Waiting , " Installed" , " Idle" },
72
+ { FotaEvent::ConnectivityLost , " Installed" , " Uninitialized" },
73
+ { FotaEvent::Waiting , " Installed" , " Idle" },
71
74
// from "Idle"
72
- { FotaEvent::ConnectivityLost , " Idle" , " Uninitialized" },
73
- { FotaEvent::Start , " Idle" , " Failed" , FotaEvent::BundleVersionUnchanged },
74
- { FotaEvent::Start , " Idle" , " Downloading" , FotaEvent::BundleVersionOK },
75
+ { FotaEvent::ConnectivityLost , " Idle" , " Uninitialized" },
76
+ { FotaEvent::Start , " Idle" , " Failed" , FotaEvent::BundleVersionUnchanged },
77
+ { FotaEvent::Start , " Idle" , " Downloading" , FotaEvent::BundleVersionOK },
78
+ // from "SendCurrentState"
79
+ { FotaEvent::ConnectivityLost , " SendCurrentState" , " Uninitialized" },
80
+ { FotaEvent::Waiting , " SendCurrentState" , " Idle" },
75
81
});
76
82
_context.stateMachine ->transitTo (" Uninitialized" );
77
83
// clang-format on
0 commit comments