Advanced configuration for Zephyr
This guide describes various advanced configuration options for the Zephyr module.
Device ID
Kconfig option
Easiest way to set device ID is by using the CONFIG_SPOTFLOW_DEVICE_ID
Kconfig option in your prj.conf
file:
CONFIG_SPOTFLOW_DEVICE_ID="your-device-id"
If setting the device ID via Kconfig works for you, there is no need to investigate other options and we recommend sticking with this approach.
Setting device ID at runtime
However, in more complex scenarios, Kconfig option may not be sufficient, especially when device ID is not known at compile time or needs to be set dynamically.
In such cases, define function spotflow_override_device_id
that returns a string with the device ID. Inside this function, you can implement the logic to determine the device ID at runtime
and Spotflow device module will call this function to get the device ID.
const char* spotflow_override_device_id()
{
return "my_nrf7002dk_test";
}
Although this approach allows to setting device ID dynamically, it most cases the function should contain deterministic logic returning consistent values across device reboots. Random or frequently changing will prevent you from efficiently analyzing device-specific behavior and performance as well as it might lead to increase subscription usage in terms of number of registered devices.
Hardware Info Interface
If no device ID is explicitly provided, the Spotflow device module will try to use the Zephyr's Hardware Info Interface to retrieve the device ID via
hwinfo_get_device_id(...)
function.
Cloud hostname and port
By default, the Spotflow device module connects to the Spotflow cloud at mqtt.spotflow.io
on port 8883
which is a standard port used for MQTT over TLS.
In case you need to change these settings (e.g. due to using proxy), following Kconfig options are available:
CONFIG_SPOTFLOW_CLOUD_HOSTNAME="mqtt.spotflow.io"
CONFIG_SPOTFLOW_CLOUD_PORT=8883
Storing sensitive information in the configuration files
Most of the configuration options are typically not sensitive and thus is it safe and beneficial to version them in the Git or other version control system. However, some options such as Ingestion Key or WiFi passwords are sensitive and it is a security issue to store them in the version control.
For such cases, we recommend store the sensitive options in a separate credentials.conf
file
that is not tracked by version control and merge them into the resulting configuration during build.
Thread priorities and stack size
Spotflow device module is using a separate thread to send data via MQTT.
To modify priority of this thread, enable SPOTFLOW_MQTT_THREAD_CUSTOM_PRIORITY
option and choose the custom priority via SPOTFLOW_MQTT_THREAD_PRIORITY
.
To modify stack size of this thread, use SPOTFLOW_PROCESSING_THREAD_STACK_SIZE
option.
CONFIG_SPOTFLOW_MQTT_THREAD_CUSTOM_PRIORITY=y
CONFIG_SPOTFLOW_MQTT_THREAD_PRIORITY=14
CONFIG_SPOTFLOW_PROCESSING_THREAD_STACK_SIZE=2560
Build ID
To disable generating and embedding build ID, disable SPOTFLOW_GENERATE_BUILD_ID
option.
Disabling build ID will prevent Spotflow from automatically linking core dumps with the uploaded ELF files. However, the ELF files can still be linked manually to specific core dumps.
CONFIG_SPOTFLOW_GENERATE_BUILD_ID=n
Internal logging
To adjust default log level of internal Spotflow device module logging, use the SPOTFLOW_MODULE_DEFAULT_LOG_LEVEL
option.
CONFIG_SPOTFLOW_MODULE_DEFAULT_LOG_LEVEL=3
How is this guide?