From 6400d7115f3d58c64038e7012c703ffe31301bcd Mon Sep 17 00:00:00 2001 From: Memfault Inc Date: Wed, 3 May 2023 18:44:22 +0000 Subject: [PATCH] Memfault Firmware SDK 0.43.2 (Build 2071) --- CHANGES.md | 8 ++++++++ VERSION | 4 ++-- components/include/memfault/version.h | 2 +- components/metrics/src/memfault_metrics.c | 3 +++ .../test_memfault_heartbeat_metrics_debug.cpp | 19 +++++++++++++++++++ 5 files changed, 33 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 5b474652a..ce7735869 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,11 @@ +### Changes between Memfault SDK 0.43.2 and 0.43.1 - May 3, 2023 + +#### :chart_with_upwards_trend: Improvements + +- Fix a bug 🐛 where metrics accumulated with `memfault_metrics_heartbeat_add()` + would no longer be included in the serialized heartbeat data. This regression + occurred in `0.42.0`. + ### Changes between Memfault SDK 0.43.1 and 0.43.0 - April 26, 2023 #### :chart_with_upwards_trend: Improvements diff --git a/VERSION b/VERSION index f46922b5d..7ef59d9d2 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ -BUILD ID: 2030 -GIT COMMIT: 6bca4dee8 +BUILD ID: 2071 +GIT COMMIT: b1c0f7c97 diff --git a/components/include/memfault/version.h b/components/include/memfault/version.h index b4343c98e..6c2a17d92 100644 --- a/components/include/memfault/version.h +++ b/components/include/memfault/version.h @@ -19,7 +19,7 @@ typedef struct { uint8_t patch; } sMfltSdkVersion; -#define MEMFAULT_SDK_VERSION { .major = 0, .minor = 43, .patch = 1 } +#define MEMFAULT_SDK_VERSION { .major = 0, .minor = 43, .patch = 2 } #ifdef __cplusplus } diff --git a/components/metrics/src/memfault_metrics.c b/components/metrics/src/memfault_metrics.c index 9f564d3d6..8beb70fa5 100644 --- a/components/metrics/src/memfault_metrics.c +++ b/components/metrics/src/memfault_metrics.c @@ -649,6 +649,9 @@ int memfault_metrics_heartbeat_add(MemfaultMetricId key, int32_t amount) { memfault_lock(); { rv = prv_find_key_and_add(key, amount); + if(rv == 0) { + prv_read_write_is_value_set(key, true); + } } memfault_unlock(); return rv; diff --git a/tests/src/test_memfault_heartbeat_metrics_debug.cpp b/tests/src/test_memfault_heartbeat_metrics_debug.cpp index 8ec85cc12..543d9e8fe 100644 --- a/tests/src/test_memfault_heartbeat_metrics_debug.cpp +++ b/tests/src/test_memfault_heartbeat_metrics_debug.cpp @@ -150,4 +150,23 @@ TEST(MemfaultHeartbeatMetricsDebug, Test_DebugPrints) { MEMFAULT_ARRAY_SIZE(heartbeat_debug_print_reset)); memfault_metrics_heartbeat_debug_print(); mock().checkExpectations(); + + // Finally test that memfault_metrics_heartbeat_add by itself sets the metric + // to is_set + const char *heartbeat_add_non_null[] = { + "Heartbeat keys/values:", + " MemfaultSdkMetric_IntervalMs: 0", + " MemfaultSdkMetric_UnexpectedRebootCount: null", + " MemfaultSdkMetric_UnexpectedRebootDidOccur: 0", + " test_key_unsigned: 123", + " test_key_signed: null", + " test_key_timer: 0", + " test_key_string: \"\"", + }; + prv_debug_print_expectations(kMemfaultPlatformLogLevel_Debug, heartbeat_add_non_null, + MEMFAULT_ARRAY_SIZE(heartbeat_add_non_null)); + // call add on this metric alone and confirm it is set + memfault_metrics_heartbeat_add(MEMFAULT_METRICS_KEY(test_key_unsigned), 123); + memfault_metrics_heartbeat_debug_print(); + mock().checkExpectations(); }