NordicSemiconductor / asset-tracker-cloud-memfault-aws-js

Memfault integration for AWS IoT developed using AWS CDK in TypeScript.

Home Page:https://github.com/NordicSemiconductor/asset-tracker-cloud-memfault-aws-js#readme

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Memfault integration for AWS IoT

GitHub Actions semantic-release Renovate @commitlint/config-conventional code style: prettier ESLint: TypeScript

Memfault integration for AWS IoT developed using AWS CDK in TypeScript.

Device information

Meta information about devices is populated by cloud when devices report their values

  • board type (hardware_version) is inferred cloud side from dev.v.brdV Thing shadow property.
  • nickname is inferred from the user's name setting for the device using the name Thing attribute.

Chunks

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.

Installation in your AWS account

Setup

Provide your AWS credentials, for example using the .envrc (see the example).

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.

Deploy

npx cdk deploy

Configure memfault settings

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>

Configure stack settings

The topic devices use to publish Memfault chunks can be configured through the CDK context variable memfaultTopic. It defaults to +/memfault/#.

About

Memfault integration for AWS IoT developed using AWS CDK in TypeScript.

https://github.com/NordicSemiconductor/asset-tracker-cloud-memfault-aws-js#readme

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:TypeScript 85.6%Language:Gherkin 14.1%Language:JavaScript 0.3%