Skip to content

Commit cbc518e

Browse files
author
Memfault Inc
committed
Memfault Firmware SDK 0.36.1 (Build 874)
1 parent e403b90 commit cbc518e

File tree

6 files changed

+59
-17
lines changed

6 files changed

+59
-17
lines changed

CHANGES.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
1-
### Changes between Memfault SDK 0.34.2 and SDK 0.35.0 - Dec 6, 2022
1+
### Changes between Memfault SDK 0.36.1 and SDK 0.36.0 - Dec 9, 2022
2+
3+
#### :chart_with_upwards_trend: Improvements
4+
5+
- ESP-IDF:
6+
- Fix a bug 🐛 in the [ESP32 example app](examples/esp32), where wifi join
7+
fails when using versions of ESP-IDF prior to 5.0
8+
9+
### Changes between Memfault SDK 0.36.0 and SDK 0.35.0 - Dec 6, 2022
210

311
#### :chart_with_upwards_trend: Improvements
412

513
- ESP-IDF:
614

715
- Add support for
816
[just-released ESP-IDF v5](https://github.com/espressif/esp-idf/releases/tag/v5.0)
9-
🎉!
17+
🎉! Thanks to @jlubawy and the patch supplied in #39 for this, very much
18+
appreciated!
1019
- Add an auto-OTA (and auto-WiFi-join) feature to the
1120
[ESP32 example app](examples/esp32)- enabled by default but can be disabled
1221
with Kconfig

VERSION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
BUILD ID: 838
2-
GIT COMMIT: 588aa169f
1+
BUILD ID: 874
2+
GIT COMMIT: 5402c68cc

components/include/memfault/version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ typedef struct {
1919
uint8_t patch;
2020
} sMfltSdkVersion;
2121

22-
#define MEMFAULT_SDK_VERSION { .major = 0, .minor = 36, .patch = 0 }
22+
#define MEMFAULT_SDK_VERSION { .major = 0, .minor = 36, .patch = 1 }
2323

2424
#ifdef __cplusplus
2525
}

