Memfault Diagnostic Service (MDS)
The Bluetooth® Low Energy (LE) GATT Memfault Diagnostic Service is a custom service that forwards diagnostic data collected by firmware through a Bluetooth gateway. The diagnostic data is collected by the Memfault SDK integrated with the nRF Connect SDK.
To get started with Memfault integration in nRF Connect SDK, see Memfault integration.
The MDS is used in the Bluetooth: Peripheral Memfault Diagnostic Service (MDS) sample.
The 128-bit service UUID is
The MDS characteristics are described in detail in the Memfault Diagnostic GATT Service documentation. The service implementation available in the nRF Connect SDK follows these requirements.
CONFIG_BT_MDS Kconfig option to enable the service.
The following configuration options are available for this module:
CONFIG_BT_MDS_PERMprovides permission to the service characteristic. In the default configuration, it is set to
CONFIG_BT_MDS_PERM_RW_ENCRYPT. This is because the potentially sensitive Memfault project key and diagnostic data are sent through service’s characteristics. There is not hard requirement for access restriction to diagnostic data.
CONFIG_BT_MDS_PIPELINE_COUNTsets the maximum number of service notifications that can be queued in the Bluetooth stack.
CONFIG_BT_MDS_DATA_POLL_INTERVALsets the interval of checking if any diagnostic data is available for sending.
See the Kconfig help for details.
The implementation uses
BT_GATT_SERVICE_DEFINE to statically define and register the Memfault Diagnostic GATT service.
The service automatically checks if there is data available to be sent with the interval defined by the
CONFIG_BT_MDS_DATA_POLL_INTERVAL and sends it using the notification mechanism.
No application input is required to send diagnostic data.
However, if you pass
bt_mds_cb to the
bt_mds_cb_register() function, the application needs to confirm that the connected client can access the diagnostic data every time the client performs a read or write operation on the service characteristic.
bt_mds_cb_register() function to register callbacks the service.
bt_mds_cb_register() function before enabling Bluetooth stack to ensure a proper access restriction to MDS service data.
Only one connected client can operate on the MDS characteristic and receive a notification with diagnostic data.
The Memfault service characteristics data might contain sensitive data.
It is recommended to use the Bluetooth privacy and encrypted link to access the diagnostic data.
CONFIG_BT_SMP Kconfig option to require encryption for access in the default configuration.
It is also highly recommended to implement the
See Bluetooth: Peripheral Memfault Diagnostic Service (MDS) for an implementation example.
It is recommended to use the Bluetooth Privacy feature when you use this service.
To enable privacy, set the
- group bt_mds
API for the Memfault Diagnostic GATT service (MDS).
UUID of the Memfault Diagnostic Service.
UUID of the MDS Supported Features Characteristic.
UUID of the MDS Device Identifier Characteristic.
UUID of the MDS Data URI Characteristic.
UUID of the MDS Authorization Characteristic.
UUID of the MDS Data Export Characteristic.
int bt_mds_cb_register(const struct bt_mds_cb *cb)
Register the Memfault Diagnostic service callback.
This function should be called before enabling Bluetooth stack to ensure proper access grating to MDS characteristics data through
cb – [in] Memfault callback structure. This parameter can be set to NULL but it will let the first connected client access the Memfault data without authentication.
- Return values:
0 – If the operation was successful. Otherwise, a negative error code is returned
- #include <mds.h>
Memfault Diagnostic Service callback structure.
bool (*access_enable)(struct bt_conn *conn)
A callback for enabling Memfault access.
If this callback is not implemented, any connected peer can access the Memfault characteristics and descriptors data, including write access to them, without authentication.
The Memfault Diagnostic service allows only one client subscription.
- Param conn:
[in] Connection object.
- Retval True:
if peer associated with connection object has granted access to the Memfault data. False if access to the Memfault data is forbidden.
- bool (*access_enable)(struct bt_conn *conn)