Forwarding Chunks via Golioth
Golioth is an IoT platform that provides cloud services for embedded devices. If your project is using Golioth, you can leverage their CoAP client to forward Memfault chunk data to Memfault.
Step 1: Set up a Pipeline for Memfault
See https://docs.golioth.io/data-routing/destinations/memfault/ for instructions on setting up Memfault as a destination.
Step 2: Configure Memfault Data Upload
In a periodic task, drain chunks and upload to Golioth via Streaming mode with a Golioth blockwise stream. See the Memfault + Golioth example app for a sample implementation.
Step 3: Configure Device Info
Golioth will attach the Golioth device serial to Memfault data when uploading to the Memfault cloud. Therefore, the on-device Memfault serial can be empty, but the remaining device info should be customized.
- Option 1: NCS Built-in Device Info
- Option 2: Custom Device Info
By default, NCS provides a built-in memfault_platform_get_device_info()
function with helpful defaults. See
Kconfig options in NCS
for configuring these!
If you need to provide a custom implementation of
memfault_platform_get_device_info()
, for example if your software version is
not available at compile-time, first set the following in your proj.conf
:
CONFIG_MEMFAULT_DEVICE_INFO_CUSTOM=y
CONFIG_MEMFAULT_NCS_DEVICE_ID_RUNTIME=y
Then, implement the memfault_platform_get_device_info()
function as follows,
customizing appropriately:
#include "memfault/core/platform/device_info.h"
void memfault_platform_get_device_info(sMemfaultDeviceInfo *info) {
// *NOTE* All strings must be populated, and the values assigned to
// the fields must have static lifetime: the data is accessed when
// this function returns.
*info = (sMemfaultDeviceInfo) {
// Device serial will typically be reported by Golioth, therefore set
// this to a dummy value
.device_serial = "NULL",
// Set the device software type- it can be simply "app" for a single-
// chip device, otherwise it should match the component name, eg "ble"
// "sensor" etc.
// This is used to filter data in the Memfault UI
.software_type = "app",
// Set the device software version.
// This is used to filter devices in the Memfault UI. If using Memfault
// OTA, this should exactly match the OTA Release Version name for the
// installed image.
.software_version = "0.0.1-dev",
// Set the device hardware revision.
// This is used to filter/group devices in the Memfault UI
.hardware_version = "evt",
};
}
Step 4: Remove the Memfault Project Key
If you are not connecting directly with Memfault's servers for data upload or OTA, you can set it to a dummy value:
- NCS
- ESP-IDF
# Disable the HTTP client (needed only for nRF91 projects)
CONFIG_MEMFAULT_HTTP_ENABLE=n
# Set to a dummy value
CONFIG_MEMFAULT_NCS_PROJECT_KEY="NULL"
CONFIG_MEMFAULT_NCS_PROJECT_KEY
is optional in nRF Connect SDK >=v3.0.0 for
any device that does not use MDS or the Memfault HTTP client to upload chunks,
which applies for all NCS-based projects leveraging Golioth for chunks
forwarding.
# Disable periodic data upload (enabled by default)
CONFIG_MEMFAULT_HTTP_PERIODIC_UPLOAD=n
# Set to a dummy value
CONFIG_MEMFAULT_PROJECT_KEY="NULL"