examples/esp32/apps/memfault_demo_app/main/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ list(APPEND
55
console_example_main.c
66
memfault_platform_device_info.c
77
)
8-
if("${IDF_VERSION_MAJOR}" VERSION_GREATER_EQUAL 4)
8+
9+
# the 'cmd_wifi.c' implementation is different for ESP-IDF v5+
10+
if("${IDF_VERSION_MAJOR}" VERSION_GREATER_EQUAL 5)
911
list(APPEND
1012
COMPONENT_SRCS
1113
cmd_wifi.c

examples/esp32/apps/memfault_demo_app/main/cmd_wifi.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include "esp_wifi.h"
1717
#include "freertos/FreeRTOS.h"
1818
#include "freertos/event_groups.h"
19-
#include "memfault/esp_port/version.h"
2019
#include "nvs.h"
2120
#include "nvs_flash.h"
2221

@@ -33,12 +32,6 @@ static char s_wifi_pass[WIFI_CREDS_MAX_SIZE];
3332

3433
#define EXAMPLE_ESP_MAXIMUM_RETRY 10 // CONFIG_ESP_MAXIMUM_RETRY
3534

36-
// this type changed in ESP-IDF v4.0, to 'nvs_handle_t'; add a backwards-compat
37-
// typedef
38-
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(4, 0, 0)
39-
typedef nvs_handle nvs_handle_t;
40-
#endif
41-
4235
#if CONFIG_ESP_WIFI_AUTH_OPEN
4336
#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_OPEN
4437
#elif CONFIG_ESP_WIFI_AUTH_WEP

examples/esp32/apps/memfault_demo_app/main/console_example_main.c

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@
3737
#define GREEN_LED 2
3838
#define BLUE_LED 4
3939

40+
// System state LED color:
41+
// Red: System is running, has not checked in to memfault (wifi might be bad)
42+
// Green: System is running, has checked in to memfault
43+
// Blue: System is performing an OTA update
44+
static int s_led_color = RED_LED;
45+
4046
static const char *TAG = "example";
4147

4248
/* Console command history can be stored to and loaded from a file.
@@ -128,7 +134,7 @@ void *g_unaligned_buffer;
128134

129135
static bool prv_handle_ota_upload_available(void *user_ctx) {
130136
// set blue when performing update
131-
gpio_set_level(BLUE_LED, 1);
137+
s_led_color = BLUE_LED;
132138

133139
MEMFAULT_LOG_INFO("Starting OTA download ...");
134140
return true;
@@ -166,15 +172,15 @@ static void prv_memfault_ota(void) {
166172

167173
MEMFAULT_LOG_INFO("Checking for OTA Update");
168174

169-
// clear ota-in-progress indicator
170-
gpio_set_level(BLUE_LED, 0);
171175
int rv = memfault_esp_port_ota_update(&handler);
172176
if (rv == 0) {
173177
MEMFAULT_LOG_INFO("Up to date!");
178+
s_led_color = GREEN_LED;
174179
} else if (rv == 1) {
175180
MEMFAULT_LOG_INFO("Update available!");
176181
} else if (rv < 0) {
177182
MEMFAULT_LOG_ERROR("OTA update failed, rv=%d", rv);
183+
s_led_color = RED_LED;
178184
}
179185
}
180186
#else
@@ -213,7 +219,7 @@ static void prv_poster_task(void *args) {
213219
int err = memfault_esp_port_http_client_post_data();
214220
// if the check-in succeeded, set green, otherwise clear.
215221
// gives a quick eyeball check that the app is alive and well
216-
gpio_set_level(GREEN_LED, err == 0);
222+
s_led_color = (err == 0) ? GREEN_LED : RED_LED;
217223

218224
memfault_metrics_heartbeat_add(MEMFAULT_METRICS_KEY(PosterTaskNumSchedules), 1);
219225
memfault_esp_port_wifi_autojoin();
@@ -298,6 +304,20 @@ static void prv_initialize_task_watchdog(void) {
298304
}
299305
#endif
300306

307+
static void prv_heartbeat_led_callback(MEMFAULT_UNUSED TimerHandle_t handle) {
308+
static bool s_led_state = false;
309+
s_led_state = !s_led_state;
310+
311+
const gpio_num_t leds[] = {RED_LED, GREEN_LED, BLUE_LED};
312+
for (size_t i = 0; i < sizeof(leds) / sizeof(leds[0]); i++) {
313+
if (leds[i] == s_led_color) {
314+
gpio_set_level(s_led_color, s_led_state);
315+
} else {
316+
gpio_set_level(leds[i], 0);
317+
}
318+
}
319+
}
320+
301321
static void led_init(void) {
302322
const gpio_num_t leds[] = {RED_LED, GREEN_LED, BLUE_LED};
303323

@@ -306,6 +326,24 @@ static void led_init(void) {
306326
gpio_set_direction(leds[i], GPIO_MODE_OUTPUT);
307327
gpio_set_level(leds[i], 0);
308328
}
329+
330+
// create a timer that blinks the LED, indicating the app is alive
331+
const char *const pcTimerName = "HeartbeatLED";
332+
const TickType_t xTimerPeriodInTicks = pdMS_TO_TICKS(500);
333+
334+
TimerHandle_t timer;
335+
336+
#if MEMFAULT_FREERTOS_PORT_USE_STATIC_ALLOCATION != 0
337+
static StaticTimer_t s_heartbeat_led_timer_context;
338+
timer = xTimerCreateStatic(pcTimerName, xTimerPeriodInTicks, pdTRUE, NULL,
339+
prv_heartbeat_led_callback, &s_heartbeat_led_timer_context);
340+
#else
341+
timer = xTimerCreate(pcTimerName, xTimerPeriodInTicks, pdTRUE, NULL, prv_heartbeat_led_callback);
342+
#endif
343+
344+
MEMFAULT_ASSERT(timer != 0);
345+
346+
xTimerStart(timer, 0);
309347
}
310348

311349
// This task started by cpu_start.c::start_cpu0_default().

0 commit comments

Comments
 (0)