This repository was archived by the owner on Jul 31, 2024. It is now read-only.
Commit 1660ba7
committed
samples: dfu: report FW state and reboot from main thread
So far there were 3 threads involved:
* Zephyr main
* initialize network
* start Golioth system client
* Golioth system_client
* handle incoming Golioth communication
* report FW states
* Zephyr sysworkq
* trigger reboot
This is overly complicated and makes callbacks implementation hard to read
due to FW state reporting logic taking most of callback body.
Change implementation to utilize only 2 threads instead, with following
changes:
* Zephyr main
* initialize network (as before)
* start Golioth system client (as before)
* report FW reporting (new)
* trigger reboot (new)
* Golioth system_client
* handle incoming Golioth communication
There is little data shared among those threads and most important thing
is to notify about state of FW download. For that reason use
semaphores, which make main() execution continue step by step, making
overall logic easy to follow.
This change solves one of the issues with pytest scripts expecting a
specific sequence of FW states. So far this sequence was not followed from
time to time, due to UDP packets reordering. This issue is now partly
solved by reporting FW states from Zephyr main thread and remaining fix
will be a conversion from asynchronous to synchronous
golioth_fw_report_state() API.
Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>1 parent c297f50 commit 1660ba7
1 file changed
+66
-55
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
28 | 25 | | |
29 | | - | |
| 26 | + | |
30 | 27 | | |
31 | 28 | | |
32 | 29 | | |
| |||
66 | 63 | | |
67 | 64 | | |
68 | 65 | | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
| 66 | + | |
101 | 67 | | |
102 | 68 | | |
103 | 69 | | |
| |||
158 | 124 | | |
159 | 125 | | |
160 | 126 | | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
| 127 | + | |
169 | 128 | | |
170 | 129 | | |
171 | 130 | | |
| |||
180 | 139 | | |
181 | 140 | | |
182 | 141 | | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
| 142 | + | |
191 | 143 | | |
192 | 144 | | |
193 | 145 | | |
| |||
222 | 174 | | |
223 | 175 | | |
224 | 176 | | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
225 | 236 | | |
0 commit comments