diff --git a/docs/_partials-common/espidf-install-environment.md b/docs/_partials-common/espidf-install-environment.md index 2d343576..e4e12ca4 100644 --- a/docs/_partials-common/espidf-install-environment.md +++ b/docs/_partials-common/espidf-install-environment.md @@ -30,9 +30,9 @@ source ~/esp/esp-idf/export.sh -```console -%HOMEPATH%\esp\esp-idf\export.bat -``` +Open the **ESP-IDF Command Prompt** from the Start menu. The ESP-IDF Tools +Installer creates this shortcut, which runs `export.bat` from the ESP-IDF +directory chosen in the installer. diff --git a/docs/_partials-common/espidf-install-sample-build.md b/docs/_partials-common/espidf-install-sample-build.md index 338fea1e..06d3822a 100644 --- a/docs/_partials-common/espidf-install-sample-build.md +++ b/docs/_partials-common/espidf-install-sample-build.md @@ -18,7 +18,7 @@ values={[ cd ~/esp cp -r $IDF_PATH/examples/get-started/hello_world . cd hello_world -idf.py set-target esp32 +idf.py set-target esp32s3 idf.py build ``` @@ -29,7 +29,7 @@ idf.py build cd ~/esp cp -r $IDF_PATH/examples/get-started/hello_world . cd hello_world -idf.py set-target esp32 +idf.py set-target esp32s3 idf.py build ``` @@ -37,10 +37,11 @@ idf.py build ```shell +mkdir %HOMEPATH%\esp cd %HOMEPATH%\esp xcopy /e /i %IDF_PATH%\examples\get-started\hello_world hello_world cd hello_world -idf.py set-target esp32 +idf.py set-target esp32s3 idf.py build ``` diff --git a/docs/_partials-common/espidf-install.md b/docs/_partials-common/espidf-install.md index 64caf48c..613f758a 100644 --- a/docs/_partials-common/espidf-install.md +++ b/docs/_partials-common/espidf-install.md @@ -42,10 +42,6 @@ sudo apt-get install git wget flex bison gperf python3 python3-venv \ brew install cmake ninja dfu-util python3 ``` -```console -sudo easy_install pip -``` - #### 2. Clone the ESP-IDF repository and set up the tools @@ -63,8 +59,8 @@ sudo easy_install pip :::note Espressif provides [comprehensive instructions for installing ESP-IDF for -Windows](https://docs.espressif.com/projects/esp-idf/en/stable/esp32/get-started/index.html#setting-up-development-environment). -It recommends [using the ESP-IDF Tools Installer](https://docs.espressif.com/projects/esp-idf/en/stable/esp32/get-started/windows-setup.html#get-started-windows-tools-installer) which installs and configures all required ESP-IDF tools for Windows systems. +Windows](https://docs.espressif.com/projects/esp-idf/en/v5.4.1/esp32s3/get-started/index.html#installation). +It recommends [using the ESP-IDF Tools Installer](https://docs.espressif.com/projects/esp-idf/en/v5.4.1/esp32s3/get-started/windows-setup.html#get-started-windows-tools-installer) which installs and configures all required ESP-IDF tools for Windows systems. ::: diff --git a/docs/_partials-common/getting-started_choose-device.md b/docs/_partials-common/getting-started_choose-device.md deleted file mode 100644 index db01e464..00000000 --- a/docs/_partials-common/getting-started_choose-device.md +++ /dev/null @@ -1,4 +0,0 @@ -The next step is to connect a device to Golioth using either the Golioth -Firmware SDK or the Golioth Zephyr SDK. - -## Next: [Hardware Overview](/firmware/hardware) diff --git a/docs/_partials-common/install-zephyr-sdk-toolchain.md b/docs/_partials-common/install-zephyr-sdk-toolchain.md index d9ac9c23..97f9cc9f 100644 --- a/docs/_partials-common/install-zephyr-sdk-toolchain.md +++ b/docs/_partials-common/install-zephyr-sdk-toolchain.md @@ -3,7 +3,7 @@ import TabItem from '@theme/TabItem'; import CodeBlock from '@theme/CodeBlock'; import ZephyrSdkNgVer from '!!raw-loader!/docs/_versions/zephyr-project-sdk-ng.md'; -Download the [latest SDK installer](https://github.com/zephyrproject-rtos/sdk-ng/releases): +Download Zephyr SDK {ZephyrSdkNgVer.replace(/(\n)/gm, "")} from the [SDK releases](https://github.com/zephyrproject-rtos/sdk-ng/releases): +On Apple Silicon Macs, replace `macos-x86_64` with `macos-aarch64` in the +commands below. + { `cd ~ diff --git a/docs/_partials-common/ncs-install-golioth-firmware-sdk-for-unix.md b/docs/_partials-common/ncs-install-golioth-firmware-sdk-for-unix.md index 8b68cafc..e663bf30 100644 --- a/docs/_partials-common/ncs-install-golioth-firmware-sdk-for-unix.md +++ b/docs/_partials-common/ncs-install-golioth-firmware-sdk-for-unix.md @@ -23,7 +23,7 @@ import FirmwareSdkVer from '!!raw-loader!/docs/_versions/golioth-firmware-sdk.md @@ -39,6 +41,8 @@ import FirmwareSdkVer from '!!raw-loader!/docs/_versions/golioth-firmware-sdk.md ``` pip3 install -r ~/golioth-ncs-workspace/zephyr/scripts/requirements.txt + pip3 install -r ~/golioth-ncs-workspace/nrf/scripts/requirements.txt + pip3 install -r ~/golioth-ncs-workspace/bootloader/mcuboot/scripts/requirements.txt ``` diff --git a/docs/_partials-common/ncs-install-golioth-firmware-sdk-for-windows.md b/docs/_partials-common/ncs-install-golioth-firmware-sdk-for-windows.md index 47142c2c..ec3ae8ad 100644 --- a/docs/_partials-common/ncs-install-golioth-firmware-sdk-for-windows.md +++ b/docs/_partials-common/ncs-install-golioth-firmware-sdk-for-windows.md @@ -6,11 +6,11 @@ import FirmwareSdkVer from '!!raw-loader!/docs/_versions/golioth-firmware-sdk.md 1. With `west` installed, grab the Golioth NCS SDK: - {` cd %HOMEPATH%` + "\n" } - {` west init -m https://github.com/golioth/golioth-firmware-sdk.git --mr ${FirmwareSdkVer.replace(/(\n)/gm, "")} --mf west-ncs.yml %HOMEPATH%/golioth-ncs-workspace` + "\n" } - {` cd golioth-ncs-workspace/modules/lib/golioth-firmware-sdk` + "\n" } + { `cd %HOMEPATH%` + "\n" } + { `west init -m https://github.com/golioth/golioth-firmware-sdk.git --mr ${FirmwareSdkVer.replace(/(\n)/gm, "")} --mf west-ncs.yml %HOMEPATH%/golioth-ncs-workspace` + "\n" } + { `cd golioth-ncs-workspace/modules/lib/golioth-firmware-sdk` + "\n" } { `git submodule update --init --recursive` + "\n" } - {` west update` } + { `west update` } 2. Tell `west` to automatically configure CMake: @@ -23,7 +23,7 @@ import FirmwareSdkVer from '!!raw-loader!/docs/_versions/golioth-firmware-sdk.md @@ -39,6 +41,8 @@ import FirmwareSdkVer from '!!raw-loader!/docs/_versions/golioth-firmware-sdk.md ``` pip3 install -r %HOMEPATH%/golioth-ncs-workspace/zephyr/scripts/requirements.txt + pip3 install -r %HOMEPATH%/golioth-ncs-workspace/nrf/scripts/requirements.txt + pip3 install -r %HOMEPATH%/golioth-ncs-workspace/bootloader/mcuboot/scripts/requirements.txt ``` diff --git a/docs/_partials-common/prerequisites-device.md b/docs/_partials-common/prerequisites-device.md deleted file mode 100644 index 49cf9886..00000000 --- a/docs/_partials-common/prerequisites-device.md +++ /dev/null @@ -1,13 +0,0 @@ -### Prerequisites - -- `goliothctl` and `west` installed -- Authenticated with Golioth - see - [Authentication](/reference/command-line-tools/tutorial/authentication) -- Have a project - see [Create a - Project](/reference/command-line-tools/tutorial/create-project) -- Have a provisioned device and credential for it - see [Authorizing - Devices](/reference/command-line-tools/tutorial/authorize-devices) - Zephyr](/getting-started/device-examples/compile-example-code/zephyr) page for the - ESP32. -- A toolchain installed. In this guide, the toolchain for the ESP32 will be - used. diff --git a/docs/_partials-common/sample-build.mdx b/docs/_partials-common/sample-build.mdx index 0db8f3e4..895b3d11 100644 --- a/docs/_partials-common/sample-build.mdx +++ b/docs/_partials-common/sample-build.mdx @@ -2,7 +2,6 @@ import CodeBlock from '@theme/CodeBlock'; import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -export { `cd ~` + "\n" } @@ -38,14 +38,14 @@ import FirmwareSdkVer from '!!raw-loader!/docs/_versions/golioth-firmware-sdk.md ``` - pip install -r ~/golioth-zephyr-workspace/zephyr/scripts/requirements.txt + west packages pip --install ``` ``` - pip3 install -r ~/golioth-zephyr-workspace/zephyr/scripts/requirements.txt + west packages pip --install --ignore-venv-check ``` diff --git a/docs/_partials-common/zephyr-install-golioth-firmware-sdk-for-windows.md b/docs/_partials-common/zephyr-install-golioth-firmware-sdk-for-windows.md index c673bd51..4b264f93 100644 --- a/docs/_partials-common/zephyr-install-golioth-firmware-sdk-for-windows.md +++ b/docs/_partials-common/zephyr-install-golioth-firmware-sdk-for-windows.md @@ -3,10 +3,10 @@ import TabItem from '@theme/TabItem'; import CodeBlock from '@theme/CodeBlock'; import FirmwareSdkVer from '!!raw-loader!/docs/_versions/golioth-firmware-sdk.md'; -1. With `west` installed, download the Zephyr SDK: +1. With `west` installed, download Zephyr and the Golioth Firmware SDK: - { `cd c:\\` + "\n" } + { `cd %HOMEPATH%` + "\n" } { `west init -m https://github.com/golioth/golioth-firmware-sdk.git --mr ${FirmwareSdkVer.replace(/(\n)/gm, "")} --mf west-zephyr.yml golioth-zephyr-workspace` + "\n" } { `cd golioth-zephyr-workspace/modules/lib/golioth-firmware-sdk` + "\n" } { `git submodule update --init --recursive` + "\n" } @@ -38,14 +38,14 @@ import FirmwareSdkVer from '!!raw-loader!/docs/_versions/golioth-firmware-sdk.md ``` - pip install -r %HOMEPATH%\golioth-zephyr-workspace\zephyr\scripts\requirements.txt + west packages pip --install ``` ``` - pip3 install -r %HOMEPATH%\golioth-zephyr-workspace\zephyr\scripts\requirements.txt + west packages pip --install --ignore-venv-check ``` diff --git a/docs/_partials-common/zephyr-setup-dependencies.md b/docs/_partials-common/zephyr-setup-dependencies.md index 048a3a68..94b8d221 100644 --- a/docs/_partials-common/zephyr-setup-dependencies.md +++ b/docs/_partials-common/zephyr-setup-dependencies.md @@ -25,31 +25,21 @@ import SetupWestWindows from './zephyr-setup-west-windows.md' sudo apt install --no-install-recommends git cmake ninja-build gperf \ ccache dfu-util device-tree-compiler wget python3-dev python3-pip \ python3-setuptools python3-tk python3-venv python3-wheel xz-utils file \ - make gcc gcc-multilib g++-multilib libsdl2-dev + make gcc gcc-multilib g++-multilib libsdl2-dev libmagic1 ``` -2. West requires CMake version 3.20.0 or higher. Check the version that your - package manager installed: +2. Zephyr supports Ubuntu 22.04 LTS and later and needs at least + CMake 3.20.5, Python 3.10 and devicetree compiler 1.4.6. Check the + installed versions: ``` - $ cmake --version - cmake version 3.16.3 - ``` - - If you have an older version, Ubuntu 20.04 systems can add the Kitware - repository which maintains the newest release: - - ``` - wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | sudo apt-key add - - sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ focal main' - sudo apt update - sudo apt install cmake cmake --version + python3 --version + dtc --version ``` - If the Kitware repository doesn't work for you (ie: your system is not - running Ubuntu 20.04), you can [build the stable version of CMake from - source](https://cmake.org/install/). + If any of them is older, see [Zephyr's dependency + instructions](https://docs.zephyrproject.org/4.3.0/develop/getting_started/index.html#install-dependencies). ### Install West @@ -61,7 +51,7 @@ import SetupWestWindows from './zephyr-setup-west-windows.md' 1. Start by installing dependencies with `brew`: ``` - brew install cmake ninja gperf python3 ccache dtc + brew install cmake ninja gperf python3 python-tk ccache dtc libmagic wget ``` ### Install West diff --git a/docs/_partials-common/zephyr-setup-west-unix.md b/docs/_partials-common/zephyr-setup-west-unix.md index c0e14ead..ff5da4bb 100644 --- a/docs/_partials-common/zephyr-setup-west-unix.md +++ b/docs/_partials-common/zephyr-setup-west-unix.md @@ -7,7 +7,7 @@ tooling incompatibilities. +:::note +Recent distributions, such as Ubuntu 23.04 and later, and Homebrew's Python +refuse system-wide `pip` installs (PEP 668). Use the virtualenv tab there. +::: + 1. Create your workspace directory: diff --git a/docs/_partials-common/zephyr-setup-west-windows.md b/docs/_partials-common/zephyr-setup-west-windows.md index 10407de5..c411ed76 100644 --- a/docs/_partials-common/zephyr-setup-west-windows.md +++ b/docs/_partials-common/zephyr-setup-west-windows.md @@ -67,7 +67,7 @@ values={[ { `mkdir ${props.workspace_directory}` } -2. Use `pip3` to install `west`: +2. Use `pip` to install `west`: ```shell pip install -U west diff --git a/docs/_versions/golioth-firmware-sdk.md b/docs/_versions/golioth-firmware-sdk.md index 4f279437..0c2a959e 100644 --- a/docs/_versions/golioth-firmware-sdk.md +++ b/docs/_versions/golioth-firmware-sdk.md @@ -1 +1 @@ -v0.22.0 +v0.23.0 diff --git a/docs/device-management/5-ota/3-managing-cohorts.md b/docs/device-management/5-ota/3-managing-cohorts.md index 21723811..9772f7d1 100644 --- a/docs/device-management/5-ota/3-managing-cohorts.md +++ b/docs/device-management/5-ota/3-managing-cohorts.md @@ -47,6 +47,11 @@ device in the table and clicking `Remove Device` in the top right corner. When you remove a device from a cohort, it stops receiving updates about its deployments. Contrary to when you added a device to a cohort, removing it will **not** prompt an immediate manifest change event on the device. +Devices running Golioth Firmware SDK v0.21.0 or later also fetch the manifest +periodically (once a day by default, configured with +`CONFIG_GOLIOTH_OTA_MANIFEST_SUBSCRIPTION_POLL_INTERVAL_S`) and pick up the +change then. + :::warning Fallback to legacy releases If you have previously used the old releases concept to distribute OTA updates, diff --git a/docs/device-management/7-settings/2-console-settings.md b/docs/device-management/7-settings/2-console-settings.md index 95ad3077..7c38eab7 100644 --- a/docs/device-management/7-settings/2-console-settings.md +++ b/docs/device-management/7-settings/2-console-settings.md @@ -82,8 +82,8 @@ Hover over the red-I icon to reveal the sync status message. ![Settings sync status](./assets/sync-status.png) For more information on types of sync status, see the `golioth_settings_status` -enumeration on [the Golioth Zephyr SDK -reference](https://zephyr-sdk-docs.golioth.io/group__golioth__settings.html). +enumeration in [the Golioth Firmware SDK +reference](https://firmware-sdk-docs.golioth.io/group__golioth__settings.html). ### Inheritance information on mouseover diff --git a/docs/getting-started/3-device-examples/1-precompiled-binaries/_partials/install_nrf_connect.md b/docs/getting-started/3-device-examples/1-precompiled-binaries/_partials/install_nrf_connect.md index ce44c02c..a895702a 100644 --- a/docs/getting-started/3-device-examples/1-precompiled-binaries/_partials/install_nrf_connect.md +++ b/docs/getting-started/3-device-examples/1-precompiled-binaries/_partials/install_nrf_connect.md @@ -2,8 +2,7 @@ Desktop](https://www.nordicsemi.com/Products/Development-tools/nRF-Connect-for-desktop) software. - 1. **Mac and Linux Users:** According to [the Nordic install - instructions](https://infocenter.nordicsemi.com/index.jsp?topic=/struct_nrftools/struct/nrftools_nrfconnect.html) + 1. **Mac and Linux Users:** According to the Nordic install instructions you also need to [install the SEGGER J-Link tools](https://www.segger.com/downloads/jlink/#J-LinkSoftwareAndDocumentationPack) diff --git a/docs/getting-started/3-device-examples/1-precompiled-binaries/thingy91.md b/docs/getting-started/3-device-examples/1-precompiled-binaries/thingy91.md index 484d5f31..9fe525f4 100644 --- a/docs/getting-started/3-device-examples/1-precompiled-binaries/thingy91.md +++ b/docs/getting-started/3-device-examples/1-precompiled-binaries/thingy91.md @@ -31,7 +31,7 @@ continue with this section. To program binaries to the Thingy91 we recommend starting with the [Nordic nRF Connect for -Desktop](https://infocenter.nordicsemi.com/index.jsp?topic=/struct_nrftools/struct/nrftools_nrfconnect.html) +Desktop](https://www.nordicsemi.com/Products/Development-tools/nRF-Connect-for-desktop) tools as they have great cross-platform support and work well. import InstallNrfConnect from './\_partials/install_nrf_connect.md' diff --git a/docs/getting-started/3-device-examples/2-compile-example-code/1-zephyr/01-set-up-zephyr.md b/docs/getting-started/3-device-examples/2-compile-example-code/1-zephyr/01-set-up-zephyr.md index 7bc56dbb..17c5ef96 100644 --- a/docs/getting-started/3-device-examples/2-compile-example-code/1-zephyr/01-set-up-zephyr.md +++ b/docs/getting-started/3-device-examples/2-compile-example-code/1-zephyr/01-set-up-zephyr.md @@ -44,20 +44,33 @@ and tools based on your specific hardware. $ west blobs fetch hal_espressif ``` + Flashing Espressif boards needs `esptool`, which is installed by the + `west packages pip --install` step above. + +- The NXP FRDM-RW612 WiFi build requires the NXP binary blobs: + + ```shell + $ west blobs fetch hal_nxp + ``` + - NXP evaluation kits usually offer on-board J-Link debugger support. To utilize this you will need to install Segger's [J-Link Software and Documentation Pack](https://www.segger.com/downloads/jlink). + On the FRDM-RW612, `west flash` uses J-Link by default, which needs the + on-board debug probe to run J-Link firmware (see [Configuring a Debug + Probe](https://docs.zephyrproject.org/4.3.0/boards/nxp/frdm_rw612/doc/index.html#configuring-a-debug-probe)). + If the probe runs NXP's CMSIS-DAP firmware instead, install + [LinkServer](https://docs.zephyrproject.org/4.3.0/develop/flash_debug/host-tools.html#linkserver-debug-host-tools) + and flash with `west flash -r linkserver`. + :::tip Device-Specific information in Zephyr's Board Index -Review your vendor's board support in the [Zephyr Board Index](https://docs.zephyrproject.org/latest/boards/index.html) to find more information on specific set up steps for your prefered hardware. +Review your vendor's board support in the [Zephyr Board Index](https://docs.zephyrproject.org/4.3.0/boards/index.html) to find more information on specific set up steps for your prefered hardware. ::: ## Build Sample Firmware -Your system is all set up and ready to start building & flashing with Zephyr. -Verify by building a minimal sample: - ### Build Firmware Your system is all set up and ready to start building & flashing with Zephyr. diff --git a/docs/getting-started/3-device-examples/2-compile-example-code/1-zephyr/02-zephyr-samples.md b/docs/getting-started/3-device-examples/2-compile-example-code/1-zephyr/02-zephyr-samples.md index eedd5f55..f62ab59d 100644 --- a/docs/getting-started/3-device-examples/2-compile-example-code/1-zephyr/02-zephyr-samples.md +++ b/docs/getting-started/3-device-examples/2-compile-example-code/1-zephyr/02-zephyr-samples.md @@ -8,7 +8,7 @@ import TabItem from '@theme/TabItem'; The Golioth Firmware SDK includes [a number of Zephyr example applications](https://github.com/golioth/golioth-firmware-sdk/tree/main/examples/zephyr) to demonstrate each of our services. In this section we'll build the `hello` -sample which connects to Golioth and sends "Hello Golioth! n" messages to our +sample which connects to Golioth and sends "Sending hello! n" messages to our remote logging service. This same configure→build→flash process may be applied to all of the @@ -20,18 +20,19 @@ These examples can be built for any hardware supported by Zephyr. However, each will need some device-specific configuration. Golioth maintains configurations for a range of development boards as part of our continuous integration (CI). -* [Nordic nRF52840 - DK](https://www.nordicsemi.com/Products/Development-hardware/nRF52840-DK) - using an ESP32 as an AT modem - ([details](https://github.com/golioth/golioth-firmware-sdk/tree/main/examples/zephyr/hello#nrf52840-dk--esp32-wroom-32)) -* [NXP i.MX 1024 Evaluation - Kit](https://www.nxp.com/design/design-center/development-boards/i-mx-evaluation-and-development-boards/i-mx-rt1024-evaluation-kit:MIMXRT1024-EVK) -* [ESP32 DevKitC - WROVER](https://www.espressif.com/en/products/devkits/esp32-devkitc) +* [Espressif + ESP32-S3-DevKitC-1](https://www.espressif.com/en/products/devkits/esp32-s3-devkitc-1) + (WiFi) +* [NXP + FRDM-RW612](https://www.nxp.com/design/design-center/development-boards-and-designs/FRDM-RW612) + (Ethernet or WiFi) + +The Nordic nRF9160 DK is covered on the [NCS +page](/getting-started/device-examples/compile-example-code/zephyr-ncs). This page includes build commands for these boards. You may model configuration for your own target hardware on the configuration and overlay files found in the -`boards` directory of each example application. +`boards` and `socs` directories of each example application. ## Build the `hello` code example @@ -71,7 +72,7 @@ cd modules/lib/golioth-firmware-sdk ```console -cd c:\golioth-zephyr-workspace +cd %HOMEPATH%\golioth-zephyr-workspace .venv\Scripts\activate.bat cd modules\lib\golioth-firmware-sdk ``` @@ -82,18 +83,18 @@ cd modules\lib\golioth-firmware-sdk ### Build the firmware and flashing the device - + ```console -west build -b nrf52840dk/nrf52840 examples/zephyr/hello +west build -b esp32s3_devkitc/esp32s3/procpu examples/zephyr/hello west flash ``` @@ -106,10 +107,10 @@ west flash ``` - + ```console -west build -b esp32_devkitc_wrover/esp32/procpu examples/zephyr/hello +west build -b frdm_rw612 examples/zephyr/hello -- -DEXTRA_CONF_FILE=boards/frdm_rw612_wifi.conf west flash ``` @@ -124,8 +125,16 @@ Zephyr Settings subsystem, and these can be set through the shell: ```console uart:~$ settings set golioth/psk-id uart:~$ settings set golioth/psk -uart:~$ settings set wifi/ssid -uart:~$ settings set wifi/psk +uart:~$ kernel reboot cold +``` + +Boards that connect over WiFi store the network with Zephyr's [WiFi +credentials](https://docs.zephyrproject.org/4.3.0/connectivity/networking/api/wifi_credentials.html) +library. For a WPA2-PSK network: + +```console +uart:~$ wifi cred add -k 1 -s -p +uart:~$ wifi cred auto_connect ```
@@ -171,6 +180,14 @@ messages listed in the Log tab: ![Golioth web console log messages](../assets/golioth-console-hello-log-messages.png) +:::note + +Logs reach the Log tab through a [CBOR logs +Pipeline](/data-routing/examples/golioth-logs-cbor). New projects include it +by default; older projects need to add it. + +::: + ## Additional Golioth Example Code Congratulations on running the Hello app! The same process may be used to run @@ -180,9 +197,10 @@ Be sure to reference the README file for each for detailed configuration and usage information. * **certificate_provisioning:** Use certificate authentication -* **firmware_update:** Use Golioth over-the-air (OTA) firmware update +* **certificate_rotation:** Rotate device certificates using Golioth PKI +* **fw_update:** Use Golioth over-the-air (OTA) firmware update * **hello:** Connect and send hello logging messages -* **lightdb:** Set, get, and observe stateful data between device and cloud +* **lightdb:** Set, get, observe, and delete stateful data between device and cloud * **location:** Use network information to determine device location * **logging:** Demonstrate logging messages of each different log level * **rpc:** Issue a remote procedure call (rpc) and received data back from device diff --git a/docs/getting-started/3-device-examples/2-compile-example-code/2-zephyr-ncs/01-set-up-ncs.md b/docs/getting-started/3-device-examples/2-compile-example-code/2-zephyr-ncs/01-set-up-ncs.md index 1ed02f1d..52b07c91 100644 --- a/docs/getting-started/3-device-examples/2-compile-example-code/2-zephyr-ncs/01-set-up-ncs.md +++ b/docs/getting-started/3-device-examples/2-compile-example-code/2-zephyr-ncs/01-set-up-ncs.md @@ -37,33 +37,39 @@ import InstallZephyrSDKtoolchain from '/docs/_partials-common/install-zephyr-sdk -## Install the Segger J-Link and nRF Command Line Tools +## Install the SEGGER J-Link software and nRF Util -Zephyr uses `nrfjprog` to flash Nordic targets using a hardware programmer like -the Segger J-Link, or the debugger that is built into the development kit (DK) -boards. This tool is part of the nRF Command Line Tools which we will install -along with the Segger tool. +`west flash` programs Nordic targets with nRF Util (`nrfutil device`), using the +SEGGER J-Link debugger that is built into the development kit (DK) boards. -1. Go to Segger and download the latest [J-Link Software and Documentation - Pack](https://www.segger.com/downloads/jlink) +1. Go to SEGGER and download the [J-Link Software and Documentation + Pack](https://www.segger.com/downloads/jlink). NCS v3.2.3 requires J-Link + v9.18. -2. Run the J-Link installer +2. Install J-Link: on macOS and Windows, run the downloaded installer; on + Debian and Ubuntu, install the downloaded package: ```bash - sudo dpkg -i JLink_Linux_V760f_x86_64.deb + sudo dpkg -i JLink_Linux__x86_64.deb ``` -3. Go to the [nRF Command Line - Tools](https://www.nordicsemi.com/Products/Development-tools/nrf-command-line-tools/download) - page. Scroll down, select your operating system, and download the installer - package. +3. Download + [nRF Util](https://www.nordicsemi.com/Products/Development-tools/nRF-Util/Download), + make it executable and move it to a directory that is in your `PATH`: -4. Run the nRF Command Line Tools installer + ```bash + chmod +x nrfutil + ``` + +4. Install the nRF Util device command ```bash - sudo dpkg -i nrf-command-line-tools_10.15.2_amd64.deb + nrfutil install device ``` +5. On Linux, install Nordic's [udev rules](https://github.com/NordicSemiconductor/nrf-udev) + which are required to access the USB ports of Nordic devices. + ## Build Sample Firmware ### Build firmware diff --git a/docs/getting-started/3-device-examples/2-compile-example-code/2-zephyr-ncs/02-zephyr-samples.md b/docs/getting-started/3-device-examples/2-compile-example-code/2-zephyr-ncs/02-zephyr-samples.md index ba291d0a..045f02c0 100644 --- a/docs/getting-started/3-device-examples/2-compile-example-code/2-zephyr-ncs/02-zephyr-samples.md +++ b/docs/getting-started/3-device-examples/2-compile-example-code/2-zephyr-ncs/02-zephyr-samples.md @@ -8,7 +8,7 @@ import TabItem from '@theme/TabItem'; The Golioth Firmware SDK includes [a number of Zephyr example applications](https://github.com/golioth/golioth-firmware-sdk/tree/main/examples/zephyr) to demonstrate each of our services. In this section we'll build the `hello` -sample which connects to Golioth and sends "Hello Golioth! n" messages to our +sample which connects to Golioth and sends "Sending hello! n" messages to our remote logging service. This same configure→build→flash process may be applied to all of the @@ -24,7 +24,7 @@ cellular development board as part of our continuous integration (CI). This page includes build commands for this board. You may model configuration for your own target hardware on the configuration and overlay files found in the -`boards` directory of each example application. +`boards` and `socs` directories of each example application. ## Build the `hello` code example @@ -64,7 +64,7 @@ cd modules/lib/golioth-firmware-sdk ```console -cd c:\golioth-ncs-workspace +cd %HOMEPATH%\golioth-ncs-workspace .venv\Scripts\activate.bat cd modules\lib\golioth-firmware-sdk ``` @@ -88,6 +88,7 @@ through the shell: ```console uart:~$ settings set golioth/psk-id uart:~$ settings set golioth/psk +uart:~$ kernel reboot cold ```
@@ -137,6 +138,14 @@ messages listed in the Log tab: ![Golioth web console log messages](../assets/golioth-console-hello-log-messages.png) +:::note + +Logs reach the Log tab through a [CBOR logs +Pipeline](/data-routing/examples/golioth-logs-cbor). New projects include it +by default; older projects need to add it. + +::: + ## Additional Golioth Example Code Congratulations on running the Hello app! The same process may be used to run @@ -146,9 +155,11 @@ Be sure to reference the README file for each for detailed configuration and usage information. * **certificate_provisioning:** Use certificate authentication -* **firmware_update:** Use Golioth over-the-air (OTA) firmware update +* **certificate_rotation:** Rotate device certificates using Golioth PKI +* **fw_update:** Use Golioth over-the-air (OTA) firmware update * **hello:** Connect and send hello logging messages -* **lightdb:** Set, get, and observe stateful data between device and cloud +* **hello_nrf91_offloaded:** Connect using the nRF91 modem's offloaded DTLS sockets +* **lightdb:** Set, get, observe, and delete stateful data between device and cloud * **location:** Use network information to determine device location * **logging:** Demonstrate logging messages of each different log level * **rpc:** Issue a remote procedure call (rpc) and received data back from device diff --git a/docs/getting-started/3-device-examples/2-compile-example-code/3-esp-idf/2-flash-sample.md b/docs/getting-started/3-device-examples/2-compile-example-code/3-esp-idf/2-flash-sample.md index ed85377a..17a81658 100644 --- a/docs/getting-started/3-device-examples/2-compile-example-code/3-esp-idf/2-flash-sample.md +++ b/docs/getting-started/3-device-examples/2-compile-example-code/3-esp-idf/2-flash-sample.md @@ -3,21 +3,25 @@ id: flash-sample title: Flashing with samples --- -Now we're getting to the good stuff - working with hardware! The sample project -provided will demonstrate a device securely communicating with Golioth and will -demonstrate core features like LightDB State/Stream, Logging, and OTA Updates. +Now we're getting to the good stuff - working with hardware! The `hello` sample +connects securely to Golioth and sends a log message every 5 seconds. -### Build the `golioth_basics` code example +### Build the `hello` code example Golioth Firmware SDK example code is located in the -`golioth-firmware-sdk/examples/esp_idf`. Navigate to the `golioth_basics` example and run -the following code to build the example app: +`golioth-firmware-sdk/examples/esp_idf`. Navigate to the `hello` example and run +the following code to build the example app for the ESP32-S3 (use the target +that matches your chip if it is a different one, e.g. `esp32c3`): ```console -idf.py set-target esp32 +cd ~/golioth-firmware-sdk/examples/esp_idf/hello +idf.py set-target esp32s3 idf.py build ``` +On Windows, the first command is +`cd %HOMEPATH%\golioth-firmware-sdk\examples\esp_idf\hello`. + ### Flashing the device Flashing is a simple `idf.py` command away. @@ -41,21 +45,19 @@ Connect to the device over a serial console. This can be done using a tool like idf.py monitor ``` -Press enter to see the command prompt and type `reset` to restart the device. -You will see boot information followed by a warning that credentials cannot be -located: +Press enter to see the command prompt. Until the WiFi credentials are set, the +sample logs a warning that tells you to use the shell `settings` commands. The +shell greeting looks like this: ```console Type 'help' to get the list of commands. Use UP/DOWN arrows to navigate through command history. Press TAB when typing command name to auto-complete. Press Enter or Ctrl+C will terminate the console environment. -esp32> W (2721) golioth_example: WiFi and golioth credentials are not set -W (2721) golioth_example: Use the shell settings commands to set them, then restart ``` -Use the `settings set ` syntax to set the for required items. Your -Golioth PSK-ID and PSK can be found on the device page of [the Golioth +Use the `settings set ` syntax to set the four required items. +Your Golioth PSK-ID and PSK can be found on the device page of [the Golioth Console](https://console.golioth.io). Use the `reset` command once you've set these credentials to restart the device. @@ -71,30 +73,28 @@ Setting golioth/psk saved esp32> reset ``` -The result should be a successful connection to Golioth. +The result should be a successful connection to Golioth. The device joins the +WiFi network and the CoAP session to Golioth is established. The SSID and +PSK-ID in this output are example values; yours will differ: ```console -I (3762) esp_netif_handlers: sta ip: 192.168.1.195, mask: 255.255.255.0, gw: 192.168.1.1 -I (3762) example_wifi: WiFi Connected. Got IP:192.168.1.195 -I (3772) example_wifi: Connected to AP SSID: MyWiFiAP -I (3792) golioth_coap_client: Start CoAP session -I (3802) libcoap: Setting PSK key - -I (3802) golioth_coap_client: Entering CoAP I/O loop -I (4042) golioth_example: Golioth client connected -I (4102) golioth_fw_update: Current firmware version: 1.2.3 -I (4222) golioth_fw_update: Waiting to receive OTA manifest -I (4342) golioth_fw_update: Received OTA manifest -I (4342) golioth_fw_update: Manifest does not contain different firmware version. Nothing to do. -I (4352) golioth_fw_update: Waiting to receive OTA manifest -I (4402) golioth_example: Synchronously got my_int = 42 -I (4412) golioth_example: Entering endless loop -I (4462) golioth_example: Callback got my_int = 42 - +I (3200) esp_netif_handlers: sta ip: 192.168.200.7, mask: 255.255.255.0, gw: 192.168.200.1 +I (3200) example_wifi: WiFi Connected. Got IP:192.168.200.7 +I (3210) example_wifi: Connected to AP SSID: golioth +I (3210) golioth_mbox: Mbox created, bufsize: 2520, num_items: 20, item_size: 120 +I (3250) golioth_coap_client_libcoap: Start CoAP session with host: coaps://coap.golioth.io +I (3250) golioth_coap_client_libcoap: Session PSK-ID: devboard-one-id@ttgo-demo +I (3270) libcoap: Setting PSK key + +I (3270) golioth_coap_client_libcoap: Entering CoAP I/O loop +I (3720) golioth_coap_client_libcoap: Golioth CoAP client connected ``` +The `hello` sample then logs `Golioth client connected` and, every 5 seconds, +`Sending hello! ` with an increasing counter. + You can exit from the ESP-IDF Monitor tool using `CTRL-]`. (A help menu can be displayed by typing `CTRL-T` followed by `CTRL-H`.) Congratulations! On the next page, we'll look at how Over-the-Air (OTA) firmware -updates work with this sample. +updates work using the `fw_update` sample. diff --git a/docs/getting-started/3-device-examples/2-compile-example-code/3-esp-idf/3-ota.md b/docs/getting-started/3-device-examples/2-compile-example-code/3-esp-idf/3-ota.md index d553161e..ff6c8046 100644 --- a/docs/getting-started/3-device-examples/2-compile-example-code/3-esp-idf/3-ota.md +++ b/docs/getting-started/3-device-examples/2-compile-example-code/3-esp-idf/3-ota.md @@ -5,35 +5,47 @@ title: Over-the-Air (OTA) Firmware Update The most sought after Golioth feature is Over-the-Air firmware update (OTA). The ability to update firmware is crucial to building a robust and reliable IoT -fleet. This is built into the Golioth SDK and the `golioth_basics` sample we -ran on the previous page includes this feature. Let's try it out! +fleet. The Golioth Firmware SDK provides the OTA service, and the ESP-IDF +`fw_update` sample implements firmware updates on top of it. Let's try it out! ## Overview -On this page we'll cover four steps to completing an OTA update: +On this page we'll cover the steps to completing an OTA update: +* Build and flash the initial `fw_update` firmware * Change the version number in the sourcecode and build the binary * Upload the binary to Golioth as a new Package * Assign the device(s) to a Cohort * Deploy the package to the device(s) -## Update version number and build firmware +## Build and flash the initial firmware + +Build the `fw_update` sample for the ESP32-S3 and flash it to the device: + +```console +cd ~/golioth-firmware-sdk/examples/esp_idf/fw_update +idf.py set-target esp32s3 +idf.py build flash monitor +``` + +On Windows, the first command is +`cd %HOMEPATH%\golioth-firmware-sdk\examples\esp_idf\fw_update`. + +Set the WiFi and Golioth credentials with the `settings set` commands from the +previous page, then type `reset`. The device reports firmware version `1.2.3` +to Golioth. -The `golioth_basics` sample uses a common file located at -`golioth-firmware-sdk/examples/common/golioth_basics.c`. Edit this file, -updating the version number to `1.2.6`. For fun, also change the tag name to -`golioth_basics_new` just so it's easy to see from the logging messages that a -new firmware version is running. +## Update version number and build firmware -```c title="changes to: golioth-firmware-sdk/examples/common/golioth_basics.c" -LOG_TAG_DEFINE(golioth_basics_new); +Edit `golioth-firmware-sdk/examples/esp_idf/fw_update/main/app_main.c`, +updating the version number to `1.2.6`: -// Current firmware version -static const char* _current_version = "1.2.6"; +```c title="changes to: golioth-firmware-sdk/examples/esp_idf/fw_update/main/app_main.c" +static const char *_current_version = "1.2.6"; ``` -Now return to the `golioth-firmware-sdk/examples/esp_idf/golioth_basics` folder -and rebuild the example. +Now rebuild the example from the same +`golioth-firmware-sdk/examples/esp_idf/fw_update` folder. ```shell idf.py build @@ -47,7 +59,7 @@ the new binary to the device over WiFi. ::: After running the build command, your new binary will be located at -`build/golioth_basics.bin`. +`build/fw_update.bin`. ## Upload the binary to Golioth and deploy it to your device @@ -75,7 +87,7 @@ Console](assets/golioth-OTA-upload-artifact.png) * Set the **Artifact Version to 1.2.6** (to match what was compiled into the firmware) * Click the upload button in the middle of the window and choose your - `golioth_basics.bin` file. + `fw_update.bin` file. * Click the **Upload Artifact** button to finish creating an artifact. ### 3. Assign the device to a Cohort @@ -113,68 +125,61 @@ update. In the terminal window you see the ESP32 almost immediately recognizes that new firmware is available: -```shell -I (175827) golioth_basics: Sending hello! 17 -I (185007) golioth_fw_update: Received OTA manifest -I (185007) golioth_fw_update: Current version = 1.2.5, Target version = 1.2.6 -I (185017) golioth_fw_update: State = Downloading -I (185317) golioth_fw_update: Image size = 1211744 -I (185327) golioth_fw_update: Getting block index 0 (1/1184) -I (185827) golioth_basics: Sending hello! 18 -W (187867) golioth_coap_client: CoAP message retransmitted -I (187947) fw_update_esp_idf: Writing to partition subtype 17 at offset 0x1a0000 -I (187947) fw_update_esp_idf: Erasing flash -I (191627) golioth_fw_update: Getting block index 1 (2/1184) -I (191837) golioth_fw_update: Getting block index 2 (3/1184) -I (192037) golioth_fw_update: Getting block index 3 (4/1184) -I (192187) golioth_fw_update: Getting block index 4 (5/1184) -I (192447) golioth_fw_update: Getting block index 5 (6/1184) -I (192597) golioth_fw_update: Getting block index 6 (7/1184) -... snip ... -I (279837) golioth_fw_update: Getting block index 1181 (1182/1184) -I (280107) golioth_fw_update: Getting block index 1182 (1183/1184) -I (280317) golioth_fw_update: Getting block index 1183 (1184/1184) -I (280457) golioth_fw_update: Total bytes written: 1211760 -I (280467) esp_image: segment 0: paddr=001a0020 vaddr=3f400020 size=29df0h (171504) map -I (280527) esp_image: segment 1: paddr=001c9e18 vaddr=3ffbdb60 size=05868h ( 22632) -I (280537) esp_image: segment 2: paddr=001cf688 vaddr=40080000 size=00990h ( 2448) -I (280547) esp_image: segment 3: paddr=001d0020 vaddr=400d0020 size=d9a64h (891492) map -I (280847) esp_image: segment 4: paddr=002a9a8c vaddr=40080990 size=1e2a0h (123552) -I (280887) esp_image: segment 5: paddr=002c7d34 vaddr=50000000 size=00010h ( 16) -I (280887) golioth_fw_update: State = Downloaded -I (281127) golioth_fw_update: State = Updating -I (281327) fw_update_esp_idf: Setting boot partition -I (281337) esp_image: segment 0: paddr=001a0020 vaddr=3f400020 size=29df0h (171504) map -I (281397) esp_image: segment 1: paddr=001c9e18 vaddr=3ffbdb60 size=05868h ( 22632) -I (281417) esp_image: segment 2: paddr=001cf688 vaddr=40080000 size=00990h ( 2448) -I (281417) esp_image: segment 3: paddr=001d0020 vaddr=400d0020 size=d9a64h (891492) map -I (281717) esp_image: segment 4: paddr=002a9a8c vaddr=40080990 size=1e2a0h (123552) -I (281757) esp_image: segment 5: paddr=002c7d34 vaddr=50000000 size=00010h ( 16) -I (281827) golioth_fw_update: Rebooting into new image in 5 seconds -I (282827) golioth_fw_update: Rebooting into new image in 4 seconds -I (283827) golioth_fw_update: Rebooting into new image in 3 seconds -I (284827) golioth_fw_update: Rebooting into new image in 2 seconds -I (285827) golioth_fw_update: Rebooting into new image in 1 seconds -... snip ... -I (4267) esp_netif_handlers: sta ip: 192.168.1.159, mask: 255.255.255.0, gw: 192.168.1.1 -I (4267) example_wifi: WiFi Connected. Got IP:192.168.1.159 -I (4277) example_wifi: Connected to AP SSID: TheNewPeachRepublic -I (4287) golioth_mbox: Mbox created, bufsize: 2184, num_items: 20, item_size: 104 -I (4287) golioth_basics_new: Waiting for connection to Golioth... -W (4297) wifi:idx:0 (ifx:0, c6:ff:d4:a8:fa:10), tid:0, ssn:1, winSize:64 -I (4307) golioth_coap_client: Start CoAP session with host: coaps://coap.golioth.io -I (4307) libcoap: Setting PSK key -I (4317) golioth_coap_client: Entering CoAP I/O loop -I (4637) golioth_basics_new: Golioth client connected -I (4647) golioth_coap_client: Golioth CoAP client connected -I (4657) golioth_basics_new: Hello, Golioth! -I (4657) golioth_fw_update: Current firmware version: 1.2.6 -I (4657) golioth_fw_update: Waiting for golioth client to connect before cancelling rollback -I (4677) golioth_fw_update: Firmware updated successfully! -I (4727) golioth_fw_update: State = Idle -I (5937) golioth_basics_new: Synchronously got my_int = 42 -I (5937) golioth_basics_new: Entering endless loop -I (5937) golioth_basics_new: Sending hello! 0 +```console +I (31160) golioth_fw_update: Received OTA manifest +I (31160) golioth_fw_update: Current version = 1.2.3, Target version = 1.2.6 +I (31160) golioth_fw_update: State = Downloading +I (31940) golioth_fw_update: Received block 0/921 +I (31950) fw_update_esp_idf: Writing to partition subtype 17 at offset 0x1a0000 +I (31950) fw_update_esp_idf: Erasing flash +W (34400) golioth_coap_client_libcoap: CoAP message retransmitted +I (36970) golioth_fw_update: Received block 1/921 +I (37480) golioth_fw_update: Received block 2/921 +I (38030) golioth_fw_update: Received block 3/921 + +... + +I (243900) golioth_fw_update: Received block 919/921 +I (244010) golioth_fw_update: Received block 920/921 +I (244110) golioth_fw_update: Received block 921/921 +I (244120) golioth_fw_update: Successfully downloaded 943248 bytes in 212390 ms +I (244120) esp_image: segment 0: paddr=001a0020 vaddr=3f400020 size=2efach (192428) map +I (244200) esp_image: segment 1: paddr=001cefd4 vaddr=3ffb0000 size=01044h ( 4164) +I (244210) esp_image: segment 2: paddr=001d0020 vaddr=400d0020 size=9d4d4h (644308) map +I (244430) esp_image: segment 3: paddr=0026d4fc vaddr=3ffb1044 size=02dc0h ( 11712) +I (244440) esp_image: segment 4: paddr=002702c4 vaddr=40080000 size=161a0h ( 90528) +I (244480) golioth_fw_update: State = Downloaded +I (244680) golioth_fw_update: State = Updating +I (244780) fw_update_esp_idf: Setting boot partition +I (244780) esp_image: segment 0: paddr=001a0020 vaddr=3f400020 size=2efach (192428) map +I (244850) esp_image: segment 1: paddr=001cefd4 vaddr=3ffb0000 size=01044h ( 4164) +I (244860) esp_image: segment 2: paddr=001d0020 vaddr=400d0020 size=9d4d4h (644308) map +I (245080) esp_image: segment 3: paddr=0026d4fc vaddr=3ffb1044 size=02dc0h ( 11712) +I (245090) esp_image: segment 4: paddr=002702c4 vaddr=40080000 size=161a0h ( 90528) +I (245160) golioth_fw_update: Rebooting into new image in 5 seconds +I (246170) golioth_fw_update: Rebooting into new image in 4 seconds +I (247170) golioth_fw_update: Rebooting into new image in 3 seconds +I (248170) golioth_fw_update: Rebooting into new image in 2 seconds +I (249170) golioth_fw_update: Rebooting into new image in 1 seconds + +... + +I (5262) esp_netif_handlers: sta ip: 192.168.200.7, mask: 255.255.255.0, gw: 192.168.200.1 +I (5262) example_wifi: WiFi Connected. Got IP:192.168.200.7 +I (5272) example_wifi: Connected to AP SSID: golioth +I (5282) golioth_mbox: Mbox created, bufsize: 2520, num_items: 20, item_size: 120 +W (5282) fw_update: Waiting for connection to Golioth... +I (5312) golioth_coap_client_libcoap: Start CoAP session with host: coaps://coap.golioth.io +I (5322) golioth_coap_client_libcoap: Session PSK-ID: devboard-one-id@ttgo-demo +I (5332) libcoap: Setting PSK key + +I (5342) golioth_coap_client_libcoap: Entering CoAP I/O loop +I (5632) golioth_coap_client_libcoap: Golioth CoAP client connected +I (5642) fw_update: Golioth client connected +W (5642) fw_update: Current FW Version: 1.2.6 +I (5652) golioth_fw_update: Current firmware version: main - 1.2.6 +I (5662) golioth_fw_update: Waiting for golioth client to connect before cancelling rollback +I (5662) golioth_fw_update: Firmware updated successfully! ``` 1. The firmware will be downloaded in blocks @@ -182,14 +187,6 @@ I (5937) golioth_basics_new: Sending hello! 0 3. After reset, the ESP32 will connect to Golioth and confirm it is running the most recent firmware version -:::tip Log messages show the new tag name - -Look closely at the terminal output and you'll see the tag name in the log -messages have changed to `golioth_basics_new`. This is because of the change we -made in the sourcecode before compiling the new firmware. - -::: - ## Confirm the new firmware version on the Golioth Console After an OTA update, devices report their firmware version to Golioth. diff --git a/docs/getting-started/3-device-examples/2-compile-example-code/3-esp-idf/4-cloud-data.md b/docs/getting-started/3-device-examples/2-compile-example-code/3-esp-idf/4-cloud-data.md index 62f47eaa..93b98987 100644 --- a/docs/getting-started/3-device-examples/2-compile-example-code/3-esp-idf/4-cloud-data.md +++ b/docs/getting-started/3-device-examples/2-compile-example-code/3-esp-idf/4-cloud-data.md @@ -3,77 +3,89 @@ id: view-cloud-data title: View Cloud Data --- -The `golioth_basics` sample sent several different types of data to the Golioth -Cloud. Included are LightDB State (persistent data), LightDB Stream (time-series -data), and Log messages. All of these can be view from [the Golioth Web +The ESP-IDF samples send different types of data to the Golioth Cloud. Included +are LightDB State (persistent data), Stream (time-series data routed by +Pipelines), and Log messages. All of these can be viewed from [the Golioth Web Console](https://console.golioth.io). ### Viewing LightDB State data ![LightDB State Data](./assets/golioth-espidf-state.png) -State data shows the last updated value for each endpoint. The example app -updates the "iteration" endpoint every 10 seconds; what is shown is the most -recent value of that counter. The example app also sets the "my_string" and -"my_data" endpoints once at run time. +State data shows the last updated value for each endpoint. The [`lightdb/set` +sample](https://github.com/golioth/golioth-firmware-sdk/tree/main/examples/esp_idf/lightdb/set) +updates the `counter` endpoint every 5 seconds; what is shown is the most +recent value of that counter. ```c -golioth_lightdb_set_int_async(client, "iteration", iteration, NULL, NULL); -golioth_lightdb_set_string_sync(client, "my_string", "asdf", 4, 5); -golioth_lightdb_set_int_async(client, "my_int", 42, NULL, NULL); +golioth_lightdb_set_int(client, "counter", counter, counter_set_handler, NULL); ``` -All of these calls are well-documented in the comments of the example app's -`main.c` file. +Build the sample from the `golioth-firmware-sdk/examples/esp_idf/lightdb/set` +folder as described on the previous pages. Its README also explains how to +enable the LightDB State service (`CONFIG_GOLIOTH_LIGHTDB_STATE`) in +`idf.py menuconfig`. ### Viewing LightDB Stream data ![LightDB Stream Data](./assets/golioth-espidf-stream.png) -Streaming data is sent just one time in this app. The view shown here is the -result of restarting the device multiple times. Notice that the timestamp -automatically applied to this data can be used to indicate the time of each -reboot. +Streaming data is routed by [Pipelines](/data-routing) on the Golioth Cloud. The +[`stream` sample](https://github.com/golioth/golioth-firmware-sdk/tree/main/examples/esp_idf/stream) +sends a CBOR-encoded temperature reading to the `data` path every 5 seconds. +The default Pipeline that every new project includes stores the data in +LightDB Stream, where the timestamp applied to each reading is visible in the +console. ```c -golioth_stream_set_int_async(client, "my_stream_int", 15, NULL, NULL); +golioth_stream_set(client, + "data", + GOLIOTH_CONTENT_TYPE_CBOR, + buf, + payload_size, + temperature_push_handler, + NULL); ``` ### Viewing Logs on the Golioth Web Console ![Log Messages](./assets/golioth-espidf-logs.png) -You can see in the Log view the example app sends a "main loop" message every 10 -seconds using this command: +The samples set `CONFIG_GOLIOTH_AUTO_LOG_TO_CLOUD=y`, so messages logged with +the `GLTH_LOGx` macros are also sent to Golioth. For example, the `hello` +sample sends this message every 5 seconds: ```c -golioth_log_info_async(client, "app_main", "main loop", NULL, NULL); +GLTH_LOGI(TAG, "Sending hello! %d", counter); ``` +:::note + +Logs reach the Log tab through a [CBOR logs +Pipeline](/data-routing/examples/golioth-logs-cbor). New projects include it +by default; older projects need to add it. + +::: + ### Viewing Data with the `goliothctl` command line tool -It is also possible to view all of this data via the Golioth command line tools. As an example, this command shows the last minute of logs: +It is also possible to view all of this data via the Golioth command line tools. +As an example, this command shows the last minute of logs: ```console $ goliothctl logs --interval 1m -[2022-07-20T22:06:57Z] level:INFO module:"app_main" message:"main loop" device_id:"62cf3a26f810c89ed3002af0" metadata:"{}" -[2022-07-20T22:07:02Z] level:INFO module:"app_main" message:"Hello, World!" device_id:"62cf3a26f810c89ed3002af0" metadata:"{}" -[2022-07-20T22:07:02Z] level:WARN module:"app_main" message:"Sync log" device_id:"62cf3a26f810c89ed3002af0" metadata:"{}" -[2022-07-20T22:07:02Z] type:DIAGNOSTICS level:INFO module:"golioth_dfu" message:"main(IDLE): ready state" device_id:"62cf3a26f810c89ed3002af0" metadata:"{"package":"main","reason":"ready state","reasonCode":"0","state":"IDLE","stateCode":"0","target":"","time":"2022-07-20T22:07:02.788082332Z","version":"1.2.3"}" -[2022-07-20T22:07:06Z] level:INFO module:"app_main" message:"main loop" device_id:"62cf3a26f810c89ed3002af0" metadata:"{}" -[2022-07-20T22:07:13Z] level:INFO module:"app_main" message:"main loop" device_id:"62cf3a26f810c89ed3002af0" metadata:"{}" -[2022-07-20T22:07:23Z] level:INFO module:"app_main" message:"main loop" device_id:"62cf3a26f810c89ed3002af0" metadata:"{}" -[2022-07-20T22:07:33Z] level:INFO module:"app_main" message:"main loop" device_id:"62cf3a26f810c89ed3002af0" metadata:"{}" -[2022-07-20T22:07:45Z] level:INFO module:"app_main" message:"Hello, World!" device_id:"62cf3a26f810c89ed3002af0" metadata:"{}" -[2022-07-20T22:07:45Z] level:WARN module:"app_main" message:"Sync log" device_id:"62cf3a26f810c89ed3002af0" metadata:"{}" -[2022-07-20T22:07:45Z] type:DIAGNOSTICS level:INFO module:"golioth_dfu" message:"main(IDLE): ready state" device_id:"62cf3a26f810c89ed3002af0" metadata:"{"package":"main","reason":"ready state","reasonCode":"0","state":"IDLE","stateCode":"0","target":"","time":"2022-07-20T22:07:45.765798699Z","version":"1.2.3"}" -[2022-07-20T22:07:46Z] level:INFO module:"app_main" message:"main loop" device_id:"62cf3a26f810c89ed3002af0" metadata:"{}" ``` -You can also filter logs. Here is a similar output, but we've filtered to shown only `WARN` level logs and above. +You can also filter logs. This command shows only `WARN` level logs and above +from the last five minutes: ```console $ goliothctl logs --interval 5m --level WARN -[2022-07-20T22:07:02Z] level:WARN module:"app_main" message:"Sync log" device_id:"62cf3a26f810c89ed3002af0" metadata:"{}" -[2022-07-20T22:07:45Z] level:WARN module:"app_main" message:"Sync log" device_id:"62cf3a26f810c89ed3002af0" metadata:"{}" +``` + +The current value of the `counter` set by the `lightdb/set` sample can be +fetched with: + +```console +$ goliothctl lightdb get /counter ``` diff --git a/docs/getting-started/3-device-examples/2-compile-example-code/3-esp-idf/README.md b/docs/getting-started/3-device-examples/2-compile-example-code/3-esp-idf/README.md index 0fa261f5..25c20b78 100644 --- a/docs/getting-started/3-device-examples/2-compile-example-code/3-esp-idf/README.md +++ b/docs/getting-started/3-device-examples/2-compile-example-code/3-esp-idf/README.md @@ -6,7 +6,7 @@ title: ESP-IDF with Golioth ## What is ESP-IDF? The Espressif IoT Development Framework -([ESP-IDF](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/)) is a +([ESP-IDF](https://docs.espressif.com/projects/esp-idf/en/v5.4.1/esp32s3/)) is a FreeRTOS-based platform developed and maintained by [Espressif Systems](https://espressif.com/) for their line of ESP32 microcontrollers. The Golioth Firmware SDK can be included in your projects as an ESP-IDF component. @@ -17,6 +17,8 @@ The ESP32 is a Wi-Fi and Bluetooth combination chip. There are multiple versions of the chip, including the ESP32, ESP32-S2, and ESP32-S3 based on the Xtensa core and the ESP32-C3 which uses the RISC-V core. -Golioth works with all ESP32 variants supported by the ESP-IDF platform. This -section shows how to set up your build environment, compile, and run demo code -that connects to Golioth. +Golioth works with ESP32 variants supported by the ESP-IDF platform. Golioth +continuously tests the ESP-IDF samples on the ESP32-S3-DevKitC-1, so this +section uses the ESP32-S3 as its target; for other chips, set the matching +target with `idf.py set-target`. This section shows how to set up your build +environment, compile, and run demo code that connects to Golioth. diff --git a/docs/getting-started/3-device-examples/2-compile-example-code/README.md b/docs/getting-started/3-device-examples/2-compile-example-code/README.md index bf974f8b..5db80e16 100644 --- a/docs/getting-started/3-device-examples/2-compile-example-code/README.md +++ b/docs/getting-started/3-device-examples/2-compile-example-code/README.md @@ -21,9 +21,8 @@ Golioth maintains a special level of support for a number of different development boards using Hardware-in-the-Loop testing. You will find a fast path to success by testing Golioth using one of these boards: -* Espressif ESP32-devkitc/ESP32S3-devkitc/ESP32C3-devkitm -* Nordic nRF9160DK -* Nordic nRF52840 + ESP32 (AT Modem) -* NXP FRDM-RW612 +* Espressif ESP32-S3-DevKitC-1 (Zephyr and ESP-IDF) +* Nordic nRF9160 DK (nRF Connect SDK) +* NXP FRDM-RW612 (Zephyr, Ethernet and WiFi) ::: diff --git a/docs/reference/2-device-api/3-api-docs/7-ota.md b/docs/reference/2-device-api/3-api-docs/7-ota.md index 7a1dc3d6..a3547e01 100644 --- a/docs/reference/2-device-api/3-api-docs/7-ota.md +++ b/docs/reference/2-device-api/3-api-docs/7-ota.md @@ -66,7 +66,7 @@ currently downloading an update of the `main` package; going from the current ```json { - "state": 3, + "state": 1, "reason": 0, "package": "main", "version": "1.2.3", @@ -89,7 +89,7 @@ currently downloading an update of the `main` package; going from the current | 0 | Idle | | 1 | Downloading | | 2 | Downloaded | -| 3 | Updated | +| 3 | Updating | - The list of `state` codes, can be viewed in the [golioth_ota_state](https://firmware-sdk-docs.golioth.io/group__golioth__ota.html) diff --git a/docs/reference/5-firmware/1-golioth-firmware-sdk/authentication/certificate-auth.md b/docs/reference/5-firmware/1-golioth-firmware-sdk/authentication/certificate-auth.md index 33de36da..81bc069a 100644 --- a/docs/reference/5-firmware/1-golioth-firmware-sdk/authentication/certificate-auth.md +++ b/docs/reference/5-firmware/1-golioth-firmware-sdk/authentication/certificate-auth.md @@ -18,8 +18,9 @@ device, the following example demonstrates one way in which a server CA certificate (`ca_cert`), device certificate (`public_cert`), and private key (`private_key`) can be passed to the Golioth client. -All data is expected to be provided as DER encoded. To convert PEM files to DER, -the following `openssl` commands can be used. +On Zephyr, provide the certificate and key DER encoded. The ESP-IDF and Linux +certificate examples pass PEM files instead. To convert PEM files to DER, the +following `openssl` commands can be used. ``` openssl x509 -in device.crt.pem -outform DER -out device.crt.der @@ -30,14 +31,18 @@ openssl ec -in device.key.pem -outform DER -out device.key.der ``` ```c -/* Get the Golioth CA Certificate from the Golioth SDK */ +/* Golioth server CA certificates, embedded by the Zephyr port of the SDK */ static const uint8_t tls_ca_crt[] = { #include "golioth-systemclient-ca_crt.inc" }; +static const uint8_t tls_secondary_ca_crt[] = { +#include "golioth-systemclient-secondary_ca_crt.inc" +}; + int main(void) { - uint8_t* device_crt = pointer_to_your_crt_der_byte_array; - uint8_t* device_key = pointer_to_your_key_der_byte_array; + const uint8_t *device_crt = pointer_to_your_crt_der_byte_array; + const uint8_t *device_key = pointer_to_your_key_der_byte_array; size_t device_crt_len = sizeof_your_crt_der_byte_array; size_t device_key_len = sizeof_your_key_der_byte_array; @@ -45,15 +50,17 @@ int main(void) { .credentials = { .auth_type = GOLIOTH_TLS_AUTH_TYPE_PKI, .pki = { - .ca_cert = server_ca_crt, - .ca_cert_len = sizeof(server_ca_crt), + .ca_cert = tls_ca_crt, + .ca_cert_len = sizeof(tls_ca_crt), .public_cert = device_crt, .public_cert_len = device_crt_len, .private_key = device_key, .private_key_len = device_key_len, + .secondary_ca_cert = tls_secondary_ca_crt, + .secondary_ca_cert_len = sizeof(tls_secondary_ca_crt), }}}; - golioth_client_t client = golioth_client_create(&client_config); + struct golioth_client *client = golioth_client_create(&client_config); /* Continue program flow */ } diff --git a/docs/reference/5-firmware/1-golioth-firmware-sdk/authentication/examples-zephyr.md b/docs/reference/5-firmware/1-golioth-firmware-sdk/authentication/examples-zephyr.md index e2e8ad31..6b6eb1bf 100644 --- a/docs/reference/5-firmware/1-golioth-firmware-sdk/authentication/examples-zephyr.md +++ b/docs/reference/5-firmware/1-golioth-firmware-sdk/authentication/examples-zephyr.md @@ -5,33 +5,6 @@ sidebar_position: 4 # Examples: Zephyr -## Hardcoding Certificates for samples - -All of our Firmware SDK samples for Zephyr can be compiled with hardcoded -certificate credentials. As an example, build [the Golioth `hello` sample -code](https://github.com/golioth/golioth-firmware-sdk/tree/main/examples/zephyr/hello). - -:::note For prototyping only - -Using a hardcoded certificate is an easy way to start using and test -certificate based authentication. It should not be used in production. - -::: - -1. Set the project to use Certificate Authentication - - As outlined in the [Certificate based auth - section](https://github.com/golioth/golioth-firmware-sdk/tree/main/examples/zephyr/hello#certificate-based-auth) - of that sample's README, a few Kconfig symbols need to be set in the - `prj.conf` file: - - ``` - CONFIG_GOLIOTH_AUTH_METHOD_CERT=y - CONFIG_GOLIOTH_SAMPLE_HARDCODED_CRT_PATH="keys/device.crt.der" - CONFIG_GOLIOTH_SAMPLE_HARDCODED_KEY_PATH="keys/device.key.der" - ``` -2. Build and flash the firmware following the instructions in the [README](https://github.com/golioth/golioth-zephyr-sdk/tree/main/samples/hello). - ## Provisioning Certificates sample [The `certificate_provisioning` @@ -41,12 +14,19 @@ store device certificates on non-volatile flash memory. This way, each device has its own unique certificates, and future firmware updates will not overwrite these stored credentials. +The [`certificate_rotation` +sample](https://github.com/golioth/golioth-firmware-sdk/tree/main/examples/zephyr/certificate_rotation) +starts from certificates provisioned the same way and then uses Golioth PKI to +request a new certificate from Golioth. + The following steps are covered in the code example: 1. Generate a set of root and device certificates [using the Golioth Docs as a guide](/connectivity/credentials/pki/offline-pki#generating-device-certificates). 2. Compile and flash the firmware example onto the device. -3. Use `mcumgr` to copy the device certificates onto the device filesystem. +3. Use `mcumgr` to copy the device certificate and key (DER) to + `/lfs1/credentials/crt.der` and `/lfs1/credentials/key.der` on the device + filesystem. 4. Upload the root certificate to Golioth. The project-id for your Golioth project is supplied as part of the device diff --git a/docs/reference/5-firmware/1-golioth-firmware-sdk/authentication/psk-auth.md b/docs/reference/5-firmware/1-golioth-firmware-sdk/authentication/psk-auth.md index f72f0720..92c37478 100644 --- a/docs/reference/5-firmware/1-golioth-firmware-sdk/authentication/psk-auth.md +++ b/docs/reference/5-firmware/1-golioth-firmware-sdk/authentication/psk-auth.md @@ -10,8 +10,8 @@ tool). PSK credentials are passed as members of the Golioth Client configuration. ```c -uint8_t* client_psk_id = pointer_to_your_psk_id_array; -uint8_t* client_psk = pointer_to_your_psk_array; +const char *client_psk_id = pointer_to_your_psk_id_array; +const char *client_psk = pointer_to_your_psk_array; size_t client_psk_id_len = strlen_of_your_psk_id_array; size_t client_psk_len = strlen_of_your_psk_array; @@ -25,7 +25,7 @@ struct golioth_client_config client_config = { .psk_len = client_psk_len, }}}; -golioth_client_t client = golioth_client_create(&client_config); +struct golioth_client *client = golioth_client_create(&client_config); ``` Golioth does not specify the means of provisioning PSK device credentials onto a diff --git a/docs/reference/5-firmware/1-golioth-firmware-sdk/device-settings-service.md b/docs/reference/5-firmware/1-golioth-firmware-sdk/device-settings-service.md index 954e329e..bf5ac3cd 100644 --- a/docs/reference/5-firmware/1-golioth-firmware-sdk/device-settings-service.md +++ b/docs/reference/5-firmware/1-golioth-firmware-sdk/device-settings-service.md @@ -16,11 +16,12 @@ messages by turning them on/off and setting the device's logging level. ## Includes ```c -#include "golioth.h" +#include +#include ``` -Including the `golioth.h` header file makes the Golioth API functions available -to your program. +These headers make the Golioth client and Device Settings API functions +available to your program. ### Registering a callback @@ -29,8 +30,11 @@ to your program. #define LOOP_DELAY_S_MIN 1 #define LOOP_DELAY_S_MAX 300 +// Create the Device Settings service handle +struct golioth_settings *settings = golioth_settings_init(client); + // Register Device Settings service callback -golioth_settings_register_int_with_range(client, +golioth_settings_register_int_with_range(settings, "LOOP_DELAY_S", LOOP_DELAY_S_MIN, LOOP_DELAY_S_MAX, @@ -43,18 +47,19 @@ callback that will execute asynchronously when receiving device settings service updates from the Golioth Cloud. Here we see a callback that expects an integer and will test the received valued for a specific valid range. -There are also API calls that register to receive a boolean value, a string, or -an integer without applying a range check: +There are also API calls that register to receive a boolean, a float, a string, +or an integer without applying a range check: ```c -golioth_settings_register_bool(client, +golioth_settings_register_bool(settings, "ENABLE_EXT_SENSOR", on_ext_sensor_setting, NULL); ``` -Required parameters are the Golioth Client object, the settings key, and the -name of the callback function. An optional callback argument may be specified, +Required parameters are the settings handle returned by +`golioth_settings_init()`, the settings key, and the name of the callback +function. An optional callback argument may be specified, this data will be available in the callback function. The Golioth servers will send an update when the callback is first registered @@ -68,7 +73,7 @@ the settings. // Global veriable to store received settings int32_t _loop_delay_s = 10; -static golioth_settings_status_t on_loop_delay_setting(int32_t new_value, void* arg) { +static enum golioth_settings_status on_loop_delay_setting(int32_t new_value, void *arg) { LOG_INF("Setting loop delay to %" PRId32 " s", new_value); _loop_delay_s = new_value; return GOLIOTH_SETTINGS_SUCCESS; @@ -80,7 +85,7 @@ servers indicating that the setting was received and processed, or indicating a reason why it was not. Once data is validated, the setting may be acted upon and a `GOLIOTH_SETTINGS_SUCCESS` response returned. There are a number of different settings-specific statuses that can be returned. Please see the -`golioth_settings_status_t` enumeration [in the Golioth Firmware SDK +`golioth_settings_status` enumeration [in the Golioth Firmware SDK reference](https://firmware-sdk-docs.golioth.io/group__golioth__settings.html) for more information. diff --git a/docs/reference/5-firmware/1-golioth-firmware-sdk/firmware-upgrade/README.md b/docs/reference/5-firmware/1-golioth-firmware-sdk/firmware-upgrade/README.md index 2e9c1b3a..ba640a64 100644 --- a/docs/reference/5-firmware/1-golioth-firmware-sdk/firmware-upgrade/README.md +++ b/docs/reference/5-firmware/1-golioth-firmware-sdk/firmware-upgrade/README.md @@ -21,11 +21,14 @@ process. Read more about how deployments are handled in the Golioth Cloud in the ### Device Side -When a device registers for firmware upgrades, it will receive a manifest from -the Golioth cloud each time a deployment occurs. The SDK automatically parses -the manifest, comparing the received firmware version number with the version -the device is currently running. If the manifest version is newer, the SDK -begins a block download of the artifact. The exact device firmware upgrade (DFU) -mechanism used to verify and flash the firmware varies from platform to -platform. Upon successful update, the device reports the new firmware version -number to the cloud. +When a device subscribes to the OTA manifest +([`golioth_ota_manifest_subscribe()`](https://firmware-sdk-docs.golioth.io/group__golioth__ota.html)), +Golioth sends it a new manifest each time a deployment changes. The device also +fetches the manifest periodically, once a day by default +(`CONFIG_GOLIOTH_OTA_MANIFEST_SUBSCRIPTION_POLL_INTERVAL_S`). The +firmware update sample code parses the manifest and compares the received +firmware version number with the version the device is currently running. If +they differ, the sample begins a block download of the artifact. The exact +device firmware upgrade (DFU) mechanism used to verify and flash the firmware +varies from platform to platform. Upon successful update, the device reports +the new firmware version number to the cloud. diff --git a/docs/reference/5-firmware/1-golioth-firmware-sdk/firmware-upgrade/fw-update-zephyr.md b/docs/reference/5-firmware/1-golioth-firmware-sdk/firmware-upgrade/fw-update-zephyr.md index ea794bc1..73d609b1 100644 --- a/docs/reference/5-firmware/1-golioth-firmware-sdk/firmware-upgrade/fw-update-zephyr.md +++ b/docs/reference/5-firmware/1-golioth-firmware-sdk/firmware-upgrade/fw-update-zephyr.md @@ -3,9 +3,6 @@ title: Zephyr Firmware Update Example Walkthrough sidebar_position: 2 --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - Over-the-Air (OTA) updates are a type of Device Firmware Upgrade (DFU). In this page we'll walk through the FW Update sample found in [the Zephyr port of the Golioth Firmware @@ -24,67 +21,63 @@ updated firmware version and report the results to the Golioth Console. ### OTA Update Sample Workflow -1. Add hardcoded credentials -2. Build and flash the initial FW Update sample application -3. Upload the signed/versioned firmware as an artifact -4. Create a release from the artifact and roll it out to the device +1. Build and flash the initial FW Update sample application +2. Set the device credentials +3. Upload the signed firmware as a new version of a Package +4. Assign the device to a Cohort and create a Deployment 5. Observe the device reporting the updated version number ## Running the OTA Sample -### 1. Add hardcoded credentials +### 1. Initial build and flash Navigate to the Golioth module in your zephyr install. This will be the -`/modules/lib/golioth-firmware-sdk` directory. - -Add the Golioth device PSK-ID and PSK to the project `prj.conf` file: +`modules/lib/golioth-firmware-sdk` directory of the west workspace. -```cfg -CONFIG_GOLIOTH_SAMPLE_PSK_ID="my-psk-id" -CONFIG_GOLIOTH_SAMPLE_PSK="my-psk" +```console +west build -b nrf9160dk/nrf9160/ns --sysbuild examples/zephyr/fw_update +west flash ``` -:::tip Where do I find my device credentials? +By default, this will build and run firmware version `1.2.3` on the Nordic +nRF9160 development kit. -Credentials can be copied from the Device details page in the [Golioth -Console](https://console.golioth.io). +:::note Devices flashed with an earlier fw_update sample + +Since Golioth Firmware SDK v0.23.0 the fw_update sample on the nRF9160 DK keeps +the MCUboot secondary slot in external flash. A device running a build of the +sample from an earlier SDK version must be reflashed with `west flash`, which +also programs MCUboot, instead of being updated over the air. ::: -### 2. Initial build and flash +### 2. Set device credentials + +Open a serial terminal to the device and set the Golioth PSK-ID and PSK through +the shell. The credentials are stored using the Zephyr Settings subsystem: ```console -west build -b nrf9160dk/nrf9160/ns --sysbuild examples/zephyr/fw_update -west flash +uart:~$ settings set golioth/psk-id +uart:~$ settings set golioth/psk +uart:~$ kernel reboot cold ``` -By default, this will build and run firmware version `1.2.3` on the Nordic -nRF9160 development kit. - -### 3. Rebuild firmware with new version number +:::tip Where do I find my device credentials? - - - Instructions for Firmware SDK version `0.15.0` and later: +Credentials can be copied from the Device details page in the [Golioth +Console](https://console.golioth.io). - Update the firmware version in the project `VERSION` file: +::: - ```cfg - VERSION_MAJOR = 1 - VERSION_MINOR = 2 - PATCHLEVEL = 4 - ``` - - - Instructions for Firmware SDK versions earlier than `0.15.0`: +### 3. Rebuild firmware with new version number - Update the firmware version in the project `prj.conf` file: +Update the firmware version in the project `VERSION` file: - ```cfg - CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION="1.2.4" - ``` - - +```cfg +VERSION_MAJOR = 1 +VERSION_MINOR = 2 +PATCHLEVEL = 4 +``` Then build the application a second time. @@ -185,13 +178,12 @@ are compiled and versioned, the process for creating the artifact and deployment on the Golioth Console, and the device reporting back a new version number after a successful update. -:::note Do not use hardcoded credential in practice +:::note Store credentials outside the application image -The Golioth FW Update sample uses hardcoded PSK credentials to simplify the -example code. An alternate option must be used when more than one device is -receiving an update (e.g. device certificate authentication stored in persistent -memory). This will ensure that credentials specific to each device are not -overwritten by hardcoded values present in the update. +The FW Update sample stores the PSK credentials in the Zephyr Settings +subsystem, so a firmware update does not overwrite them. In production, store +per-device credentials (for example a device certificate) in persistent storage +that updates do not touch. ::: diff --git a/docs/reference/5-firmware/1-golioth-firmware-sdk/firmware-upgrade/guide-ota.md b/docs/reference/5-firmware/1-golioth-firmware-sdk/firmware-upgrade/guide-ota.md index 256f5f3a..d7e665a7 100644 --- a/docs/reference/5-firmware/1-golioth-firmware-sdk/firmware-upgrade/guide-ota.md +++ b/docs/reference/5-firmware/1-golioth-firmware-sdk/firmware-upgrade/guide-ota.md @@ -3,17 +3,25 @@ title: Golioth OTA API sidebar_position: 1 --- -The firmware upgrade process is handled by the SDK, requiring just one function -call that sets the currently running firmware version and registers for updates. +The Golioth Firmware SDK provides the OTA service API (`golioth/ota.h`). The +firmware update logic built on it (manifest handling, download, flashing and +state reporting) is sample code that you copy into your application: +`examples/zephyr/fw_update/src/fw_update.c` for Zephyr and NCS, +`examples/esp_idf/fw_update/main/fw_update.c` for ESP-IDF, and +`examples/common/fw_update.c` with a platform backend (for example +`examples/linux/golioth_basics/fw_update_linux.c`) for Linux and ModusToolbox. +It needs just one function call that sets the currently running firmware +version and registers for updates. ## Includes ```c -#include "golioth.h" +#include +#include +#include "fw_update.h" ``` -Including the `golioth.h` header file makes the Golioth API functions available -to your program. +Include the `fw_update.h` header of the sample you based your application on. ## Current firmware version @@ -22,8 +30,8 @@ static const char* _current_version = "1.2.5"; ``` Your firmware binary must indicate a version number using [semantic -versioning](https://semver.org/). Pass this version to the SDK as a string (an -array of char values). +versioning](https://semver.org/). Pass this version to the firmware update +sample code as a string (an array of char values). ## Registering for OTA firmware updates @@ -31,10 +39,20 @@ array of char values). golioth_fw_update_init(client, _current_version); ``` -A pointer to the firmware version string is passed via an API call that +A pointer to the firmware version string is passed via a function call that initializes the Over-the-Air (OTA) firmware update. This spawns a background thread that listens for firmware updates from Golioth to automatically update -firmware on the device +firmware on the device. + +The Zephyr `fw_update` sample provides `golioth_fw_update_run()` instead, which +runs the update loop on the calling thread and does not return: + +```c +golioth_fw_update_run(client, _current_version); +``` + +Applications based on the Zephyr sample also need +`CONFIG_IMG_ENABLE_IMAGE_CHECK=y` and `CONFIG_MBEDTLS_PSA_CRYPTO_C=y`. ## Using a custom package name @@ -43,7 +61,7 @@ By default, firmware updates will use `main` as the name of the package during initialization. ```c -golioth_fw_update_config_t fw_config = { +struct golioth_fw_update_config fw_config = { .current_version = "1.2.3", .fw_package_name = "dev" }; @@ -53,21 +71,25 @@ golioth_fw_update_config_t fw_config = { golioth_fw_update_init_with_config(client, &fw_config); ``` +The Zephyr `fw_update` sample has no `golioth_fw_update_init_with_config()`. +Set the package name with `CONFIG_GOLIOTH_FW_UPDATE_PACKAGE_NAME` instead. + Custom package names are one way to differentiate firmware types used by your IoT fleet. The package name specified here must match the package name used when uploading the binary update to Golioth. ## Examples -* [Golioth - Basics](https://github.com/golioth/golioth-firmware-sdk/blob/main/examples/common/golioth_basics.c) - demonstrates the OTA update process. -* The Zephyr port includes [a standalone DFU - sample](https://github.com/golioth/golioth-firmware-sdk/tree/main/examples/zephyr/fw_update). +* The [ESP-IDF `fw_update` + sample](https://github.com/golioth/golioth-firmware-sdk/tree/main/examples/esp_idf/fw_update) + uses `golioth_fw_update_init()`. +* The [Zephyr `fw_update` + sample](https://github.com/golioth/golioth-firmware-sdk/tree/main/examples/zephyr/fw_update) + uses `golioth_fw_update_run()`. ## Resources -Further documentation of the device SDK is available in the [Golioth Firmware -SDK -Reference](https://firmware-sdk-docs.golioth.io/group__golioth__fw__update.html) +Further documentation of the OTA API that the firmware update sample code is +built on is available in the [Golioth Firmware SDK +Reference](https://firmware-sdk-docs.golioth.io/group__golioth__ota.html) (Doxygen). diff --git a/docs/reference/5-firmware/1-golioth-firmware-sdk/golioth-client.md b/docs/reference/5-firmware/1-golioth-firmware-sdk/golioth-client.md index 7284ccf7..91c9a872 100644 --- a/docs/reference/5-firmware/1-golioth-firmware-sdk/golioth-client.md +++ b/docs/reference/5-firmware/1-golioth-firmware-sdk/golioth-client.md @@ -10,11 +10,10 @@ registering callbacks as needed. ## Includes ```c -#include "golioth.h" +#include ``` -Including the `golioth.h` header file makes the Golioth API functions available -to your program. +This header makes the Golioth client API available to your program. ## Set up the Golioth Client @@ -69,7 +68,9 @@ Golioth logging system to print a log message following a connection event: LOG_TAG_DEFINE(golioth_basics); /* Callback registered using previous code example */ -static void on_client_event(golioth_client_t client, golioth_client_event_t event, void* arg) { +static void on_client_event(struct golioth_client *client, + enum golioth_client_event event, + void *arg) { bool is_connected = (event == GOLIOTH_CLIENT_EVENT_CONNECTED); GLTH_LOGI(TAG, "Golioth client %s", is_connected ? "connected" : "disconnected"); } @@ -85,10 +86,12 @@ the event callback when a connection to Golioth is successfully established. ## Summary -* The best demonstration of working with the Golioth Client is found in the - `examples//golioth_basics` example application. Navigate to [the - examples +* The best demonstration of working with the Golioth Client is the `hello` + sample for your platform (`examples/zephyr/hello`, `examples/esp_idf/hello`) + or the `golioth_basics` example for Linux and ModusToolbox + (`examples/linux/golioth_basics`, `examples/modus_toolbox/golioth_basics`). + Navigate to [the examples folder](https://github.com/golioth/golioth-firmware-sdk/tree/main/examples) to - locate it. + locate them. * Further documentation for this SDK is available in the [Golioth Firmware SDK Reference](https://firmware-sdk-docs.golioth.io) (Doxygen). diff --git a/docs/reference/5-firmware/1-golioth-firmware-sdk/light-db-state/README.md b/docs/reference/5-firmware/1-golioth-firmware-sdk/light-db-state/README.md index 783409c9..eba052d2 100644 --- a/docs/reference/5-firmware/1-golioth-firmware-sdk/light-db-state/README.md +++ b/docs/reference/5-firmware/1-golioth-firmware-sdk/light-db-state/README.md @@ -38,4 +38,4 @@ into four categories: These categories are described in-depth in the pages to follow. Please review the Golioth Firmware SDK Doxygen site for [a comprehensive LightDB API -reference](https://firmware-sdk-docs.golioth.io/group__golioth__lightdb.html). +reference](https://firmware-sdk-docs.golioth.io/group__golioth__lightdb__state.html). diff --git a/docs/reference/5-firmware/1-golioth-firmware-sdk/light-db-state/guide-lightdb-delete.md b/docs/reference/5-firmware/1-golioth-firmware-sdk/light-db-state/guide-lightdb-delete.md index 54420f76..a1448486 100644 --- a/docs/reference/5-firmware/1-golioth-firmware-sdk/light-db-state/guide-lightdb-delete.md +++ b/docs/reference/5-firmware/1-golioth-firmware-sdk/light-db-state/guide-lightdb-delete.md @@ -9,51 +9,42 @@ operation, the path and all of its child nodes will cease to exist. ## Includes ```c -#include "golioth.h" +#include +#include ``` -Including the `golioth.h` header file makes the Golioth API functions available -to your program. +These headers make the Golioth client and LightDB State API functions +available to your program. -## Synchronous Delete +## Deleting a path ```c -int err = golioth_lightdb_delete_sync(client, "counter", 1); +int err = golioth_lightdb_delete(client, + "counter", + counter_delete_handler, + NULL); ``` -The simplest way to delete LightDB State data from Golioth is using a synchronous -delete function. This blocking function will delete the given path and wait -for a response (or error) from the server. If a response is not received within -the given timeout, a `GOLIOTH_ERR_TIMEOUT` error code will be returned. - -In the above example, we tell Golioth to delete the `"counter"` path, with a `1` -second timeout. - -## Asynchronous Delete - -The asynchronous function is a non-blocking approach to deleting a LightDB State -path from Golioth. When the task completes, an optional callback function may be -run to process the result of the async operation. - -### Calling the async delete function - -```c -int err = golioth_lightdb_delete_async(client, - "counter", - counter_delete_handler, - NULL); -``` - -The async delete function deletes a given path, but the request is enqueued by -the Golioth Client so that program execution is not blocked. If a callback -function is supplied, it will be called by the Golioth Client when the delete -operation is completed. An optional callback argument can be specified, this -data will be available in the callback function. +The delete function does not block. The request is enqueued by the Golioth +Client and the function returns immediately; its return value only reports +whether the request was queued. If a callback function is supplied, it will be +called by the Golioth Client when the delete operation is completed. An +optional callback argument can be specified, this data will be available in the +callback function. The server reports success even if the path does not exist. In the above example, we tell Golioth to delete the `"counter"` path, with `counter_delete_handler` as the callback function and no callback argument (`NULL`). +:::note Waiting for the result + +The synchronous `_sync` functions were removed in Golioth Firmware SDK +v0.23.0. An application that needs to block until the request completes can +wait (for example on a semaphore) for the callback to run, but not from inside +a Golioth callback, because callbacks run on the Golioth client thread. + +::: + ### Callback function Callback functions need to follow the type specified by the function that @@ -61,11 +52,12 @@ registers them. In this case a `golioth_set_cb_fn` type callback function must be defined: ```c -static void counter_delete_handler(golioth_client_t client, - const golioth_response_t* response, - const char* path, - void* arg) { - if (response->status != GOLIOTH_OK) { +static void counter_delete_handler(struct golioth_client *client, + enum golioth_status status, + const struct golioth_coap_rsp_code *coap_rsp_code, + const char *path, + void *arg) { + if (status != GOLIOTH_OK) { // The delete operation failed. return; } @@ -75,20 +67,23 @@ static void counter_delete_handler(golioth_client_t client, } ``` -The response is passed to the callback function as a `golioth_response_t` struct -that includes `status`. It is recommended that callbacks test for the -`GOLIOTH_OK` status which indicates a successful operation. +The result is passed to the callback in `status`. It is recommended that +callbacks test for the `GOLIOTH_OK` status which indicates a successful +operation. When `status` is `GOLIOTH_ERR_COAP_RESPONSE`, `coap_rsp_code` holds +the non-success CoAP response code sent by the server; for other errors (for +example `GOLIOTH_ERR_TIMEOUT`) no response was received and `coap_rsp_code` is +`NULL`. -The same callback may be used by multiple async functions. Add logic to react +The same callback may be used by multiple requests. Add logic to react based on which `path` was being deleted, and any callback arguments found in the `arg` variable. -## Example in the Golioth Basics Application +## Example application -An asynchronous LightDB delete API call is demonstrated [in the Golioth Basics -example -application](https://github.com/golioth/golioth-firmware-sdk/blob/develop/examples/common/golioth_basics.c). -It can be easily located by searching for `golioth_lightdb_delete`. +LightDB Delete API calls are demonstrated in the [LightDB DELETE sample for +Zephyr](https://github.com/golioth/golioth-firmware-sdk/tree/main/examples/zephyr/lightdb/delete) +and the [LightDB DELETE sample for +ESP-IDF](https://github.com/golioth/golioth-firmware-sdk/tree/main/examples/esp_idf/lightdb/delete). ## Resources diff --git a/docs/reference/5-firmware/1-golioth-firmware-sdk/light-db-state/guide-lightdb-get.md b/docs/reference/5-firmware/1-golioth-firmware-sdk/light-db-state/guide-lightdb-get.md index 5f004946..b1193447 100644 --- a/docs/reference/5-firmware/1-golioth-firmware-sdk/light-db-state/guide-lightdb-get.md +++ b/docs/reference/5-firmware/1-golioth-firmware-sdk/light-db-state/guide-lightdb-get.md @@ -5,62 +5,55 @@ sidebar_position: 2 Use a LightDB get function to get a data value from a specific path on the cloud. This data is stateful, the most recently set value will be retrieved. If -the path does not already exist, the `GOLIOTH_ERR_NULL` error code will be -returned. +the path holds no data, the callback receives a `null` payload; check for it +with `golioth_payload_is_null()`. -A number of functions exist to handle different data types, as well as JSON -objects. +A single function, `golioth_lightdb_get()`, retrieves data as JSON or CBOR; +helper functions decode the payload in the callback. ## Includes ```c -#include "golioth.h" +#include +#include +#include ``` -Including the `golioth.h` header file makes the Golioth API functions available -to your program. +These headers make the Golioth client and LightDB State API functions, and the +payload helper functions from `golioth/payload_utils.h`, available to your +program. -## Synchronous Get +## Getting a value ```c -int err; -int32_t value; - -err = golioth_lightdb_get_int_sync(client, "counter", &value, 1); +int err = golioth_lightdb_get(client, + "counter", + GOLIOTH_CONTENT_TYPE_JSON, + counter_get_handler, + NULL); ``` -The simplest way to get LightDB State data from Golioth is using a synchronous -get function. This blocking function will request data from the given path and -wait for a response (or error) from the server. If a response is not received -within the given timeout, a `GOLIOTH_ERR_TIMEOUT` error code will be returned. - -In the above example, we tell Golioth to get the value from the `"counter"` path -and store it in a variable pointed to by `&value`, with a `1` second timeout. - -## Asynchronous Get - -The asynchronous function `golioth_lightdb_get_async()` is a non-blocking -approach to retrieving LightDB State data from Golioth. When the task completes, -a callback function runs to supply a payload of the requested data. +The get function does not block. The request is enqueued by the Golioth Client +and the function returns immediately; its return value only reports whether the +request was queued. A user-defined callback function is supplied so that you +may process the received data once the get operation is completed. An optional +callback argument can be specified, this data will be available in the callback +function. -### Calling the async get function +In the above example, we request the `"counter"` path from Golioth as JSON, +specifying `counter_get_handler` as the callback function and no callback +argument (`NULL`). -```c -int err = golioth_lightdb_get_async(client, - "counter", - counter_get_handler, - NULL); -``` +:::note Waiting for the result -The async get function requests data from a given path, but the request is -enqueued by the Golioth Client so that program execution is not blocked. A -user-defined callback function is supplied so that you may process the received -data once the get operation is completed. An optional callback argument can be -specified, this data will be available in the callback function. +The synchronous `_sync` functions were removed in Golioth Firmware SDK +v0.23.0, and the typed `golioth_lightdb_get__sync()` getters were +replaced by `golioth_lightdb_get()` with the payload decoded in the callback. +An application that needs to block until the request completes can wait (for +example on a semaphore) for the callback to run, but not from inside a Golioth +callback, because callbacks run on the Golioth client thread. -In the above example, we request the `"counter"` path from Golioth, specifying -`counter_get_handler` as the callback function and no callback argument -(`NULL`). +::: ### Callback function @@ -69,14 +62,15 @@ registers them. In this case a `golioth_get_cb_fn` type callback function must be defined: ```c -static void counter_get_handler(golioth_client_t client, - const golioth_response_t* response, - const char* path, - const uint8_t* payload, +static void counter_get_handler(struct golioth_client *client, + enum golioth_status status, + const struct golioth_coap_rsp_code *coap_rsp_code, + const char *path, + const uint8_t *payload, size_t payload_size, - void* arg) { - if (response->status != GOLIOTH_OK) { - // The get operation failed. + void *arg) { + if ((status != GOLIOTH_OK) || golioth_payload_is_null(payload, payload_size)) { + // The get operation failed, or there is no data at this path. return; } @@ -87,53 +81,46 @@ static void counter_get_handler(golioth_client_t client, } ``` -The response is passed to the callback function as a `golioth_response_t` struct -that includes `status`. It is recommended that callbacks test for the -`GOLIOTH_OK` status which indicates a successful operation. +The result is passed to the callback in `status`. It is recommended that +callbacks test for the `GOLIOTH_OK` status which indicates a successful +operation. -By default the data received from Golioth is in JSON format, stored in memory at -the `payload` pointer location, with `payload_size` indicating the length of -data. Helper functions like `golioth_payload_as_int()` are used to convert the -payload to the desired type, or a JSON parser of your choosing may be used to -unpack the payload. +Data requested with `GOLIOTH_CONTENT_TYPE_JSON` is received in JSON format, +stored in memory at the `payload` pointer location, with `payload_size` +indicating the length of data. Helper functions like `golioth_payload_as_int()` +are used to convert the payload to the desired type, or a JSON parser of your +choosing may be used to unpack the payload. -The same callback may be used by multiple async functions. Add logic to react -based on which `path` was being written to, and any callback arguments found in +The same callback may be used by multiple requests. Add logic to react +based on which `path` was requested, and any callback arguments found in the `arg` variable. ## Getting Complex JSON Objects -Both examples above get `int` type data from Golioth, and similar functions exist -for `bool`, `float`, and `string`. However, it is often more convenient to get -several paths in one operation. To do so, the API supports JSON objects. +The example above decodes an `int`; `golioth_payload_as_bool()` and +`golioth_payload_as_float()` decode other types. However, it is often more +convenient to get several paths in one operation. To do so, the API supports +JSON objects. ```c -uint8_t json_buf[128]; - /* Get root of LightDB State, but JSON can be returned for any path */ -int err = golioth_lightdb_get_sync(client, - "", - GOLIOTH_CONTENT_TYPE_JSON, - json_buf, - sizeof(json_buf), - 1); +int err = golioth_lightdb_get(client, + "", + GOLIOTH_CONTENT_TYPE_JSON, + json_get_handler, + NULL); ``` -In the example above, the `json_buf[128]` character array of an arbitrary length -is created to store the returned JSON object. The API call instructs Golioth to -get the `""` (root) path using content type `GOLIOTH_CONTENT_TYPE_JSON`. We pass -in the `json_buf` pointer which has a length limit of `sizeof(json_buf)`. This -is a synchronous function, so a timeout of `1` second has been specified. - -The async example shown earlier in this page receives JSON formatted payloads by -default and may be used to get complex objects from Golioth. +The callback receives the whole JSON object in `payload`, `payload_size` bytes +long; pass it to a JSON parser of your choosing. Use +`GOLIOTH_CONTENT_TYPE_CBOR` to receive the same data as CBOR. -## Example in the Golioth Basics Application +## Example application -Both synchronous and asynchronous LightDB Get API calls are demonstrated [in the -Golioth Basics example -application](https://github.com/golioth/golioth-firmware-sdk/blob/develop/examples/common/golioth_basics.c). -They can be easily located by searching for `golioth_lightdb_get`. +LightDB Get API calls are demonstrated in the [LightDB GET sample for +Zephyr](https://github.com/golioth/golioth-firmware-sdk/tree/main/examples/zephyr/lightdb/get) +and the [LightDB GET sample for +ESP-IDF](https://github.com/golioth/golioth-firmware-sdk/tree/main/examples/esp_idf/lightdb/get). ## Resources diff --git a/docs/reference/5-firmware/1-golioth-firmware-sdk/light-db-state/guide-lightdb-observe.md b/docs/reference/5-firmware/1-golioth-firmware-sdk/light-db-state/guide-lightdb-observe.md index 556ffd6a..aaa1ce12 100644 --- a/docs/reference/5-firmware/1-golioth-firmware-sdk/light-db-state/guide-lightdb-observe.md +++ b/docs/reference/5-firmware/1-golioth-firmware-sdk/light-db-state/guide-lightdb-observe.md @@ -6,11 +6,11 @@ sidebar_position: 3 Use a LightDB observe function to receive an update whenever a specific path value changes on the cloud. -The observe request works in a similar way to an async get request and much of -the setup is the same. Data is received asynchronously and sent to a handler -function. However, an async get request runs only once and is relatively -short-lived (the transaction ends when a payload is passed to the -callback)—this is not the case for observations. +The observe request works in a similar way to a get request and much of the +setup is the same. Data is received asynchronously and sent to a handler +function. However, a get request runs only once and is relatively short-lived +(the transaction ends when a payload is passed to the callback)—this is +not the case for observations. Once the observe request is made, the callback will receive an initial payload from the server. After this, the callback remains in place and may be called @@ -20,35 +20,39 @@ changes on the cloud. ## Includes ```c -#include "golioth.h" +#include +#include +#include ``` -Including the `golioth.h` header file makes the Golioth API functions available -to your program. +These headers make the Golioth client and LightDB State API functions, and the +payload helper functions from `golioth/payload_utils.h`, available to your +program. -## Asynchronous Observe +## Observing a path -The asynchronous function `golioth_lightdb_observe_async()` is a non-blocking -approach to receiving data updates from Golioth. When data on your observed path -changes, a callback function runs to supply a payload with the updated data. +The function `golioth_lightdb_observe()` is a non-blocking approach to receiving +data updates from Golioth. When data on your observed path changes, a callback +function runs to supply a payload with the updated data. -### Calling the async observe function +### Calling the observe function ```c -int err = golioth_lightdb_observe_async(client, - "counter", - counter_observe_handler, - NULL); +int err = golioth_lightdb_observe(client, + "counter", + GOLIOTH_CONTENT_TYPE_JSON, + counter_observe_handler, + NULL); ``` -The async observe function requests that Golioth send a new payload to the +The observe function requests that Golioth send a new payload to the device whenever data from a given path changes. A user-defined callback function is supplied so that you may process the received data. An optional callback argument can be specified, this data will be available in the callback function. -In the above example, we observe the `"counter"` path from Golioth, specifying -`counter_observe_handler` as the callback function and no callback argument -(`NULL`). +In the above example, we observe the `"counter"` path from Golioth as JSON, +specifying `counter_observe_handler` as the callback function and no callback +argument (`NULL`). ### Callback function @@ -57,14 +61,15 @@ registers them. In this case a `golioth_get_cb_fn` type callback function must be defined: ```c -static void counter_observe_handler(golioth_client_t client, - const golioth_response_t* response, - const char* path, - const uint8_t* payload, +static void counter_observe_handler(struct golioth_client *client, + enum golioth_status status, + const struct golioth_coap_rsp_code *coap_rsp_code, + const char *path, + const uint8_t *payload, size_t payload_size, - void* arg) { - if (response->status != GOLIOTH_OK) { - // Failed to receive the payload. + void *arg) { + if ((status != GOLIOTH_OK) || golioth_payload_is_null(payload, payload_size)) { + // Failed to receive the payload, or there is no data at this path. return; } @@ -75,30 +80,31 @@ static void counter_observe_handler(golioth_client_t client, } ``` -The response is passed to the callback function as a `golioth_response_t` struct -that includes `status`. It is recommended that callbacks test for the -`GOLIOTH_OK` status which indicates a successful operation. +The result is passed to the callback in `status`. It is recommended that +callbacks test for the `GOLIOTH_OK` status which indicates a successful +operation. -By default the data received from Golioth is in JSON format, stored in memory at -the `payload` pointer location, with `payload_size` indicating the length of -data. Helper functions like `golioth_payload_as_int()` are used to convert the -payload to the desired type, or a JSON parser of your choosing may be used to -unpack the payload. +Data observed with `GOLIOTH_CONTENT_TYPE_JSON` is received in JSON format, +stored in memory at the `payload` pointer location, with `payload_size` +indicating the length of data. Helper functions like `golioth_payload_as_int()` +are used to convert the payload to the desired type, or a JSON parser of your +choosing may be used to unpack the payload. -The same callback may be used by multiple async functions. Add logic to react -based on which `path` was being written to, and any callback arguments found in +The same callback may be used by multiple requests. Add logic to react +based on which `path` was observed, and any callback arguments found in the `arg` variable. ## Observing Complex JSON Objects -The async example receives JSON formatted payloads by default and may be used to -observe complex objects from Golioth. +The example above requests JSON payloads and may be used to observe complex +objects from Golioth. -## Example in the Golioth Basics Application +## Example application -The LightDB observe API call is demonstrated [in the Golioth Basics example -application](https://github.com/golioth/golioth-firmware-sdk/blob/develop/examples/common/golioth_basics.c). -It can be easily located by searching for `golioth_lightdb_observe`. +LightDB Observe API calls are demonstrated in the [LightDB OBSERVE sample for +Zephyr](https://github.com/golioth/golioth-firmware-sdk/tree/main/examples/zephyr/lightdb/observe) +and the [LightDB OBSERVE sample for +ESP-IDF](https://github.com/golioth/golioth-firmware-sdk/tree/main/examples/esp_idf/lightdb/observe). ## Resources diff --git a/docs/reference/5-firmware/1-golioth-firmware-sdk/light-db-state/guide-lightdb-set.md b/docs/reference/5-firmware/1-golioth-firmware-sdk/light-db-state/guide-lightdb-set.md index ddbd032b..1a6ce42c 100644 --- a/docs/reference/5-firmware/1-golioth-firmware-sdk/light-db-state/guide-lightdb-set.md +++ b/docs/reference/5-firmware/1-golioth-firmware-sdk/light-db-state/guide-lightdb-set.md @@ -13,52 +13,43 @@ CBOR objects. ## Includes ```c -#include "golioth.h" +#include +#include ``` -Including the `golioth.h` header file makes the Golioth API functions available -to your program. +These headers make the Golioth client and LightDB State API functions +available to your program. -## Synchronous Set +## Setting a value ```c -int err = golioth_lightdb_set_int_sync(client, "counter", counter, 1); +int err = golioth_lightdb_set_int(client, + "counter", + counter, + counter_set_handler, + NULL); ``` -The simplest way to send LightDB State data to Golioth is using a synchronous -set function. This blocking function will send data to the given path and wait -for a response (or error) from the server. If a response is not received within -the given timeout, a `GOLIOTH_ERR_TIMEOUT` error code will be returned. - -In the above example, we tell Golioth to set the `"counter"` path to the -value of a variable called `counter`, with a `1` second timeout. - -## Asynchronous Set - -The asynchronous functions are a non-blocking approach to sending LightDB State -data to Golioth. When the task completes, an optional callback function may be -run to process the result of the async operation. - -### Calling the async set function - -```c -int err = golioth_lightdb_set_int_async(client, - "counter", - counter, - counter_set_handler, - NULL); -``` - -The async set functions send data to a given path, but the request is enqueued -by the Golioth Client so that program execution is not blocked. If a callback -function is supplied, it will be called by the Golioth Client when the set -operation is completed. An optional callback argument can be specified, this -data will be available in the callback function. +The set functions do not block. The request is enqueued by the Golioth Client +and the function returns immediately; its return value only reports whether the +request was queued. The result of the set operation is passed to the callback +function, if one is supplied (pass `NULL` to ignore the result). An optional +callback argument can be specified, this data will be available in the callback +function. In the above example, we tell Golioth to set the `"counter"` path to the value of a variable called `counter`, with `counter_set_handler` as the callback function and no callback argument (`NULL`). +:::note Waiting for the result + +The synchronous `_sync` functions were removed in Golioth Firmware SDK +v0.23.0. An application that needs to block until the request completes can +wait (for example on a semaphore) for the callback to run, but not from inside +a Golioth callback, because callbacks run on the Golioth client thread. + +::: + ### Callback function Callback functions need to follow the type specified by the function that @@ -66,11 +57,12 @@ registers them. In this case a `golioth_set_cb_fn` type callback function must be defined: ```c -static void counter_set_handler(golioth_client_t client, - const golioth_response_t* response, - const char* path, - void* arg) { - if (response->status != GOLIOTH_OK) { +static void counter_set_handler(struct golioth_client *client, + enum golioth_status status, + const struct golioth_coap_rsp_code *coap_rsp_code, + const char *path, + void *arg) { + if (status != GOLIOTH_OK) { // The set operation failed. return; } @@ -80,39 +72,41 @@ static void counter_set_handler(golioth_client_t client, } ``` -The response is passed to the callback function as a `golioth_response_t` struct -that includes `status`. It is recommended that callbacks test for the -`GOLIOTH_OK` status which indicates a successful operation. +The result is passed to the callback in `status`. It is recommended that +callbacks test for the `GOLIOTH_OK` status which indicates a successful +operation. When `status` is `GOLIOTH_ERR_COAP_RESPONSE`, `coap_rsp_code` holds +the non-success CoAP response code sent by the server; for other errors (for +example `GOLIOTH_ERR_TIMEOUT`) no response was received and `coap_rsp_code` is +`NULL`. -The same callback may be used by multiple async functions. Add logic to react +The same callback may be used by multiple requests. Add logic to react based on which `path` was being written to, and any callback arguments found in the `arg` variable. ## Setting Complex Objects -Both examples above send `int` type data to Golioth, and similar functions exist +The example above sends `int` type data to Golioth, and similar functions exist for `bool`, `float`, and `string`. However, it is often more convenient to set several paths in one operation. To do so, the API supports using both JSON and CBOR objects. ```c /* Create a valid JSON string */ -char json_buf[] = "{\"name\":\"seconds\",\"data\":{\"val\":42,\"inc\":1}}" - -int err = golioth_lightdb_set_async(client, - "counter", - GOLIOTH_CONTENT_TYPE_JSON, - json_buf, - strlen(json_buf), - counter_set_handler, - NULL); +char json_buf[] = "{\"name\":\"seconds\",\"data\":{\"val\":42,\"inc\":1}}"; + +int err = golioth_lightdb_set(client, + "counter", + GOLIOTH_CONTENT_TYPE_JSON, + (const uint8_t *)json_buf, + strlen(json_buf), + counter_set_handler, + NULL); ``` In the example above, a JSON object is first prepared as a character array. The API call instructs Golioth to set the `"counter"` path using content type `GOLIOTH_CONTENT_TYPE_JSON`. We pass the function the `json_buf` pointer to the -data which is `strlen(json_buf)` long (the null terminator is not counted). This -is an async function (although a sync version is also available) so the +data which is `strlen(json_buf)` long (the null terminator is not counted). The `counter_set_handler` function is registered as a callback with no callback argument (`NULL`) specified. @@ -130,12 +124,12 @@ Here is what the resulting data on the cloud will look like: } ``` -## Example in the Golioth Basics Application +## Example application -Both synchronous and asynchronous LightDB Set API calls are demonstrated [in the -Golioth Basics example -application](https://github.com/golioth/golioth-firmware-sdk/blob/develop/examples/common/golioth_basics.c). -They can be easily located by searching for `golioth_lightdb_set`. +LightDB Set API calls are demonstrated in the [LightDB SET sample for +Zephyr](https://github.com/golioth/golioth-firmware-sdk/tree/main/examples/zephyr/lightdb/set) +and the [LightDB SET sample for +ESP-IDF](https://github.com/golioth/golioth-firmware-sdk/tree/main/examples/esp_idf/lightdb/set). ## Resources diff --git a/docs/reference/5-firmware/1-golioth-firmware-sdk/remote-procedure-call.md b/docs/reference/5-firmware/1-golioth-firmware-sdk/remote-procedure-call.md index a4489a39..e63fa30d 100644 --- a/docs/reference/5-firmware/1-golioth-firmware-sdk/remote-procedure-call.md +++ b/docs/reference/5-firmware/1-golioth-firmware-sdk/remote-procedure-call.md @@ -12,31 +12,34 @@ compile time. ## Includes ```c -#include "golioth.h" +#include +#include ``` -Including the `golioth.h` header file makes the Golioth API functions available -to your program. +These headers make the Golioth client and RPC API functions available to your +program. ### Registering a callback ```c -int err = golioth_rpc_register(client, "multiply", on_multiply, NULL); +struct golioth_rpc *rpc = golioth_rpc_init(client); + +int err = golioth_rpc_register(rpc, "multiply", on_multiply, NULL); ``` Use the `golioth_rpc_register()` function to register a callback that will execute asynchronously when an RPC request is received from the Golioth Cloud. -Required parameters are the Golioth Client object, the method name (as a -string), the name of the callback function, and an optional user-defined -parameter. +Required parameters are the RPC handle returned by `golioth_rpc_init()`, the +method name (as a string), the name of the callback function, and an optional +user-defined parameter. ### Callback function ```c -static golioth_rpc_status_t on_multiply( - zcbor_state_t* request_params_array, - zcbor_state_t* response_detail_map, - void* callback_arg) { +static enum golioth_rpc_status on_multiply( + zcbor_state_t *request_params_array, + zcbor_state_t *response_detail_map, + void *callback_arg) { double a, b; double value; bool ok; @@ -45,7 +48,7 @@ static golioth_rpc_status_t on_multiply( && zcbor_float_decode(request_params_array, &b); if (!ok) { LOG_ERR("Failed to decode array items"); - return RPC_INVALID_ARGUMENT; + return GOLIOTH_RPC_INVALID_ARGUMENT; } value = a * b; @@ -56,7 +59,7 @@ static golioth_rpc_status_t on_multiply( && zcbor_float64_put(response_detail_map, value); if (!ok) { LOG_ERR("Failed to encode value"); - return RPC_RESOURCE_EXHAUSTED; + return GOLIOTH_RPC_RESOURCE_EXHAUSTED; } return GOLIOTH_RPC_OK; @@ -92,7 +95,7 @@ Once the firmware is running, an RPC request can be sent from the device-level The status of the RPC request is shown in the same tab. The response can be viewed by clicking the three-dot button in the "Recent calls" list. -## Example in the Golioth Basics Application +## Example application The `multiply` remote procedure call is demonstrated [in the Golioth RPC example diff --git a/docs/reference/5-firmware/1-golioth-firmware-sdk/stream-client.md b/docs/reference/5-firmware/1-golioth-firmware-sdk/stream-client.md index d767c304..63828c5e 100644 --- a/docs/reference/5-firmware/1-golioth-firmware-sdk/stream-client.md +++ b/docs/reference/5-firmware/1-golioth-firmware-sdk/stream-client.md @@ -27,17 +27,17 @@ information. ::: -Synchronous and asynchronous functions exist to set multiple data types and -paths using your choice of these content types: `JSON`, `CBOR`, and -`OCTET_STREAM` for arbitrary binary data. +`golioth_stream_set()` sends data to any path using your choice of these content +types: `JSON`, `CBOR`, and `OCTET_STREAM` for arbitrary binary data. ## Includes ```c -#include "golioth.h" +#include +#include ``` -Including the `golioth.h` header file makes the Golioth API functions available +These headers make the Golioth client and Stream API functions available to your program. ## Preparing the Data @@ -94,7 +94,7 @@ While CBOR is not human readable, there are online tools like Click to reveal a zcbor encoding example Here is an example of using zcbor in canonical mode (`ZCBOR_CANONICAL` or in -Zephyr: `CONFIG_ZCBOR_CANONICAL`)to encode a CBOR payload. +Zephyr: `CONFIG_ZCBOR_CANONICAL`) to encode a CBOR payload. ```c #include @@ -137,31 +137,35 @@ devices in a fleet over large time periods becomes substantial. ::: -## Synchronous +## Sending stream data ```c /* Send JSON object */ -err = golioth_stream_set_sync(client, - "sensor", - GOLIOTH_CONTENT_TYPE_JSON, - json_buf, - strlen(json_buf), - 1); +err = golioth_stream_set(client, + "sensor", + GOLIOTH_CONTENT_TYPE_JSON, + (const uint8_t *)json_buf, + strlen(json_buf), + NULL, + NULL); /* Send CBOR object */ -err = golioth_stream_set_sync(client, - "sensor", - GOLIOTH_CONTENT_TYPE_CBOR, - cbor_buf, - sizeof(cbor_buf), - 1); +err = golioth_stream_set(client, + "sensor", + GOLIOTH_CONTENT_TYPE_CBOR, + cbor_buf, + sizeof(cbor_buf), + NULL, + NULL); ``` - -The simplest way to send Stream data to Golioth is using a synchronous function -call. This blocking function will send data to the given path and wait for a -response (or error) from the server. If a response is not received within the -given timeout, a `GOLIOTH_ERR_TIMEOUT` error code will be returned. +`golioth_stream_set()` does not block: the request is enqueued by the Golioth +Client and the function returns immediately. Its return value only reports +whether the request was queued; pass a callback (see below) to learn the +result. The synchronous `golioth_stream_set_sync()` was removed in Golioth +Firmware SDK v0.23.0. For payloads too large to send in one request, use +`golioth_stream_set_blockwise_sync()`, which reads the data block by block from +a callback and blocks until the upload completes. :::info Path Values and Pipelines @@ -173,9 +177,9 @@ Golioth Docs. In the above examples, we tell Golioth to set the `"sensor"` path using the enum for our desired content type, along with the `json_buf`/`cbor_buf` pointer and -the length of that array. The final argument is a timeout value (in seconds). -When Golioth receives this data, the server will automatically add a timestamp -based on when it was received. +the length of that array. No callback is registered (`NULL`). When Golioth +receives this data, the server will automatically add a timestamp based on when +it was received. :::tip Multiple Data Points and Nested Data @@ -198,13 +202,12 @@ Golioth servers will have a record of the data that looks like this: ::: -## Asynchronous +## Using a callback -The asynchronous functions are a non-blocking approach to sending Stream data to -Golioth. When the task completes, an optional callback function may be run to -process the result of the async operation. +When the request completes, an optional callback function may be run to process +the result. -### Calling the Async Stream Set Function +### Calling the Stream Set Function with a Callback ```c enum obj_type { @@ -212,24 +215,24 @@ enum obj_type { CBOR_ASYNC }; -err = golioth_stream_set_async(client, - "sensor", - GOLIOTH_CONTENT_TYPE_JSON, - json_buf, - strlen(json_buf), - obj_async_handler, - (void *)JSON_ASYNC); - -err = golioth_stream_set_async(client, - "sensor", - GOLIOTH_CONTENT_TYPE_CBOR, - cbor_buf, - sizeof(cbor_buf), - obj_async_handler, - (void *)CBOR_ASYNC); +err = golioth_stream_set(client, + "sensor", + GOLIOTH_CONTENT_TYPE_JSON, + (const uint8_t *)json_buf, + strlen(json_buf), + obj_async_handler, + (void *)JSON_ASYNC); + +err = golioth_stream_set(client, + "sensor", + GOLIOTH_CONTENT_TYPE_CBOR, + cbor_buf, + sizeof(cbor_buf), + obj_async_handler, + (void *)CBOR_ASYNC); ``` -The async set functions send data to a given path, but the request is enqueued +`golioth_stream_set()` sends data to a given path, but the request is enqueued by the Golioth Client so that program execution is not blocked. If a callback function is supplied, it will be called by the Golioth Client when the set operation is completed. An optional callback argument can be specified, this @@ -238,7 +241,7 @@ data will be available in the callback function. In the above examples, we tell Golioth to set the `"sensor"` path using the enum for our desired content type, along with the pointer to the `json_buf`/`cbor_buf` array. The length of that array is supplied, along with -with `async_set_handler` as the callback function. An enum value is used as the +with `obj_async_handler` as the callback function. An enum value is used as the callback argument. ### Callback Function @@ -248,11 +251,12 @@ registers them. In this case a `golioth_set_cb_fn` type callback function must be defined: ```c -static void obj_async_handler(golioth_client_t client, - const golioth_response_t* response, - const char* path, - void* arg) { - if (response->status != GOLIOTH_OK) { +static void obj_async_handler(struct golioth_client *client, + enum golioth_status status, + const struct golioth_coap_rsp_code *coap_rsp_code, + const char *path, + void *arg) { + if (status != GOLIOTH_OK) { // The set operation failed. return; } @@ -272,11 +276,14 @@ static void obj_async_handler(golioth_client_t client, } ``` -The response is passed to the callback function as a `golioth_response_t` struct -that includes `status`. It is recommended that callbacks test for the -`GOLIOTH_OK` status which indicates a successful operation. +The result is passed to the callback in `status`. It is recommended that +callbacks test for the `GOLIOTH_OK` status which indicates a successful +operation. When `status` is `GOLIOTH_ERR_COAP_RESPONSE`, `coap_rsp_code` holds +the non-success CoAP response code sent by the server; for other errors (for +example `GOLIOTH_ERR_TIMEOUT`) no response was received and `coap_rsp_code` is +`NULL`. -The same callback may be used by multiple async functions. In this example, the +The same callback may be used by multiple requests. In this example, the `arg` value is used to determine which function led to this callback so that a different message may be printed. diff --git a/docs/reference/7-hardware/5-virtual-devices/2-zephyr-quickstart/4-simulating-devices-native-sim.md b/docs/reference/7-hardware/5-virtual-devices/2-zephyr-quickstart/4-simulating-devices-native-sim.md index 7e0e2772..8a4843ef 100644 --- a/docs/reference/7-hardware/5-virtual-devices/2-zephyr-quickstart/4-simulating-devices-native-sim.md +++ b/docs/reference/7-hardware/5-virtual-devices/2-zephyr-quickstart/4-simulating-devices-native-sim.md @@ -4,6 +4,13 @@ title: Simulating devices with Native Simulator toc_max_heading_level: 2 --- +:::caution + +Native Simulator runs on Linux only. On Windows, follow this guide inside a +Linux VM or WSL 2. Use the Linux tab in the setup steps below. + +::: + ## Install Dependencies and West import SetupZephyr from '/docs/_partials-common/zephyr-setup-dependencies.md' @@ -23,18 +30,32 @@ import CheckToolchain from './\_partials/check-toolchain.md' ## Build for Native Simulator -2-zephyr-quickstart/4-simulating-devices-native-sim.md -At this point, you can build a Golioth Zephyr project: +At this point, you can build a Golioth Zephyr sample: ``` -west build -b native_sim/native/64 samples/hello -p +cd ~/golioth-zephyr-workspace/modules/lib/golioth-firmware-sdk +west build -p -b native_sim/native/64 examples/zephyr/hello ``` -and run it: +Native Simulator samples load Golioth credentials from host environment +variables. Set `GOLIOTH_SAMPLE_PSK_ID` and `GOLIOTH_SAMPLE_PSK` when running +the program: + +
+ How to find credentials + +![Golioth Console device credentials](../../../../getting-started/assets/gettingstarted-console-deviceview-credentialspanel.png) + +* Golioth credentials are available in the `Credentials` tab for your device + * Open the Golioth Console + * Select `Devices` on the left sidebar and choose your device from the + resulting list + * Click on the `Credentials` tab and copy your `PSK-ID` and `PSK` +
``` -./build/zephyr/zephyr.exe +GOLIOTH_SAMPLE_PSK_ID="" GOLIOTH_SAMPLE_PSK="" ./build/zephyr/zephyr.exe ``` The program will create a pseudo-terminal and print its name (e.g.): @@ -50,35 +71,11 @@ interactive shell: screen /dev/pts/1 ``` -## Setting Credentials - -You must set Golioth credentials for the example to authenticate with Golioth. The -SDK samples store credentials in the Zephyr Settings subsystem, and these can be set -through the shell: - -```console -uart:~$ settings set golioth/psk-id -uart:~$ settings set golioth/psk -``` - -
- How to find credentials - -![Golioth Console device credentials](../../../../getting-started/assets/gettingstarted-console-deviceview-credentialspanel.png) - -* Golioth credentials are available in the `Credentials` tab for your device - * Open the Golioth Console - * Select `Devices` on the left sidebar and choose your device from the - resulting list - * Click on the `Credentials` tab and copy your `PSK-ID` and `PSK` -
- -For more on networking, see [the native_sim page on the Zephyr Docs](https://docs.zephyrproject.org/latest/connectivity/networking/native_sim_setup.html) - +For more on networking, see [the native_sim page on the Zephyr Docs](https://docs.zephyrproject.org/4.3.0/connectivity/networking/native_sim_setup.html#using-offloaded-sockets) ## Example Output -After setting credentials, you can view program output either in the +After starting the program, you can view program output either in the pseudo-terminal or on stdout. It should look similar to the following: ```console @@ -86,11 +83,6 @@ WARNING: Using a test - not safe - entropy source uart connected to pseudotty: /dev/pts/1 *** Booting Zephyr OS build 7823374e8721 *** *** Golioth Firmware SDK v0.17.0-65-g3634d7e1d392 *** -[00:00:00.000,000] golioth_settings_autoload: Initializing settings subsystem -[00:00:00.000,000] fs_nvs: 4 Sectors of 4096 bytes -[00:00:00.000,000] fs_nvs: alloc wra: 0, fb0 -[00:00:00.000,000] fs_nvs: data wra: 0, 6d -[00:00:00.000,000] golioth_settings_autoload: Loading settings [00:00:00.000,000] net_config: Initializing network [00:00:00.000,000] net_config: IPv4 address: 192.0.2.1 [00:00:00.000,000] hello_zephyr: main: start hello sample @@ -110,6 +102,14 @@ messages listed in the Log tab: ![Golioth web console log messages](../../../../getting-started/3-device-examples/2-compile-example-code/assets/golioth-console-hello-log-messages.png) +:::note + +Logs reach the Log tab through a [CBOR logs +Pipeline](/data-routing/examples/golioth-logs-cbor). New projects include it +by default; older projects need to add it. + +::: + ## Additional Golioth Example Code Congratulations on running the Hello app! The same process may be used to run @@ -119,9 +119,10 @@ Be sure to reference the README file for each for detailed configuration and usage information. * **certificate_provisioning:** Use certificate authentication -* **firmware_update:** Use Golioth over-the-air (OTA) firmware update +* **certificate_rotation:** Rotate device certificates using Golioth PKI +* **fw_update:** Use Golioth over-the-air (OTA) firmware update * **hello:** Connect and send hello logging messages -* **lightdb:** Set, get, and observe stateful data between device and cloud +* **lightdb:** Set, get, observe, and delete stateful data between device and cloud * **location:** Use network information to determine device location * **logging:** Demonstrate logging messages of each different log level * **rpc:** Issue a remote procedure call (rpc) and received data back from device diff --git a/docs/reference/7-hardware/5-virtual-devices/2-zephyr-quickstart/README.md b/docs/reference/7-hardware/5-virtual-devices/2-zephyr-quickstart/README.md index edb20b1d..0f36dee4 100644 --- a/docs/reference/7-hardware/5-virtual-devices/2-zephyr-quickstart/README.md +++ b/docs/reference/7-hardware/5-virtual-devices/2-zephyr-quickstart/README.md @@ -1,11 +1,10 @@ --- id: overview title: Virtual Device Zephyr Quickstart -slug: /firmware/hardware/virtual-devices/zephyr-quickstart --- :::caution You must first follow the [Golioth Platform Quickstart](/getting-started) before attempting this guide. ::: -This walk-through will demonstrate how to use virtual devices to communicate with Golioth. We first will demonstrate using the `coap` command line tool to simulate commands coming from a hardware device and then move on to running Zephyr code natively on a host PC using [Native Simulator](https://docs.zephyrproject.org/latest/boards/native/native_sim/doc/index.html). +This walk-through will demonstrate how to use virtual devices to communicate with Golioth. We first will demonstrate using the `coap` command line tool to simulate commands coming from a hardware device and then move on to running Zephyr code natively on a host PC using [Native Simulator](https://docs.zephyrproject.org/4.3.0/boards/native/native_sim/doc/index.html). diff --git a/docs/reference/7-hardware/5-virtual-devices/2-zephyr-quickstart/_partials/check-toolchain.md b/docs/reference/7-hardware/5-virtual-devices/2-zephyr-quickstart/_partials/check-toolchain.md index ba4eccde..10c6326a 100644 --- a/docs/reference/7-hardware/5-virtual-devices/2-zephyr-quickstart/_partials/check-toolchain.md +++ b/docs/reference/7-hardware/5-virtual-devices/2-zephyr-quickstart/_partials/check-toolchain.md @@ -1,66 +1,19 @@ +Native Simulator builds Zephyr as a Linux executable with your host's `gcc`. +See [the POSIX architecture host +requirements](https://docs.zephyrproject.org/4.3.0/boards/native/doc/arch_soc.html#host-system-dependencies). -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - -If you've been using some of the other tutorials on this site, you may have been changing the toolchain, specifically if you used the ESP32. Type the following: +If you have been following other tutorials, make sure no toolchain override +is left in your environment: ``` export -p | grep "ZEPHYR" ``` -This should list the following variable -* `ZEPHYR_TOOLCHAIN_VARIANT` - -If these are set to Espressif, change them to use the default zephyr toolchain (part of the SDK you installed above) - - - - - -On Linux we compile (non-Espressif) Zephyr using the Zephyr SDK. Do you have that installed? If not, [go check out this page on the Zephyr getting started docs](https://docs.zephyrproject.org/latest/getting_started/index.html#install-a-toolchain). +If `ZEPHYR_TOOLCHAIN_VARIANT` is set to anything other than `zephyr`, set it +to `zephyr` before building: ``` export ZEPHYR_TOOLCHAIN_VARIANT=zephyr -export ZEPHYR_SDK_INSTALL_DIR=~/zephyr-sdk-x.y.z ``` -:::caution -Be sure to fill in the sdk name that matches your Zephyr SDK install! -::: - - - - - - -As stated in the [Zephyr Getting Started Guide](https://docs.zephyrproject.org/latest/getting_started/index.html), the toolchains are more manual for Mac and Windows - -For ARM based components, you will need to [install the GNU ARM Embedded toolchain somewhere on your machine](https://docs.zephyrproject.org/latest/getting_started/toolchain_3rd_party_x_compilers.html#gnu-arm-embedded) and then point to it. It will likely look something like this: - -``` -export ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb -export GNUARMEMB_TOOLCHAIN_PATH=/home/you/Downloads/gnu_arm_embedded -``` - - - - - -As stated in the [Zephyr Getting Started Guide](https://docs.zephyrproject.org/latest/getting_started/index.html), the toolchains are more manual for Mac and Windows - -For ARM based components, you will need to [install the GNU ARM Embedded toolchain somewhere on your machine](https://docs.zephyrproject.org/latest/getting_started/toolchain_3rd_party_x_compilers.html#gnu-arm-embedded) (the recommendation is at c:\ for windows, hello 1995) and then point to it. It will likely look something like this: - -``` -export ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb -export GNUARMEMB_TOOLCHAIN_PATH=C:\gnu_arm_embedded -``` - - - \ No newline at end of file +Zephyr then builds Native Simulator targets with the host toolchain. diff --git a/docs/reference/7-hardware/README.md b/docs/reference/7-hardware/README.md index 4cf1d516..55cddee3 100644 --- a/docs/reference/7-hardware/README.md +++ b/docs/reference/7-hardware/README.md @@ -2,9 +2,8 @@ title: Hardware --- -The Hardware section includes a catalog of supported boards for the Golioth -platform. Additionally, there are quickstart guides and recommended boards for -common MCUs, such as the ESP32 and nRF91. +The Hardware section describes Golioth's board support tiers and includes +quickstart guides for virtual devices. ## Board Support Tiers @@ -16,16 +15,17 @@ and Unverified. A continuously verified board: * is highly recommended for new users that want to try out Golioth. -* is tested on every release of the [Golioth Zephyr SDK](https://github.com/golioth/golioth-zephyr-sdk). +* is tested on every commit of the [Golioth Firmware SDK](https://github.com/golioth/golioth-firmware-sdk#verified-devices). * is regularly tested and used by the Golioth development team. * has first class support and maintenance from Golioth. If you encounter a problem with one of these boards, you can reach out to us on [the Golioth Forum](https://forum.golioth.io) or - [file a bug report](https://github.com/golioth/golioth-zephyr-sdk/issues), + [file a bug report](https://github.com/golioth/golioth-firmware-sdk/issues), and we will address it quickly. The set of boards in this category covers commonly used -connectivity options including WiFi, cellular, and Thread. -Additionally, these boards cover common MCUs, such as the ESP32 and nRF91. +connectivity options including WiFi, Ethernet, and cellular. +Additionally, these boards cover common MCUs, such as the ESP32-S3, NXP RW612, +and nRF91. ### Verified Boards @@ -33,7 +33,7 @@ A verified board: * is tested and confirmed to work with Golioth. * is tested less frequently than continuously verified boards. This means it - was tested on an older version of the Golioth Zephyr SDK, but may not + was tested on an older version of the Golioth Firmware SDK, but may not have been tested on the most recent commits. * is supported and maintained by the Golioth development team. You can reach out to us on [the Golioth Forum](https://forum.golioth.io) for help and troubleshooting. @@ -49,7 +49,7 @@ An unverified board: It's very possible that the board may work well with Golioth, but it has not yet been tested by the Golioth team. -Check if the board is in [Zephyr's list of supported boards](https://docs.zephyrproject.org/latest/boards/index.html). +Check if the board is in [Zephyr's list of supported boards](https://docs.zephyrproject.org/4.3.0/boards/index.html). If it's in the list, there's a good chance it will work with Golioth with low development effort. diff --git a/firebase.json b/firebase.json index 781072f4..5cac79bf 100644 --- a/firebase.json +++ b/firebase.json @@ -205,6 +205,16 @@ "destination": "/data-routing", "type": 301 }, + { + "source": "/firmware/golioth-firmware-sdk/authentication/certificate-auth", + "destination": "/reference/firmware/golioth-firmware-sdk/authentication/certificate-auth", + "type": 301 + }, + { + "source": "/firmware/golioth-firmware-sdk", + "destination": "/reference/firmware/golioth-firmware-sdk", + "type": 301 + }, { "source": "/firmware/hardware/:hw*", "destination": "/reference/hardware/:hw", @@ -234,7 +244,32 @@ "source": "/reference/device-api/api-docs/logging", "destination": "/data-routing/destinations/logs", "type": 301 - } + }, + { + "source": "/reference/device-api/api-docs/location", + "destination": "/data-routing/transformers/location", + "type": 301 + }, + { + "source": "/reference/protocols/coap/lightdb", + "destination": "/reference/device-api/api-docs/lightdb", + "type": 301 + }, + { + "source": "/reference/protocols/coap/logging", + "destination": "/device-management/logging/sending-logs", + "type": 301 + }, + { + "source": "/reference/protocols/coap/ota", + "destination": "/reference/device-api/api-docs/ota", + "type": 301 + }, + { + "source": "/reference/protocols/coap/stream", + "destination": "/reference/device-api/api-docs/streaming-data", + "type": 301 + } ], "rewrites": [ { @@ -473,6 +508,16 @@ "destination": "/reference/golioth-firmware-sdk", "type": 301 }, + { + "source": "/firmware/golioth-firmware-sdk/authentication/certificate-auth", + "destination": "/reference/firmware/golioth-firmware-sdk/authentication/certificate-auth", + "type": 301 + }, + { + "source": "/firmware/golioth-firmware-sdk", + "destination": "/reference/firmware/golioth-firmware-sdk", + "type": 301 + }, { "source": "/firmware/hardware/:hw*", "destination": "/reference/hardware/:hw", @@ -502,7 +547,32 @@ "source": "/reference/device-api/api-docs/logging", "destination": "/data-routing/destinations/logs", "type": 301 - } + }, + { + "source": "/reference/device-api/api-docs/location", + "destination": "/data-routing/transformers/location", + "type": 301 + }, + { + "source": "/reference/protocols/coap/lightdb", + "destination": "/reference/device-api/api-docs/lightdb", + "type": 301 + }, + { + "source": "/reference/protocols/coap/logging", + "destination": "/device-management/logging/sending-logs", + "type": 301 + }, + { + "source": "/reference/protocols/coap/ota", + "destination": "/reference/device-api/api-docs/ota", + "type": 301 + }, + { + "source": "/reference/protocols/coap/stream", + "destination": "/reference/device-api/api-docs/streaming-data", + "type": 301 + } ], "rewrites": [ {