Note
This repository has been archived, because it is considered feature-complete. ✔️
Memfault integration for AWS IoT developed using AWS CDK in TypeScript.
Meta information about devices is populated by cloud when devices report their values
- board type
(
hardware_version
) is inferred cloud side fromdev.v.brdV
Thing shadow property. nickname
is inferred from the user's name setting for the device using thename
Thing attribute.
The Memfault SDK packages the data from all modules in chunks. They are received via MQTT and forwared to the Memfault chunks API.
Memfault embeds offset information in each chunk so they can re-assemble data that arrives out of order, so there is no need to buffer the chunks on the cloudside.
Devices publish the chunks via MQTT to a configurable topic. Right now the
asset_tracker_v2
uses <deviceId>/memfault/<Memfault project key>
,
however deviceId
and Memfault project key
are superfluous because they can
be inferred on the cloud side from the MQTT connection.
To support devices publishing to a MQTT topic named memfault
directly, the
Memfault project key
needed for chunks API
is stored on the cloud side in an SSM parameter.
This also allows for changing the project key on the fly if needed without needing deploy a new firmware to devices. However, note that the project key is not a secret and does not need rotation.
It is also useful to have the Memfault project key on the device to directly publish to the Memfault HTTP API to be able to debug problems with the MQTT connections.
This can however also be solved by setting up an API endpoint the accepts requests signed with JWT tokens created using the devices keypair. This would allow to remove the Memfault project key entirely from the firmware. Right now however this is not supported in nRF Connect SDK. Please reach out if you would like to see this feature.
Install zip
.
Install the dependencies:
npm ci
Optionally,
enable THING
events
for your AWS IoT Hub to automatically sync your devices' name
attribute with
the Memfault device nickname
property.
npx cdk deploy
You can retrieve the project settings from the settings page of the Memfault dashboard of your organization.
aws ssm put-parameter --type String --name /${STACK_NAME:-nrf-memfault}/thirdParty/memfault/projectKey --value <your Memfault project key>
aws ssm put-parameter --type String --name /${STACK_NAME:-nrf-memfault}/thirdParty/memfault/organization --value <your organization slug>
aws ssm put-parameter --type String --name /${STACK_NAME:-nrf-memfault}/thirdParty/memfault/project --value <your project slug>
The organization auth token can be accessed and managed by Administrators at Admin → Organization Auth Tokens in the Memfault UI.
aws ssm put-parameter --type String --name /${STACK_NAME:-nrf-memfault}/thirdParty/memfault/authToken --value <your auth token>
The topic devices use to publish Memfault chunks can be configured through the
CDK context variable
memfaultTopic
. It defaults to +/memfault/#
.