Skip to content

Commit

Permalink
MFLT-12997 better sync_memfault_successful metric
Browse files Browse the repository at this point in the history
Due to how memfault data is typically sent over MQTT, the
`sync_memfault_successful` built-in (zephyr port) metric doesn't fire,
since that is set in the http uploader.

Add the metric to the MQTT Memfault data uploader.

Drive-by changes included:

- update to Memfault SDK v1.5.2
- set a default static `software_version` of `0.0.99-dev`, which should
  be overridden at OTA image build time on the command line. this helps
  distinguish dev builds from OTA builds.
  • Loading branch information
noahp committed Dec 20, 2023
1 parent 20c437a commit 51667f7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
3 changes: 3 additions & 0 deletions overlay-memfault.conf
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ CONFIG_DEBUG_MODULE_MEMFAULT_HEARTBEAT_INTERVAL_SEC=3600
# Disable NRF Cloud FOTA to save some kB, we don't use it
CONFIG_NRF_CLOUD_FOTA=n
CONFIG_MEMFAULT_FOTA=y

CONFIG_MEMFAULT_NCS_FW_VERSION_STATIC=y
CONFIG_MEMFAULT_NCS_FW_VERSION="0.0.99-dev"
13 changes: 12 additions & 1 deletion src/modules/debug_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,13 @@ static void memfault_internal_send(void)
* Memfault SDKs internal HTTP transport is used.
*/
#if !defined(CONFIG_DEBUG_MODULE_MEMFAULT_USE_EXTERNAL_TRANSPORT)
memfault_zephyr_port_post_data();
int rv = memfault_zephyr_port_post_data();
if (rv != 0) {
LOG_ERR("memfault_zephyr_port_post_data, error: %d", rv);
} else {

}
goto entry;
#else
uint8_t data[CONFIG_DEBUG_MODULE_MEMFAULT_CHUNK_SIZE_MAX];
size_t len = sizeof(data);
Expand All @@ -89,6 +95,7 @@ static void memfault_internal_send(void)
message = k_malloc(len);
if (message == NULL) {
LOG_ERR("Failed to allocate memory for Memfault data");
memfault_metrics_connectivity_record_memfault_sync_failure();
goto entry;
}

Expand All @@ -106,6 +113,10 @@ static void memfault_internal_send(void)

len = sizeof(data);
}

// Finished submitting Memfault chunks to the MQTT QoS handler, count this
// as a Memfault sync success
memfault_metrics_connectivity_record_memfault_sync_success();
#endif
goto entry;
}
Expand Down
2 changes: 1 addition & 1 deletion west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ manifest:
- name: memfault-firmware-sdk
url: https://github.com/memfault/memfault-firmware-sdk
path: modules/lib/memfault-firmware-sdk
revision: "release/1.5.0"
revision: "1.5.2"

self:
path: firmware

0 comments on commit 51667f7

Please sign in to comment.