├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── NOTICE ├── README.md ├── bubblemaker ├── CMakeLists.txt ├── README.md ├── boards │ ├── nrf7002dk_nrf5340_cpuapp_ns.conf │ ├── nrf7002dk_nrf5340_cpuapp_ns.overlay │ ├── nrf9160dk_nrf9160_ns.conf │ ├── nrf9160dk_nrf9160_ns.overlay │ ├── nrf9160dk_nrf9160_ns_0_14_0.overlay │ ├── nrf9160dk_nrf9160_ns_intflash.conf │ └── nrf_led_strip_bindings.h ├── pm_static_nrf9160dk_nrf9160_ns.yml ├── pm_static_nrf9160dk_nrf9160_ns_intflash.yml ├── prj.conf ├── prj_intflash.conf ├── src │ ├── bubblemaker.c │ ├── bubblemaker.h │ ├── led_strip.c │ ├── led_strip.h │ ├── main_app.c │ ├── peripherals.h │ ├── sensors.c │ ├── sensors.h │ ├── status_led.c │ ├── status_led.h │ ├── water_meter.c │ ├── water_meter.h │ ├── water_pump.c │ └── water_pump.h └── west-nrf.yml ├── demo ├── CMakeLists.txt ├── Kconfig ├── README.md ├── _sysbuild │ └── mcuboot │ │ └── boards │ │ ├── disco_l475_iot1.conf │ │ ├── disco_l475_iot1.overlay │ │ ├── tmo_dev_edge.conf │ │ └── tmo_dev_edge.overlay ├── boards │ ├── arduino_nano_33_ble_sense.conf │ ├── arduino_nano_33_ble_sense.overlay │ ├── disco_l475_iot1.conf │ ├── disco_l475_iot1.overlay │ ├── esp32_devkitc_wroom.conf │ ├── esp32_devkitc_wroom.overlay │ ├── nrf52840dk_nrf52840.conf │ ├── nrf52840dk_nrf52840.overlay │ ├── nrf7002dk_nrf5340_cpuapp_ns.conf │ ├── nrf7002dk_nrf5340_cpuapp_ns.overlay │ ├── nrf9151dk_nrf9151_ns.conf │ ├── nrf9151dk_nrf9151_ns.overlay │ ├── nrf9160dk_nrf9160_ns.conf │ ├── nrf9160dk_nrf9160_ns.overlay │ ├── nrf9160dk_nrf9160_ns_0_14_0.overlay │ ├── nrf9160dk_nrf9160_ns_intflash.conf │ ├── thingy91_nrf9160_ns.conf │ ├── thingy91_nrf9160_ns.overlay │ ├── tmo_dev_edge.conf │ ├── tmo_dev_edge.overlay │ └── tmo_dev_edge_partitions.overlay ├── child_image │ └── mcuboot │ │ ├── boards │ │ ├── nrf7002dk_nrf5340_cpuapp.conf │ │ ├── nrf7002dk_nrf5340_cpuapp.overlay │ │ ├── nrf9151dk_nrf9151.conf │ │ ├── nrf9151dk_nrf9151.overlay │ │ ├── nrf9160dk_nrf9160.conf │ │ ├── nrf9160dk_nrf9160_0_14_0.overlay │ │ └── nrf9160dk_nrf9160_intflash.conf │ │ └── prj.conf ├── overlay_nrf9160_afu.conf ├── overlay_nrf9160_afu_full.conf ├── overlay_nrf_mbedtls.conf ├── pm_static_nrf7002dk_nrf5340_cpuapp_ns.yml ├── pm_static_nrf9151dk_nrf9151_ns.yml ├── pm_static_nrf9160dk_nrf9160_ns.yml ├── pm_static_nrf9160dk_nrf9160_ns_intflash.yml ├── prj.conf ├── src │ ├── factory_provisioning │ │ ├── factory_flash.c │ │ ├── factory_flash.h │ │ └── provisioning_app.c │ ├── main_app.c │ ├── peripherals.h │ ├── sensors_config.c │ ├── sensors_config.h │ ├── status_led.c │ └── status_led.h ├── sysbuild.cmake ├── sysbuild.conf ├── west-nrf.yml ├── west-t-mobile.yml └── west.yml ├── ei_demo ├── CMakeLists.txt ├── README.md ├── boards │ └── thingy91_nrf9160_ns.conf ├── ei_model.zip ├── prj.conf ├── src │ ├── led.c │ ├── led.h │ ├── main.c │ └── objects │ │ ├── objects.h │ │ └── pattern_detector.c └── west-nrf.yml ├── minimal ├── CMakeLists.txt ├── README.md ├── anjay_qemu_net.sh ├── boards │ ├── arduino_nano_33_ble_sense.conf │ ├── disco_l475_iot1.conf │ ├── esp32_devkitc_wroom.conf │ ├── esp32_devkitc_wroom.overlay │ ├── nrf52840dk_nrf52840.conf │ ├── nrf7002dk_nrf5340_cpuapp_ns.conf │ ├── nrf9160dk_nrf9160_ns.conf │ ├── qemu_x86.conf │ ├── thingy91_nrf9160_ns.conf │ └── tmo_dev_edge.conf ├── prj.conf ├── src │ └── main.c ├── west-nrf.yml ├── west-t-mobile.yml └── west.yml └── tools ├── build_release_binaries.sh ├── provisioning-tool ├── configs │ ├── cert_info.json │ ├── endpoint_cfg │ ├── endpoint_cfg_cert │ └── lwm2m_server.json ├── final_overlay.conf ├── final_overlay_nrf9160dk.conf ├── initial_overlay.conf └── ptool.py └── validate_fota_file_size.py /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | .vscode 3 | .idea 4 | __pycache__ 5 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## 25.05 (May 29th, 2025) 4 | 5 | ### Improvements 6 | - Updated Anjay-zephyr to 3.10.0 7 | 8 | ## 25.02 (February 28th, 2025) 9 | 10 | ### Features 11 | - Added nRF9151DK board as a target for demo sample 12 | 13 | ### Improvements 14 | - Updated Anjay-zephyr to 3.9.0 15 | 16 | ## 24.11 (November 13th, 2024) 17 | 18 | ### Features 19 | - Added FOTA support for nRF7002DK board 20 | 21 | ### Improvements 22 | - Updated Zephyr to 3.6.0 23 | - Updated sdk-nrf to 2.7.0 24 | - Updated Anjay-zephyr to 3.8.1 25 | - Added instruction for updating es-WiFi module for B-L475E-IOT01A Discovery kit 26 | 27 | ## 24.05 (May 28th, 2024) 28 | 29 | ### Improvements 30 | - Adjusted `nrf9160dk_nrf9160_ns` build to meet new default target 31 | - Reworked build system to use `sysbuild` for FOTA builds on upstream Zephyr and T-Mobile SDKs 32 | 33 | ## 24.02 (February 16th, 2024) 34 | 35 | ### Improvements 36 | - Changed C stdlib to Picolibc (Zephyr's default) for most projects 37 | - Added TF-M support for nRF7002 DK board (changed the board variant from `nrf7002dk_nrf5340_cpuapp` to `nrf7002dk_nrf5340_cpuapp_ns`) 38 | - Added new parameter to specify log virtual port for factory provisioning script 39 | - Updated Zephyr SDK to 0.16.4 40 | 41 | ## 23.11 (November 21st, 2023) 42 | 43 | ### Improvements 44 | - Updated Zephyr to 3.5.0 45 | - Updated sdk-nrf to 2.5.0 46 | - Adjusted Kconfig options to make projects build on newest Zephyr and nCS versions 47 | 48 | ## 23.09.1 (September 22nd, 2023) 49 | 50 | ### Bugfixes 51 | - Fix Anjay-zephyr revision in west*.yml files 52 | 53 | ## 23.09 (September 7th, 2023) 54 | 55 | ### Features 56 | - Added Bubblemaker app 57 | - Added tmo_dev_edge board as a target for demo and minimal samples with the possibility to switch 58 | preferred network bearer and perform firmware update using the external flash 59 | - Added support for Location object in `asset_tracker` application 60 | 61 | ## 23.06 (June 23rd, 2023) 62 | 63 | ### Features 64 | - Added support for nRF7002DK board 65 | 66 | ### Improvements 67 | - Updated Zephyr to 3.3.0 68 | - Updated sdk-nrf to 2.3.0 69 | - Updated Anjay-zephyr to 3.4.1 70 | - Adjusted partition layout and MCUboot configuration on nRF9160DK builds to 71 | support the newer version of sdk-nrf 72 | - Added overlay for nRF9160DK in demo application which enables experimental Advanced Firmware Update object (/33629) 73 | 74 | ### Bugfixes 75 | - Fixed firmware update on Thingy:91 - made sure that enough free space is left 76 | on the flash partition for MCUboot's move algorithm to work 77 | - Fixed runtime certificate configuration on nRF52840 based boards 78 | 79 | ## 23.02 (Feb 21st, 2023) 80 | 81 | ### Features 82 | - Added support for arduino_nano_33_ble_sense board 83 | - Added runtime certificate configuration option 84 | - Added possibility to set PSK in hexadecimal format 85 | 86 | ### Improvements 87 | - Moved common code from demo samples to Anjay Zephyr 88 | - Updated sdk-nrf to final 2.2.0 89 | - Disabled Access Control in the minimal project 90 | 91 | ### Bugfixes 92 | - Made firmware update with external flash on nRF9160DK work again 93 | 94 | ## 22.12 (Dec 13th, 2022) 95 | 96 | ### Features 97 | - Added provisioning script for `demo` examples 98 | - Added nRF52840dk_nRF52840 with OpenThread support 99 | - Added automatic handling of connection link state 100 | - Added option for use of non-secure WiFi networks 101 | - Added configuration for software-based security on nRF9160DK 102 | 103 | ### Improvements 104 | - Updated Zephyr to 3.2.0 105 | - Updated sdk-nrf to 2.2.0-rc1 106 | - Refactored network connection handling 107 | - Firmware update success status can be now persisted across reboots until actual delivery 108 | 109 | ### Bugfixes 110 | - Fixed critical memory corruption bug in the factory provisioning app 111 | - Fixed problem with push buttons IID 112 | 113 | ## 22.08.1 (Aug 31st, 2022) 114 | 115 | ### Features 116 | - Added ESP32-DevKitC board support to `demo` and `minimal` examples 117 | - Experimental support for firmware update on the L475 board 118 | - Added GPS and assisted location to Thingy:91 and nRF9160dk targets as default 119 | - Turned off Thread Analyzer and TCP support by default. 120 | 121 | ### Improvements 122 | - Deferred network initialization so that network settings can actually be changed if connection fails 123 | - Updated Anjay-zephyr to 3.1.2 124 | 125 | ### Bugfixes 126 | 127 | ## 22.08 (Aug 5th, 2022) 128 | 129 | ### Features 130 | - Added support for factory provisioning 131 | - Added `nls_agps_req` shell command for Nordic Location Services A-GPS testing purposes 132 | 133 | ### Improvements 134 | - Updated Anjay-zephyr to 3.1.1 135 | - Updated static partition definitions 136 | - Improved logging in Location Assistance object 137 | - Cleaned up use of logging statements 138 | - Separated factory provisioning-related code from the main application 139 | 140 | ### Bugfixes 141 | - Enabled full printf to work with Zephyr SDK 0.14.2 142 | - Fixed PWM code for Thingy:91 143 | - LwM2M 1.1 is not enforced anymore when using persistence 144 | - Fixed memleak in persist_target_to_settings() 145 | 146 | ## 22.06 (Jun 21st, 2022) 147 | 148 | ### Improvements 149 | - Updated Anjay-zephyr to 3.0.0 150 | - Reformatted code so it meets Zephyr standards 151 | 152 | ### Features 153 | - Implemented Location Assistance object 154 | - Implemented Connectivity Monitoring object 155 | - Added shell command to enable runtime lifetime reconfiguration 156 | - Added persistence implementation 157 | 158 | ## 22.03 (Mar 24th, 2022) 159 | 160 | ### Features 161 | - Added support for firmware update 162 | 163 | ### Improvements 164 | - Made GPS support configurable through Kconfig 165 | - Migrated nRF targets to use nrfxlib sockets 166 | - Migrated configuration to use Zephyr settings API 167 | - Updated Anjay-zephyr to 2.14.1 168 | - Updated Zephyr to 2.7.0 169 | - Updated sdk-nrf to 1.9.1 170 | - Updated ei_demo to use the Edge Impulse wrapper from sdk-nrf 171 | 172 | ### Bugfixes 173 | - Made the code more thread-safe 174 | - Fixed erroneous uses of memset() 175 | 176 | ## 21.10 (Oct 11th, 2021) 177 | 178 | ### Features 179 | - Edge Impulse example 180 | - L475 support in minimal client 181 | - nRF9160 DK support in minimal client 182 | - Thingy:91 support in minimal client 183 | 184 | ### Improvements 185 | - Cleaner code using Anjay event loop 186 | - Simpler demo implementation using Anjay IPSO objects 187 | - Updated Anjay-zephyr to 2.14.0 188 | 189 | ### Bugfixes 190 | - Fixed global names 191 | 192 | ## 21.07 (Jul 30th, 2021) 193 | 194 | ### Features 195 | - Moved client containing all features to demo folder 196 | - Minimal client example for qemu_x86 197 | - Support for Thingy:91 in demo application 198 | - Location object 199 | - Buzzer object 200 | 201 | ### Improvements 202 | - Changed regulatory domain on eS-WiFi modem to World Wide 203 | - Sensor objects implementation depends on sensor presence, rather than 204 | board name. 205 | - Updated Anjay-zephyr to 2.13.0 206 | - Updated Zephyr to 2.6.0 207 | - Updated sdk-nrf to 1.6.0 208 | 209 | ## 21.06 (Jun 7th, 2021) 210 | 211 | ### Improvements 212 | - Use Anjay-zephyr 2.11.1 integration layer 213 | - Use Zephyr v2.5.0 214 | - Use Zephyr logger as log handler 215 | 216 | ## 20.10 (Oct 1st, 2020) 217 | 218 | ### Features 219 | - Add initial support for nRF9160DK board 220 | 221 | ### Bugfixes 222 | - Fix assertion failure when invalid URI is passed 223 | - Fix problem with invalid file state after write 224 | 225 | ## 20.07 (Jul 7th, 2020) 226 | 227 | ### Features 228 | - Initial release 229 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Anjay-zephyr-client 2 | Copyright 2020-2025 AVSystem 3 | 4 | This product includes software developed at AVSystem (www.avsystem.com). 5 | 6 | This product bundles Anjay 7 | (https://github.com/AVSystem/Anjay), also licensed under the terms of the 8 | Apache License, version 2.0. See Anjay/NOTICE file for details. 9 | 10 | This product bundles the AVSystem Commons Library 11 | (https://github.com/AVSystem/avs_commons), also licensed under the terms of the 12 | Apache License, version 2.0. See avs_commons/NOTICE file for details. 13 | 14 | This product's integration testing framework uses pybind11 15 | (https://github.com/pybind/pybind11), licensed under the terms of 16 | a 3-clause BSD-style license. For details, see the 17 | tests/integration/framework/nsh-lwm2m/pymbedtls/src/pybind11/LICENSE file. 18 | -------------------------------------------------------------------------------- /bubblemaker/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2020-2025 AVSystem 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | cmake_minimum_required(VERSION 3.13.1) 16 | 17 | find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) 18 | project(anjay_zephyr_demo) 19 | set(root_dir ${ANJAY_ZEPHYR_CLIENT_DIR}) 20 | 21 | if(CONFIG_PARTITION_MANAGER_ENABLED) 22 | if(CONFIG_ANJAY_ZEPHYR_FOTA) 23 | # defined in nrf/cmake/partition_manager.cmake 24 | if(NOT EXISTS "${static_configuration_file}") 25 | set(pm_missing_message "Missing static partition manager file for board: ${BOARD}") 26 | 27 | if(ACTIVE_BOARD_REVISION) 28 | set(pm_missing_message "${pm_missing_message}, rev: ${ACTIVE_BOARD_REVISION}") 29 | endif() 30 | 31 | if(CONF_FILE_BUILD_TYPE) 32 | set(pm_missing_message "${pm_missing_message}, build type: ${CONF_FILE_BUILD_TYPE}") 33 | endif() 34 | 35 | message(FATAL_ERROR "${pm_missing_message}") 36 | endif() 37 | 38 | endif() 39 | endif() 40 | 41 | set(app_sources 42 | src/main_app.c 43 | src/sensors.c 44 | src/sensors.h 45 | src/status_led.c 46 | src/status_led.h 47 | src/peripherals.h 48 | src/bubblemaker.c 49 | src/bubblemaker.h 50 | src/led_strip.c 51 | src/led_strip.h 52 | src/water_meter.c 53 | src/water_meter.h 54 | src/water_pump.c 55 | src/water_pump.h) 56 | 57 | target_sources(app PRIVATE 58 | ${app_sources}) 59 | -------------------------------------------------------------------------------- /bubblemaker/README.md: -------------------------------------------------------------------------------- 1 | # Bubblemaker [](http://www.avsystem.com/) 2 | 3 | ## Supported hardware and overview 4 | This folder contains support for the following targets: 5 | - [nrf9160dk/nrf9160/ns](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/ug_nrf9160.html) 6 | - [nrf7002dk/nrf5340/cpuapp/ns](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/device_guides/working_with_nrf/nrf70/gs.html) 7 | 8 | The following LwM2M Objects are supported: 9 | - Security (/0) 10 | - Server (/1) 11 | - Device (/3) 12 | - Connectivity Monitoring (/4) 13 | - Firmware Update (/5) 14 | - Sensors: 15 | - Temperature (/3303) with multiple DS18B20 sensors on single 1Wire line 16 | - Pressure (/3323) 17 | - Acidity (/3326) 18 | - On/Off switch (/3342) 19 | - Push button (/3347) 20 | - Water meter (/3424) 21 | 22 | The Bubblemaker contains an example smart water meter demo with basic IPSO 23 | sensor support. It is possible to use a single water meter with an electrical or 24 | hand pump as well as two water meters with two hand pumps. When using two water 25 | meters, two players can compete and the winner is indicated through led strip 26 | light. 27 | 28 | To exclude sensor in a build, it is enough to comment or delete it's name in 29 | the `aliases` section or it's name and corresponding io-channel in the 30 | `zephyr,user` section in the `boards/.overlay` file. For example, 31 | if the final configuration for `nRF9160 DK` should not contain temperature 32 | sensor #1, water pump and pressure sensors, the 33 | `boards/nrf9160dk_nrf9160_ns.overlay` file should look like this: 34 | ``` 35 | / { 36 | aliases { 37 | push-button-0 = &button0; 38 | push-button-1 = &button1; 39 | switch-0 = &button2; 40 | switch-1 = &button3; 41 | status-led = &led0; 42 | temperature-0 = &ds18b200; 43 | //temperature-1 = &ds18b201; 44 | led-strip = &led_strip; 45 | water-meter-0 = &water_meter0; 46 | water-meter-1 = &water_meter1; 47 | //water-pump-0 = &water_pump0; 48 | }; 49 | zephyr,user { 50 | /* these settings act as aliases for ADC sensors */ 51 | io-channels = <&adc 2>, <&adc 3>; 52 | io-channel-names = "acidity0", "acidity1"; 53 | }; 54 | /* rest of the file */ 55 | ``` 56 | -------------------------------------------------------------------------------- /bubblemaker/boards/nrf7002dk_nrf5340_cpuapp_ns.conf: -------------------------------------------------------------------------------- 1 | # anjay-zephyr-client 2 | CONFIG_ANJAY_ZEPHYR_DEVICE_MANUFACTURER="Nordic Semiconductor" 3 | CONFIG_ANJAY_ZEPHYR_MODEL_NUMBER="nRF7002DK" 4 | 5 | # Anjay Settings 6 | CONFIG_ANJAY_COMPAT_MBEDTLS=y 7 | CONFIG_ANJAY_COMPAT_NET=y 8 | CONFIG_ANJAY_LOG_LEVEL_INF=y 9 | CONFIG_ANJAY_WITH_NET_STATS=n 10 | CONFIG_ANJAY_WITH_SENML_JSON=y 11 | CONFIG_ANJAY_WITH_TRACE_LOGS=n 12 | CONFIG_ANJAY_WITH_ACCESS_CONTROL=n 13 | 14 | # General Settings 15 | CONFIG_MAIN_STACK_SIZE=2048 16 | CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096 17 | CONFIG_LOG_MAX_LEVEL=3 18 | CONFIG_POSIX_MAX_FDS=16 19 | 20 | # Networking 21 | CONFIG_NET_NATIVE=y 22 | CONFIG_NET_DHCPV4=y 23 | CONFIG_DNS_RESOLVER=y 24 | 25 | # WiFi 26 | CONFIG_WIFI=y 27 | CONFIG_WIFI_NRF700X=y 28 | CONFIG_WPA_SUPP=y 29 | CONFIG_WPA_SUPP_CRYPTO_PSA=y 30 | CONFIG_PSA_WANT_ALG_HMAC=y 31 | CONFIG_NET_L2_WIFI_MGMT=y 32 | CONFIG_NET_L2_WIFI_MGMT_LOG_LEVEL_ERR=y 33 | CONFIG_NET_L2_ETHERNET=y 34 | 35 | # Clock synchronization 36 | CONFIG_DATE_TIME=y 37 | CONFIG_DATE_TIME_UPDATE_INTERVAL_SECONDS=600 38 | CONFIG_DATE_TIME_TOO_OLD_SECONDS=600 39 | CONFIG_DATE_TIME_NTP_QUERY_TIME_SECONDS=5 40 | CONFIG_DATE_TIME_THREAD_STACK_SIZE=16384 41 | 42 | # File system 43 | CONFIG_FLASH_PAGE_LAYOUT=y 44 | CONFIG_MPU_ALLOW_FLASH_WRITE=y 45 | 46 | # Heap 47 | CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=150000 48 | CONFIG_HEAP_MEM_POOL_SIZE=150000 49 | 50 | # Bubblemaker 51 | CONFIG_SENSOR=y 52 | CONFIG_ADC=y 53 | CONFIG_W1=y 54 | 55 | CONFIG_LED_STRIP=y 56 | CONFIG_SPI=y 57 | 58 | CONFIG_GPIO=y 59 | -------------------------------------------------------------------------------- /bubblemaker/boards/nrf7002dk_nrf5340_cpuapp_ns.overlay: -------------------------------------------------------------------------------- 1 | #include 2 | #include "nrf_led_strip_bindings.h" 3 | 4 | / { 5 | aliases { 6 | push-button-0 = &button0; 7 | push-button-1 = &button1; 8 | status-led = &led0; 9 | light-control-0 = &led1; 10 | temperature-0 = &ds18b200; 11 | temperature-1 = &ds18b201; 12 | led-strip = &led_strip; 13 | water-meter-0 = &water_meter0; 14 | water-meter-1 = &water_meter1; 15 | //water-pump-0 = &water_pump0; 16 | }; 17 | zephyr,user { 18 | /* these settings act as aliases for ADC sensors */ 19 | io-channels = <&adc 0>, <&adc 1>, <&adc 2>, <&adc 3>; 20 | io-channel-names = "pressure0", "pressure1", "acidity0", "acidity1"; 21 | }; 22 | water_meters { 23 | compatible = "gpio-keys"; 24 | water_meter0: water_meter_0 { 25 | gpios = <&gpio0 27 GPIO_ACTIVE_LOW>; 26 | }; 27 | water_meter1: water_meter_1 { 28 | gpios = <&gpio1 14 GPIO_ACTIVE_LOW>; 29 | }; 30 | }; 31 | water_pumps { 32 | compatible = "gpio-keys"; 33 | water_pump0: water_pump_0 { 34 | gpios = <&gpio0 4 GPIO_ACTIVE_HIGH>; 35 | }; 36 | }; 37 | }; 38 | 39 | &arduino_spi { 40 | status = "okay"; 41 | compatible = "nordic,nrf-spim"; 42 | led_strip: ws2812@0 { 43 | compatible = "worldsemi,ws2812-spi"; 44 | 45 | /* SPI */ 46 | reg = <0>; /* ignored, but necessary for SPI bindings */ 47 | spi-max-frequency = ; 48 | 49 | /* WS2812 */ 50 | chain-length = <32>; /* arbitrary; change at will */ 51 | color-mapping = ; 54 | spi-one-frame = ; 55 | spi-zero-frame = ; 56 | }; 57 | }; 58 | 59 | &adc { 60 | #address-cells = <1>; 61 | #size-cells = <0>; 62 | 63 | channel@0 { 64 | reg = <0>; 65 | zephyr,gain = "ADC_GAIN_1_6"; 66 | zephyr,reference = "ADC_REF_INTERNAL"; 67 | zephyr,acquisition-time = ; 68 | zephyr,resolution = <12>; 69 | zephyr,input-positive = ; 70 | zephyr,oversampling = <8>; 71 | }; 72 | 73 | channel@1 { 74 | reg = <1>; 75 | zephyr,gain = "ADC_GAIN_1_6"; 76 | zephyr,reference = "ADC_REF_INTERNAL"; 77 | zephyr,acquisition-time = ; 78 | zephyr,resolution = <12>; 79 | zephyr,input-positive = ; 80 | zephyr,oversampling = <8>; 81 | }; 82 | 83 | channel@2 { 84 | reg = <2>; 85 | zephyr,gain = "ADC_GAIN_1_6"; 86 | zephyr,reference = "ADC_REF_INTERNAL"; 87 | zephyr,acquisition-time = ; 88 | zephyr,resolution = <12>; 89 | zephyr,input-positive = ; 90 | zephyr,oversampling = <8>; 91 | }; 92 | 93 | channel@3 { 94 | reg = <3>; 95 | zephyr,gain = "ADC_GAIN_1_6"; 96 | zephyr,reference = "ADC_REF_INTERNAL"; 97 | zephyr,acquisition-time = ; 98 | zephyr,resolution = <12>; 99 | zephyr,input-positive = ; 100 | zephyr,oversampling = <8>; 101 | }; 102 | }; 103 | 104 | &uart1 { 105 | status = "okay"; 106 | 107 | w1: w1-zephyr-serial-0 { 108 | compatible = "zephyr,w1-serial"; 109 | #address-cells = <1>; 110 | #size-cells = <0>; 111 | status = "okay"; 112 | 113 | ds18b200: ds18b20_0 { 114 | compatible = "maxim,ds18b20"; 115 | family-code = <0x28>; 116 | resolution = <12>; 117 | status = "okay"; 118 | }; 119 | ds18b201: ds18b20_1 { 120 | compatible = "maxim,ds18b20"; 121 | family-code = <0x28>; 122 | resolution = <12>; 123 | status = "okay"; 124 | }; 125 | }; 126 | }; 127 | 128 | &pinctrl { 129 | uart1_default: uart1_default { 130 | group1 { 131 | psels = ; 132 | nordic,drive-mode = ; 133 | }; 134 | group2 { 135 | psels = ; 136 | bias-pull-up; 137 | }; 138 | }; 139 | }; 140 | -------------------------------------------------------------------------------- /bubblemaker/boards/nrf9160dk_nrf9160_ns.conf: -------------------------------------------------------------------------------- 1 | # anjay-zephyr-client 2 | CONFIG_ANJAY_ZEPHYR_DEVICE_MANUFACTURER="AVSystem" 3 | CONFIG_ANJAY_ZEPHYR_MODEL_NUMBER="Bubblemaker" 4 | CONFIG_ANJAY_ZEPHYR_GPS=n 5 | CONFIG_ANJAY_ZEPHYR_GPS_NRF_A_GPS=n 6 | 7 | CONFIG_ANJAY_ZEPHYR_FOTA=y 8 | 9 | # Anjay Settings 10 | CONFIG_ANJAY_COMPAT_ZEPHYR_TLS=y 11 | CONFIG_ANJAY_COMPAT_NET=y 12 | CONFIG_ANJAY_COMPAT_TIME=y 13 | CONFIG_ANJAY_LOG_LEVEL_INF=y 14 | CONFIG_ANJAY_WITH_NET_STATS=n 15 | CONFIG_ANJAY_WITH_SENML_JSON=y 16 | CONFIG_ANJAY_WITH_TRACE_LOGS=n 17 | CONFIG_ANJAY_WITH_ACCESS_CONTROL=n 18 | 19 | # General Settings 20 | CONFIG_MAIN_STACK_SIZE=2048 21 | CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096 22 | CONFIG_LOG_RUNTIME_FILTERING=n 23 | CONFIG_LOG_CMDS=n 24 | CONFIG_LOG_MAX_LEVEL=3 25 | CONFIG_HWINFO=n 26 | 27 | # Networking 28 | CONFIG_NET_NATIVE=n 29 | CONFIG_NET_IF_MAX_IPV4_COUNT=2 30 | CONFIG_NET_TCP_ISN_RFC6528=n 31 | CONFIG_NET_LOG=n 32 | 33 | # nRF LTE 34 | CONFIG_NRF_MODEM_LIB=y 35 | CONFIG_MODEM_INFO=y 36 | CONFIG_LTE_LINK_CONTROL=y 37 | CONFIG_LTE_NETWORK_MODE_LTE_M_GPS=y 38 | CONFIG_LTE_NETWORK_TIMEOUT=600 39 | CONFIG_NRF_CLOUD_GPS_LOG_LEVEL_INF=y 40 | 41 | # Clock synchronization 42 | CONFIG_DATE_TIME=y 43 | CONFIG_DATE_TIME_UPDATE_INTERVAL_SECONDS=600 44 | CONFIG_DATE_TIME_TOO_OLD_SECONDS=600 45 | CONFIG_DATE_TIME_NTP_QUERY_TIME_SECONDS=5 46 | 47 | # File system 48 | CONFIG_FLASH_PAGE_LAYOUT=y 49 | CONFIG_MPU_ALLOW_FLASH_WRITE=y 50 | CONFIG_STREAM_FLASH=y 51 | 52 | # Heap 53 | CONFIG_HEAP_MEM_POOL_SIZE=2048 54 | 55 | # MCUboot 56 | CONFIG_BOOTLOADER_MCUBOOT=y 57 | CONFIG_IMG_MANAGER=y 58 | CONFIG_IMG_ERASE_PROGRESSIVELY=y 59 | CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION="25.5.0" 60 | 61 | # Shell settings 62 | CONFIG_SHELL_MINIMAL=y 63 | CONFIG_SHELL_WILDCARD=n 64 | CONFIG_SHELL_VT100_COMMANDS=y 65 | CONFIG_SHELL_VT100_COLORS=n 66 | CONFIG_SHELL_STATS=n 67 | CONFIG_SHELL_CMDS=n 68 | CONFIG_SHELL_TAB=y 69 | CONFIG_SHELL_TAB_AUTOCOMPLETION=y 70 | CONFIG_SHELL_CMDS_RESIZE=n 71 | CONFIG_DEVICE_SHELL=n 72 | CONFIG_DATE_SHELL=n 73 | CONFIG_DEVMEM_SHELL=n 74 | CONFIG_MCUBOOT_SHELL=n 75 | CONFIG_KERNEL_SHELL=y 76 | 77 | # Bubblemaker 78 | CONFIG_SENSOR=y 79 | CONFIG_ADC=y 80 | CONFIG_W1=y 81 | 82 | CONFIG_LED_STRIP=y 83 | CONFIG_SPI=y 84 | 85 | CONFIG_GPIO=y 86 | 87 | # External flash 88 | CONFIG_SPI=y 89 | CONFIG_SPI_NOR=y 90 | CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096 91 | CONFIG_SPI_NOR_SFDP_DEVICETREE=y 92 | CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y 93 | -------------------------------------------------------------------------------- /bubblemaker/boards/nrf9160dk_nrf9160_ns.overlay: -------------------------------------------------------------------------------- 1 | #include 2 | #include "nrf_led_strip_bindings.h" 3 | 4 | / { 5 | aliases { 6 | push-button-0 = &button0; 7 | push-button-1 = &button1; 8 | switch-0 = &button2; 9 | switch-1 = &button3; 10 | status-led = &led0; 11 | temperature-0 = &ds18b200; 12 | temperature-1 = &ds18b201; 13 | led-strip = &led_strip; 14 | water-meter-0 = &water_meter0; 15 | water-meter-1 = &water_meter1; 16 | //water-pump-0 = &water_pump0; 17 | }; 18 | zephyr,user { 19 | /* these settings act as aliases for ADC sensors */ 20 | io-channels = <&adc 0>, <&adc 1>, <&adc 2>, <&adc 3>; 21 | io-channel-names = "pressure0", "pressure1", "acidity0", "acidity1"; 22 | }; 23 | water_meters { 24 | compatible = "gpio-keys"; 25 | water_meter0: water_meter_0 { 26 | gpios = <&gpio0 20 GPIO_ACTIVE_LOW>; 27 | }; 28 | water_meter1: water_meter_1 { 29 | gpios = <&gpio0 12 GPIO_ACTIVE_LOW>; 30 | }; 31 | }; 32 | water_pumps { 33 | compatible = "gpio-keys"; 34 | water_pump0: water_pump_0 { 35 | gpios = <&gpio0 14 GPIO_ACTIVE_HIGH>; 36 | }; 37 | }; 38 | }; 39 | 40 | &arduino_spi { 41 | compatible = "nordic,nrf-spim"; 42 | led_strip: ws2812@0 { 43 | compatible = "worldsemi,ws2812-spi"; 44 | 45 | /* SPI */ 46 | reg = <0>; /* ignored, but necessary for SPI bindings */ 47 | spi-max-frequency = ; 48 | 49 | /* WS2812 */ 50 | chain-length = <32>; /* arbitrary; change at will */ 51 | color-mapping = ; 54 | spi-one-frame = ; 55 | spi-zero-frame = ; 56 | }; 57 | }; 58 | 59 | &adc { 60 | #address-cells = <1>; 61 | #size-cells = <0>; 62 | 63 | channel@0 { 64 | reg = <0>; 65 | zephyr,gain = "ADC_GAIN_1_6"; 66 | zephyr,reference = "ADC_REF_INTERNAL"; 67 | zephyr,acquisition-time = ; 68 | zephyr,resolution = <12>; 69 | zephyr,input-positive = ; 70 | zephyr,oversampling = <8>; 71 | }; 72 | 73 | channel@1 { 74 | reg = <1>; 75 | zephyr,gain = "ADC_GAIN_1_6"; 76 | zephyr,reference = "ADC_REF_INTERNAL"; 77 | zephyr,acquisition-time = ; 78 | zephyr,resolution = <12>; 79 | zephyr,input-positive = ; 80 | zephyr,oversampling = <8>; 81 | }; 82 | 83 | channel@2 { 84 | reg = <2>; 85 | zephyr,gain = "ADC_GAIN_1_6"; 86 | zephyr,reference = "ADC_REF_INTERNAL"; 87 | zephyr,acquisition-time = ; 88 | zephyr,resolution = <12>; 89 | zephyr,input-positive = ; 90 | zephyr,oversampling = <8>; 91 | }; 92 | 93 | channel@3 { 94 | reg = <3>; 95 | zephyr,gain = "ADC_GAIN_1_6"; 96 | zephyr,reference = "ADC_REF_INTERNAL"; 97 | zephyr,acquisition-time = ; 98 | zephyr,resolution = <12>; 99 | zephyr,input-positive = ; 100 | zephyr,oversampling = <8>; 101 | }; 102 | }; 103 | 104 | &uart1 { 105 | status = "okay"; 106 | 107 | w1: w1-zephyr-serial-0 { 108 | compatible = "zephyr,w1-serial"; 109 | #address-cells = <1>; 110 | #size-cells = <0>; 111 | status = "okay"; 112 | 113 | ds18b200: ds18b20_0 { 114 | compatible = "maxim,ds18b20"; 115 | family-code = <0x28>; 116 | resolution = <12>; 117 | status = "okay"; 118 | }; 119 | ds18b201: ds18b20_1 { 120 | compatible = "maxim,ds18b20"; 121 | family-code = <0x28>; 122 | resolution = <12>; 123 | status = "okay"; 124 | }; 125 | }; 126 | }; 127 | 128 | &pinctrl { 129 | uart1_default: uart1_default { 130 | group1 { 131 | psels = , 132 | ; 133 | nordic,drive-mode = ; 134 | }; 135 | group2 { 136 | psels = , 137 | ; 138 | bias-pull-up; 139 | }; 140 | }; 141 | }; 142 | -------------------------------------------------------------------------------- /bubblemaker/boards/nrf9160dk_nrf9160_ns_0_14_0.overlay: -------------------------------------------------------------------------------- 1 | / { 2 | chosen { 3 | nordic,pm-ext-flash = &mx25r64; 4 | }; 5 | }; 6 | 7 | &mx25r64 { 8 | status = "ok"; 9 | }; 10 | -------------------------------------------------------------------------------- /bubblemaker/boards/nrf9160dk_nrf9160_ns_intflash.conf: -------------------------------------------------------------------------------- 1 | # anjay-zephyr-client 2 | CONFIG_ANJAY_ZEPHYR_DEVICE_MANUFACTURER="AVSystem" 3 | CONFIG_ANJAY_ZEPHYR_MODEL_NUMBER="Bubblemaker" 4 | CONFIG_ANJAY_ZEPHYR_GPS=n 5 | CONFIG_ANJAY_ZEPHYR_GPS_NRF_A_GPS=n 6 | 7 | CONFIG_ANJAY_ZEPHYR_FOTA=y 8 | 9 | # Anjay Settings 10 | CONFIG_ANJAY_COMPAT_ZEPHYR_TLS=y 11 | CONFIG_ANJAY_COMPAT_NET=y 12 | CONFIG_ANJAY_COMPAT_TIME=y 13 | CONFIG_ANJAY_LOG_LEVEL_INF=y 14 | CONFIG_ANJAY_WITH_NET_STATS=n 15 | CONFIG_ANJAY_WITH_SENML_JSON=y 16 | CONFIG_ANJAY_WITH_TRACE_LOGS=n 17 | CONFIG_ANJAY_WITH_ACCESS_CONTROL=n 18 | 19 | # General Settings 20 | CONFIG_MAIN_STACK_SIZE=2048 21 | CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096 22 | CONFIG_LOG_RUNTIME_FILTERING=n 23 | CONFIG_LOG_CMDS=n 24 | CONFIG_LOG_MAX_LEVEL=3 25 | CONFIG_HWINFO=n 26 | 27 | # Networking 28 | CONFIG_NET_NATIVE=n 29 | CONFIG_NET_IF_MAX_IPV4_COUNT=2 30 | CONFIG_NET_TCP_ISN_RFC6528=n 31 | CONFIG_NET_LOG=n 32 | 33 | # nRF LTE 34 | CONFIG_NRF_MODEM_LIB=y 35 | CONFIG_MODEM_INFO=y 36 | CONFIG_LTE_LINK_CONTROL=y 37 | CONFIG_LTE_NETWORK_MODE_LTE_M_GPS=y 38 | CONFIG_LTE_NETWORK_TIMEOUT=600 39 | CONFIG_NRF_CLOUD_GPS_LOG_LEVEL_INF=y 40 | 41 | # Clock synchronization 42 | CONFIG_DATE_TIME=y 43 | CONFIG_DATE_TIME_UPDATE_INTERVAL_SECONDS=600 44 | CONFIG_DATE_TIME_TOO_OLD_SECONDS=600 45 | CONFIG_DATE_TIME_NTP_QUERY_TIME_SECONDS=5 46 | 47 | # File system 48 | CONFIG_FLASH_PAGE_LAYOUT=y 49 | CONFIG_MPU_ALLOW_FLASH_WRITE=y 50 | CONFIG_STREAM_FLASH=y 51 | 52 | # Heap 53 | CONFIG_HEAP_MEM_POOL_SIZE=2048 54 | 55 | # MCUboot 56 | CONFIG_BOOTLOADER_MCUBOOT=y 57 | CONFIG_IMG_MANAGER=y 58 | CONFIG_IMG_ERASE_PROGRESSIVELY=y 59 | CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION="25.5.0" 60 | 61 | # Shell settings 62 | CONFIG_SHELL_MINIMAL=y 63 | CONFIG_SHELL_WILDCARD=n 64 | CONFIG_SHELL_VT100_COMMANDS=y 65 | CONFIG_SHELL_VT100_COLORS=n 66 | CONFIG_SHELL_STATS=n 67 | CONFIG_SHELL_CMDS=n 68 | CONFIG_SHELL_TAB=y 69 | CONFIG_SHELL_TAB_AUTOCOMPLETION=y 70 | CONFIG_SHELL_CMDS_RESIZE=n 71 | CONFIG_DEVICE_SHELL=n 72 | CONFIG_DATE_SHELL=n 73 | CONFIG_DEVMEM_SHELL=n 74 | CONFIG_MCUBOOT_SHELL=n 75 | CONFIG_KERNEL_SHELL=y 76 | 77 | # Bubblemaker 78 | CONFIG_SENSOR=y 79 | CONFIG_ADC=y 80 | CONFIG_W1=y 81 | 82 | CONFIG_LED_STRIP=y 83 | CONFIG_SPI=y 84 | 85 | CONFIG_GPIO=y 86 | -------------------------------------------------------------------------------- /bubblemaker/boards/nrf_led_strip_bindings.h: -------------------------------------------------------------------------------- 1 | #ifndef ZEPHYR_SAMPLES_DRIVERS_LED_WS2812_H_ 2 | #define ZEPHYR_SAMPLES_DRIVERS_LED_WS2812_H_ 3 | 4 | /* 5 | * At 4 MHz, 1 bit is 250 ns, so 3 bits is 750 ns. 6 | * 7 | * That's cutting it a bit close to the edge of the timing parameters, 8 | * but it seems to work on AdaFruit LED rings. 9 | */ 10 | #define SPI_FREQ 4000000 11 | #define ZERO_FRAME 0x40 12 | #define ONE_FRAME 0x70 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /bubblemaker/pm_static_nrf9160dk_nrf9160_ns.yml: -------------------------------------------------------------------------------- 1 | EMPTY_0: 2 | address: 0xfa000 3 | end_address: 0x100000 4 | placement: 5 | after: 6 | - settings_storage 7 | region: flash_primary 8 | size: 0x6000 9 | app: 10 | address: 0x18000 11 | end_address: 0xe8000 12 | region: flash_primary 13 | size: 0xd0000 14 | external_flash: 15 | address: 0xd8000 16 | end_address: 0x800000 17 | region: external_flash 18 | size: 0x728000 19 | mcuboot: 20 | address: 0x0 21 | end_address: 0x10000 22 | placement: 23 | before: 24 | - mcuboot_primary 25 | region: flash_primary 26 | size: 0x10000 27 | mcuboot_pad: 28 | address: 0x10000 29 | end_address: 0x10200 30 | placement: 31 | align: 32 | start: 0x8000 33 | before: 34 | - mcuboot_primary_app 35 | region: flash_primary 36 | size: 0x200 37 | mcuboot_primary: 38 | address: 0x10000 39 | end_address: 0xe8000 40 | orig_span: &id001 41 | - tfm 42 | - app 43 | - mcuboot_pad 44 | region: flash_primary 45 | size: 0xd8000 46 | span: *id001 47 | mcuboot_primary_app: 48 | address: 0x10200 49 | end_address: 0xe8000 50 | orig_span: &id002 51 | - app 52 | - tfm 53 | region: flash_primary 54 | size: 0xd7e00 55 | span: *id002 56 | mcuboot_scratch: 57 | address: 0xe8000 58 | end_address: 0xf8000 59 | placement: 60 | after: 61 | - app 62 | align: 63 | start: 0x8000 64 | region: flash_primary 65 | size: 0x10000 66 | mcuboot_secondary: 67 | address: 0x0 68 | device: DT_CHOSEN(nordic_pm_ext_flash) 69 | end_address: 0xd8000 70 | placement: 71 | align: 72 | start: 0x4 73 | region: external_flash 74 | share_size: 75 | - mcuboot_primary 76 | size: 0xd8000 77 | dfu_target_fmfu: 78 | address: 0xd8000 79 | device: DT_CHOSEN(nordic_pm_ext_flash) 80 | end_address: 0x2d8000 81 | placement: 82 | after: 83 | - mcuboot_secondary 84 | region: external_flash 85 | size: 0x200000 86 | nonsecure_storage: 87 | address: 0xf8000 88 | end_address: 0xfa000 89 | orig_span: &id004 90 | - settings_storage 91 | region: flash_primary 92 | size: 0x2000 93 | span: *id004 94 | settings_storage: 95 | address: 0xf8000 96 | end_address: 0xfa000 97 | inside: 98 | - nonsecure_storage 99 | placement: 100 | align: 101 | start: 0x8000 102 | before: 103 | - end 104 | region: flash_primary 105 | size: 0x2000 106 | tfm: 107 | address: 0x10200 108 | end_address: 0x18000 109 | inside: 110 | - mcuboot_primary_app 111 | placement: 112 | before: 113 | - app 114 | region: flash_primary 115 | size: 0x7e00 116 | tfm_nonsecure: 117 | address: 0x18000 118 | end_address: 0xe8000 119 | orig_span: &id008 120 | - app 121 | region: flash_primary 122 | size: 0xd0000 123 | span: *id008 124 | tfm_secure: 125 | address: 0x10000 126 | end_address: 0x18000 127 | orig_span: &id009 128 | - mcuboot_pad 129 | - tfm 130 | region: flash_primary 131 | size: 0x8000 132 | span: *id009 133 | -------------------------------------------------------------------------------- /bubblemaker/pm_static_nrf9160dk_nrf9160_ns_intflash.yml: -------------------------------------------------------------------------------- 1 | EMPTY_0: 2 | address: 0xfa000 3 | end_address: 0x100000 4 | placement: 5 | after: 6 | - settings_storage 7 | region: flash_primary 8 | size: 0x6000 9 | EMPTY_1: 10 | address: 0xe0000 11 | end_address: 0xe8000 12 | placement: 13 | after: 14 | - mcuboot_secondary 15 | region: flash_primary 16 | size: 0x8000 17 | app: 18 | address: 0x18000 19 | end_address: 0x78000 20 | region: flash_primary 21 | size: 0x60000 22 | mcuboot: 23 | address: 0x0 24 | end_address: 0x10000 25 | placement: 26 | before: 27 | - mcuboot_primary 28 | region: flash_primary 29 | size: 0x10000 30 | mcuboot_pad: 31 | address: 0x10000 32 | end_address: 0x10200 33 | placement: 34 | align: 35 | start: 0x8000 36 | before: 37 | - mcuboot_primary_app 38 | region: flash_primary 39 | size: 0x200 40 | mcuboot_primary: 41 | address: 0x10000 42 | end_address: 0x78000 43 | orig_span: &id001 44 | - mcuboot_pad 45 | - tfm 46 | - app 47 | region: flash_primary 48 | sharers: 0x1 49 | size: 0x68000 50 | span: *id001 51 | mcuboot_primary_app: 52 | address: 0x10200 53 | end_address: 0x78000 54 | orig_span: &id002 55 | - app 56 | - tfm 57 | region: flash_primary 58 | size: 0x67e00 59 | span: *id002 60 | mcuboot_scratch: 61 | address: 0xe8000 62 | end_address: 0xf8000 63 | placement: 64 | after: 65 | - app 66 | align: 67 | start: 0x8000 68 | region: flash_primary 69 | size: 0x10000 70 | mcuboot_secondary: 71 | address: 0x78000 72 | end_address: 0xe0000 73 | placement: 74 | after: 75 | - mcuboot_primary 76 | align: 77 | start: 0x8000 78 | region: flash_primary 79 | share_size: 80 | - mcuboot_primary 81 | size: 0x68000 82 | nonsecure_storage: 83 | address: 0xf8000 84 | end_address: 0xfa000 85 | orig_span: &id004 86 | - settings_storage 87 | region: flash_primary 88 | size: 0x2000 89 | span: *id004 90 | settings_storage: 91 | address: 0xf8000 92 | end_address: 0xfa000 93 | inside: 94 | - nonsecure_storage 95 | placement: 96 | align: 97 | start: 0x8000 98 | before: 99 | - end 100 | region: flash_primary 101 | size: 0x2000 102 | tfm: 103 | address: 0x10200 104 | end_address: 0x18000 105 | inside: 106 | - mcuboot_primary_app 107 | placement: 108 | before: 109 | - app 110 | region: flash_primary 111 | size: 0x7e00 112 | tfm_nonsecure: 113 | address: 0x18000 114 | end_address: 0x78000 115 | orig_span: &id008 116 | - app 117 | region: flash_primary 118 | size: 0x60000 119 | span: *id008 120 | tfm_secure: 121 | address: 0x10000 122 | end_address: 0x18000 123 | orig_span: &id009 124 | - mcuboot_pad 125 | - tfm 126 | region: flash_primary 127 | size: 0x8000 128 | span: *id009 129 | -------------------------------------------------------------------------------- /bubblemaker/prj.conf: -------------------------------------------------------------------------------- 1 | # Anjay Settings 2 | CONFIG_ANJAY=y 3 | 4 | # Anjay Zephyr Settings 5 | CONFIG_ANJAY_ZEPHYR_SHELL=y 6 | 7 | # General settings 8 | CONFIG_LOG=y 9 | CONFIG_REBOOT=y 10 | CONFIG_FPU=y 11 | CONFIG_PRINTK=y 12 | CONFIG_SHELL=y 13 | 14 | # Networking 15 | CONFIG_NETWORKING=y 16 | CONFIG_NET_MGMT=y 17 | CONFIG_NET_MGMT_EVENT=y 18 | CONFIG_NET_SOCKETS=y 19 | CONFIG_NET_IPV4=y 20 | CONFIG_NET_IPV6=n 21 | CONFIG_NET_TCP=n 22 | CONFIG_NET_LOG=y 23 | 24 | # Logging 25 | CONFIG_LOG_MODE_DEFERRED=y 26 | CONFIG_LOG_BLOCK_IN_THREAD=y 27 | 28 | # Config menu 29 | CONFIG_HWINFO=y 30 | 31 | # Storage 32 | CONFIG_FLASH=y 33 | CONFIG_FLASH_MAP=y 34 | CONFIG_NVS=y 35 | CONFIG_SETTINGS=y 36 | CONFIG_FLASH_LOG_LEVEL_ERR=y 37 | -------------------------------------------------------------------------------- /bubblemaker/prj_intflash.conf: -------------------------------------------------------------------------------- 1 | # Anjay Settings 2 | CONFIG_ANJAY=y 3 | 4 | # Anjay Zephyr Settings 5 | CONFIG_ANJAY_ZEPHYR_SHELL=y 6 | 7 | # General settings 8 | CONFIG_LOG=y 9 | CONFIG_REBOOT=y 10 | CONFIG_FPU=y 11 | CONFIG_PRINTK=y 12 | CONFIG_SHELL=y 13 | 14 | # Networking 15 | CONFIG_NETWORKING=y 16 | CONFIG_NET_MGMT=y 17 | CONFIG_NET_MGMT_EVENT=y 18 | CONFIG_NET_SOCKETS=y 19 | CONFIG_NET_IPV4=y 20 | CONFIG_NET_IPV6=n 21 | CONFIG_NET_TCP=n 22 | CONFIG_NET_LOG=y 23 | 24 | # Logging 25 | CONFIG_LOG_MODE_DEFERRED=y 26 | CONFIG_LOG_BLOCK_IN_THREAD=y 27 | 28 | # Config menu 29 | CONFIG_HWINFO=y 30 | 31 | # Storage 32 | CONFIG_FLASH=y 33 | CONFIG_FLASH_MAP=y 34 | CONFIG_NVS=y 35 | CONFIG_SETTINGS=y 36 | CONFIG_FLASH_LOG_LEVEL_ERR=y 37 | -------------------------------------------------------------------------------- /bubblemaker/src/bubblemaker.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 AVSystem 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | #include "bubblemaker.h" 25 | #include "water_pump.h" 26 | #include "led_strip.h" 27 | #include "water_meter.h" 28 | 29 | LOG_MODULE_REGISTER(bubblemaker); 30 | 31 | #define IDLE_STATE_DURATION K_MSEC(500) 32 | #define RED_LIGHT_DURATION K_SECONDS(2) 33 | #define YELLOW_LIGHT_DURATION K_SECONDS(1) 34 | #define MEASURE_STATE_DURATION K_SECONDS(10) 35 | #define END_STATE_DURATION K_SECONDS(3) 36 | 37 | static struct k_thread bubblemaker_thread; 38 | static K_THREAD_STACK_DEFINE(bubblemaker_stack, 1024); 39 | 40 | enum bubblemaker_state bm_state = BUBBLEMAKER_IDLE; 41 | 42 | static void run_bubblemaker(void *arg1, void *arg2, void *arg3) 43 | { 44 | LOG_INF("Waiting for Water meter instances to initialize..."); 45 | 46 | while (water_meter_is_null()) { 47 | k_sleep(K_SECONDS(1)); 48 | } 49 | 50 | while (1) { 51 | switch (bm_state) { 52 | case BUBBLEMAKER_IDLE: 53 | k_sleep(IDLE_STATE_DURATION); 54 | break; 55 | case BUBBLEMAKER_START_RED_LIGHT: 56 | k_sleep(RED_LIGHT_DURATION); 57 | bm_state = BUBBLEMAKER_START_YELLOW_LIGHT; 58 | break; 59 | case BUBBLEMAKER_START_YELLOW_LIGHT: 60 | k_sleep(YELLOW_LIGHT_DURATION); 61 | bm_state = BUBBLEMAKER_MEASURE; 62 | break; 63 | case BUBBLEMAKER_MEASURE: 64 | water_meter_instances_reset(); 65 | k_sleep(MEASURE_STATE_DURATION); 66 | #if WATER_METER_0_AVAILABLE && WATER_METER_1_AVAILABLE 67 | double out_volumes[2]; 68 | 69 | water_meter_get_cumulated_volumes(out_volumes); 70 | bm_state = out_volumes[0] > out_volumes[1] ? BUBBLEMAKER_END_P1_WON : 71 | BUBBLEMAKER_END_P2_WON; 72 | #else // WATER_METER_0_AVAILABLE && WATER_METER_1_AVAILABLE 73 | bm_state = BUBBLEMAKER_END; 74 | #endif // WATER_METER_0_AVAILABLE && WATER_METER_1_AVAILABLE 75 | break; 76 | #if WATER_METER_0_AVAILABLE && WATER_METER_1_AVAILABLE 77 | case BUBBLEMAKER_END_P1_WON: 78 | case BUBBLEMAKER_END_P2_WON: 79 | water_meter_instances_reset(); 80 | k_sleep(END_STATE_DURATION); 81 | bm_state = BUBBLEMAKER_IDLE; 82 | break; 83 | #else // WATER_METER_0_AVAILABLE && WATER_METER_1_AVAILABLE 84 | case BUBBLEMAKER_END: 85 | k_sleep(END_STATE_DURATION); 86 | bm_state = BUBBLEMAKER_IDLE; 87 | break; 88 | #endif // WATER_METER_0_AVAILABLE && WATER_METER_1_AVAILABLE 89 | default: 90 | AVS_UNREACHABLE("Invalid enum value"); 91 | break; 92 | } 93 | } 94 | } 95 | 96 | int bubblemaker_init(void) 97 | { 98 | LOG_INF("Initializing Bubblemaker"); 99 | 100 | if (water_meter_init() 101 | #if LED_STRIP_AVAILABLE 102 | || led_strip_init() 103 | #endif // LED_STRIP_AVAILABLE 104 | #if WATER_PUMP_0_AVAILABLE 105 | || water_pump_initialize() 106 | #endif // WATER_PUMP_0_AVAILABLE 107 | ) { 108 | return -1; 109 | } 110 | 111 | if (!k_thread_create(&bubblemaker_thread, bubblemaker_stack, 112 | K_THREAD_STACK_SIZEOF(bubblemaker_stack), run_bubblemaker, NULL, NULL, 113 | NULL, 2, 0, K_NO_WAIT)) { 114 | LOG_ERR("Failed to create bubblemaker thread"); 115 | return -1; 116 | } 117 | 118 | return 0; 119 | } 120 | -------------------------------------------------------------------------------- /bubblemaker/src/bubblemaker.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 AVSystem 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "water_meter.h" 20 | 21 | enum bubblemaker_state { 22 | BUBBLEMAKER_IDLE, 23 | BUBBLEMAKER_START_RED_LIGHT, 24 | BUBBLEMAKER_START_YELLOW_LIGHT, 25 | BUBBLEMAKER_MEASURE, 26 | #if WATER_METER_0_AVAILABLE && WATER_METER_1_AVAILABLE 27 | BUBBLEMAKER_END_P1_WON, 28 | BUBBLEMAKER_END_P2_WON 29 | #else // WATER_METER_0_AVAILABLE && WATER_METER_1_AVAILABLE 30 | BUBBLEMAKER_END 31 | #endif // WATER_METER_0_AVAILABLE && WATER_METER_1_AVAILABLE 32 | }; 33 | 34 | extern enum bubblemaker_state bm_state; 35 | 36 | int bubblemaker_init(void); 37 | -------------------------------------------------------------------------------- /bubblemaker/src/led_strip.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 AVSystem 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | 20 | #include 21 | 22 | #include "led_strip.h" 23 | #include "bubblemaker.h" 24 | #include "water_meter.h" 25 | 26 | #if LED_STRIP_AVAILABLE 27 | 28 | LOG_MODULE_REGISTER(led_strip); 29 | 30 | #define STRIP_NODE DT_ALIAS(led_strip) 31 | #define STRIP_NUM_PIXELS DT_PROP(STRIP_NODE, chain_length) 32 | #define RGB(_r, _g, _b) { .r = (_r), .g = (_g), .b = (_b) } 33 | 34 | static struct k_thread led_strip_thread; 35 | static K_THREAD_STACK_DEFINE(led_strip_stack, 1024); 36 | static const struct device *const strip = DEVICE_DT_GET(STRIP_NODE); 37 | struct led_rgb pixels[STRIP_NUM_PIXELS]; 38 | 39 | enum uniform_colors { 40 | STRIP_COLOR_RED, 41 | STRIP_COLOR_GREEN, 42 | STRIP_COLOR_BLUE, 43 | STRIP_COLOR_YELLOW, 44 | #if WATER_METER_0_AVAILABLE && WATER_METER_1_AVAILABLE 45 | STRIP_COLOR_P1, 46 | STRIP_COLOR_P2, 47 | #endif // WATER_METER_0_AVAILABLE && WATER_METER_1_AVAILABLE 48 | STRIP_COLOR_NONE 49 | }; 50 | 51 | static const struct led_rgb colors[] = { 52 | [STRIP_COLOR_RED] = RGB(0xff, 0x00, 0x00), [STRIP_COLOR_GREEN] = RGB(0x00, 0xff, 0x00), 53 | [STRIP_COLOR_BLUE] = RGB(0x00, 0x00, 0xff), [STRIP_COLOR_YELLOW] = RGB(0xff, 0xff, 0x00), 54 | #if WATER_METER_0_AVAILABLE && WATER_METER_1_AVAILABLE 55 | [STRIP_COLOR_P1] = RGB(0x62, 0x09, 0xff), [STRIP_COLOR_P2] = RGB(0x00, 0xb9, 0xe2), 56 | #endif // WATER_METER_0_AVAILABLE && WATER_METER_1_AVAILABLE 57 | [STRIP_COLOR_NONE] = RGB(0x00, 0x00, 0x00), 58 | }; 59 | 60 | static void ws2812_strip_hsv2rgb(uint32_t h, uint32_t s, uint32_t v, uint8_t *r, uint8_t *g, 61 | uint8_t *b) 62 | { 63 | h %= 360; 64 | uint32_t rgb_max = v * 255 / 100; 65 | uint32_t rgb_min = rgb_max * (100 - s) / 100; 66 | 67 | uint32_t i = h / 60; 68 | uint32_t diff = h % 60; 69 | 70 | uint32_t rgb_adj = (rgb_max - rgb_min) * diff / 60; 71 | 72 | switch (i) { 73 | case 0: 74 | *r = rgb_max; 75 | *g = rgb_min + rgb_adj; 76 | *b = rgb_min; 77 | break; 78 | case 1: 79 | *r = rgb_max - rgb_adj; 80 | *g = rgb_max; 81 | *b = rgb_min; 82 | break; 83 | case 2: 84 | *r = rgb_min; 85 | *g = rgb_max; 86 | *b = rgb_min + rgb_adj; 87 | break; 88 | case 3: 89 | *r = rgb_min; 90 | *g = rgb_max - rgb_adj; 91 | *b = rgb_max; 92 | break; 93 | case 4: 94 | *r = rgb_min + rgb_adj; 95 | *g = rgb_min; 96 | *b = rgb_max; 97 | break; 98 | case 5: 99 | *r = rgb_max; 100 | *g = rgb_min; 101 | *b = rgb_max - rgb_adj; 102 | break; 103 | default: 104 | AVS_UNREACHABLE("Invalid value"); 105 | break; 106 | } 107 | } 108 | 109 | static void ws2812_strip_update(void) 110 | { 111 | led_strip_update_rgb(strip, pixels, STRIP_NUM_PIXELS); 112 | } 113 | 114 | static void ws2812_strip_set_color(enum uniform_colors color) 115 | { 116 | for (size_t i = 0; i < STRIP_NUM_PIXELS; i++) { 117 | pixels[i] = colors[color]; 118 | } 119 | ws2812_strip_update(); 120 | } 121 | 122 | static void ws2812_strip_display_rainbow(void) 123 | { 124 | static uint32_t rgb_increase; 125 | 126 | for (int i = 0; i < 3; i++) { 127 | for (int j = i; j < STRIP_NUM_PIXELS; j++) { 128 | uint32_t hue = j * 360 / STRIP_NUM_PIXELS + rgb_increase; 129 | 130 | ws2812_strip_hsv2rgb(hue, 100, 100, &pixels[j].r, &pixels[j].g, 131 | &pixels[j].b); 132 | } 133 | ws2812_strip_update(); 134 | k_sleep(K_MSEC(10)); 135 | } 136 | rgb_increase += 5; 137 | } 138 | 139 | static void led_strip_task(void *arg1, void *arg2, void *arg3) 140 | { 141 | ws2812_strip_set_color(STRIP_COLOR_NONE); 142 | 143 | while (1) { 144 | switch (bm_state) { 145 | case BUBBLEMAKER_IDLE: 146 | ws2812_strip_display_rainbow(); 147 | break; 148 | case BUBBLEMAKER_START_RED_LIGHT: 149 | ws2812_strip_set_color(STRIP_COLOR_RED); 150 | break; 151 | case BUBBLEMAKER_START_YELLOW_LIGHT: 152 | ws2812_strip_set_color(STRIP_COLOR_YELLOW); 153 | break; 154 | case BUBBLEMAKER_MEASURE: 155 | ws2812_strip_set_color(STRIP_COLOR_GREEN); 156 | break; 157 | #if WATER_METER_0_AVAILABLE && WATER_METER_1_AVAILABLE 158 | case BUBBLEMAKER_END_P1_WON: 159 | ws2812_strip_set_color(STRIP_COLOR_P1); 160 | break; 161 | case BUBBLEMAKER_END_P2_WON: 162 | ws2812_strip_set_color(STRIP_COLOR_P2); 163 | break; 164 | #else // WATER_METER_0_AVAILABLE && WATER_METER_1_AVAILABLE 165 | case BUBBLEMAKER_END: 166 | ws2812_strip_set_color(STRIP_COLOR_RED); 167 | break; 168 | #endif // WATER_METER_0_AVAILABLE && WATER_METER_1_AVAILABLE 169 | default: 170 | AVS_UNREACHABLE("Invalid enum value"); 171 | } 172 | } 173 | } 174 | 175 | int led_strip_init(void) 176 | { 177 | LOG_INF("Initializing led_strip"); 178 | 179 | if (device_is_ready(strip)) { 180 | LOG_INF("Found LED strip device %s", strip->name); 181 | } else { 182 | LOG_ERR("LED strip device %s is not ready", strip->name); 183 | return -1; 184 | } 185 | 186 | if (!k_thread_create(&led_strip_thread, led_strip_stack, 187 | K_THREAD_STACK_SIZEOF(led_strip_stack), led_strip_task, NULL, NULL, 188 | NULL, 2, 0, K_NO_WAIT)) { 189 | LOG_ERR("Failed to create led_strip thread"); 190 | return -1; 191 | } 192 | 193 | return 0; 194 | } 195 | 196 | #endif // LED_STRIP_AVAILABLE 197 | -------------------------------------------------------------------------------- /bubblemaker/src/led_strip.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 AVSystem 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #define LED_STRIP_NODE DT_ALIAS(led_strip) 20 | #define LED_STRIP_AVAILABLE DT_NODE_HAS_STATUS(LED_STRIP_NODE, okay) 21 | 22 | #if LED_STRIP_AVAILABLE 23 | int led_strip_init(void); 24 | #endif // LED_STRIP_AVAILABLE 25 | -------------------------------------------------------------------------------- /bubblemaker/src/main_app.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 AVSystem 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | #include 20 | #include 21 | 22 | #include 23 | #include 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | #include "peripherals.h" 30 | #include "status_led.h" 31 | #include "sensors.h" 32 | #include "bubblemaker.h" 33 | #include "water_pump.h" 34 | 35 | LOG_MODULE_REGISTER(main_app); 36 | 37 | static const anjay_dm_object_def_t **water_meter_obj; 38 | #if WATER_PUMP_0_AVAILABLE 39 | static const anjay_dm_object_def_t **power_control_obj; 40 | #endif // WATER_PUMP_0_AVAILABLE 41 | #if LED_COLOR_LIGHT_AVAILABLE 42 | static const anjay_dm_object_def_t **led_color_light_obj; 43 | #endif // LED_COLOR_LIGHT_AVAILABLE 44 | #if SWITCH_AVAILABLE_ANY 45 | static const anjay_dm_object_def_t **switch_obj; 46 | #endif // SWITCH_AVAILABLE_ANY 47 | static avs_sched_handle_t update_objects_handle; 48 | 49 | #if PUSH_BUTTON_AVAILABLE_ANY 50 | static struct anjay_zephyr_ipso_button_instance buttons[] = { 51 | #if PUSH_BUTTON_AVAILABLE(0) && !WATER_PUMP_0_AVAILABLE 52 | PUSH_BUTTON_GLUE_ITEM(0), 53 | #endif // PUSH_BUTTON_AVAILABLE(0) && !WATER_PUMP_0_AVAILABLE 54 | #if PUSH_BUTTON_AVAILABLE(1) 55 | PUSH_BUTTON_GLUE_ITEM(1), 56 | #endif // PUSH_BUTTON_AVAILABLE(1) 57 | #if PUSH_BUTTON_AVAILABLE(2) 58 | PUSH_BUTTON_GLUE_ITEM(2), 59 | #endif // PUSH_BUTTON_AVAILABLE(2) 60 | #if PUSH_BUTTON_AVAILABLE(3) 61 | PUSH_BUTTON_GLUE_ITEM(3), 62 | #endif // PUSH_BUTTON_AVAILABLE(3) 63 | }; 64 | #endif // PUSH_BUTTON_AVAILABLE_ANY 65 | 66 | #if SWITCH_AVAILABLE_ANY 67 | static struct anjay_zephyr_switch_instance switches[] = { 68 | #if SWITCH_AVAILABLE(0) 69 | SWITCH_BUTTON_GLUE_ITEM(0), 70 | #endif // SWITCH_AVAILABLE(0) 71 | #if SWITCH_AVAILABLE(1) 72 | SWITCH_BUTTON_GLUE_ITEM(1), 73 | #endif // SWITCH_AVAILABLE(1) 74 | #if SWITCH_AVAILABLE(2) 75 | SWITCH_BUTTON_GLUE_ITEM(2), 76 | #endif // SWITCH_AVAILABLE(2) 77 | }; 78 | #endif // SWITCH_AVAILABLE_ANY 79 | 80 | static int register_objects(anjay_t *anjay) 81 | { 82 | water_meter_obj = water_meter_object_create(); 83 | if (water_meter_obj) { 84 | anjay_register_object(anjay, water_meter_obj); 85 | } else { 86 | LOG_ERR("water_meter object could not be created"); 87 | return -1; 88 | } 89 | 90 | #if WATER_PUMP_0_AVAILABLE 91 | power_control_obj = power_control_object_create(); 92 | if (power_control_obj) { 93 | anjay_register_object(anjay, power_control_obj); 94 | } 95 | #endif // WATER_PUMP_0_AVAILABLE 96 | 97 | basic_sensor_objects_install(anjay); 98 | #if PUSH_BUTTON_AVAILABLE_ANY 99 | anjay_zephyr_ipso_push_button_object_install(anjay, buttons, AVS_ARRAY_SIZE(buttons)); 100 | #endif // PUSH_BUTTON_AVAILABLE_ANY 101 | 102 | #if LED_COLOR_LIGHT_AVAILABLE 103 | led_color_light_obj = anjay_zephyr_led_color_light_object_create(DEVICE_DT_GET(RGB_NODE)); 104 | if (led_color_light_obj) { 105 | anjay_register_object(anjay, led_color_light_obj); 106 | } 107 | #endif // LED_COLOR_LIGHT_AVAILABLE 108 | 109 | #if SWITCH_AVAILABLE_ANY 110 | switch_obj = anjay_zephyr_switch_object_create(switches, AVS_ARRAY_SIZE(switches)); 111 | if (switch_obj) { 112 | anjay_register_object(anjay, switch_obj); 113 | } 114 | #endif // SWITCH_AVAILABLE_ANY 115 | return 0; 116 | } 117 | 118 | static void update_objects_frequent(anjay_t *anjay) 119 | { 120 | #if SWITCH_AVAILABLE_ANY 121 | anjay_zephyr_switch_object_update(anjay, switch_obj); 122 | #endif // SWITCH_AVAILABLE_ANY 123 | basic_sensor_objects_update(anjay); 124 | } 125 | 126 | static void update_objects(avs_sched_t *sched, const void *anjay_ptr) 127 | { 128 | anjay_t *anjay = *(anjay_t *const *)anjay_ptr; 129 | 130 | update_objects_frequent(anjay); 131 | 132 | status_led_toggle(); 133 | 134 | AVS_SCHED_DELAYED(sched, &update_objects_handle, 135 | avs_time_duration_from_scalar(1, AVS_TIME_S), update_objects, &anjay, 136 | sizeof(anjay)); 137 | } 138 | 139 | static int init_update_objects(anjay_t *anjay) 140 | { 141 | avs_sched_t *sched = anjay_get_scheduler(anjay); 142 | 143 | update_objects(sched, &anjay); 144 | 145 | status_led_init(); 146 | 147 | return 0; 148 | } 149 | 150 | static int clean_before_anjay_destroy(anjay_t *anjay) 151 | { 152 | avs_sched_del(&update_objects_handle); 153 | 154 | return 0; 155 | } 156 | 157 | static int release_objects(void) 158 | { 159 | water_meter_object_release(water_meter_obj); 160 | #if WATER_PUMP_0_AVAILABLE 161 | power_control_object_release(power_control_obj); 162 | #endif // WATER_PUMP_0_AVAILABLE 163 | #if SWITCH_AVAILABLE_ANY 164 | anjay_zephyr_switch_object_release(&switch_obj); 165 | #endif // SWITCH_AVAILABLE_ANY 166 | #if LED_COLOR_LIGHT_AVAILABLE 167 | anjay_zephyr_led_color_light_object_release(&led_color_light_obj); 168 | #endif // LED_COLOR_LIGHT_AVAILABLE 169 | 170 | return 0; 171 | } 172 | 173 | int lwm2m_callback(anjay_t *anjay, enum anjay_zephyr_lwm2m_callback_reasons reason) 174 | { 175 | switch (reason) { 176 | case ANJAY_ZEPHYR_LWM2M_CALLBACK_REASON_INIT: 177 | return register_objects(anjay); 178 | case ANJAY_ZEPHYR_LWM2M_CALLBACK_REASON_ANJAY_READY: 179 | return init_update_objects(anjay); 180 | case ANJAY_ZEPHYR_LWM2M_CALLBACK_REASON_ANJAY_SHUTTING_DOWN: 181 | return clean_before_anjay_destroy(anjay); 182 | case ANJAY_ZEPHYR_LWM2M_CALLBACK_REASON_CLEANUP: 183 | return release_objects(); 184 | default: 185 | return -1; 186 | } 187 | } 188 | 189 | int main(void) 190 | { 191 | LOG_INF("Initializing Anjay-zephyr-client Bubblemaker " CONFIG_ANJAY_ZEPHYR_VERSION); 192 | 193 | anjay_zephyr_lwm2m_set_user_callback(lwm2m_callback); 194 | anjay_zephyr_lwm2m_init_from_settings(); 195 | anjay_zephyr_lwm2m_start(); 196 | bubblemaker_init(); 197 | 198 | // Anjay runs in a separate thread and preceding function doesn't block 199 | // add your own code here 200 | return 0; 201 | } 202 | -------------------------------------------------------------------------------- /bubblemaker/src/peripherals.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 AVSystem 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | 22 | #define RGB_NODE DT_ALIAS(rgb_pwm) 23 | #define LED_COLOR_LIGHT_AVAILABLE DT_NODE_HAS_STATUS(RGB_NODE, okay) 24 | 25 | #define PUSH_BUTTON_NODE(idx) DT_ALIAS(push_button_##idx) 26 | #define PUSH_BUTTON_AVAILABLE(idx) DT_NODE_HAS_STATUS(PUSH_BUTTON_NODE(idx), okay) 27 | #define PUSH_BUTTON_AVAILABLE_ANY \ 28 | (PUSH_BUTTON_AVAILABLE(0) || PUSH_BUTTON_AVAILABLE(1) || PUSH_BUTTON_AVAILABLE(2) || \ 29 | PUSH_BUTTON_AVAILABLE(3)) 30 | 31 | #define SWITCH_NODE(idx) DT_ALIAS(switch_##idx) 32 | #define SWITCH_AVAILABLE(idx) DT_NODE_HAS_STATUS(SWITCH_NODE(idx), okay) 33 | #define SWITCH_AVAILABLE_ANY (SWITCH_AVAILABLE(0) || SWITCH_AVAILABLE(1) || SWITCH_AVAILABLE(2)) 34 | 35 | #define PUSH_BUTTON_GLUE_ITEM(num) \ 36 | { .device = DEVICE_DT_GET(DT_GPIO_CTLR(PUSH_BUTTON_NODE(num), gpios)), \ 37 | .gpio_pin = DT_GPIO_PIN(PUSH_BUTTON_NODE(num), gpios), \ 38 | .gpio_flags = (GPIO_INPUT | DT_GPIO_FLAGS(PUSH_BUTTON_NODE(num), gpios)) } 39 | 40 | #define SWITCH_BUTTON_GLUE_ITEM(num) \ 41 | { .device = DEVICE_DT_GET(DT_GPIO_CTLR(SWITCH_NODE(num), gpios)), \ 42 | .gpio_pin = DT_GPIO_PIN(SWITCH_NODE(num), gpios), \ 43 | .gpio_flags = (GPIO_INPUT | DT_GPIO_FLAGS(SWITCH_NODE(num), gpios)) } 44 | 45 | #define TEMPERATURE_0_NODE DT_ALIAS(temperature_0) 46 | #define TEMPERATURE_0_AVAILABLE DT_NODE_HAS_STATUS(TEMPERATURE_0_NODE, okay) 47 | 48 | #define TEMPERATURE_1_NODE DT_ALIAS(temperature_1) 49 | #define TEMPERATURE_1_AVAILABLE DT_NODE_HAS_STATUS(TEMPERATURE_1_NODE, okay) 50 | -------------------------------------------------------------------------------- /bubblemaker/src/sensors.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 AVSystem 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | 22 | void basic_sensor_objects_install(anjay_t *anjay); 23 | void basic_sensor_objects_update(anjay_t *anjay); 24 | -------------------------------------------------------------------------------- /bubblemaker/src/status_led.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 AVSystem 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "status_led.h" 18 | 19 | #if STATUS_LED_AVAILABLE 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | LOG_MODULE_REGISTER(status_led); 26 | 27 | static const struct gpio_dt_spec status_led_spec = GPIO_DT_SPEC_GET(STATUS_LED_NODE, gpios); 28 | 29 | void status_led_init(void) 30 | { 31 | if (!device_is_ready(status_led_spec.port) || 32 | gpio_pin_configure_dt(&status_led_spec, GPIO_OUTPUT_INACTIVE)) { 33 | LOG_WRN("failed to initialize status led"); 34 | } 35 | } 36 | 37 | static void status_led_set(int value) 38 | { 39 | if (device_is_ready(status_led_spec.port)) { 40 | gpio_pin_set_dt(&status_led_spec, value); 41 | } 42 | } 43 | 44 | void status_led_on(void) 45 | { 46 | status_led_set(1); 47 | } 48 | 49 | void status_led_off(void) 50 | { 51 | status_led_set(0); 52 | } 53 | 54 | void status_led_toggle(void) 55 | { 56 | if (device_is_ready(status_led_spec.port)) { 57 | gpio_pin_toggle_dt(&status_led_spec); 58 | } 59 | } 60 | #else // STATUS_LED_AVAILABLE 61 | 62 | void status_led_init(void) 63 | { 64 | } 65 | 66 | void status_led_on(void) 67 | { 68 | } 69 | 70 | void status_led_off(void) 71 | { 72 | } 73 | 74 | void status_led_toggle(void) 75 | { 76 | } 77 | #endif // STATUS_LED_AVAILABLE 78 | -------------------------------------------------------------------------------- /bubblemaker/src/status_led.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 AVSystem 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | 21 | #define STATUS_LED_NODE DT_ALIAS(status_led) 22 | #define STATUS_LED_AVAILABLE DT_NODE_HAS_STATUS(STATUS_LED_NODE, okay) 23 | 24 | void status_led_init(void); 25 | 26 | void status_led_on(void); 27 | 28 | void status_led_off(void); 29 | 30 | void status_led_toggle(void); 31 | -------------------------------------------------------------------------------- /bubblemaker/src/water_meter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 AVSystem 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | 21 | #define WATER_METER_0_NODE DT_ALIAS(water_meter_0) 22 | #define WATER_METER_1_NODE DT_ALIAS(water_meter_1) 23 | 24 | #define WATER_METER_0_AVAILABLE DT_NODE_HAS_STATUS(WATER_METER_0_NODE, okay) 25 | #define WATER_METER_1_AVAILABLE DT_NODE_HAS_STATUS(WATER_METER_1_NODE, okay) 26 | 27 | #if !WATER_METER_0_AVAILABLE && !WATER_METER_1_AVAILABLE 28 | #error "No water meter has been found in the devicetree" 29 | #endif // !WATER_METER_0_AVAILABLE && !WATER_METER_1_AVAILABLE 30 | 31 | int water_meter_init(void); 32 | void water_meter_instances_reset(void); 33 | bool water_meter_is_null(void); 34 | #if WATER_METER_0_AVAILABLE && WATER_METER_1_AVAILABLE 35 | void water_meter_get_cumulated_volumes(double *out_result); 36 | #endif // WATER_METER_0_AVAILABLE && WATER_METER_1_AVAILABLE 37 | 38 | const anjay_dm_object_def_t **water_meter_object_create(void); 39 | void water_meter_object_release(const anjay_dm_object_def_t **def); 40 | -------------------------------------------------------------------------------- /bubblemaker/src/water_pump.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 AVSystem 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "water_pump.h" 18 | 19 | #if WATER_PUMP_0_AVAILABLE 20 | #include 21 | #include 22 | #include 23 | 24 | LOG_MODULE_REGISTER(water_pump); 25 | 26 | /** 27 | * Application Type: RW, Single, Optional 28 | * type: string, range: N/A, unit: N/A 29 | * The application type of the sensor or actuator as a string depending 30 | * on the use case. 31 | */ 32 | #define RID_APPLICATION_TYPE 5750 33 | 34 | /** 35 | * Cumulative active power: R, Single, Optional 36 | * type: float, range: N/A, unit: Wh 37 | * The cumulative active power since the last cumulative energy reset or 38 | * device start. 39 | */ 40 | #define RID_CUMULATIVE_ACTIVE_POWER 5805 41 | 42 | /** 43 | * Power factor: R, Single, Optional 44 | * type: float, range: N/A, unit: N/A 45 | * If applicable, the power factor of the current consumption. 46 | */ 47 | #define RID_POWER_FACTOR 5820 48 | 49 | /** 50 | * On/Off: RW, Single, Mandatory 51 | * type: boolean, range: N/A, unit: N/A 52 | * On/off control. Boolean value where True is On and False is Off. 53 | */ 54 | #define RID_ON_OFF 5850 55 | 56 | /** 57 | * Dimmer: RW, Single, Optional 58 | * type: integer, range: 0..100, unit: /100 59 | * This resource represents a dimmer setting, which has an Integer value 60 | * between 0 and 100 as a percentage. 61 | */ 62 | #define RID_DIMMER 5851 63 | 64 | /** 65 | * On time: RW, Single, Optional 66 | * type: integer, range: N/A, unit: s 67 | * The time in seconds that the device has been on. Writing a value of 0 68 | * resets the counter. 69 | */ 70 | #define RID_ON_TIME 5852 71 | 72 | #define SYNCHRONIZED(Mtx) \ 73 | for (int _synchronized_exit = k_mutex_lock(&(Mtx), K_FOREVER); !_synchronized_exit; \ 74 | _synchronized_exit = -1, k_mutex_unlock(&(Mtx))) 75 | 76 | static K_MUTEX_DEFINE(water_pump_mutex); 77 | 78 | static struct k_work gpio_toggle_work; 79 | 80 | static const struct gpio_dt_spec water_pump_0_spec = GPIO_DT_SPEC_GET(WATER_PUMP_0_NODE, gpios); 81 | static const struct gpio_dt_spec button_0_spec = GPIO_DT_SPEC_GET(BUTTON_0_NODE, gpios); 82 | 83 | static struct gpio_callback button_0_callback; 84 | 85 | struct power_control_instance { 86 | anjay_iid_t iid; 87 | char application_type[64]; 88 | bool state; 89 | }; 90 | 91 | struct power_control_object { 92 | const anjay_dm_object_def_t *def; 93 | 94 | AVS_LIST(struct power_control_instance) instances; 95 | }; 96 | 97 | static inline struct power_control_object *get_obj(const anjay_dm_object_def_t *const *obj_ptr) 98 | { 99 | assert(obj_ptr); 100 | return AVS_CONTAINER_OF(obj_ptr, struct power_control_object, def); 101 | } 102 | 103 | static struct power_control_instance *find_instance(const struct power_control_object *obj, 104 | anjay_iid_t iid) 105 | { 106 | AVS_LIST(struct power_control_instance) it; 107 | AVS_LIST_FOREACH(it, obj->instances) 108 | { 109 | if (it->iid == iid) { 110 | return it; 111 | } else if (it->iid > iid) { 112 | break; 113 | } 114 | } 115 | 116 | return NULL; 117 | } 118 | 119 | static int list_instances(anjay_t *anjay, const anjay_dm_object_def_t *const *obj_ptr, 120 | anjay_dm_list_ctx_t *ctx) 121 | { 122 | (void)anjay; 123 | 124 | AVS_LIST(struct power_control_instance) it; 125 | AVS_LIST_FOREACH(it, get_obj(obj_ptr)->instances) 126 | { 127 | anjay_dm_emit(ctx, it->iid); 128 | } 129 | 130 | return 0; 131 | } 132 | 133 | static int init_instance(struct power_control_instance *inst, anjay_iid_t iid) 134 | { 135 | assert(iid != ANJAY_ID_INVALID); 136 | 137 | inst->iid = iid; 138 | strncpy(inst->application_type, "Water pump", sizeof(inst->application_type)); 139 | SYNCHRONIZED(water_pump_mutex) 140 | { 141 | inst->state = gpio_pin_get_dt(&water_pump_0_spec); 142 | } 143 | 144 | return 0; 145 | } 146 | 147 | static void release_instance(struct power_control_instance *inst) 148 | { 149 | (void)inst; 150 | } 151 | 152 | static struct power_control_instance *add_instance(struct power_control_object *obj, 153 | anjay_iid_t iid) 154 | { 155 | assert(find_instance(obj, iid) == NULL); 156 | 157 | AVS_LIST(struct power_control_instance) 158 | created = AVS_LIST_NEW_ELEMENT(struct power_control_instance); 159 | if (!created) { 160 | return NULL; 161 | } 162 | 163 | int result = init_instance(created, iid); 164 | 165 | if (result) { 166 | AVS_LIST_CLEAR(&created); 167 | return NULL; 168 | } 169 | 170 | AVS_LIST(struct power_control_instance) * ptr; 171 | AVS_LIST_FOREACH_PTR(ptr, &obj->instances) 172 | { 173 | if ((*ptr)->iid > created->iid) { 174 | break; 175 | } 176 | } 177 | 178 | AVS_LIST_INSERT(ptr, created); 179 | return created; 180 | } 181 | 182 | static int instance_create(anjay_t *anjay, const anjay_dm_object_def_t *const *obj_ptr, 183 | anjay_iid_t iid) 184 | { 185 | (void)anjay; 186 | struct power_control_object *obj = get_obj(obj_ptr); 187 | 188 | return add_instance(obj, iid) ? 0 : ANJAY_ERR_INTERNAL; 189 | } 190 | 191 | static int instance_remove(anjay_t *anjay, const anjay_dm_object_def_t *const *obj_ptr, 192 | anjay_iid_t iid) 193 | { 194 | (void)anjay; 195 | struct power_control_object *obj = get_obj(obj_ptr); 196 | 197 | AVS_LIST(struct power_control_instance) * it; 198 | AVS_LIST_FOREACH_PTR(it, &obj->instances) 199 | { 200 | if ((*it)->iid == iid) { 201 | release_instance(*it); 202 | AVS_LIST_DELETE(it); 203 | return 0; 204 | } else if ((*it)->iid > iid) { 205 | break; 206 | } 207 | } 208 | 209 | assert(0); 210 | return ANJAY_ERR_NOT_FOUND; 211 | } 212 | 213 | static int instance_reset(anjay_t *anjay, const anjay_dm_object_def_t *const *obj_ptr, 214 | anjay_iid_t iid) 215 | { 216 | (void)anjay; 217 | 218 | struct power_control_object *obj = get_obj(obj_ptr); 219 | struct power_control_instance *inst = find_instance(obj, iid); 220 | 221 | assert(inst); 222 | 223 | return 0; 224 | } 225 | 226 | static int list_resources(anjay_t *anjay, const anjay_dm_object_def_t *const *obj_ptr, 227 | anjay_iid_t iid, anjay_dm_resource_list_ctx_t *ctx) 228 | { 229 | (void)anjay; 230 | (void)obj_ptr; 231 | (void)iid; 232 | 233 | anjay_dm_emit_res(ctx, RID_APPLICATION_TYPE, ANJAY_DM_RES_RW, ANJAY_DM_RES_PRESENT); 234 | anjay_dm_emit_res(ctx, RID_CUMULATIVE_ACTIVE_POWER, ANJAY_DM_RES_R, ANJAY_DM_RES_ABSENT); 235 | anjay_dm_emit_res(ctx, RID_POWER_FACTOR, ANJAY_DM_RES_R, ANJAY_DM_RES_ABSENT); 236 | anjay_dm_emit_res(ctx, RID_ON_OFF, ANJAY_DM_RES_RW, ANJAY_DM_RES_PRESENT); 237 | anjay_dm_emit_res(ctx, RID_DIMMER, ANJAY_DM_RES_RW, ANJAY_DM_RES_ABSENT); 238 | anjay_dm_emit_res(ctx, RID_ON_TIME, ANJAY_DM_RES_RW, ANJAY_DM_RES_ABSENT); 239 | return 0; 240 | } 241 | 242 | static int resource_read(anjay_t *anjay, const anjay_dm_object_def_t *const *obj_ptr, 243 | anjay_iid_t iid, anjay_rid_t rid, anjay_riid_t riid, 244 | anjay_output_ctx_t *ctx) 245 | { 246 | (void)anjay; 247 | 248 | struct power_control_object *obj = get_obj(obj_ptr); 249 | struct power_control_instance *inst = find_instance(obj, iid); 250 | 251 | assert(inst); 252 | 253 | switch (rid) { 254 | case RID_APPLICATION_TYPE: 255 | assert(riid == ANJAY_ID_INVALID); 256 | return anjay_ret_string(ctx, inst->application_type); 257 | 258 | case RID_ON_OFF: 259 | assert(riid == ANJAY_ID_INVALID); 260 | SYNCHRONIZED(water_pump_mutex) 261 | { 262 | inst->state = gpio_pin_get_dt(&water_pump_0_spec); 263 | } 264 | return anjay_ret_bool(ctx, inst->state); 265 | 266 | default: 267 | return ANJAY_ERR_METHOD_NOT_ALLOWED; 268 | } 269 | } 270 | 271 | static int resource_write(anjay_t *anjay, const anjay_dm_object_def_t *const *obj_ptr, 272 | anjay_iid_t iid, anjay_rid_t rid, anjay_riid_t riid, 273 | anjay_input_ctx_t *ctx) 274 | { 275 | (void)anjay; 276 | 277 | struct power_control_object *obj = get_obj(obj_ptr); 278 | struct power_control_instance *inst = find_instance(obj, iid); 279 | 280 | assert(inst); 281 | 282 | switch (rid) { 283 | case RID_APPLICATION_TYPE: { 284 | assert(riid == ANJAY_ID_INVALID); 285 | return anjay_get_string(ctx, inst->application_type, 286 | sizeof(inst->application_type)); 287 | } 288 | 289 | case RID_ON_OFF: { 290 | assert(riid == ANJAY_ID_INVALID); 291 | bool value; 292 | int ret = anjay_get_bool(ctx, &value); 293 | 294 | SYNCHRONIZED(water_pump_mutex) 295 | { 296 | inst->state = value; 297 | gpio_pin_set_dt(&water_pump_0_spec, value); 298 | } 299 | return ret; 300 | } 301 | 302 | default: 303 | return ANJAY_ERR_METHOD_NOT_ALLOWED; 304 | } 305 | } 306 | 307 | static const anjay_dm_object_def_t OBJ_DEF = { 308 | .oid = 3312, 309 | .handlers = { .list_instances = list_instances, 310 | .instance_create = instance_create, 311 | .instance_remove = instance_remove, 312 | .instance_reset = instance_reset, 313 | 314 | .list_resources = list_resources, 315 | .resource_read = resource_read, 316 | .resource_write = resource_write, 317 | 318 | .transaction_begin = anjay_dm_transaction_NOOP, 319 | .transaction_validate = anjay_dm_transaction_NOOP, 320 | .transaction_commit = anjay_dm_transaction_NOOP, 321 | .transaction_rollback = anjay_dm_transaction_NOOP } 322 | }; 323 | 324 | const anjay_dm_object_def_t **power_control_object_create(void) 325 | { 326 | struct power_control_object *obj = 327 | (struct power_control_object *)avs_calloc(1, sizeof(struct power_control_object)); 328 | if (!obj) { 329 | return NULL; 330 | } 331 | obj->def = &OBJ_DEF; 332 | 333 | if (!add_instance(obj, 0)) { 334 | avs_free(obj); 335 | return NULL; 336 | } 337 | 338 | return &obj->def; 339 | } 340 | 341 | void power_control_object_release(const anjay_dm_object_def_t **def) 342 | { 343 | if (def) { 344 | struct power_control_object *obj = get_obj(def); 345 | 346 | AVS_LIST_CLEAR(&obj->instances) 347 | { 348 | release_instance(obj->instances); 349 | } 350 | avs_free(obj); 351 | } 352 | } 353 | 354 | static void button_0_callback_handler(const struct device *port, struct gpio_callback *cb, 355 | gpio_port_pins_t pins) 356 | { 357 | k_work_submit(&gpio_toggle_work); 358 | } 359 | 360 | void gpio_toggle_work_handler(struct k_work *work) 361 | { 362 | SYNCHRONIZED(water_pump_mutex) 363 | { 364 | gpio_pin_toggle_dt(&water_pump_0_spec); 365 | } 366 | } 367 | 368 | int water_pump_initialize(void) 369 | { 370 | if (!device_is_ready(water_pump_0_spec.port)) { 371 | LOG_ERR("Water Pump 0 is not ready"); 372 | return -1; 373 | } 374 | 375 | gpio_pin_configure_dt(&water_pump_0_spec, GPIO_OUTPUT_ACTIVE | GPIO_INPUT); 376 | 377 | if (!device_is_ready(button_0_spec.port)) { 378 | LOG_ERR("Button 0 is not ready"); 379 | return -1; 380 | } 381 | 382 | gpio_pin_configure_dt(&button_0_spec, GPIO_INPUT); 383 | gpio_init_callback(&button_0_callback, button_0_callback_handler, BIT(button_0_spec.pin)); 384 | gpio_add_callback(button_0_spec.port, &button_0_callback); 385 | gpio_pin_interrupt_configure_dt(&button_0_spec, GPIO_INT_EDGE_RISING); 386 | 387 | k_work_init(&gpio_toggle_work, gpio_toggle_work_handler); 388 | 389 | return 0; 390 | } 391 | #endif // WATER_PUMP_0_AVAILABLE 392 | -------------------------------------------------------------------------------- /bubblemaker/src/water_pump.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 AVSystem 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | 21 | #include 22 | 23 | #define WATER_PUMP_0_NODE DT_ALIAS(water_pump_0) 24 | #define WATER_PUMP_0_AVAILABLE DT_NODE_HAS_STATUS(WATER_PUMP_0_NODE, okay) 25 | 26 | #define BUTTON_0_NODE DT_ALIAS(push_button_0) 27 | #define BUTTON_0_AVAILABLE DT_NODE_HAS_STATUS(BUTTON_0_NODE, okay) 28 | 29 | #if WATER_PUMP_0_AVAILABLE 30 | int water_pump_initialize(void); 31 | 32 | const anjay_dm_object_def_t **power_control_object_create(void); 33 | void power_control_object_release(const anjay_dm_object_def_t **def); 34 | 35 | #endif // WATER_PUMP_0_AVAILABLE 36 | -------------------------------------------------------------------------------- /bubblemaker/west-nrf.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2020-2025 AVSystem 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Manifest for sdk-nrf based samples 16 | manifest: 17 | remotes: 18 | - name: anjay 19 | url-base: https://github.com/AVSystem 20 | - name: ncs 21 | url-base: https://github.com/nrfconnect 22 | projects: 23 | - name: sdk-nrf 24 | path: nrf 25 | remote: ncs 26 | revision: v2.7.0 27 | import: true 28 | - name: Anjay-zephyr 29 | submodules: true 30 | remote: anjay 31 | revision: 3.10.0 32 | path: modules/lib/anjay 33 | -------------------------------------------------------------------------------- /demo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2020-2025 AVSystem 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | cmake_minimum_required(VERSION 3.13.1) 16 | find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) 17 | project(anjay_zephyr_demo) 18 | set(root_dir ${ANJAY_ZEPHYR_CLIENT_DIR}) 19 | 20 | if(CONFIG_PARTITION_MANAGER_ENABLED) 21 | if(CONFIG_ANJAY_ZEPHYR_FOTA) 22 | # defined in nrf/cmake/partition_manager.cmake 23 | if(NOT EXISTS "${static_configuration_file}") 24 | set(pm_missing_message "Missing static partition manager file for board: ${BOARD}") 25 | 26 | if(ACTIVE_BOARD_REVISION) 27 | set(pm_missing_message "${pm_missing_message}, rev: ${ACTIVE_BOARD_REVISION}") 28 | endif() 29 | 30 | if(CONF_FILE_BUILD_TYPE) 31 | set(pm_missing_message "${pm_missing_message}, build type: ${CONF_FILE_BUILD_TYPE}") 32 | endif() 33 | 34 | if(NOT SKIP_PM_CHECK) 35 | message(FATAL_ERROR "${pm_missing_message}. If you want to skip this warning, temporarily pass -DSKIP_PM_CHECK=ON to CMake args.") 36 | endif() 37 | endif() 38 | endif() 39 | endif() 40 | 41 | if(CONFIG_ANJAY_ZEPHYR_FACTORY_PROVISIONING_INITIAL_FLASH) 42 | set(app_sources 43 | src/factory_provisioning/factory_flash.c 44 | src/factory_provisioning/factory_flash.h 45 | src/factory_provisioning/provisioning_app.c) 46 | else() 47 | set(app_sources 48 | src/main_app.c 49 | src/sensors_config.c 50 | src/sensors_config.h 51 | src/status_led.c 52 | src/status_led.h 53 | src/peripherals.h) 54 | endif() 55 | 56 | target_sources(app PRIVATE 57 | ${app_sources}) 58 | -------------------------------------------------------------------------------- /demo/Kconfig: -------------------------------------------------------------------------------- 1 | menu "anjay-zephyr-client-app" 2 | 3 | endmenu 4 | 5 | source "Kconfig.zephyr" 6 | -------------------------------------------------------------------------------- /demo/_sysbuild/mcuboot/boards/disco_l475_iot1.conf: -------------------------------------------------------------------------------- 1 | CONFIG_BOOT_MAX_IMG_SECTORS=512 2 | 3 | CONFIG_WATCHDOG=n 4 | CONFIG_IWDG_STM32=n 5 | -------------------------------------------------------------------------------- /demo/_sysbuild/mcuboot/boards/disco_l475_iot1.overlay: -------------------------------------------------------------------------------- 1 | / { 2 | chosen { 3 | zephyr,code-partition = &boot_partition; 4 | }; 5 | }; 6 | -------------------------------------------------------------------------------- /demo/_sysbuild/mcuboot/boards/tmo_dev_edge.conf: -------------------------------------------------------------------------------- 1 | CONFIG_SPI=y 2 | CONFIG_SPI_NOR=y 3 | CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096 4 | CONFIG_STREAM_FLASH_ERASE=y 5 | 6 | CONFIG_BOOT_MAX_IMG_SECTORS=512 7 | -------------------------------------------------------------------------------- /demo/_sysbuild/mcuboot/boards/tmo_dev_edge.overlay: -------------------------------------------------------------------------------- 1 | / { 2 | chosen { 3 | zephyr,code-partition = &boot_partition; 4 | }; 5 | }; 6 | 7 | #include "../../../boards/tmo_dev_edge_partitions.overlay" 8 | -------------------------------------------------------------------------------- /demo/boards/arduino_nano_33_ble_sense.conf: -------------------------------------------------------------------------------- 1 | # anjay-zephyr-client 2 | CONFIG_ANJAY_ZEPHYR_DEVICE_MANUFACTURER="Arduino" 3 | CONFIG_ANJAY_ZEPHYR_MODEL_NUMBER="arduino_nano_33_ble" 4 | 5 | # Anjay Settings 6 | CONFIG_ANJAY_COMPAT_TIME=y 7 | CONFIG_ANJAY_COMPAT_MBEDTLS=y 8 | CONFIG_ANJAY_COMPAT_NET=y 9 | 10 | # General Settings 11 | CONFIG_MAIN_STACK_SIZE=2048 12 | CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048 13 | 14 | # Logging 15 | CONFIG_LOG_BLOCK_IN_THREAD=y 16 | CONFIG_LOG_MODE_DEFERRED=y 17 | 18 | # Clock synchronization 19 | CONFIG_DATE_TIME=y 20 | CONFIG_DATE_TIME_AUTO_UPDATE=n 21 | 22 | # Networking 23 | CONFIG_NET_IPV4=n 24 | CONFIG_NET_IPV6=y 25 | CONFIG_NET_IPV6_NBR_CACHE=n 26 | CONFIG_NET_IPV6_MLD=n 27 | CONFIG_NET_CONFIG_NEED_IPV4=n 28 | CONFIG_NET_MGMT_EVENT_INFO=y 29 | CONFIG_NET_L2_OPENTHREAD=y 30 | 31 | # DNS 32 | CONFIG_DNS_RESOLVER=y 33 | CONFIG_DNS_SERVER_IP_ADDRESSES=y 34 | CONFIG_DNS_SERVER1="fdaa:bb:1::2" 35 | 36 | # OpenThread 37 | CONFIG_OPENTHREAD_JOINER=y 38 | CONFIG_OPENTHREAD_JOINER_AUTOSTART=y 39 | CONFIG_OPENTHREAD_MANUAL_START=y 40 | CONFIG_OPENTHREAD_SLAAC=y 41 | CONFIG_OPENTHREAD_JOINER_PSKD="J01NME" 42 | CONFIG_OPENTHREAD_FTD=y 43 | 44 | # MbedTLS and security 45 | CONFIG_MBEDTLS_LEGACY_CRYPTO_C=y 46 | CONFIG_MBEDTLS_CTR_DRBG_C=y 47 | CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED=y 48 | CONFIG_MBEDTLS_HEAP_SIZE=15360 49 | 50 | # Sensors 51 | CONFIG_I2C=y 52 | CONFIG_SENSOR=y 53 | CONFIG_LPS22HB=y 54 | CONFIG_APDS9960=y 55 | 56 | # Shell settings 57 | CONFIG_SHELL_MINIMAL=y 58 | CONFIG_SHELL_WILDCARD=n 59 | CONFIG_SHELL_VT100_COMMANDS=y 60 | CONFIG_SHELL_VT100_COLORS=n 61 | CONFIG_SHELL_STATS=n 62 | CONFIG_SHELL_CMDS=n 63 | CONFIG_SHELL_TAB=y 64 | CONFIG_SHELL_TAB_AUTOCOMPLETION=y 65 | CONFIG_SHELL_CMDS_RESIZE=n 66 | CONFIG_DEVICE_SHELL=n 67 | CONFIG_DATE_SHELL=n 68 | CONFIG_DEVMEM_SHELL=n 69 | CONFIG_MCUBOOT_SHELL=n 70 | CONFIG_KERNEL_SHELL=y 71 | CONFIG_OPENTHREAD_SHELL=y 72 | -------------------------------------------------------------------------------- /demo/boards/arduino_nano_33_ble_sense.overlay: -------------------------------------------------------------------------------- 1 | / { 2 | aliases { 3 | barometer = &lps22hb_press; 4 | temperature = &lps22hb_press; 5 | status-led = &led1; 6 | }; 7 | }; 8 | 9 | &i2c1 { 10 | lps22hb_press: lps22hb-press@5c {}; 11 | apds9960: apds9960@39 {}; 12 | }; -------------------------------------------------------------------------------- /demo/boards/disco_l475_iot1.conf: -------------------------------------------------------------------------------- 1 | # anjay-zephyr-client 2 | CONFIG_ANJAY_ZEPHYR_DEVICE_MANUFACTURER="STMicroelectronics" 3 | CONFIG_ANJAY_ZEPHYR_MODEL_NUMBER="B-L475E-IOT01A" 4 | CONFIG_ANJAY_ZEPHYR_FOTA=y 5 | CONFIG_ANJAY_ZEPHYR_THREAD_STACK_SIZE=6144 6 | 7 | # Networking 8 | CONFIG_ANJAY_COMPAT_MBEDTLS=y 9 | CONFIG_ANJAY_COMPAT_NET=y 10 | 11 | # General settings 12 | CONFIG_MAIN_STACK_SIZE=2048 13 | CONFIG_POSIX_API=y 14 | CONFIG_STREAM_FLASH=y 15 | 16 | # Networking 17 | CONFIG_WIFI=y 18 | CONFIG_WIFI_LOG_LEVEL_ERR=y 19 | CONFIG_NET_L2_WIFI_MGMT=y 20 | CONFIG_NET_L2_WIFI_MGMT_LOG_LEVEL_ERR=y 21 | 22 | # MbedTLS and security 23 | CONFIG_MBEDTLS_CIPHER_CCM_ENABLED=y 24 | CONFIG_ENTROPY_DEVICE_RANDOM_GENERATOR=y 25 | CONFIG_ENTROPY_STM32_RNG=y 26 | 27 | # Sensors 28 | CONFIG_I2C=y 29 | CONFIG_SENSOR=y 30 | CONFIG_HTS221=y 31 | CONFIG_VL53L0X=y 32 | CONFIG_LPS22HB=y 33 | CONFIG_LSM6DSL=y 34 | CONFIG_LSM6DSL_GYRO_ODR=1 35 | CONFIG_LSM6DSL_ACCEL_ODR=1 36 | CONFIG_LIS3MDL=y 37 | 38 | # Clock synchronization 39 | CONFIG_SNTP=y 40 | 41 | # Boot options 42 | CONFIG_BOOTLOADER_MCUBOOT=y 43 | # Note: if relative paths are used here, it is treated as 44 | # relative to $WEST_TOPDIR (typically ~/zephyrproject) 45 | CONFIG_MCUBOOT_SIGNATURE_KEY_FILE="bootloader/mcuboot/root-rsa-2048.pem" 46 | CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION="25.5.0" 47 | -------------------------------------------------------------------------------- /demo/boards/disco_l475_iot1.overlay: -------------------------------------------------------------------------------- 1 | / { 2 | aliases { 3 | temperature = &hts221; 4 | humidity = &hts221; 5 | accelerometer = &lsm6dsl; 6 | magnetometer = &lis3mdl_magn; 7 | barometer = &lps22hb_press; 8 | distance = &vl53l0x; 9 | gyrometer = &lsm6dsl; 10 | push-button-0 = &user_button; 11 | status-led = &green_led_1; 12 | }; 13 | }; 14 | 15 | &i2c2 { 16 | hts221: hts221@5f {}; 17 | lsm6dsl: lsm6dsl@6a {}; 18 | lis3mdl_magn: lis3mdl-magn@1e {}; 19 | lps22hb_press: lps22hb-press@5d {}; 20 | vl53l0x: vl53l0x@29 {}; 21 | }; 22 | -------------------------------------------------------------------------------- /demo/boards/esp32_devkitc_wroom.conf: -------------------------------------------------------------------------------- 1 | # anjay-zephyr-client 2 | CONFIG_ANJAY_ZEPHYR_DEVICE_MANUFACTURER="Espressif" 3 | CONFIG_ANJAY_ZEPHYR_MODEL_NUMBER="ESP32-DevKitC" 4 | 5 | # General 6 | CONFIG_NEWLIB_LIBC=y 7 | CONFIG_NEWLIB_LIBC_NANO=n 8 | 9 | # Networking 10 | CONFIG_ANJAY_COMPAT_NET=y 11 | 12 | CONFIG_NETWORKING=y 13 | CONFIG_POSIX_API=y 14 | CONFIG_NET_L2_WIFI_MGMT=y 15 | CONFIG_NET_MGMT=y 16 | CONFIG_NET_MGMT_EVENT=y 17 | CONFIG_NET_LOG=y 18 | CONFIG_DNS_RESOLVER=y 19 | 20 | # MbedTLS and security 21 | CONFIG_ANJAY_COMPAT_MBEDTLS=y 22 | CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED=y 23 | CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y 24 | 25 | # Clock synchronization 26 | CONFIG_SNTP=y 27 | 28 | # ESP32 Wi-Fi 29 | CONFIG_WIFI=y 30 | CONFIG_WIFI_ESP32=y 31 | CONFIG_HEAP_MEM_POOL_SIZE=98304 32 | CONFIG_NET_L2_ETHERNET=y 33 | CONFIG_NET_DEFAULT_IF_FIRST=y 34 | 35 | CONFIG_NET_IPV6=n 36 | CONFIG_NET_IPV4=y 37 | CONFIG_NET_DHCPV4=y 38 | 39 | # ESP32 memory optimization 40 | CONFIG_ESP32_WIFI_IRAM_OPT=n 41 | CONFIG_ESP32_WIFI_RX_IRAM_OPT=n 42 | -------------------------------------------------------------------------------- /demo/boards/esp32_devkitc_wroom.overlay: -------------------------------------------------------------------------------- 1 | &wifi { 2 | status = "okay"; 3 | }; 4 | -------------------------------------------------------------------------------- /demo/boards/nrf52840dk_nrf52840.conf: -------------------------------------------------------------------------------- 1 | # anjay-zephyr-client 2 | CONFIG_ANJAY_ZEPHYR_DEVICE_MANUFACTURER="Nordic Semiconductor" 3 | CONFIG_ANJAY_ZEPHYR_MODEL_NUMBER="nRF52840DK" 4 | 5 | # Anjay Settings 6 | CONFIG_ANJAY_COMPAT_TIME=y 7 | CONFIG_ANJAY_COMPAT_MBEDTLS=y 8 | CONFIG_ANJAY_COMPAT_NET=y 9 | 10 | # General Settings 11 | CONFIG_MAIN_STACK_SIZE=2048 12 | CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048 13 | 14 | # Logging 15 | CONFIG_LOG_BLOCK_IN_THREAD=y 16 | CONFIG_LOG_MODE_DEFERRED=y 17 | 18 | # Clock synchronization 19 | CONFIG_DATE_TIME=y 20 | CONFIG_DATE_TIME_AUTO_UPDATE=n 21 | 22 | # Networking 23 | CONFIG_NET_IPV4=n 24 | CONFIG_NET_IPV6=y 25 | CONFIG_NET_IPV6_NBR_CACHE=n 26 | CONFIG_NET_IPV6_MLD=n 27 | CONFIG_NET_CONFIG_NEED_IPV4=n 28 | CONFIG_NET_MGMT_EVENT_INFO=y 29 | CONFIG_NET_L2_OPENTHREAD=y 30 | 31 | # DNS 32 | CONFIG_DNS_RESOLVER=y 33 | CONFIG_DNS_SERVER_IP_ADDRESSES=y 34 | CONFIG_DNS_SERVER1="fdaa:bb:1::2" 35 | 36 | # OpenThread 37 | CONFIG_OPENTHREAD_JOINER=y 38 | CONFIG_OPENTHREAD_JOINER_AUTOSTART=y 39 | CONFIG_OPENTHREAD_MANUAL_START=y 40 | CONFIG_OPENTHREAD_SLAAC=y 41 | CONFIG_OPENTHREAD_JOINER_PSKD="J01NME" 42 | CONFIG_OPENTHREAD_FTD=y 43 | 44 | # MbedTLS and security 45 | CONFIG_MBEDTLS_LEGACY_CRYPTO_C=y 46 | CONFIG_MBEDTLS_CTR_DRBG_C=y 47 | CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED=y 48 | CONFIG_MBEDTLS_HEAP_SIZE=12288 49 | 50 | # Shell settings 51 | CONFIG_SHELL_MINIMAL=y 52 | CONFIG_SHELL_WILDCARD=n 53 | CONFIG_SHELL_VT100_COMMANDS=y 54 | CONFIG_SHELL_VT100_COLORS=n 55 | CONFIG_SHELL_STATS=n 56 | CONFIG_SHELL_CMDS=n 57 | CONFIG_SHELL_TAB=y 58 | CONFIG_SHELL_TAB_AUTOCOMPLETION=y 59 | CONFIG_SHELL_CMDS_RESIZE=n 60 | CONFIG_DEVICE_SHELL=n 61 | CONFIG_DATE_SHELL=n 62 | CONFIG_DEVMEM_SHELL=n 63 | CONFIG_MCUBOOT_SHELL=n 64 | CONFIG_KERNEL_SHELL=y 65 | CONFIG_OPENTHREAD_SHELL=y 66 | -------------------------------------------------------------------------------- /demo/boards/nrf52840dk_nrf52840.overlay: -------------------------------------------------------------------------------- 1 | / { 2 | aliases { 3 | push-button-0 = &button0; 4 | push-button-1 = &button1; 5 | push-button-2 = &button2; 6 | push-button-3 = &button3; 7 | status-led = &led0; 8 | }; 9 | }; 10 | -------------------------------------------------------------------------------- /demo/boards/nrf7002dk_nrf5340_cpuapp_ns.conf: -------------------------------------------------------------------------------- 1 | # anjay-zephyr-client 2 | CONFIG_ANJAY_ZEPHYR_DEVICE_MANUFACTURER="Nordic Semiconductor" 3 | CONFIG_ANJAY_ZEPHYR_MODEL_NUMBER="nRF7002DK" 4 | 5 | CONFIG_ANJAY_ZEPHYR_FOTA=y 6 | 7 | # Anjay Settings 8 | CONFIG_ANJAY_COMPAT_MBEDTLS=y 9 | CONFIG_ANJAY_COMPAT_NET=y 10 | CONFIG_ANJAY_LOG_LEVEL_INF=y 11 | CONFIG_ANJAY_WITH_NET_STATS=n 12 | CONFIG_ANJAY_WITH_TRACE_LOGS=n 13 | CONFIG_ANJAY_WITH_ACCESS_CONTROL=n 14 | 15 | # General Settings 16 | CONFIG_MAIN_STACK_SIZE=2048 17 | CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096 18 | CONFIG_LOG_MAX_LEVEL=3 19 | CONFIG_POSIX_MAX_FDS=16 20 | 21 | # Networking 22 | CONFIG_NET_NATIVE=y 23 | CONFIG_NET_DHCPV4=y 24 | CONFIG_DNS_RESOLVER=y 25 | # on nRF7002DK the default (4) is not enough. Besides DNS, DHCP, LwM2M server 26 | # connection and possible connection for FOTA download, there's also an EAPOL 27 | # connection opened by wpa_supplicant. 28 | CONFIG_NET_MAX_CONN=5 29 | 30 | # WiFi 31 | CONFIG_WIFI=y 32 | CONFIG_WIFI_NRF700X=y 33 | CONFIG_WPA_SUPP=y 34 | CONFIG_WPA_SUPP_CRYPTO_PSA=y 35 | CONFIG_PSA_WANT_ALG_HMAC=y 36 | CONFIG_NET_L2_WIFI_MGMT=y 37 | CONFIG_NET_L2_WIFI_MGMT_LOG_LEVEL_ERR=y 38 | CONFIG_NET_L2_ETHERNET=y 39 | 40 | # Clock synchronization 41 | CONFIG_DATE_TIME=y 42 | CONFIG_DATE_TIME_UPDATE_INTERVAL_SECONDS=600 43 | CONFIG_DATE_TIME_TOO_OLD_SECONDS=600 44 | CONFIG_DATE_TIME_NTP_QUERY_TIME_SECONDS=5 45 | 46 | # File system 47 | CONFIG_STREAM_FLASH=y 48 | CONFIG_FLASH_PAGE_LAYOUT=y 49 | CONFIG_MPU_ALLOW_FLASH_WRITE=y 50 | 51 | # Heap 52 | CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=150000 53 | CONFIG_HEAP_MEM_POOL_SIZE=150000 54 | 55 | # MCUboot 56 | CONFIG_BOOTLOADER_MCUBOOT=y 57 | CONFIG_IMG_MANAGER=y 58 | CONFIG_IMG_ERASE_PROGRESSIVELY=y 59 | CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION="25.5.0" 60 | 61 | # External flash 62 | CONFIG_SPI=y 63 | CONFIG_SPI_NOR=y 64 | CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096 65 | CONFIG_SPI_NOR_SFDP_DEVICETREE=y 66 | CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y 67 | 68 | # Network core upgrades collide with app FOTA 69 | CONFIG_NRF53_UPGRADE_NETWORK_CORE=n 70 | -------------------------------------------------------------------------------- /demo/boards/nrf7002dk_nrf5340_cpuapp_ns.overlay: -------------------------------------------------------------------------------- 1 | / { 2 | aliases { 3 | push-button-0 = &button0; 4 | push-button-1 = &button1; 5 | status-led = &led0; 6 | light-control-0 = &led1; 7 | }; 8 | 9 | chosen { 10 | nordic,pm-ext-flash = &mx25r64; 11 | }; 12 | }; 13 | 14 | &mx25r64 { 15 | status = "ok"; 16 | }; 17 | -------------------------------------------------------------------------------- /demo/boards/nrf9151dk_nrf9151_ns.conf: -------------------------------------------------------------------------------- 1 | # anjay-zephyr-client 2 | CONFIG_ANJAY_ZEPHYR_DEVICE_MANUFACTURER="Nordic Semiconductor" 3 | CONFIG_ANJAY_ZEPHYR_MODEL_NUMBER="nRF9151DK" 4 | CONFIG_ANJAY_ZEPHYR_GPS=y 5 | CONFIG_ANJAY_ZEPHYR_GPS_NRF_A_GPS=y 6 | 7 | CONFIG_ANJAY_ZEPHYR_FOTA=y 8 | 9 | # Anjay Settings 10 | CONFIG_ANJAY_COMPAT_ZEPHYR_TLS=y 11 | CONFIG_ANJAY_COMPAT_NET=y 12 | CONFIG_ANJAY_COMPAT_TIME=y 13 | 14 | # General Settings 15 | CONFIG_MAIN_STACK_SIZE=2048 16 | CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096 17 | 18 | # Networking 19 | CONFIG_NET_NATIVE=n 20 | CONFIG_NET_IF_MAX_IPV4_COUNT=2 21 | CONFIG_NET_TCP_ISN_RFC6528=n 22 | CONFIG_NET_TCP=y 23 | 24 | # nRF modem information library 25 | CONFIG_MODEM_INFO=y 26 | 27 | # nRF modem library 28 | CONFIG_NRF_MODEM_LIB=y 29 | 30 | # nRF LTE 31 | CONFIG_LTE_LINK_CONTROL=y 32 | CONFIG_LTE_NETWORK_MODE_LTE_M_GPS=y 33 | CONFIG_LTE_NETWORK_TIMEOUT=600 34 | 35 | # Clock synchronization 36 | CONFIG_DATE_TIME=y 37 | CONFIG_DATE_TIME_UPDATE_INTERVAL_SECONDS=600 38 | CONFIG_DATE_TIME_TOO_OLD_SECONDS=600 39 | CONFIG_DATE_TIME_NTP_QUERY_TIME_SECONDS=5 40 | 41 | # File system 42 | CONFIG_FLASH_PAGE_LAYOUT=y 43 | CONFIG_MPU_ALLOW_FLASH_WRITE=y 44 | CONFIG_STREAM_FLASH=y 45 | 46 | # Heap 47 | CONFIG_HEAP_MEM_POOL_SIZE=2048 48 | 49 | # MCUboot 50 | CONFIG_BOOTLOADER_MCUBOOT=y 51 | CONFIG_IMG_MANAGER=y 52 | CONFIG_IMG_ERASE_PROGRESSIVELY=y 53 | CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION="25.5.0" 54 | 55 | # Config menu 56 | CONFIG_CONSOLE_SUBSYS=y 57 | CONFIG_CONSOLE_GETLINE=y 58 | 59 | # External flash 60 | CONFIG_SPI=y 61 | CONFIG_SPI_NOR=y 62 | CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096 63 | CONFIG_SPI_NOR_SFDP_DEVICETREE=y 64 | CONFIG_PM_OVERRIDE_EXTERNAL_DRIVER_CHECK=y 65 | -------------------------------------------------------------------------------- /demo/boards/nrf9151dk_nrf9151_ns.overlay: -------------------------------------------------------------------------------- 1 | / { 2 | aliases { 3 | push-button-0 = &button0; 4 | push-button-1 = &button1; 5 | switch-0 = &button2; 6 | switch-1 = &button3; 7 | status-led = &led0; 8 | }; 9 | 10 | /* Configure partition manager to use gd25wb256 as the external flash */ 11 | chosen { 12 | nordic,pm-ext-flash = &gd25wb256; 13 | }; 14 | }; 15 | 16 | &gd25wb256 { 17 | status = "okay"; 18 | }; 19 | -------------------------------------------------------------------------------- /demo/boards/nrf9160dk_nrf9160_ns.conf: -------------------------------------------------------------------------------- 1 | # anjay-zephyr-client 2 | CONFIG_ANJAY_ZEPHYR_DEVICE_MANUFACTURER="Nordic Semiconductor" 3 | CONFIG_ANJAY_ZEPHYR_MODEL_NUMBER="nRF9160DK" 4 | CONFIG_ANJAY_ZEPHYR_GPS=y 5 | CONFIG_ANJAY_ZEPHYR_GPS_NRF_A_GPS=y 6 | 7 | CONFIG_ANJAY_ZEPHYR_FOTA=y 8 | 9 | # Anjay Settings 10 | CONFIG_ANJAY_COMPAT_ZEPHYR_TLS=y 11 | CONFIG_ANJAY_COMPAT_NET=y 12 | CONFIG_ANJAY_COMPAT_TIME=y 13 | 14 | # General Settings 15 | CONFIG_MAIN_STACK_SIZE=2048 16 | CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096 17 | 18 | # Networking 19 | CONFIG_NET_NATIVE=n 20 | CONFIG_NET_IF_MAX_IPV4_COUNT=2 21 | CONFIG_NET_TCP_ISN_RFC6528=n 22 | CONFIG_NET_TCP=y 23 | 24 | # nRF modem information library 25 | CONFIG_MODEM_INFO=y 26 | 27 | # nRF modem library 28 | CONFIG_NRF_MODEM_LIB=y 29 | 30 | # nRF LTE 31 | CONFIG_LTE_LINK_CONTROL=y 32 | CONFIG_LTE_NETWORK_MODE_LTE_M_GPS=y 33 | CONFIG_LTE_NETWORK_TIMEOUT=600 34 | 35 | # Clock synchronization 36 | CONFIG_DATE_TIME=y 37 | CONFIG_DATE_TIME_UPDATE_INTERVAL_SECONDS=600 38 | CONFIG_DATE_TIME_TOO_OLD_SECONDS=600 39 | CONFIG_DATE_TIME_NTP_QUERY_TIME_SECONDS=5 40 | 41 | # File system 42 | CONFIG_FLASH_PAGE_LAYOUT=y 43 | CONFIG_MPU_ALLOW_FLASH_WRITE=y 44 | CONFIG_STREAM_FLASH=y 45 | 46 | # Heap 47 | CONFIG_HEAP_MEM_POOL_SIZE=2048 48 | 49 | # MCUboot 50 | CONFIG_BOOTLOADER_MCUBOOT=y 51 | CONFIG_IMG_MANAGER=y 52 | CONFIG_IMG_ERASE_PROGRESSIVELY=y 53 | CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION="25.5.0" 54 | 55 | # Config menu 56 | CONFIG_CONSOLE_SUBSYS=y 57 | CONFIG_CONSOLE_GETLINE=y 58 | 59 | # External flash 60 | CONFIG_SPI=y 61 | CONFIG_SPI_NOR=y 62 | CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096 63 | CONFIG_SPI_NOR_SFDP_DEVICETREE=y 64 | CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y 65 | -------------------------------------------------------------------------------- /demo/boards/nrf9160dk_nrf9160_ns.overlay: -------------------------------------------------------------------------------- 1 | / { 2 | aliases { 3 | push-button-0 = &button0; 4 | push-button-1 = &button1; 5 | switch-0 = &button2; 6 | switch-1 = &button3; 7 | status-led = &led0; 8 | }; 9 | }; 10 | -------------------------------------------------------------------------------- /demo/boards/nrf9160dk_nrf9160_ns_0_14_0.overlay: -------------------------------------------------------------------------------- 1 | / { 2 | chosen { 3 | nordic,pm-ext-flash = &mx25r64; 4 | }; 5 | }; 6 | 7 | &mx25r64 { 8 | status = "ok"; 9 | }; 10 | -------------------------------------------------------------------------------- /demo/boards/nrf9160dk_nrf9160_ns_intflash.conf: -------------------------------------------------------------------------------- 1 | # anjay-zephyr-client 2 | CONFIG_ANJAY_ZEPHYR_DEVICE_MANUFACTURER="Nordic Semiconductor" 3 | CONFIG_ANJAY_ZEPHYR_MODEL_NUMBER="nRF9160DK" 4 | CONFIG_ANJAY_ZEPHYR_GPS=y 5 | CONFIG_ANJAY_ZEPHYR_GPS_NRF_A_GPS=y 6 | 7 | CONFIG_ANJAY_ZEPHYR_FOTA=y 8 | 9 | # Anjay Settings 10 | CONFIG_ANJAY_COMPAT_ZEPHYR_TLS=y 11 | CONFIG_ANJAY_COMPAT_NET=y 12 | CONFIG_ANJAY_COMPAT_TIME=y 13 | CONFIG_ANJAY_LOG_LEVEL_INF=y 14 | CONFIG_ANJAY_WITH_NET_STATS=n 15 | CONFIG_ANJAY_WITH_SENML_JSON=y 16 | CONFIG_ANJAY_WITH_TRACE_LOGS=n 17 | CONFIG_ANJAY_WITH_ACCESS_CONTROL=n 18 | 19 | # General Settings 20 | CONFIG_MAIN_STACK_SIZE=2048 21 | CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096 22 | CONFIG_LOG_RUNTIME_FILTERING=n 23 | CONFIG_LOG_CMDS=n 24 | CONFIG_LOG_MAX_LEVEL=3 25 | CONFIG_HWINFO=n 26 | 27 | # Networking 28 | CONFIG_NET_NATIVE=n 29 | CONFIG_NET_IF_MAX_IPV4_COUNT=2 30 | CONFIG_NET_TCP_ISN_RFC6528=n 31 | CONFIG_NET_LOG=n 32 | 33 | # nRF modem information library 34 | CONFIG_MODEM_INFO=y 35 | 36 | # nRF modem library 37 | CONFIG_NRF_MODEM_LIB=y 38 | 39 | # nRF LTE 40 | CONFIG_LTE_LINK_CONTROL=y 41 | CONFIG_LTE_NETWORK_MODE_LTE_M_GPS=y 42 | CONFIG_LTE_NETWORK_TIMEOUT=600 43 | CONFIG_NRF_CLOUD_GPS_LOG_LEVEL_INF=y 44 | 45 | # Clock synchronization 46 | CONFIG_DATE_TIME=y 47 | CONFIG_DATE_TIME_UPDATE_INTERVAL_SECONDS=600 48 | CONFIG_DATE_TIME_TOO_OLD_SECONDS=600 49 | CONFIG_DATE_TIME_NTP_QUERY_TIME_SECONDS=5 50 | 51 | # File system 52 | CONFIG_FLASH_PAGE_LAYOUT=y 53 | CONFIG_MPU_ALLOW_FLASH_WRITE=y 54 | CONFIG_STREAM_FLASH=y 55 | 56 | # Heap 57 | CONFIG_HEAP_MEM_POOL_SIZE=2048 58 | 59 | # MCUboot 60 | CONFIG_BOOTLOADER_MCUBOOT=y 61 | CONFIG_IMG_MANAGER=y 62 | CONFIG_IMG_ERASE_PROGRESSIVELY=y 63 | CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION="25.5.0" 64 | 65 | # Shell settings 66 | CONFIG_SHELL_MINIMAL=y 67 | CONFIG_SHELL_WILDCARD=n 68 | CONFIG_SHELL_VT100_COMMANDS=y 69 | CONFIG_SHELL_VT100_COLORS=n 70 | CONFIG_SHELL_STATS=n 71 | CONFIG_SHELL_CMDS=n 72 | CONFIG_SHELL_TAB=y 73 | CONFIG_SHELL_TAB_AUTOCOMPLETION=y 74 | CONFIG_SHELL_CMDS_RESIZE=n 75 | CONFIG_DEVICE_SHELL=n 76 | CONFIG_DATE_SHELL=n 77 | CONFIG_DEVMEM_SHELL=n 78 | CONFIG_MCUBOOT_SHELL=n 79 | CONFIG_KERNEL_SHELL=y 80 | -------------------------------------------------------------------------------- /demo/boards/thingy91_nrf9160_ns.conf: -------------------------------------------------------------------------------- 1 | # anjay-zephyr-client 2 | CONFIG_ANJAY_ZEPHYR_DEVICE_MANUFACTURER="Nordic Semiconductor" 3 | CONFIG_ANJAY_ZEPHYR_MODEL_NUMBER="Thingy:91" 4 | CONFIG_ANJAY_ZEPHYR_GPS=y 5 | CONFIG_ANJAY_ZEPHYR_GPS_NRF_A_GPS=y 6 | 7 | CONFIG_ANJAY_ZEPHYR_FOTA=y 8 | 9 | # Anjay Settings 10 | CONFIG_ANJAY_COMPAT_ZEPHYR_TLS=y 11 | CONFIG_ANJAY_COMPAT_NET=y 12 | CONFIG_ANJAY_COMPAT_TIME=y 13 | CONFIG_ANJAY_WITH_NET_STATS=n 14 | CONFIG_ANJAY_WITH_SENML_JSON=y 15 | CONFIG_ANJAY_WITH_TRACE_LOGS=n 16 | CONFIG_ANJAY_WITH_ACCESS_CONTROL=n 17 | 18 | # I2C Settings 19 | CONFIG_I2C_SHELL=n 20 | 21 | # General Settings 22 | CONFIG_MAIN_STACK_SIZE=2048 23 | CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096 24 | CONFIG_INIT_STACKS=n 25 | CONFIG_LOG_RUNTIME_FILTERING=n 26 | CONFIG_LOG_CMDS=n 27 | CONFIG_LOG_MAX_LEVEL=3 28 | CONFIG_HWINFO=n 29 | CONFIG_CBPRINTF_NANO=y 30 | 31 | # Networking 32 | CONFIG_NET_NATIVE=n 33 | CONFIG_NET_IF_MAX_IPV4_COUNT=2 34 | CONFIG_NET_TCP_ISN_RFC6528=n 35 | CONFIG_NET_LOG=n 36 | 37 | # nRF modem information library 38 | CONFIG_MODEM_INFO=y 39 | 40 | # nRF modem library 41 | CONFIG_NRF_MODEM_LIB=y 42 | 43 | # nRF LTE 44 | CONFIG_LTE_LINK_CONTROL=y 45 | CONFIG_LTE_NETWORK_MODE_LTE_M_GPS=y 46 | CONFIG_LTE_NETWORK_TIMEOUT=600 47 | 48 | # Clock synchronization 49 | CONFIG_DATE_TIME=y 50 | CONFIG_DATE_TIME_UPDATE_INTERVAL_SECONDS=600 51 | CONFIG_DATE_TIME_TOO_OLD_SECONDS=600 52 | CONFIG_DATE_TIME_MODEM=n 53 | CONFIG_DATE_TIME_NTP_QUERY_TIME_SECONDS=5 54 | 55 | # File system 56 | CONFIG_FLASH_PAGE_LAYOUT=y 57 | CONFIG_MPU_ALLOW_FLASH_WRITE=y 58 | CONFIG_STREAM_FLASH=y 59 | 60 | # Heap 61 | CONFIG_HEAP_MEM_POOL_SIZE=2048 62 | 63 | # Peripherals 64 | CONFIG_I2C=y 65 | CONFIG_PWM=y 66 | CONFIG_SENSOR=y 67 | CONFIG_BME680=y 68 | CONFIG_ADXL362=y 69 | CONFIG_ADXL362_ACCEL_ODR_12_5=y 70 | CONFIG_ADXL362_ACCEL_RANGE_2G=y 71 | CONFIG_REGULATOR=n 72 | 73 | # MCUboot 74 | CONFIG_BOOTLOADER_MCUBOOT=y 75 | CONFIG_IMG_MANAGER=y 76 | CONFIG_IMG_ERASE_PROGRESSIVELY=y 77 | CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION="25.5.0" 78 | 79 | # Shell settings 80 | CONFIG_SHELL_MINIMAL=y 81 | CONFIG_SHELL_WILDCARD=n 82 | CONFIG_SHELL_VT100_COMMANDS=y 83 | CONFIG_SHELL_VT100_COLORS=n 84 | CONFIG_SHELL_STATS=n 85 | CONFIG_SHELL_CMDS=n 86 | CONFIG_SHELL_TAB=y 87 | CONFIG_SHELL_TAB_AUTOCOMPLETION=y 88 | CONFIG_SHELL_CMDS_RESIZE=n 89 | CONFIG_DATE_SHELL=n 90 | CONFIG_DEVICE_SHELL=n 91 | CONFIG_DEVMEM_SHELL=n 92 | CONFIG_KERNEL_SHELL=y 93 | CONFIG_LTE_SHELL=n 94 | CONFIG_MCUBOOT_SHELL=n 95 | CONFIG_PWM_SHELL=n 96 | CONFIG_CLOCK_CONTROL_NRF_SHELL=n 97 | 98 | # Log level 99 | CONFIG_ANJAY_LOG_LEVEL_INF=y 100 | CONFIG_LTE_LINK_CONTROL_LOG_LEVEL_WRN=y 101 | CONFIG_NRF_CLOUD_GPS_LOG_LEVEL_OFF=y 102 | CONFIG_NRF_CLOUD_LOG_LEVEL_OFF=y 103 | CONFIG_AT_MONITOR_LOG_LEVEL_ERR=y 104 | CONFIG_MODEM_KEY_MGMT_LOG_LEVEL_ERR=y 105 | CONFIG_MODEM_ANTENNA_LOG_LEVEL_ERR=y 106 | CONFIG_MPSL_FEM_LOG_LEVEL_ERR=y 107 | CONFIG_MPSL_LOG_LEVEL_ERR=y 108 | CONFIG_MGMT_FMFU_LOG_LEVEL_ERR=y 109 | CONFIG_DATE_TIME_LOG_LEVEL_ERR=y 110 | CONFIG_BOARD_LOG_LEVEL_ERR=y 111 | CONFIG_ARCH_LOG_LEVEL_ERR=y 112 | CONFIG_MPU_LOG_LEVEL_ERR=y 113 | CONFIG_UART_CONSOLE_LOG_LEVEL_ERR=y 114 | CONFIG_UART_LOG_LEVEL_ERR=y 115 | CONFIG_INTC_LOG_LEVEL_ERR=y 116 | CONFIG_ENTROPY_LOG_LEVEL_ERR=y 117 | CONFIG_GPIO_LOG_LEVEL_ERR=y 118 | CONFIG_SPI_LOG_LEVEL_ERR=y 119 | CONFIG_I2C_LOG_LEVEL_ERR=y 120 | CONFIG_PWM_LOG_LEVEL_ERR=y 121 | CONFIG_CLOCK_CONTROL_LOG_LEVEL_ERR=y 122 | CONFIG_PINCTRL_LOG_LEVEL_ERR=y 123 | CONFIG_USBC_LOG_LEVEL_ERR=y 124 | CONFIG_CBPRINTF_PACKAGE_LOG_LEVEL_ERR=y 125 | CONFIG_NVS_LOG_LEVEL_ERR=y 126 | CONFIG_SHELL_BACKEND_SERIAL_LOG_LEVEL_ERR=y 127 | CONFIG_IMG_MANAGER_LOG_LEVEL_ERR=y 128 | CONFIG_STREAM_FLASH_LOG_LEVEL_ERR=y 129 | -------------------------------------------------------------------------------- /demo/boards/thingy91_nrf9160_ns.overlay: -------------------------------------------------------------------------------- 1 | / { 2 | aliases { 3 | temperature = &bme680; 4 | humidity = &bme680; 5 | accelerometer = &adxl362; 6 | barometer = &bme680; 7 | push-button-0 = &button0; 8 | }; 9 | }; 10 | 11 | &i2c2 { 12 | bme680: bme680@76 {}; 13 | }; 14 | 15 | &spi3 { 16 | adxl362: adxl362@0 {}; 17 | }; 18 | -------------------------------------------------------------------------------- /demo/boards/tmo_dev_edge.conf: -------------------------------------------------------------------------------- 1 | # anjay-zephyr-client 2 | CONFIG_ANJAY_ZEPHYR_DEVICE_MANUFACTURER="T-Mobile" 3 | CONFIG_ANJAY_ZEPHYR_MODEL_NUMBER="DevEdge" 4 | CONFIG_ANJAY_ZEPHYR_FOTA=y 5 | CONFIG_ANJAY_ZEPHYR_GPS=y 6 | 7 | # Anjay Settings 8 | CONFIG_ANJAY_COMPAT_MBEDTLS=y 9 | CONFIG_ANJAY_COMPAT_NET=y 10 | CONFIG_ANJAY_COMPAT_TIME=y 11 | 12 | # Allow runtime certificate configuration 13 | CONFIG_ANJAY_ZEPHYR_RUNTIME_CERT_CONFIG=y 14 | CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED=y 15 | CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y 16 | CONFIG_MBEDTLS_PEM_CERTIFICATE_FORMAT=y 17 | CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED=y 18 | 19 | # Monitoring (uncomment if needed) 20 | # CONFIG_THREAD_ANALYZER=y 21 | # CONFIG_THREAD_ANALYZER_USE_LOG=y 22 | # CONFIG_THREAD_NAME=y 23 | 24 | # MbedTLS and security 25 | CONFIG_MBEDTLS_ECP_C=y 26 | CONFIG_MBEDTLS_ECDH_C=y 27 | CONFIG_MBEDTLS_ECDSA_C=y 28 | CONFIG_MBEDTLS_CIPHER_CCM_ENABLED=y 29 | 30 | # Hardware Configuration 31 | CONFIG_SOC_GECKO_EMU_DCDC=y 32 | CONFIG_SOC_GECKO_EMU_DCDC_MODE_OFF=y 33 | CONFIG_CMU_HFCLK_HFXO=y 34 | 35 | # General settings 36 | CONFIG_NEWLIB_LIBC=y 37 | CONFIG_NEWLIB_LIBC_NANO=n 38 | CONFIG_MAIN_STACK_SIZE=16384 39 | 40 | # Hardware class support 41 | CONFIG_I2C=y 42 | CONFIG_LED=y 43 | CONFIG_LED_PWM=y 44 | CONFIG_PWM=y 45 | CONFIG_SENSOR=y 46 | CONFIG_SPI=y 47 | CONFIG_SPI_NOR=y 48 | CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096 49 | CONFIG_STREAM_FLASH_ERASE=y 50 | CONFIG_WIFI=y 51 | 52 | # Device Drivers 53 | CONFIG_PWM_GECKO=y 54 | CONFIG_LIS2DW12=y 55 | CONFIG_LPS22HH=y 56 | CONFIG_TMP108=y 57 | CONFIG_TSL2540=y 58 | CONFIG_COUNTER=y 59 | CONFIG_WIFI_RS9116W=y 60 | 61 | CONFIG_MODEM=y 62 | CONFIG_MODEM_SHELL=y 63 | CONFIG_MODEM_MURATA_1SC=y 64 | CONFIG_MODEM_MURATA_1SC_RX_STACK_SIZE=4096 65 | CONFIG_MODEM_MURATA_1SC_APN="iot.t-mobile.com" 66 | 67 | # OS Support library 68 | CONFIG_REBOOT=y 69 | CONFIG_POSIX_CLOCK=y 70 | 71 | # Logging 72 | CONFIG_LOG_MODE_DEFERRED=y 73 | CONFIG_LOG_BLOCK_IN_THREAD=y 74 | 75 | CONFIG_CONSOLE_SUBSYS=y 76 | CONFIG_CONSOLE_GETLINE=y 77 | 78 | # Networking 79 | CONFIG_NET_L2_WIFI_MGMT=y 80 | CONFIG_NET_TCP=y 81 | 82 | # Offload TCP/IP stack to a co-processor 83 | CONFIG_RS9116W_TLS_OFFLOAD=y 84 | CONFIG_NET_NATIVE=n 85 | CONFIG_NET_OFFLOAD=y 86 | CONFIG_NET_SOCKETS_OFFLOAD=y 87 | 88 | # Clock synchronization 89 | CONFIG_SNTP=y 90 | 91 | # FOTA support 92 | CONFIG_STREAM_FLASH=y 93 | 94 | # Boot options 95 | CONFIG_BOOTLOADER_MCUBOOT=y 96 | # Note: if relative paths are used here, it is treated as 97 | # relative to $WEST_TOPDIR (typically ~/zephyrproject) 98 | CONFIG_MCUBOOT_SIGNATURE_KEY_FILE="bootloader/mcuboot/root-rsa-2048.pem" 99 | CONFIG_MCUBOOT_EXTRA_IMGTOOL_ARGS="--version 25.5.0" 100 | -------------------------------------------------------------------------------- /demo/boards/tmo_dev_edge.overlay: -------------------------------------------------------------------------------- 1 | / { 2 | aliases { 3 | temperature = &as6212; 4 | accelerometer = &lis2dw12; 5 | barometer = &lps22hh; 6 | push-button-0 = &button0; 7 | status-led = &led1; 8 | illuminance = &tsl2540; 9 | }; 10 | chosen { 11 | zephyr,code-partition = &slot0_partition; 12 | zephyr,console = &usart0; 13 | zephyr,shell-uart = &usart0; 14 | }; 15 | }; 16 | 17 | #include "tmo_dev_edge_partitions.overlay" 18 | -------------------------------------------------------------------------------- /demo/boards/tmo_dev_edge_partitions.overlay: -------------------------------------------------------------------------------- 1 | &flash0 { 2 | partitions { 3 | boot_partition: partition@0 { 4 | label = "mcuboot"; 5 | reg = <0x00000000 DT_SIZE_K(48)>; 6 | }; 7 | slot0_partition: partition@C000 { 8 | label = "image-0"; 9 | reg = <0x0000C000 DT_SIZE_K(936)>; 10 | }; 11 | scratch_partition: partition@F6000 { 12 | label = "image-scratch"; 13 | reg = <0x000F6000 DT_SIZE_K(32)>; 14 | }; 15 | }; 16 | }; 17 | 18 | &w25q64 { 19 | partitions { 20 | // This overrides the default configuration which configures it as 8MiB 21 | storage_partition1: partition@0 { 22 | label = "storage"; 23 | reg = <0x00000000 DT_SIZE_K(7256)>; 24 | }; 25 | slot1_partition: partition@716000 { 26 | label = "image-1"; 27 | reg = <0x00716000 DT_SIZE_K(936)>; 28 | }; 29 | }; 30 | }; 31 | -------------------------------------------------------------------------------- /demo/child_image/mcuboot/boards/nrf7002dk_nrf5340_cpuapp.conf: -------------------------------------------------------------------------------- 1 | # This file sets some board-dependent variables in MCUBoot child image. 2 | # Refer to: 3 | # https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.7.0/nrf/config_and_build/multi_image.html#image-specific-variables 4 | 5 | ### anjay-zephyr-client 6 | CONFIG_PM_PARTITION_SIZE_MCUBOOT=0x10000 7 | CONFIG_PM_PARTITION_SIZE_MCUBOOT_PAD=0x200 8 | CONFIG_PM_PARTITION_SIZE_MCUBOOT_SCRATCH=0x10000 9 | 10 | # External flash config 11 | CONFIG_SPI=y 12 | CONFIG_SPI_NOR=y 13 | CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096 14 | CONFIG_SPI_NOR_SFDP_DEVICETREE=y 15 | 16 | CONFIG_NRF53_UPGRADE_NETWORK_CORE=n 17 | CONFIG_FLASH_SIMULATOR=n 18 | -------------------------------------------------------------------------------- /demo/child_image/mcuboot/boards/nrf7002dk_nrf5340_cpuapp.overlay: -------------------------------------------------------------------------------- 1 | / { 2 | chosen { 3 | nordic,pm-ext-flash = &mx25r64; 4 | }; 5 | }; 6 | 7 | &mx25r64 { 8 | status = "ok"; 9 | }; 10 | -------------------------------------------------------------------------------- /demo/child_image/mcuboot/boards/nrf9151dk_nrf9151.conf: -------------------------------------------------------------------------------- 1 | # This file sets some board-dependent variables in MCUBoot child image. 2 | # Refer to: 3 | # https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.7.0/nrf/config_and_build/multi_image.html#image-specific-variables 4 | 5 | ### anjay-zephyr-client 6 | CONFIG_PM_PARTITION_SIZE_MCUBOOT=0x10000 7 | CONFIG_PM_PARTITION_SIZE_MCUBOOT_PAD=0x200 8 | CONFIG_PM_PARTITION_SIZE_MCUBOOT_SCRATCH=0x10000 9 | 10 | # External flash config 11 | CONFIG_SPI=y 12 | CONFIG_SPI_NOR=y 13 | CONFIG_SPI_NOR_SFDP_DEVICETREE=y 14 | CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096 15 | -------------------------------------------------------------------------------- /demo/child_image/mcuboot/boards/nrf9151dk_nrf9151.overlay: -------------------------------------------------------------------------------- 1 | / { 2 | /* Configure partition manager to use gd25wb256 as the external flash */ 3 | chosen { 4 | nordic,pm-ext-flash = &gd25wb256; 5 | }; 6 | }; 7 | 8 | &gd25wb256 { 9 | status = "okay"; 10 | }; 11 | -------------------------------------------------------------------------------- /demo/child_image/mcuboot/boards/nrf9160dk_nrf9160.conf: -------------------------------------------------------------------------------- 1 | # This file sets some board-dependent variables in MCUBoot child image. 2 | # Refer to: 3 | # https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.7.0/nrf/config_and_build/multi_image.html#image-specific-variables 4 | 5 | ### anjay-zephyr-client 6 | CONFIG_PM_PARTITION_SIZE_MCUBOOT=0x10000 7 | CONFIG_PM_PARTITION_SIZE_MCUBOOT_PAD=0x200 8 | CONFIG_PM_PARTITION_SIZE_MCUBOOT_SCRATCH=0x10000 9 | 10 | # External flash config 11 | CONFIG_SPI=y 12 | CONFIG_SPI_NOR=y 13 | CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096 14 | CONFIG_SPI_NOR_SFDP_DEVICETREE=y 15 | -------------------------------------------------------------------------------- /demo/child_image/mcuboot/boards/nrf9160dk_nrf9160_0_14_0.overlay: -------------------------------------------------------------------------------- 1 | / { 2 | chosen { 3 | nordic,pm-ext-flash = &mx25r64; 4 | }; 5 | }; 6 | 7 | &mx25r64 { 8 | status = "ok"; 9 | }; 10 | -------------------------------------------------------------------------------- /demo/child_image/mcuboot/boards/nrf9160dk_nrf9160_intflash.conf: -------------------------------------------------------------------------------- 1 | # This file sets some board-dependent variables in MCUBoot child image. 2 | # Refer to: 3 | # https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.7.0/nrf/config_and_build/multi_image.html#image-specific-variables 4 | 5 | ### Original source 6 | CONFIG_PM=n 7 | 8 | CONFIG_MAIN_STACK_SIZE=10240 9 | CONFIG_MBEDTLS_CFG_FILE="mcuboot-mbedtls-cfg.h" 10 | 11 | CONFIG_BOOT_SWAP_SAVE_ENCTLV=n 12 | 13 | CONFIG_BOOT_UPGRADE_ONLY=n 14 | CONFIG_BOOT_BOOTSTRAP=n 15 | 16 | ### mbedTLS has its own heap 17 | # CONFIG_HEAP_MEM_POOL_SIZE is not set 18 | 19 | ### We never want Zephyr's copy of tinycrypt. If tinycrypt is needed, 20 | ### MCUboot has its own copy in tree. 21 | # CONFIG_TINYCRYPT is not set 22 | # CONFIG_TINYCRYPT_ECC_DSA is not set 23 | # CONFIG_TINYCRYPT_SHA256 is not set 24 | 25 | CONFIG_FLASH=y 26 | CONFIG_FPROTECT=y 27 | 28 | ### Various Zephyr boards enable features that we don't want. 29 | # CONFIG_BT is not set 30 | # CONFIG_BT_CTLR is not set 31 | # CONFIG_I2C is not set 32 | 33 | CONFIG_LOG=y 34 | CONFIG_LOG_MODE_MINIMAL=y # former CONFIG_MODE_MINIMAL 35 | ### Ensure Zephyr logging changes don't use more resources 36 | CONFIG_LOG_DEFAULT_LEVEL=0 37 | ### Decrease footprint by ~4 KB in comparison to CBPRINTF_COMPLETE=y 38 | CONFIG_CBPRINTF_NANO=y 39 | 40 | ### anjay-zephyr-client 41 | CONFIG_BOOT_SWAP_USING_SCRATCH=y 42 | CONFIG_PM_PARTITION_SIZE_MCUBOOT=0x10000 43 | CONFIG_PM_PARTITION_SIZE_MCUBOOT_PAD=0x200 44 | CONFIG_PM_PARTITION_SIZE_MCUBOOT_SCRATCH=0x10000 45 | -------------------------------------------------------------------------------- /demo/child_image/mcuboot/prj.conf: -------------------------------------------------------------------------------- 1 | # This file sets some board-dependent variables in MCUBoot child image. 2 | # Refer to: 3 | # https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.7.0/nrf/config_and_build/multi_image.html#image-specific-variables 4 | 5 | ### Original source 6 | CONFIG_PM=n 7 | 8 | CONFIG_MAIN_STACK_SIZE=10240 9 | CONFIG_MBEDTLS_CFG_FILE="mcuboot-mbedtls-cfg.h" 10 | 11 | CONFIG_BOOT_SWAP_SAVE_ENCTLV=n 12 | 13 | CONFIG_BOOT_UPGRADE_ONLY=n 14 | CONFIG_BOOT_BOOTSTRAP=n 15 | 16 | CONFIG_FLASH=y 17 | CONFIG_FPROTECT=y 18 | 19 | CONFIG_LOG=y 20 | CONFIG_LOG_MODE_MINIMAL=y # former CONFIG_MODE_MINIMAL 21 | ### Ensure Zephyr logging changes don't use more resources 22 | CONFIG_LOG_DEFAULT_LEVEL=0 23 | ### Decrease footprint by ~4 KB in comparison to CBPRINTF_COMPLETE=y 24 | CONFIG_CBPRINTF_NANO=y 25 | 26 | ### anjay-zephyr-client 27 | CONFIG_BOOT_SWAP_USING_SCRATCH=y 28 | 29 | # Additional MCUBoot config 30 | CONFIG_MCUBOOT_IMG_MANAGER=y 31 | # Sector size is ~4 kB, largest partitions are less than 1 MB 32 | # This is the value also Nordic seems to be using in their samples 33 | CONFIG_BOOT_MAX_IMG_SECTORS=256 34 | 35 | # External flash 36 | CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y 37 | 38 | # It looks that MCUBoot needs some multithreading support 39 | CONFIG_MULTITHREADING=y 40 | -------------------------------------------------------------------------------- /demo/overlay_nrf9160_afu.conf: -------------------------------------------------------------------------------- 1 | CONFIG_ANJAY_ZEPHYR_FOTA=n 2 | CONFIG_ANJAY_ZEPHYR_ADVANCED_FOTA_NRF9160_APP_DELTA_MODEM=y 3 | -------------------------------------------------------------------------------- /demo/overlay_nrf9160_afu_full.conf: -------------------------------------------------------------------------------- 1 | CONFIG_ANJAY_ZEPHYR_FOTA=n 2 | CONFIG_ANJAY_ZEPHYR_ADVANCED_FOTA_NRF9160_APP_DELTA_FULL_MODEM=y 3 | -------------------------------------------------------------------------------- /demo/overlay_nrf_mbedtls.conf: -------------------------------------------------------------------------------- 1 | CONFIG_ANJAY_COMPAT_ZEPHYR_TLS=n 2 | CONFIG_ANJAY_COMPAT_MBEDTLS=y 3 | 4 | CONFIG_NORDIC_SECURITY_BACKEND=n 5 | CONFIG_OBERON_BACKEND=n 6 | 7 | CONFIG_MBEDTLS_TLS_LIBRARY=y 8 | CONFIG_MBEDTLS_ENTROPY_C=y 9 | CONFIG_MBEDTLS_CIPHER_MODE_CBC=y 10 | CONFIG_MBEDTLS_DHM_C=y 11 | CONFIG_MBEDTLS_CTR_DRBG_C=y 12 | CONFIG_MBEDTLS_CCM_C=y 13 | CONFIG_MBEDTLS_ECP_C=y 14 | CONFIG_MBEDTLS_LEGACY_CRYPTO_C=y 15 | CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED=y 16 | CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y 17 | CONFIG_MBEDTLS_PEM_CERTIFICATE_FORMAT=y 18 | CONFIG_ANJAY_ZEPHYR_RUNTIME_CERT_CONFIG=y 19 | CONFIG_MBEDTLS_SSL_DTLS_CONNECTION_ID=y 20 | -------------------------------------------------------------------------------- /demo/pm_static_nrf7002dk_nrf5340_cpuapp_ns.yml: -------------------------------------------------------------------------------- 1 | EMPTY_0: 2 | address: 0xfe000 3 | end_address: 0x100000 4 | placement: 5 | after: 6 | - settings_storage 7 | region: flash_primary 8 | size: 0x2000 9 | app: 10 | address: 0x18000 11 | end_address: 0xec000 12 | region: flash_primary 13 | size: 0xd4000 14 | external_flash: 15 | address: 0xdc000 16 | end_address: 0x800000 17 | region: external_flash 18 | size: 0x724000 19 | mcuboot: 20 | address: 0x0 21 | end_address: 0x10000 22 | placement: 23 | before: 24 | - mcuboot_primary 25 | region: flash_primary 26 | size: 0x10000 27 | mcuboot_pad: 28 | address: 0x10000 29 | end_address: 0x10200 30 | placement: 31 | align: 32 | start: 0x4000 33 | before: 34 | - mcuboot_primary_app 35 | region: flash_primary 36 | size: 0x200 37 | mcuboot_primary: 38 | address: 0x10000 39 | end_address: 0xec000 40 | orig_span: &id001 41 | - mcuboot_pad 42 | - app 43 | - tfm 44 | region: flash_primary 45 | size: 0xdc000 46 | span: *id001 47 | mcuboot_primary_app: 48 | address: 0x10200 49 | end_address: 0xec000 50 | orig_span: &id002 51 | - app 52 | - tfm 53 | region: flash_primary 54 | size: 0xdbe00 55 | span: *id002 56 | mcuboot_scratch: 57 | address: 0xec000 58 | end_address: 0xfc000 59 | placement: 60 | after: 61 | - app 62 | align: 63 | start: 0x4000 64 | region: flash_primary 65 | size: 0x10000 66 | mcuboot_secondary: 67 | address: 0x0 68 | device: DT_CHOSEN(nordic_pm_ext_flash) 69 | end_address: 0xdc000 70 | placement: 71 | align: 72 | start: 0x4 73 | region: external_flash 74 | share_size: 75 | - mcuboot_primary 76 | size: 0xdc000 77 | nonsecure_storage: 78 | address: 0xfc000 79 | end_address: 0xfe000 80 | orig_span: &id004 81 | - settings_storage 82 | region: flash_primary 83 | size: 0x2000 84 | span: *id004 85 | settings_storage: 86 | address: 0xfc000 87 | end_address: 0xfe000 88 | inside: 89 | - nonsecure_storage 90 | placement: 91 | align: 92 | start: 0x4000 93 | before: 94 | - end 95 | region: flash_primary 96 | size: 0x2000 97 | tfm: 98 | address: 0x10200 99 | end_address: 0x18000 100 | inside: 101 | - mcuboot_primary_app 102 | placement: 103 | before: 104 | - app 105 | region: flash_primary 106 | size: 0x7e00 107 | tfm_nonsecure: 108 | address: 0x18000 109 | end_address: 0xec000 110 | orig_span: &id007 111 | - app 112 | region: flash_primary 113 | size: 0xd4000 114 | span: *id007 115 | tfm_secure: 116 | address: 0x10000 117 | end_address: 0x18000 118 | orig_span: &id008 119 | - mcuboot_pad 120 | - tfm 121 | region: flash_primary 122 | size: 0x8000 123 | span: *id008 124 | -------------------------------------------------------------------------------- /demo/pm_static_nrf9151dk_nrf9151_ns.yml: -------------------------------------------------------------------------------- 1 | EMPTY_0: 2 | address: 0xfa000 3 | end_address: 0x100000 4 | placement: 5 | after: 6 | - settings_storage 7 | region: flash_primary 8 | size: 0x6000 9 | app: 10 | address: 0x18000 11 | end_address: 0xe8000 12 | region: flash_primary 13 | size: 0xd0000 14 | external_flash: 15 | address: 0xd8000 16 | end_address: 0x2000000 17 | region: external_flash 18 | size: 0x1f28000 19 | mcuboot: 20 | address: 0x0 21 | end_address: 0x10000 22 | placement: 23 | before: 24 | - mcuboot_primary 25 | region: flash_primary 26 | size: 0x10000 27 | mcuboot_pad: 28 | address: 0x10000 29 | end_address: 0x10200 30 | placement: 31 | align: 32 | start: 0x8000 33 | before: 34 | - mcuboot_primary_app 35 | region: flash_primary 36 | size: 0x200 37 | mcuboot_primary: 38 | address: 0x10000 39 | end_address: 0xe8000 40 | orig_span: &id001 41 | - mcuboot_pad 42 | - app 43 | - tfm 44 | region: flash_primary 45 | size: 0xd8000 46 | span: *id001 47 | mcuboot_primary_app: 48 | address: 0x10200 49 | end_address: 0xe8000 50 | orig_span: &id002 51 | - app 52 | - tfm 53 | region: flash_primary 54 | size: 0xd7e00 55 | span: *id002 56 | mcuboot_scratch: 57 | address: 0xe8000 58 | end_address: 0xf8000 59 | placement: 60 | after: 61 | - app 62 | align: 63 | start: 0x8000 64 | region: flash_primary 65 | size: 0x10000 66 | mcuboot_secondary: 67 | address: 0x0 68 | device: DT_CHOSEN(nordic_pm_ext_flash) 69 | end_address: 0xd8000 70 | placement: 71 | align: 72 | start: 0x4 73 | region: external_flash 74 | share_size: 75 | - mcuboot_primary 76 | size: 0xd8000 77 | nonsecure_storage: 78 | address: 0xf8000 79 | end_address: 0xfa000 80 | orig_span: &id004 81 | - settings_storage 82 | region: flash_primary 83 | size: 0x2000 84 | span: *id004 85 | settings_storage: 86 | address: 0xf8000 87 | end_address: 0xfa000 88 | inside: 89 | - nonsecure_storage 90 | placement: 91 | align: 92 | start: 0x8000 93 | before: 94 | - end 95 | region: flash_primary 96 | size: 0x2000 97 | tfm: 98 | address: 0x10200 99 | end_address: 0x18000 100 | inside: 101 | - mcuboot_primary_app 102 | placement: 103 | before: 104 | - app 105 | region: flash_primary 106 | size: 0x7e00 107 | tfm_nonsecure: 108 | address: 0x18000 109 | end_address: 0xe8000 110 | orig_span: &id008 111 | - app 112 | region: flash_primary 113 | size: 0xd0000 114 | span: *id008 115 | tfm_secure: 116 | address: 0x10000 117 | end_address: 0x18000 118 | orig_span: &id009 119 | - mcuboot_pad 120 | - tfm 121 | region: flash_primary 122 | size: 0x8000 123 | span: *id009 124 | -------------------------------------------------------------------------------- /demo/pm_static_nrf9160dk_nrf9160_ns.yml: -------------------------------------------------------------------------------- 1 | EMPTY_0: 2 | address: 0xfa000 3 | end_address: 0x100000 4 | placement: 5 | after: 6 | - settings_storage 7 | region: flash_primary 8 | size: 0x6000 9 | app: 10 | address: 0x18000 11 | end_address: 0xe8000 12 | region: flash_primary 13 | size: 0xd0000 14 | external_flash: 15 | address: 0xd8000 16 | end_address: 0x800000 17 | region: external_flash 18 | size: 0x728000 19 | mcuboot: 20 | address: 0x0 21 | end_address: 0x10000 22 | placement: 23 | before: 24 | - mcuboot_primary 25 | region: flash_primary 26 | size: 0x10000 27 | mcuboot_pad: 28 | address: 0x10000 29 | end_address: 0x10200 30 | placement: 31 | align: 32 | start: 0x8000 33 | before: 34 | - mcuboot_primary_app 35 | region: flash_primary 36 | size: 0x200 37 | mcuboot_primary: 38 | address: 0x10000 39 | end_address: 0xe8000 40 | orig_span: &id001 41 | - tfm 42 | - app 43 | - mcuboot_pad 44 | region: flash_primary 45 | size: 0xd8000 46 | span: *id001 47 | mcuboot_primary_app: 48 | address: 0x10200 49 | end_address: 0xe8000 50 | orig_span: &id002 51 | - app 52 | - tfm 53 | region: flash_primary 54 | size: 0xd7e00 55 | span: *id002 56 | mcuboot_scratch: 57 | address: 0xe8000 58 | end_address: 0xf8000 59 | placement: 60 | after: 61 | - app 62 | align: 63 | start: 0x8000 64 | region: flash_primary 65 | size: 0x10000 66 | mcuboot_secondary: 67 | address: 0x0 68 | device: DT_CHOSEN(nordic_pm_ext_flash) 69 | end_address: 0xd8000 70 | placement: 71 | align: 72 | start: 0x4 73 | region: external_flash 74 | share_size: 75 | - mcuboot_primary 76 | size: 0xd8000 77 | dfu_target_fmfu: 78 | address: 0xd8000 79 | device: DT_CHOSEN(nordic_pm_ext_flash) 80 | end_address: 0x2d8000 81 | placement: 82 | after: 83 | - mcuboot_secondary 84 | region: external_flash 85 | size: 0x200000 86 | nonsecure_storage: 87 | address: 0xf8000 88 | end_address: 0xfa000 89 | orig_span: &id004 90 | - settings_storage 91 | region: flash_primary 92 | size: 0x2000 93 | span: *id004 94 | settings_storage: 95 | address: 0xf8000 96 | end_address: 0xfa000 97 | inside: 98 | - nonsecure_storage 99 | placement: 100 | align: 101 | start: 0x8000 102 | before: 103 | - end 104 | region: flash_primary 105 | size: 0x2000 106 | tfm: 107 | address: 0x10200 108 | end_address: 0x18000 109 | inside: 110 | - mcuboot_primary_app 111 | placement: 112 | before: 113 | - app 114 | region: flash_primary 115 | size: 0x7e00 116 | tfm_nonsecure: 117 | address: 0x18000 118 | end_address: 0xe8000 119 | orig_span: &id008 120 | - app 121 | region: flash_primary 122 | size: 0xd0000 123 | span: *id008 124 | tfm_secure: 125 | address: 0x10000 126 | end_address: 0x18000 127 | orig_span: &id009 128 | - mcuboot_pad 129 | - tfm 130 | region: flash_primary 131 | size: 0x8000 132 | span: *id009 133 | -------------------------------------------------------------------------------- /demo/pm_static_nrf9160dk_nrf9160_ns_intflash.yml: -------------------------------------------------------------------------------- 1 | EMPTY_0: 2 | address: 0xfa000 3 | end_address: 0x100000 4 | placement: 5 | after: 6 | - settings_storage 7 | region: flash_primary 8 | size: 0x6000 9 | EMPTY_1: 10 | address: 0xe0000 11 | end_address: 0xe8000 12 | placement: 13 | after: 14 | - mcuboot_secondary 15 | region: flash_primary 16 | size: 0x8000 17 | app: 18 | address: 0x18000 19 | end_address: 0x78000 20 | region: flash_primary 21 | size: 0x60000 22 | mcuboot: 23 | address: 0x0 24 | end_address: 0x10000 25 | placement: 26 | before: 27 | - mcuboot_primary 28 | region: flash_primary 29 | size: 0x10000 30 | mcuboot_pad: 31 | address: 0x10000 32 | end_address: 0x10200 33 | placement: 34 | align: 35 | start: 0x8000 36 | before: 37 | - mcuboot_primary_app 38 | region: flash_primary 39 | size: 0x200 40 | mcuboot_primary: 41 | address: 0x10000 42 | end_address: 0x78000 43 | orig_span: &id001 44 | - mcuboot_pad 45 | - tfm 46 | - app 47 | region: flash_primary 48 | sharers: 0x1 49 | size: 0x68000 50 | span: *id001 51 | mcuboot_primary_app: 52 | address: 0x10200 53 | end_address: 0x78000 54 | orig_span: &id002 55 | - app 56 | - tfm 57 | region: flash_primary 58 | size: 0x67e00 59 | span: *id002 60 | mcuboot_scratch: 61 | address: 0xe8000 62 | end_address: 0xf8000 63 | placement: 64 | after: 65 | - app 66 | align: 67 | start: 0x8000 68 | region: flash_primary 69 | size: 0x10000 70 | mcuboot_secondary: 71 | address: 0x78000 72 | end_address: 0xe0000 73 | placement: 74 | after: 75 | - mcuboot_primary 76 | align: 77 | start: 0x8000 78 | region: flash_primary 79 | share_size: 80 | - mcuboot_primary 81 | size: 0x68000 82 | nonsecure_storage: 83 | address: 0xf8000 84 | end_address: 0xfa000 85 | orig_span: &id004 86 | - settings_storage 87 | region: flash_primary 88 | size: 0x2000 89 | span: *id004 90 | settings_storage: 91 | address: 0xf8000 92 | end_address: 0xfa000 93 | inside: 94 | - nonsecure_storage 95 | placement: 96 | align: 97 | start: 0x8000 98 | before: 99 | - end 100 | region: flash_primary 101 | size: 0x2000 102 | tfm: 103 | address: 0x10200 104 | end_address: 0x18000 105 | inside: 106 | - mcuboot_primary_app 107 | placement: 108 | before: 109 | - app 110 | region: flash_primary 111 | size: 0x7e00 112 | tfm_nonsecure: 113 | address: 0x18000 114 | end_address: 0x78000 115 | orig_span: &id008 116 | - app 117 | region: flash_primary 118 | size: 0x60000 119 | span: *id008 120 | tfm_secure: 121 | address: 0x10000 122 | end_address: 0x18000 123 | orig_span: &id009 124 | - mcuboot_pad 125 | - tfm 126 | region: flash_primary 127 | size: 0x8000 128 | span: *id009 129 | -------------------------------------------------------------------------------- /demo/prj.conf: -------------------------------------------------------------------------------- 1 | # Anjay Settings 2 | CONFIG_ANJAY=y 3 | 4 | # Anjay Zephyr Settings 5 | CONFIG_ANJAY_ZEPHYR_SHELL=y 6 | 7 | # General settings 8 | CONFIG_LOG=y 9 | CONFIG_REBOOT=y 10 | CONFIG_FPU=y 11 | CONFIG_PRINTK=y 12 | CONFIG_SHELL=y 13 | 14 | # Networking 15 | CONFIG_NETWORKING=y 16 | CONFIG_NET_MGMT=y 17 | CONFIG_NET_MGMT_EVENT=y 18 | CONFIG_NET_SOCKETS=y 19 | CONFIG_NET_IPV4=y 20 | CONFIG_NET_IPV6=n 21 | CONFIG_NET_TCP=n 22 | CONFIG_NET_LOG=y 23 | 24 | # Logging 25 | CONFIG_LOG_MODE_DEFERRED=y 26 | CONFIG_LOG_BLOCK_IN_THREAD=y 27 | 28 | # Config menu 29 | CONFIG_HWINFO=y 30 | 31 | # Storage 32 | CONFIG_FLASH=y 33 | CONFIG_FLASH_MAP=y 34 | CONFIG_NVS=y 35 | CONFIG_SETTINGS=y 36 | CONFIG_FLASH_LOG_LEVEL_ERR=y 37 | -------------------------------------------------------------------------------- /demo/src/factory_provisioning/factory_flash.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 AVSystem 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | 21 | avs_stream_t *factory_flash_input_stream_init(void); 22 | void factory_flash_finished(int result); 23 | -------------------------------------------------------------------------------- /demo/src/factory_provisioning/provisioning_app.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 AVSystem 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | #include 29 | 30 | #include "factory_flash.h" 31 | 32 | LOG_MODULE_REGISTER(provisioning_app); 33 | 34 | static anjay_t *initialize_anjay(void) 35 | { 36 | anjay_t *anjay = anjay_new(&(const anjay_configuration_t){ 37 | .endpoint_name = anjay_zephyr_config_default_ep_name() }); 38 | 39 | if (!anjay) { 40 | LOG_ERR("Could not create Anjay object"); 41 | return NULL; 42 | } 43 | 44 | if (anjay_security_object_install(anjay) || anjay_server_object_install(anjay) || 45 | anjay_access_control_install(anjay)) { 46 | anjay_delete(anjay); 47 | LOG_ERR("Failed to install necessary modules"); 48 | return NULL; 49 | } 50 | 51 | return anjay; 52 | } 53 | 54 | static void factory_provision(void) 55 | { 56 | anjay_t *anjay = initialize_anjay(); 57 | 58 | if (!anjay) { 59 | LOG_ERR("Couldn't initialize Anjay. Rebooting."); 60 | abort(); 61 | } 62 | 63 | if (anjay_zephyr_is_factory_provisioning_info_present()) { 64 | LOG_INF("Factory provisioning information already present. " 65 | "Please flash production firmware. Halting."); 66 | } else { 67 | LOG_WRN("NOTE: No more log messages will be displayed. Please use " 68 | "mcumgr to check provisioning results"); 69 | 70 | LOG_INF("Device ready for provisioning."); 71 | 72 | z_shell_log_backend_disable(shell_backend_uart_get_ptr()->log_backend); 73 | 74 | avs_stream_t *stream = factory_flash_input_stream_init(); 75 | 76 | assert(stream); 77 | 78 | avs_error_t err = anjay_factory_provision(anjay, stream); 79 | // NOTE: Not calling avs_stream_cleanup() because stream is *NOT* heap-allocated 80 | 81 | if (avs_is_ok(err) && anjay_zephyr_persist_factory_provisioning_info(anjay)) { 82 | err = avs_errno(AVS_EIO); 83 | } 84 | factory_flash_finished(avs_is_ok(err) ? 0 : -1); 85 | } 86 | 87 | while (true) { 88 | k_sleep(K_SECONDS(1)); 89 | } 90 | } 91 | 92 | void main(void) 93 | { 94 | LOG_PANIC(); 95 | 96 | if (anjay_zephyr_persistence_init()) { 97 | LOG_ERR("Can't initialize persistence"); 98 | } 99 | 100 | factory_provision(); 101 | } 102 | -------------------------------------------------------------------------------- /demo/src/main_app.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 AVSystem 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include "sensors_config.h" 28 | #include "peripherals.h" 29 | #include "status_led.h" 30 | 31 | LOG_MODULE_REGISTER(main_app); 32 | static const anjay_dm_object_def_t **location_obj; 33 | #if BUZZER_AVAILABLE 34 | static const anjay_dm_object_def_t **buzzer_obj; 35 | #endif // BUZZER_AVAILABLE 36 | #if LED_COLOR_LIGHT_AVAILABLE 37 | static const anjay_dm_object_def_t **led_color_light_obj; 38 | #endif // LED_COLOR_LIGHT_AVAILABLE 39 | #if SWITCH_AVAILABLE_ANY 40 | static const anjay_dm_object_def_t **switch_obj; 41 | #endif // SWITCH_AVAILABLE_ANY 42 | static avs_sched_handle_t update_objects_handle; 43 | 44 | #if LIGHT_CONTROL_AVAILABLE_ANY 45 | static const struct gpio_dt_spec leds[] = { 46 | #if LIGHT_CONTROL_AVAILABLE(0) 47 | GPIO_DT_SPEC_GET(LIGHT_CONTROL_NODE(0), gpios), 48 | #endif // LIGHT_CONTROL_AVAILABLE(0) 49 | #if LIGHT_CONTROL_AVAILABLE(1) 50 | GPIO_DT_SPEC_GET(LIGHT_CONTROL_NODE(1), gpios), 51 | #endif // LIGHT_CONTROL_AVAILABLE(1) 52 | #if LIGHT_CONTROL_AVAILABLE(2) 53 | GPIO_DT_SPEC_GET(LIGHT_CONTROL_NODE(2), gpios), 54 | #endif // LIGHT_CONTROL_AVAILABLE(2) 55 | #if LIGHT_CONTROL_AVAILABLE(3) 56 | GPIO_DT_SPEC_GET(LIGHT_CONTROL_NODE(3), gpios), 57 | #endif // LIGHT_CONTROL_AVAILABLE(3) 58 | }; 59 | static const anjay_dm_object_def_t **light_control_obj; 60 | #endif // LIGHT_CONTROL_AVAILABLE_ANY 61 | 62 | #if PUSH_BUTTON_AVAILABLE_ANY 63 | static struct anjay_zephyr_ipso_button_instance buttons[] = { 64 | #if PUSH_BUTTON_AVAILABLE(0) 65 | PUSH_BUTTON_GLUE_ITEM(0), 66 | #endif // PUSH_BUTTON_AVAILABLE(0) 67 | #if PUSH_BUTTON_AVAILABLE(1) 68 | PUSH_BUTTON_GLUE_ITEM(1), 69 | #endif // PUSH_BUTTON_AVAILABLE(1) 70 | #if PUSH_BUTTON_AVAILABLE(2) 71 | PUSH_BUTTON_GLUE_ITEM(2), 72 | #endif // PUSH_BUTTON_AVAILABLE(2) 73 | #if PUSH_BUTTON_AVAILABLE(3) 74 | PUSH_BUTTON_GLUE_ITEM(3), 75 | #endif // PUSH_BUTTON_AVAILABLE(3) 76 | }; 77 | #endif // PUSH_BUTTON_AVAILABLE_ANY 78 | 79 | #if SWITCH_AVAILABLE_ANY 80 | static struct anjay_zephyr_switch_instance switches[] = { 81 | #if SWITCH_AVAILABLE(0) 82 | SWITCH_BUTTON_GLUE_ITEM(0), 83 | #endif // SWITCH_AVAILABLE(0) 84 | #if SWITCH_AVAILABLE(1) 85 | SWITCH_BUTTON_GLUE_ITEM(1), 86 | #endif // SWITCH_AVAILABLE(1) 87 | #if SWITCH_AVAILABLE(2) 88 | SWITCH_BUTTON_GLUE_ITEM(2), 89 | #endif // SWITCH_AVAILABLE(2) 90 | }; 91 | #endif // SWITCH_AVAILABLE_ANY 92 | struct anjay_zephyr_network_preferred_bearer_list_t anjay_zephyr_config_get_preferred_bearers(void); 93 | 94 | static int register_objects(anjay_t *anjay) 95 | { 96 | location_obj = anjay_zephyr_location_object_create(); 97 | if (location_obj) { 98 | anjay_register_object(anjay, location_obj); 99 | } 100 | 101 | sensors_install(anjay); 102 | #if PUSH_BUTTON_AVAILABLE_ANY 103 | anjay_zephyr_ipso_push_button_object_install(anjay, buttons, AVS_ARRAY_SIZE(buttons)); 104 | #endif // PUSH_BUTTON_AVAILABLE_ANY 105 | 106 | #if BUZZER_AVAILABLE 107 | buzzer_obj = anjay_zephyr_buzzer_object_create(BUZZER_NODE); 108 | if (buzzer_obj) { 109 | anjay_register_object(anjay, buzzer_obj); 110 | } 111 | #endif // BUZZER_AVAILABLE 112 | 113 | #if LED_COLOR_LIGHT_AVAILABLE 114 | led_color_light_obj = anjay_zephyr_led_color_light_object_create(DEVICE_DT_GET(RGB_NODE)); 115 | if (led_color_light_obj) { 116 | anjay_register_object(anjay, led_color_light_obj); 117 | } 118 | #endif // LED_COLOR_LIGHT_AVAILABLE 119 | 120 | #if LIGHT_CONTROL_AVAILABLE_ANY 121 | light_control_obj = anjay_zephyr_light_control_object_create(leds, AVS_ARRAY_SIZE(leds)); 122 | if (light_control_obj) { 123 | anjay_register_object(anjay, light_control_obj); 124 | } 125 | #endif // LIGHT_CONTROL_AVAILABLE_ANY 126 | 127 | #if SWITCH_AVAILABLE_ANY 128 | switch_obj = anjay_zephyr_switch_object_create(switches, AVS_ARRAY_SIZE(switches)); 129 | if (switch_obj) { 130 | anjay_register_object(anjay, switch_obj); 131 | } 132 | #endif // SWITCH_AVAILABLE_ANY 133 | return 0; 134 | } 135 | 136 | static void update_objects_frequent(anjay_t *anjay) 137 | { 138 | #if SWITCH_AVAILABLE_ANY 139 | anjay_zephyr_switch_object_update(anjay, switch_obj); 140 | #endif // SWITCH_AVAILABLE_ANY 141 | #if BUZZER_AVAILABLE 142 | anjay_zephyr_buzzer_object_update(anjay, buzzer_obj); 143 | #endif // BUZZER_AVAILABLE 144 | } 145 | 146 | static void update_objects_periodic(anjay_t *anjay) 147 | { 148 | anjay_zephyr_ipso_sensors_update(anjay); 149 | anjay_zephyr_location_object_update(anjay, location_obj); 150 | } 151 | 152 | static void update_objects(avs_sched_t *sched, const void *anjay_ptr) 153 | { 154 | anjay_t *anjay = *(anjay_t *const *)anjay_ptr; 155 | 156 | static size_t cycle; 157 | 158 | update_objects_frequent(anjay); 159 | if (cycle % 5 == 0) { 160 | update_objects_periodic(anjay); 161 | } 162 | 163 | status_led_toggle(); 164 | 165 | cycle++; 166 | AVS_SCHED_DELAYED(sched, &update_objects_handle, 167 | avs_time_duration_from_scalar(1, AVS_TIME_S), update_objects, &anjay, 168 | sizeof(anjay)); 169 | } 170 | 171 | static int init_update_objects(anjay_t *anjay) 172 | { 173 | avs_sched_t *sched = anjay_get_scheduler(anjay); 174 | 175 | update_objects(sched, &anjay); 176 | 177 | status_led_init(); 178 | 179 | return 0; 180 | } 181 | 182 | static int clean_before_anjay_destroy(anjay_t *anjay) 183 | { 184 | avs_sched_del(&update_objects_handle); 185 | 186 | return 0; 187 | } 188 | 189 | static int release_objects(void) 190 | { 191 | anjay_zephyr_location_object_release(&location_obj); 192 | #if SWITCH_AVAILABLE_ANY 193 | anjay_zephyr_switch_object_release(&switch_obj); 194 | #endif // SWITCH_AVAILABLE_ANY 195 | #if LED_COLOR_LIGHT_AVAILABLE 196 | anjay_zephyr_led_color_light_object_release(&led_color_light_obj); 197 | #endif // LED_COLOR_LIGHT_AVAILABLE 198 | #if LIGHT_CONTROL_AVAILABLE_ANY 199 | anjay_zephyr_light_control_object_release(&light_control_obj); 200 | #endif // LIGHT_CONTROL_AVAILABLE_ANY 201 | #if BUZZER_AVAILABLE 202 | anjay_zephyr_buzzer_object_release(&buzzer_obj); 203 | #endif // BUZZER_AVAILABLE 204 | return 0; 205 | } 206 | 207 | int lwm2m_callback(anjay_t *anjay, enum anjay_zephyr_lwm2m_callback_reasons reason) 208 | { 209 | switch (reason) { 210 | case ANJAY_ZEPHYR_LWM2M_CALLBACK_REASON_INIT: 211 | return register_objects(anjay); 212 | case ANJAY_ZEPHYR_LWM2M_CALLBACK_REASON_ANJAY_READY: 213 | return init_update_objects(anjay); 214 | case ANJAY_ZEPHYR_LWM2M_CALLBACK_REASON_ANJAY_SHUTTING_DOWN: 215 | return clean_before_anjay_destroy(anjay); 216 | case ANJAY_ZEPHYR_LWM2M_CALLBACK_REASON_CLEANUP: 217 | return release_objects(); 218 | default: 219 | return -1; 220 | } 221 | } 222 | 223 | int main(void) 224 | { 225 | LOG_INF("Initializing Anjay-zephyr-client demo " CONFIG_ANJAY_ZEPHYR_VERSION); 226 | 227 | anjay_zephyr_lwm2m_set_user_callback(lwm2m_callback); 228 | 229 | anjay_zephyr_lwm2m_init_from_settings(); 230 | anjay_zephyr_lwm2m_start(); 231 | 232 | // Anjay runs in a separate thread and preceding function doesn't block 233 | // add your own code here 234 | return 0; 235 | } 236 | -------------------------------------------------------------------------------- /demo/src/peripherals.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 AVSystem 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | 22 | #define RGB_NODE DT_ALIAS(rgb_pwm) 23 | #define LED_COLOR_LIGHT_AVAILABLE DT_NODE_HAS_STATUS(RGB_NODE, okay) 24 | 25 | #define BUZZER_NODE DT_ALIAS(buzzer_pwm) 26 | #define BUZZER_AVAILABLE DT_NODE_HAS_STATUS(BUZZER_NODE, okay) 27 | 28 | #define LIGHT_CONTROL_NODE(idx) DT_ALIAS(light_control_##idx) 29 | #define LIGHT_CONTROL_AVAILABLE(idx) DT_NODE_HAS_STATUS(LIGHT_CONTROL_NODE(idx), okay) 30 | #define LIGHT_CONTROL_AVAILABLE_ANY \ 31 | (LIGHT_CONTROL_AVAILABLE(0) || LIGHT_CONTROL_AVAILABLE(1) || LIGHT_CONTROL_AVAILABLE(2) || \ 32 | LIGHT_CONTROL_AVAILABLE(3)) 33 | 34 | #define PUSH_BUTTON_NODE(idx) DT_ALIAS(push_button_##idx) 35 | #define PUSH_BUTTON_AVAILABLE(idx) DT_NODE_HAS_STATUS(PUSH_BUTTON_NODE(idx), okay) 36 | #define PUSH_BUTTON_AVAILABLE_ANY \ 37 | (PUSH_BUTTON_AVAILABLE(0) || PUSH_BUTTON_AVAILABLE(1) || PUSH_BUTTON_AVAILABLE(2) || \ 38 | PUSH_BUTTON_AVAILABLE(3)) 39 | 40 | #define SWITCH_NODE(idx) DT_ALIAS(switch_##idx) 41 | #define SWITCH_AVAILABLE(idx) DT_NODE_HAS_STATUS(SWITCH_NODE(idx), okay) 42 | #define SWITCH_AVAILABLE_ANY (SWITCH_AVAILABLE(0) || SWITCH_AVAILABLE(1) || SWITCH_AVAILABLE(2)) 43 | 44 | #define PUSH_BUTTON_GLUE_ITEM(num) \ 45 | { .device = DEVICE_DT_GET(DT_GPIO_CTLR(PUSH_BUTTON_NODE(num), gpios)), \ 46 | .gpio_pin = DT_GPIO_PIN(PUSH_BUTTON_NODE(num), gpios), \ 47 | .gpio_flags = (GPIO_INPUT | DT_GPIO_FLAGS(PUSH_BUTTON_NODE(num), gpios)) } 48 | 49 | #define SWITCH_BUTTON_GLUE_ITEM(num) \ 50 | { .device = DEVICE_DT_GET(DT_GPIO_CTLR(SWITCH_NODE(num), gpios)), \ 51 | .gpio_pin = DT_GPIO_PIN(SWITCH_NODE(num), gpios), \ 52 | .gpio_flags = (GPIO_INPUT | DT_GPIO_FLAGS(SWITCH_NODE(num), gpios)) } 53 | 54 | #define TEMPERATURE_NODE DT_ALIAS(temperature) 55 | #define TEMPERATURE_AVAILABLE DT_NODE_HAS_STATUS(TEMPERATURE_NODE, okay) 56 | 57 | #define HUMIDITY_NODE DT_ALIAS(humidity) 58 | #define HUMIDITY_AVAILABLE DT_NODE_HAS_STATUS(HUMIDITY_NODE, okay) 59 | 60 | #define BAROMETER_NODE DT_ALIAS(barometer) 61 | #define BAROMETER_AVAILABLE DT_NODE_HAS_STATUS(BAROMETER_NODE, okay) 62 | 63 | #define DISTANCE_NODE DT_ALIAS(distance) 64 | #define DISTANCE_AVAILABLE DT_NODE_HAS_STATUS(DISTANCE_NODE, okay) 65 | 66 | #define ILLUMINANCE_NODE DT_ALIAS(illuminance) 67 | #define ILLUMINANCE_AVAILABLE DT_NODE_HAS_STATUS(ILLUMINANCE_NODE, okay) 68 | 69 | #define ACCELEROMETER_NODE DT_ALIAS(accelerometer) 70 | #define ACCELEROMETER_AVAILABLE DT_NODE_HAS_STATUS(ACCELEROMETER_NODE, okay) 71 | 72 | #define GYROMETER_NODE DT_ALIAS(gyrometer) 73 | #define GYROMETER_AVAILABLE DT_NODE_HAS_STATUS(GYROMETER_NODE, okay) 74 | 75 | #define MAGNETOMETER_NODE DT_ALIAS(magnetometer) 76 | #define MAGNETOMETER_AVAILABLE DT_NODE_HAS_STATUS(MAGNETOMETER_NODE, okay) 77 | -------------------------------------------------------------------------------- /demo/src/sensors_config.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 AVSystem 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include 17 | 18 | #include "sensors_config.h" 19 | #include "peripherals.h" 20 | 21 | #define KPA_TO_PA_FACTOR 1e3 22 | #define GAUSS_TO_TESLA_FACTOR 1e-4 23 | 24 | static struct anjay_zephyr_ipso_sensor_context illuminance_sensor_def[] = { 25 | #if ILLUMINANCE_AVAILABLE 26 | { .name = "Illuminance", 27 | .unit = "lx", 28 | .device = DEVICE_DT_GET(ILLUMINANCE_NODE), 29 | .channel = SENSOR_CHAN_LIGHT, 30 | .min_range_value = NAN, 31 | .max_range_value = NAN } 32 | #endif // ILLUMINANCE_AVAILABLE 33 | }; 34 | 35 | static struct anjay_zephyr_ipso_sensor_context temperature_sensor_def[] = { 36 | #if TEMPERATURE_AVAILABLE 37 | { .name = "Temperature", 38 | .unit = "Cel", 39 | .device = DEVICE_DT_GET(TEMPERATURE_NODE), 40 | .channel = SENSOR_CHAN_AMBIENT_TEMP, 41 | .min_range_value = NAN, 42 | .max_range_value = NAN } 43 | #endif // TEMPERATURE_AVAILABLE 44 | }; 45 | 46 | static struct anjay_zephyr_ipso_sensor_context humidity_sensor_def[] = { 47 | #if HUMIDITY_AVAILABLE 48 | { .name = "Humidity", 49 | .unit = "%RH", 50 | .device = DEVICE_DT_GET(HUMIDITY_NODE), 51 | .channel = SENSOR_CHAN_HUMIDITY, 52 | .min_range_value = NAN, 53 | .max_range_value = NAN } 54 | #endif // HUMIDITY_AVAILABLE 55 | }; 56 | 57 | static struct anjay_zephyr_ipso_sensor_context acceleration_sensor_def[] = { 58 | #if ACCELEROMETER_AVAILABLE 59 | { .name = "Accelerometer", 60 | .unit = "m/s2", 61 | .device = DEVICE_DT_GET(ACCELEROMETER_NODE), 62 | .channel = SENSOR_CHAN_ACCEL_XYZ, 63 | .use_y_value = true, 64 | .use_z_value = true, 65 | .min_range_value = NAN, 66 | .max_range_value = NAN } 67 | #endif // ACCELEROMETER_AVAILABLE 68 | }; 69 | 70 | static struct anjay_zephyr_ipso_sensor_context magnetic_field_sensor_def[] = { 71 | #if MAGNETOMETER_AVAILABLE 72 | { .name = "Magnetometer", 73 | .unit = "T", 74 | .device = DEVICE_DT_GET(MAGNETOMETER_NODE), 75 | .channel = SENSOR_CHAN_MAGN_XYZ, 76 | .scale_factor = GAUSS_TO_TESLA_FACTOR, 77 | .use_y_value = true, 78 | .use_z_value = true, 79 | .min_range_value = NAN, 80 | .max_range_value = NAN } 81 | #endif // MAGNETOMETER_AVAILABLE 82 | }; 83 | 84 | static struct anjay_zephyr_ipso_sensor_context pressure_sensor_def[] = { 85 | #if BAROMETER_AVAILABLE 86 | { .name = "Barometer", 87 | .unit = "Pa", 88 | .device = DEVICE_DT_GET(BAROMETER_NODE), 89 | .channel = SENSOR_CHAN_PRESS, 90 | .scale_factor = KPA_TO_PA_FACTOR, 91 | .min_range_value = NAN, 92 | .max_range_value = NAN } 93 | #endif // BAROMETER_AVAILABLE 94 | }; 95 | 96 | static struct anjay_zephyr_ipso_sensor_context distance_sensor_def[] = { 97 | #if DISTANCE_AVAILABLE 98 | { .name = "Distance", 99 | .unit = "m", 100 | .device = DEVICE_DT_GET(DISTANCE_NODE), 101 | .channel = SENSOR_CHAN_DISTANCE, 102 | .min_range_value = NAN, 103 | .max_range_value = NAN } 104 | #endif // DISTANCE_AVAILABLE 105 | }; 106 | 107 | static struct anjay_zephyr_ipso_sensor_context angular_rate_sensor_def[] = { 108 | #if GYROMETER_AVAILABLE 109 | { .name = "Gyrometer", 110 | .unit = "deg/s", 111 | .device = DEVICE_DT_GET(GYROMETER_NODE), 112 | .channel = SENSOR_CHAN_GYRO_XYZ, 113 | .use_y_value = true, 114 | .use_z_value = true, 115 | .min_range_value = NAN, 116 | .max_range_value = NAN } 117 | #endif // GYROMETER_AVAILABLE 118 | }; 119 | 120 | static struct anjay_zephyr_ipso_sensor_oid_set sensors_basic_oid_def[] = { 121 | { .user_sensors = illuminance_sensor_def, 122 | .oid = 3301, 123 | .user_sensors_array_length = AVS_ARRAY_SIZE(illuminance_sensor_def) }, 124 | { .user_sensors = temperature_sensor_def, 125 | .oid = 3303, 126 | .user_sensors_array_length = AVS_ARRAY_SIZE(temperature_sensor_def) }, 127 | { .user_sensors = humidity_sensor_def, 128 | .oid = 3304, 129 | .user_sensors_array_length = AVS_ARRAY_SIZE(humidity_sensor_def) }, 130 | { .user_sensors = pressure_sensor_def, 131 | .oid = 3315, 132 | .user_sensors_array_length = AVS_ARRAY_SIZE(pressure_sensor_def) }, 133 | { .user_sensors = distance_sensor_def, 134 | .oid = 3330, 135 | .user_sensors_array_length = AVS_ARRAY_SIZE(distance_sensor_def) } 136 | }; 137 | 138 | static struct anjay_zephyr_ipso_sensor_oid_set sensors_3d_oid_def[] = { 139 | { .user_sensors = acceleration_sensor_def, 140 | .oid = 3313, 141 | .user_sensors_array_length = AVS_ARRAY_SIZE(acceleration_sensor_def) }, 142 | { .user_sensors = magnetic_field_sensor_def, 143 | .oid = 3314, 144 | .user_sensors_array_length = AVS_ARRAY_SIZE(magnetic_field_sensor_def) }, 145 | { .user_sensors = angular_rate_sensor_def, 146 | .oid = 3334, 147 | .user_sensors_array_length = AVS_ARRAY_SIZE(angular_rate_sensor_def) } 148 | }; 149 | 150 | void sensors_install(anjay_t *anjay) 151 | { 152 | anjay_zephyr_ipso_basic_sensors_install(anjay, sensors_basic_oid_def, 153 | AVS_ARRAY_SIZE(sensors_basic_oid_def)); 154 | anjay_zephyr_ipso_three_axis_sensors_install(anjay, sensors_3d_oid_def, 155 | AVS_ARRAY_SIZE(sensors_3d_oid_def)); 156 | } 157 | -------------------------------------------------------------------------------- /demo/src/sensors_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 AVSystem 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | 21 | void sensors_install(anjay_t *anjay); 22 | -------------------------------------------------------------------------------- /demo/src/status_led.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 AVSystem 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "status_led.h" 18 | 19 | #if STATUS_LED_AVAILABLE 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | LOG_MODULE_REGISTER(status_led); 26 | 27 | static const struct gpio_dt_spec status_led_spec = GPIO_DT_SPEC_GET(STATUS_LED_NODE, gpios); 28 | 29 | void status_led_init(void) 30 | { 31 | if (!device_is_ready(status_led_spec.port) || 32 | gpio_pin_configure_dt(&status_led_spec, GPIO_OUTPUT_INACTIVE)) { 33 | LOG_WRN("failed to initialize status led"); 34 | } 35 | } 36 | 37 | static void status_led_set(int value) 38 | { 39 | if (device_is_ready(status_led_spec.port)) { 40 | gpio_pin_set_dt(&status_led_spec, value); 41 | } 42 | } 43 | 44 | void status_led_on(void) 45 | { 46 | status_led_set(1); 47 | } 48 | 49 | void status_led_off(void) 50 | { 51 | status_led_set(0); 52 | } 53 | 54 | void status_led_toggle(void) 55 | { 56 | if (device_is_ready(status_led_spec.port)) { 57 | gpio_pin_toggle_dt(&status_led_spec); 58 | } 59 | } 60 | #else // STATUS_LED_AVAILABLE 61 | 62 | void status_led_init(void) 63 | { 64 | } 65 | 66 | void status_led_on(void) 67 | { 68 | } 69 | 70 | void status_led_off(void) 71 | { 72 | } 73 | 74 | void status_led_toggle(void) 75 | { 76 | } 77 | #endif // STATUS_LED_AVAILABLE 78 | -------------------------------------------------------------------------------- /demo/src/status_led.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 AVSystem 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | 21 | #define STATUS_LED_NODE DT_ALIAS(status_led) 22 | #define STATUS_LED_AVAILABLE DT_NODE_HAS_STATUS(STATUS_LED_NODE, okay) 23 | 24 | void status_led_init(void); 25 | 26 | void status_led_on(void); 27 | 28 | void status_led_off(void); 29 | 30 | void status_led_toggle(void); 31 | -------------------------------------------------------------------------------- /demo/sysbuild.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2020-2025 AVSystem 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | if(NOT DEFINED Zephyr_VERSION) 16 | message(ERROR "Zephyr version not set") 17 | endif() 18 | 19 | # NOTE: The directory for sysbuild has been called _sysbuild instead of 20 | # sysbuild, because we want to avoid any tries of default merging .conf 21 | # or .overlay by sysbuild, because we are not using that mechanism, 22 | # which is not completely correct for our use case. 23 | if(EXISTS "${CMAKE_BINARY_DIR}/../_sysbuild/mcuboot/boards/${BOARD}.conf") 24 | if (Zephyr_VERSION VERSION_LESS "3.4") 25 | set(MCUBOOT_CONF_FILE "mcuboot_OVERLAY_CONFIG") 26 | else() 27 | set(MCUBOOT_CONF_FILE "mcuboot_EXTRA_CONF_FILE") 28 | endif() 29 | 30 | set(${MCUBOOT_CONF_FILE} 31 | "${CMAKE_BINARY_DIR}/../_sysbuild/mcuboot/boards/${BOARD}.conf" 32 | CACHE INTERNAL "Conf for mcuboot") 33 | endif() 34 | 35 | set(MCUBOOT_DIR ${ZEPHYR_BASE}/../bootloader/mcuboot) 36 | set(mcuboot_DTC_OVERLAY_FILE 37 | ${MCUBOOT_DIR}/boot/zephyr/app.overlay 38 | CACHE INTERNAL "Overlay for mcuboot") 39 | 40 | if(EXISTS "${CMAKE_BINARY_DIR}/../_sysbuild/mcuboot/boards/${BOARD}.overlay") 41 | list(APPEND mcuboot_DTC_OVERLAY_FILE 42 | "${CMAKE_BINARY_DIR}/../_sysbuild/mcuboot/boards/${BOARD}.overlay") 43 | endif() 44 | 45 | # NOTE: This is largely copied from CMakeLists.txt in Zephyr itself. 46 | # However, using that would require setting HEX_FILES_TO_MERGE *before* 47 | # find_package(Zephyr), and we can't do that because we need to examine 48 | # Kconfig variables, which are populated by find_package(Zephyr). 49 | # That's why we do it ourselves here... 50 | set(MERGED_HEX_NAME "${CMAKE_CURRENT_BINARY_DIR}/zephyr/merged.hex") 51 | set(MCUBOOT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/mcuboot") 52 | 53 | if(Zephyr_VERSION VERSION_LESS "3.2") 54 | set(MERGEHEX_SCRIPT "${ZEPHYR_BASE}/scripts/mergehex.py") 55 | else() 56 | set(MERGEHEX_SCRIPT "${ZEPHYR_BASE}/scripts/build/mergehex.py") 57 | endif() 58 | 59 | add_custom_command(OUTPUT "${MERGED_HEX_NAME}" 60 | COMMAND "${PYTHON_EXECUTABLE}" 61 | "${MERGEHEX_SCRIPT}" 62 | -o "${MERGED_HEX_NAME}" 63 | "${MCUBOOT_BINARY_DIR}/zephyr/zephyr.hex" 64 | "${CMAKE_CURRENT_BINARY_DIR}/demo/zephyr/zephyr.signed.hex" 65 | DEPENDS demo mcuboot) 66 | add_custom_target(merged_hex ALL DEPENDS "${MERGED_HEX_NAME}") 67 | 68 | set(FOTA_BINARY_FILE "${CMAKE_CURRENT_BINARY_DIR}/demo/zephyr/zephyr.signed.bin") 69 | if(CONFIG_ANJAY_ZEPHYR_FOTA) 70 | # NOTE: Condider removing this (and the validate_fota_file_size.py script 71 | # itself) when https://github.com/nrfconnect/sdk-mcuboot/pull/185 is merged 72 | add_custom_target(validate_fota_file_size ALL DEPENDS merged_hex 73 | COMMAND "${PYTHON_EXECUTABLE}" 74 | "${CMAKE_CURRENT_SOURCE_DIR}/../tools/validate_fota_file_size.py" 75 | "${FOTA_BINARY_FILE}") 76 | endif() 77 | -------------------------------------------------------------------------------- /demo/sysbuild.conf: -------------------------------------------------------------------------------- 1 | SB_CONFIG_BOOTLOADER_MCUBOOT=y 2 | -------------------------------------------------------------------------------- /demo/west-nrf.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2020-2025 AVSystem 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Manifest for sdk-nrf based samples 16 | manifest: 17 | remotes: 18 | - name: anjay 19 | url-base: https://github.com/AVSystem 20 | - name: ncs 21 | url-base: https://github.com/nrfconnect 22 | projects: 23 | - name: sdk-nrf 24 | path: nrf 25 | remote: ncs 26 | revision: v2.7.0 27 | import: true 28 | - name: Anjay-zephyr 29 | submodules: true 30 | remote: anjay 31 | revision: 3.10.0 32 | path: modules/lib/anjay 33 | -------------------------------------------------------------------------------- /demo/west-t-mobile.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2020-2025 AVSystem 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Manifest for zephyr based samples 16 | manifest: 17 | remotes: 18 | - name: anjay 19 | url-base: https://github.com/AVSystem 20 | - name: t-mobile 21 | url-base: https://github.com/tmobile 22 | projects: 23 | - name: DevEdge-IoTDevKit-ZephyrRTOS 24 | path: zephyr 25 | remote: t-mobile 26 | revision: tmz-1.19.2-qa 27 | import: true 28 | - name: Anjay-zephyr 29 | submodules: true 30 | remote: anjay 31 | revision: 3.10.0 32 | path: modules/lib/anjay 33 | - name: DevEdge-IoTDevKit-ZephyrSDK 34 | path: modules/lib/t-mobile-sdk 35 | remote: t-mobile 36 | revision: tmz-sdk-1.19.2-qa 37 | -------------------------------------------------------------------------------- /demo/west.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2020-2025 AVSystem 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Manifest for zephyr based samples 16 | manifest: 17 | remotes: 18 | - name: anjay 19 | url-base: https://github.com/AVSystem 20 | - name: zephyrproject-rtos 21 | url-base: https://github.com/zephyrproject-rtos 22 | projects: 23 | - name: zephyr 24 | path: zephyr 25 | remote: zephyrproject-rtos 26 | revision: v3.6.0 27 | import: true 28 | - name: Anjay-zephyr 29 | submodules: true 30 | remote: anjay 31 | revision: 3.10.0 32 | path: modules/lib/anjay 33 | -------------------------------------------------------------------------------- /ei_demo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2020-2025 AVSystem 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | cmake_minimum_required(VERSION 3.13.1) 16 | 17 | # Edge Impulse 18 | set(CMAKE_CXX_STANDARD 11) 19 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 20 | # EI API key has to be set in order to download the TinyML model from EI. 21 | # set(EI_API_KEY_HEADER "x-api-key:ei_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") 22 | 23 | # Anjay zephyr client 24 | find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) 25 | project(anjay_zephyr_demo) 26 | set(root_dir ${ANJAY_ZEPHYR_CLIENT_DIR}) 27 | 28 | # Anjay zephyr client 29 | set(app_common_sources 30 | src/main.c 31 | src/led.c 32 | src/led.h 33 | src/objects/objects.h 34 | src/objects/pattern_detector.c) 35 | 36 | target_sources(app PRIVATE ${app_common_sources}) 37 | -------------------------------------------------------------------------------- /ei_demo/README.md: -------------------------------------------------------------------------------- 1 | # Anjay Edge Impulse example [](http://www.avsystem.com/) 2 | 3 | This example runs example motion recognition model, built with Edge Impulse, and streams detection statistics to a LwM2M server. 4 | ## Supported hardware and overview 5 | 6 | This example works on following targets: 7 | - `thingy91/nrf9160/ns` 8 | 9 | The following LwM2M Objects are supported: 10 | - Security (/0) 11 | - Server (/1) 12 | - Device (/3) 13 | - Pattern Detector (/33650, custom object, see pattern_detector.xml) 14 | 15 | ## Compilation 16 | 17 | Set West manifest path to `Anjay-zephyr-client/ei_demo`, and manifest file to `west-nrf.yml` and do `west update`. 18 | ``` 19 | west config manifest.path Anjay-zephyr-client/ei_demo 20 | west config manifest.file west-nrf.yml 21 | west update 22 | ``` 23 | 24 | You can now compile the project for Thingy:91 using `west build -b thingy91/nrf9160/ns` in `ei_demo` directory. 25 | 26 | ## Flashing the target 27 | 28 | After successful build you can flash the target using `west flash`. 29 | 30 | ## Connecting to the LwM2M Server 31 | 32 | To connect to [Coiote IoT Device 33 | Management](https://www.avsystem.com/products/coiote-iot-device-management-platform/) 34 | LwM2M Server, please register at https://eu.iot.avsystem.cloud/. Then have 35 | a look at the Configuration menu using `west build -t guiconfig` or `west build -t menuconfig` to configure security credentials and other 36 | necessary settings (like Wi-Fi SSID etc.). 37 | 38 | [Guide showing basic usage of Coiote DM](https://iotdevzone.avsystem.com/docs/IoT_quick_start/Device_onboarding/) 39 | is available on IoT Developer Zone. 40 | 41 | NOTE: You may use any LwM2M Server compliant with LwM2M 1.0 TS. The server URI 42 | can be changed in the Configuration menu. 43 | -------------------------------------------------------------------------------- /ei_demo/boards/thingy91_nrf9160_ns.conf: -------------------------------------------------------------------------------- 1 | # anjay-zephyr-client 2 | CONFIG_ANJAY_ZEPHYR_DEVICE_MANUFACTURER="Nordic Semiconductor" 3 | CONFIG_ANJAY_ZEPHYR_MODEL_NUMBER="Thingy:91" 4 | 5 | # Anjay Settings 6 | CONFIG_ANJAY_COMPAT_TIME=y 7 | CONFIG_ANJAY_COMPAT_ZEPHYR_TLS=y 8 | CONFIG_ANJAY_WITH_MICRO_LOGS=y 9 | CONFIG_LOG_MODE_IMMEDIATE=y 10 | 11 | # General settings 12 | CONFIG_MAIN_STACK_SIZE=32768 13 | CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=16384 14 | 15 | # Networking 16 | CONFIG_NET_IF_MAX_IPV4_COUNT=2 17 | CONFIG_NET_TCP_ISN_RFC6528=n 18 | 19 | # nRF LTE 20 | CONFIG_NRF_MODEM_LIB=y 21 | CONFIG_MODEM_INFO=y 22 | CONFIG_LTE_LINK_CONTROL=y 23 | CONFIG_LTE_NETWORK_TIMEOUT=600 24 | 25 | # Clock synchronization 26 | CONFIG_DATE_TIME=y 27 | CONFIG_DATE_TIME_UPDATE_INTERVAL_SECONDS=600 28 | CONFIG_DATE_TIME_TOO_OLD_SECONDS=600 29 | CONFIG_DATE_TIME_MODEM=n 30 | CONFIG_DATE_TIME_NTP_QUERY_TIME_SECONDS=5 31 | 32 | # File system 33 | CONFIG_FLASH_PAGE_LAYOUT=y 34 | CONFIG_MPU_ALLOW_FLASH_WRITE=y 35 | 36 | # Heap 37 | CONFIG_HEAP_MEM_POOL_SIZE=2048 38 | 39 | # Shell settings 40 | CONFIG_SHELL_MINIMAL=y 41 | CONFIG_SHELL_TAB=y 42 | CONFIG_SHELL_TAB_AUTOCOMPLETION=y 43 | CONFIG_DATE_SHELL=n 44 | CONFIG_DEVICE_SHELL=n 45 | CONFIG_DEVMEM_SHELL=n 46 | CONFIG_KERNEL_SHELL=y 47 | 48 | # Peripherals 49 | CONFIG_SENSOR=y 50 | CONFIG_ADXL362=y 51 | CONFIG_REGULATOR=n 52 | -------------------------------------------------------------------------------- /ei_demo/ei_model.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AVSystem/Anjay-zephyr-client/0bc849d3998fd8506e30554b74860f89cb1f3bf2/ei_demo/ei_model.zip -------------------------------------------------------------------------------- /ei_demo/prj.conf: -------------------------------------------------------------------------------- 1 | # Anjay Settings 2 | CONFIG_ANJAY=y 3 | CONFIG_ANJAY_COMPAT_NET=y 4 | CONFIG_ANJAY_WITH_BOOTSTRAP=n 5 | 6 | # General settings 7 | CONFIG_NEWLIB_LIBC=y 8 | CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y 9 | CONFIG_REBOOT=y 10 | CONFIG_FPU=y 11 | CONFIG_HWINFO=y 12 | CONFIG_SNTP=y 13 | CONFIG_SETTINGS=y 14 | 15 | # Generic networking options 16 | CONFIG_NETWORKING=y 17 | CONFIG_NET_UDP=y 18 | CONFIG_NET_IPV4=y 19 | CONFIG_NET_SOCKETS=y 20 | CONFIG_POSIX_MAX_FDS=6 21 | CONFIG_NET_CONNECTION_MANAGER=y 22 | 23 | # Logging 24 | CONFIG_NET_LOG=y 25 | CONFIG_LOG=y 26 | CONFIG_PRINTK=y 27 | CONFIG_SHELL=y 28 | 29 | # C++ support 30 | CONFIG_CPLUSPLUS=y 31 | CONFIG_LIB_CPLUSPLUS=y 32 | CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y 33 | 34 | # Enable Edge Impulse dependencies 35 | CONFIG_CPLUSPLUS=y 36 | CONFIG_STD_CPP11=y 37 | CONFIG_LIB_CPLUSPLUS=y 38 | CONFIG_NEWLIB_LIBC=y 39 | CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y 40 | CONFIG_FP16=n 41 | 42 | # Enable Edge Impulse 43 | CONFIG_EDGE_IMPULSE=y 44 | # TinyML model can be downloaded from the EI or be provided as a .zip file. 45 | # CONFIG_EDGE_IMPULSE_URI="http://studio.edgeimpulse.com/v1/api/XXXXX/deployment/download?type=zip" 46 | CONFIG_EDGE_IMPULSE_URI="ei_model.zip" 47 | CONFIG_EI_WRAPPER=y 48 | -------------------------------------------------------------------------------- /ei_demo/src/led.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 AVSystem 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | #include 20 | 21 | #include "led.h" 22 | 23 | void led_init(void) 24 | { 25 | if (device_is_ready(LED_DEV(0))) { 26 | gpio_pin_configure(LED_DEV(0), LED_PIN(0), LED_FLAGS(0)); 27 | } 28 | if (device_is_ready(LED_DEV(1))) { 29 | gpio_pin_configure(LED_DEV(1), LED_PIN(1), LED_FLAGS(1)); 30 | } 31 | if (device_is_ready(LED_DEV(2))) { 32 | gpio_pin_configure(LED_DEV(2), LED_PIN(2), LED_FLAGS(2)); 33 | } 34 | } 35 | 36 | static void led_set(int led, bool state) 37 | { 38 | switch (led) { 39 | case 0: 40 | if (device_is_ready(LED_DEV(0))) { 41 | gpio_pin_set(LED_DEV(0), LED_PIN(0), state); 42 | } 43 | break; 44 | case 1: 45 | if (device_is_ready(LED_DEV(1))) { 46 | gpio_pin_set(LED_DEV(1), LED_PIN(1), state); 47 | } 48 | break; 49 | case 2: 50 | if (device_is_ready(LED_DEV(2))) { 51 | gpio_pin_set(LED_DEV(2), LED_PIN(2), state); 52 | } 53 | break; 54 | default: 55 | break; 56 | } 57 | } 58 | 59 | void led_on(int led) 60 | { 61 | led_set(led, true); 62 | } 63 | 64 | void led_off(int led) 65 | { 66 | led_set(led, false); 67 | } 68 | -------------------------------------------------------------------------------- /ei_demo/src/led.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 AVSystem 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | #define LED_NODE(n) DT_ALIAS(led##n) 25 | #define LED_AVAILABLE(n) DT_NODE_HAS_STATUS(LED_NODE(n), okay) 26 | 27 | #define LED_DEV(n) DEVICE_DT_GET(DT_GPIO_CTLR(LED_NODE(n), gpios)) 28 | #define LED_PIN(n) DT_GPIO_PIN(LED_NODE(n), gpios) 29 | #define LED_FLAGS(n) (GPIO_OUTPUT_INACTIVE | DT_GPIO_FLAGS(LED_NODE(n), gpios)) 30 | 31 | void led_init(void); 32 | void led_on(int led); 33 | void led_off(int led); 34 | -------------------------------------------------------------------------------- /ei_demo/src/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 AVSystem 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #include "objects/objects.h" 24 | #include "led.h" 25 | 26 | static const anjay_dm_object_def_t **pattern_detector_obj; 27 | 28 | static avs_sched_handle_t update_objects_handle; 29 | 30 | static int register_objects(anjay_t *anjay) 31 | { 32 | pattern_detector_obj = pattern_detector_object_create(); 33 | if (pattern_detector_obj) { 34 | anjay_register_object(anjay, pattern_detector_obj); 35 | } 36 | 37 | return 0; 38 | } 39 | 40 | static void update_objects(avs_sched_t *sched, const void *anjay_ptr) 41 | { 42 | anjay_t *anjay = *(anjay_t *const *)anjay_ptr; 43 | 44 | pattern_detector_object_update(anjay, pattern_detector_obj); 45 | 46 | AVS_SCHED_DELAYED(sched, &update_objects_handle, 47 | avs_time_duration_from_scalar(1, AVS_TIME_S), update_objects, &anjay, 48 | sizeof(anjay)); 49 | } 50 | 51 | static int release_objects(void) 52 | { 53 | pattern_detector_object_release(pattern_detector_obj); 54 | 55 | return 0; 56 | } 57 | 58 | static int init_update_objects(anjay_t *anjay) 59 | { 60 | avs_sched_t *sched = anjay_get_scheduler(anjay); 61 | 62 | update_objects(sched, &anjay); 63 | 64 | return 0; 65 | } 66 | 67 | static int clean_before_anjay_destroy(anjay_t *anjay) 68 | { 69 | avs_sched_del(&update_objects_handle); 70 | 71 | return 0; 72 | } 73 | 74 | int lwm2m_callback(anjay_t *anjay, enum anjay_zephyr_lwm2m_callback_reasons reason) 75 | { 76 | switch (reason) { 77 | case ANJAY_ZEPHYR_LWM2M_CALLBACK_REASON_INIT: 78 | return register_objects(anjay); 79 | case ANJAY_ZEPHYR_LWM2M_CALLBACK_REASON_ANJAY_READY: 80 | return init_update_objects(anjay); 81 | case ANJAY_ZEPHYR_LWM2M_CALLBACK_REASON_ANJAY_SHUTTING_DOWN: 82 | return clean_before_anjay_destroy(anjay); 83 | case ANJAY_ZEPHYR_LWM2M_CALLBACK_REASON_CLEANUP: 84 | return release_objects(); 85 | default: 86 | return -1; 87 | } 88 | } 89 | 90 | int main(void) 91 | { 92 | led_init(); 93 | 94 | anjay_zephyr_lwm2m_set_user_callback(lwm2m_callback); 95 | 96 | anjay_zephyr_lwm2m_init_from_settings(); 97 | anjay_zephyr_lwm2m_start(); 98 | 99 | // Anjay runs in a separate thread and preceding function doesn't block 100 | // add your own code here 101 | return 0; 102 | } 103 | -------------------------------------------------------------------------------- /ei_demo/src/objects/objects.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 AVSystem 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | 21 | const anjay_dm_object_def_t **pattern_detector_object_create(void); 22 | void pattern_detector_object_release(const anjay_dm_object_def_t **def); 23 | void pattern_detector_object_update(anjay_t *anjay, const anjay_dm_object_def_t *const *def); 24 | -------------------------------------------------------------------------------- /ei_demo/west-nrf.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2020-2025 AVSystem 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Manifest for sdk-nrf based samples 16 | manifest: 17 | remotes: 18 | - name: anjay 19 | url-base: https://github.com/AVSystem 20 | - name: ncs 21 | url-base: https://github.com/nrfconnect 22 | projects: 23 | - name: sdk-nrf 24 | path: nrf 25 | remote: ncs 26 | revision: v2.7.0 27 | import: true 28 | - name: Anjay-zephyr 29 | submodules: true 30 | remote: anjay 31 | revision: 3.10.0 32 | path: modules/lib/anjay 33 | -------------------------------------------------------------------------------- /minimal/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2020-2025 AVSystem 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | cmake_minimum_required(VERSION 3.13.1) 16 | find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) 17 | project(anjay_zephyr_demo) 18 | set(root_dir ${ANJAY_ZEPHYR_CLIENT_DIR}) 19 | 20 | set(app_common_sources 21 | src/main.c) 22 | 23 | target_sources(app PRIVATE 24 | ${app_common_sources} 25 | ) 26 | -------------------------------------------------------------------------------- /minimal/README.md: -------------------------------------------------------------------------------- 1 | # Anjay Minimal Client [](http://www.avsystem.com/) 2 | 3 | Project with minimal features needed to run Anjay on zephyr. 4 | It should serve as a template for custom projects. 5 | ## Supported hardware and overview 6 | 7 | This folder contains LwM2M Client minimal application example for following targets: 8 | - [qemu_x86](https://docs.zephyrproject.org/latest/boards/x86/qemu_x86/doc/index.html) 9 | - [disco_l475_iot1](https://docs.zephyrproject.org/latest/boards/arm/disco_l475_iot1/doc/index.html) 10 | - [nrf9160dk/nrf9160/ns](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/ug_nrf9160.html) 11 | - [thingy91/nrf9160/ns](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/ug_thingy91.html) 12 | - [ESP32-DevKitC](https://www.espressif.com/en/products/devkits/esp32-devkitc) 13 | - [nrf52840dk/nrf52840](https://docs.zephyrproject.org/latest/boards/arm/nrf52840dk_nrf52840/doc/index.html) 14 | - [nRF7002 Development kit](https://www.nordicsemi.com/Products/Development-hardware/nRF7002-DK) 15 | - [Arduino Nano 33 BLE Sense Lite](https://store.arduino.cc/products/arduino-nano-33-ble-sense) 16 | - [DevEdge](https://devedge.t-mobile.com/solutions/iotdevkit) 17 | 18 | The following LwM2M Objects are supported: 19 | - Security (/0) 20 | - Server (/1) 21 | - Device (/3) 22 | 23 | ## Compilation 24 | 25 | Set West manifest path to `Anjay-zephyr-client/minimal`, and manifest file to `west.yml` and do `west update`. 26 | ``` 27 | west config manifest.path Anjay-zephyr-client/minimal 28 | west config manifest.file west.yml 29 | west update 30 | ``` 31 | 32 | You can now compile the project using `west build -b ` in `minimal` directory. 33 | 34 | ### Compilation guide for nRF9160DK, Thingy:91, nRF7002DK, nRF52840DK and Arduino Nano 33 BLE Sense 35 | 36 | Because NCS uses different Zephyr version, it is necessary to change our Zephyr workspace, it is handled by using different manifest file. 37 | Set West manifest path to `Anjay-zephyr-client/minimal`, and manifest file to `west-nrf.yml` and do `west update`. 38 | ``` 39 | west config manifest.path Anjay-zephyr-client/minimal 40 | west config manifest.file west-nrf.yml 41 | west update 42 | ``` 43 | Now you can compile the project using `west build -b nrf9160dk/nrf9160/ns`, `west build -b thingy91/nrf9160/ns`, `west build -b nrf7002dk/nrf5340/cpuapp/ns`, `west build -b nrf52840dk/nrf52840` or `west build -b arduino_nano_33_ble/nrf52840/sense` in `minimal` directory, respectively. The last two commands compiles project for use with the OpenThread network, more about this can be found in the section [Connecting to the LwM2M Server with OpenThread](#connecting-to-the-lwm2m-server-with-openthread). 44 | 45 | ### Compilation guide for T-Mobile DevEdge 46 | 47 | Because T-Mobile DevEdge board uses fork of Zephyr, it is necessary to change our Zephyr workspace, it is handled by using different manifest file. 48 | Set West manifest path to `Anjay-zephyr-client/minimal`, and manifest file to `west-t-mobile.yml` and do `west update`. 49 | ``` 50 | west config manifest.path Anjay-zephyr-client/minimal 51 | west config manifest.file west-t-mobile.yml 52 | west update 53 | ``` 54 | Now you can compile the project using `west build -b tmo_dev_edge` in `minimal` directory. 55 | 56 | > **__NOTE:__** 57 | > For proper support of the cellular connection, you may need to set the right value of CONFIG_MODEM_MURATA_1SC_APN in `tmo_dev_edge.conf` file beforehand. 58 | 59 | 60 | > **__NOTE:__** 61 | > To switch back to mainstream zephyr version, change manifest file to `west.yml` and do `west update`. 62 | > ``` 63 | > west config manifest.file west.yml 64 | > west update 65 | > ``` 66 | > [More about managing west workspace through manifests can be found here.](https://docs.zephyrproject.org/latest/guides/west/manifest.html) 67 | 68 | ## Flashing the target 69 | 70 | After successful build you can flash the target using: 71 | 72 | ```shell 73 | west flash 74 | ``` 75 | 76 | For the Thingy:91 target, if you don't have an external programmer board, you can also enter the MCUboot recovery mode by turning the Thingy:91 on while holding the main button (SW3), and use [mcumgr](https://github.com/apache/mynewt-mcumgr-cli): 77 | 78 | ```shell 79 | mcumgr --conntype serial --connstring dev=/dev/ttyACM0 image upload build/zephyr/app_update.bin 80 | mcumgr --conntype serial --connstring dev=/dev/ttyACM0 reset 81 | ``` 82 | 83 | ### Flashing Arduino Nano 33 BLE Sense 84 | 85 | Arduino boards are shipped with an onboard bootloader that requires Arduino variant of bossac tool. 86 | There are two ways to obtain it, as described in `Programming and Debugging` section of 87 | [Arduino Nano 33 BLE in Zephyr documentation](https://docs.zephyrproject.org/latest/boards/arm/arduino_nano_33_ble/doc/index.html). 88 | According to the above, once you have a path to bossac, you are ready to flash the board. 89 | 90 | Attach the board to your computer using the USB cable. Then, to get onboard bootloader ready to flash the program, 91 | double-tap the RESET button. There should be a pulsing orange LED near the USB port. 92 | In directory `anjay-zephyr-client/demo/` run command to flash a board: 93 | ```bash 94 | west flash --bossac="" 95 | ``` 96 | For example 97 | ```bash 98 | west flash --bossac=$HOME/.arduino15/packages/arduino/tools/bossac/1.9.1-arduino2/bossac 99 | ``` 100 | 101 | ## qemu_x86 networking setup 102 | 103 | To enable networking when running qemu_x86 target and be able to connect to the internet, 104 | there is an [official guide on networking with the host system](https://docs.zephyrproject.org/latest/connectivity/networking/networking_with_host.html). Below is a shorter version on how to run the example. 105 | 106 | First download [Zephyr `net-tools` project](https://github.com/zephyrproject-rtos/net-tools) 107 | and run `net-setup.sh`, this will create `zeth` interface that will be used for networking by qemu. 108 | ``` 109 | git clone https://github.com/zephyrproject-rtos/net-tools 110 | cd net-tools 111 | sudo ./net-setup.sh 112 | ``` 113 | While the script is running, `zeth` interface is available. Open up a second terminal window and set up ip forwarding 114 | to allow connection to the internet, as `[internet_interface]` use your current interface that has access to internet. 115 | 116 | There is a helper script `anjay_qemu_net.sh` that accepts interface name as an argument and calls commands below. 117 | For example if network connection is on interface `wlan0` it can be called like this `sudo ./anjay_qemu_net.sh wlan0` 118 | ``` 119 | sysctl -w net.ipv4.ip_forward=1 120 | iptables -A FORWARD -i zeth -o [internet_interface] -j ACCEPT 121 | iptables -A FORWARD -i [internet_interface] -o zeth -m state --state ESTABLISHED,RELATED -j ACCEPT 122 | iptables -t nat -A POSTROUTING -o [internet_interface] -j MASQUERADE 123 | ``` 124 | 125 | After that, `qemu_x86` target can be run, and will successfully register to outside lwm2m servers. 126 | ``` 127 | west build -t run 128 | ``` 129 | 130 | ## Connecting to the LwM2M Server 131 | 132 | To connect to [Coiote IoT Device 133 | Management](https://www.avsystem.com/products/coiote-iot-device-management-platform/) 134 | LwM2M Server, please register at https://eu.iot.avsystem.cloud/. Then have 135 | a look at the Configuration menu using `west build -t guiconfig` or `west build -t menuconfig` to configure security credentials and other 136 | necessary settings (like Wi-Fi SSID etc.). 137 | 138 | [Guide showing basic usage of Coiote DM](https://iotdevzone.avsystem.com/docs/IoT_quick_start/Device_onboarding/) 139 | is available on IoT Developer Zone. 140 | 141 | NOTE: You may use any LwM2M Server compliant with LwM2M 1.0 TS. The server URI 142 | can be changed in the Configuration menu. 143 | 144 | ## Connecting to the LwM2M Server with OpenThread 145 | 146 | To use this project on the nRF52840dk board or Arduino Nano 33 BLE Sense in addition to the configuration shown in the previous paragraph, you will need to configure the OpenThread Border Router and Commissioner as described in the guides from the links below. 147 | You can change default `CONFIG_OPENTHREAD_JOINER_PSKD` value in the `boards/nrf52840dk_nrf52840.conf` for nRF or in `boards/arduino_nano_33_ble_sense.conf` for Arduino. In same file, replace `CONFIG_OPENTHREAD_MTD=y` with `CONFIG_OPENTHREAD_FTD=y` if you want your device to run as an FTD. 148 | 149 | Resources: 150 | - [Introduction to OpenThread](https://openthread.io/guides) 151 | - [Border Router guide](https://openthread.io/guides/border-router) 152 | - [Commissioner guide](https://openthread.io/guides/commissioner) 153 | -------------------------------------------------------------------------------- /minimal/anjay_qemu_net.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | sysctl -w net.ipv4.ip_forward=1 4 | iptables -A FORWARD -i zeth -o ${@:1} -j ACCEPT 5 | iptables -A FORWARD -i ${@:1} -o zeth -m state --state ESTABLISHED,RELATED -j ACCEPT 6 | iptables -t nat -A POSTROUTING -o ${@:1} -j MASQUERADE 7 | -------------------------------------------------------------------------------- /minimal/boards/arduino_nano_33_ble_sense.conf: -------------------------------------------------------------------------------- 1 | # Anjay Settings 2 | CONFIG_ANJAY_COMPAT_TIME=y 3 | CONFIG_ANJAY_COMPAT_MBEDTLS=y 4 | 5 | # General Settings 6 | CONFIG_MAIN_STACK_SIZE=2048 7 | CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048 8 | 9 | # Logging 10 | CONFIG_LOG_BLOCK_IN_THREAD=y 11 | CONFIG_LOG_MODE_DEFERRED=y 12 | 13 | # Clock synchronization 14 | CONFIG_DATE_TIME=y 15 | CONFIG_DATE_TIME_AUTO_UPDATE=n 16 | 17 | # Networking 18 | CONFIG_NET_IPV4=n 19 | CONFIG_NET_TCP=n 20 | CONFIG_NET_IPV6=y 21 | CONFIG_NET_IPV6_NBR_CACHE=n 22 | CONFIG_NET_IPV6_MLD=n 23 | CONFIG_NET_CONFIG_NEED_IPV4=n 24 | CONFIG_NET_L2_OPENTHREAD=y 25 | 26 | # DNS 27 | CONFIG_DNS_RESOLVER=y 28 | CONFIG_DNS_SERVER_IP_ADDRESSES=y 29 | CONFIG_DNS_SERVER1="fdaa:bb:1::2" 30 | 31 | # OpenThread 32 | CONFIG_OPENTHREAD_JOINER=y 33 | CONFIG_OPENTHREAD_JOINER_AUTOSTART=y 34 | CONFIG_OPENTHREAD_MANUAL_START=n 35 | CONFIG_OPENTHREAD_SLAAC=y 36 | CONFIG_OPENTHREAD_JOINER_PSKD="J01NME" 37 | CONFIG_OPENTHREAD_MTD=y 38 | 39 | # MbedTLS and security 40 | CONFIG_MBEDTLS_LEGACY_CRYPTO_C=y 41 | CONFIG_MBEDTLS_CTR_DRBG_C=y 42 | CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED=y 43 | -------------------------------------------------------------------------------- /minimal/boards/disco_l475_iot1.conf: -------------------------------------------------------------------------------- 1 | # Anjay Settings 2 | CONFIG_ANJAY_COMPAT_MBEDTLS=y 3 | 4 | # General settings 5 | CONFIG_MAIN_STACK_SIZE=16384 6 | CONFIG_POSIX_API=y 7 | 8 | # Networking 9 | CONFIG_WIFI=y 10 | CONFIG_WIFI_LOG_LEVEL_ERR=y 11 | CONFIG_NET_L2_WIFI_MGMT=y 12 | CONFIG_NET_L2_WIFI_MGMT_LOG_LEVEL_ERR=y 13 | 14 | # Logging 15 | CONFIG_LOG_BLOCK_IN_THREAD=y 16 | CONFIG_LOG_MODE_DEFERRED=y 17 | 18 | # MbedTLS and security 19 | CONFIG_MBEDTLS_CIPHER_CCM_ENABLED=y 20 | 21 | # Clock synchronization 22 | CONFIG_SNTP=y 23 | -------------------------------------------------------------------------------- /minimal/boards/esp32_devkitc_wroom.conf: -------------------------------------------------------------------------------- 1 | # anjay-zephyr-client 2 | CONFIG_ANJAY_ZEPHYR_DEVICE_MANUFACTURER="Espressif" 3 | CONFIG_ANJAY_ZEPHYR_MODEL_NUMBER="ESP32-DevKitC" 4 | 5 | # Networking 6 | CONFIG_ANJAY_COMPAT_NET=y 7 | 8 | CONFIG_NETWORKING=y 9 | CONFIG_POSIX_API=y 10 | CONFIG_NET_L2_WIFI_MGMT=y 11 | CONFIG_NET_LOG=y 12 | CONFIG_DNS_RESOLVER=y 13 | 14 | # MbedTLS and security 15 | CONFIG_ANJAY_COMPAT_MBEDTLS=y 16 | CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED=y 17 | CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y 18 | 19 | # Clock synchronization 20 | CONFIG_SNTP=y 21 | 22 | # ESP32 Wi-Fi 23 | CONFIG_WIFI=y 24 | CONFIG_WIFI_ESP32=y 25 | CONFIG_HEAP_MEM_POOL_SIZE=98304 26 | CONFIG_NET_L2_ETHERNET=y 27 | CONFIG_NET_DEFAULT_IF_FIRST=y 28 | 29 | CONFIG_NET_IPV6=n 30 | CONFIG_NET_IPV4=y 31 | CONFIG_NET_DHCPV4=y 32 | 33 | # ESP32 memory optimization 34 | CONFIG_ESP32_WIFI_IRAM_OPT=n 35 | CONFIG_ESP32_WIFI_RX_IRAM_OPT=n 36 | -------------------------------------------------------------------------------- /minimal/boards/esp32_devkitc_wroom.overlay: -------------------------------------------------------------------------------- 1 | &wifi { 2 | status = "okay"; 3 | }; 4 | -------------------------------------------------------------------------------- /minimal/boards/nrf52840dk_nrf52840.conf: -------------------------------------------------------------------------------- 1 | # Anjay Settings 2 | CONFIG_ANJAY_COMPAT_TIME=y 3 | CONFIG_ANJAY_COMPAT_MBEDTLS=y 4 | 5 | # General Settings 6 | CONFIG_MAIN_STACK_SIZE=8192 7 | CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048 8 | 9 | # Logging 10 | CONFIG_LOG_BLOCK_IN_THREAD=y 11 | CONFIG_LOG_MODE_DEFERRED=y 12 | 13 | # Clock synchronization 14 | CONFIG_DATE_TIME=y 15 | CONFIG_DATE_TIME_AUTO_UPDATE=n 16 | 17 | # Networking 18 | CONFIG_NET_IPV4=n 19 | CONFIG_NET_TCP=n 20 | CONFIG_NET_IPV6=y 21 | CONFIG_NET_IPV6_NBR_CACHE=n 22 | CONFIG_NET_IPV6_MLD=n 23 | CONFIG_NET_CONFIG_NEED_IPV4=n 24 | CONFIG_NET_L2_OPENTHREAD=y 25 | 26 | # DNS 27 | CONFIG_DNS_RESOLVER=y 28 | CONFIG_DNS_SERVER_IP_ADDRESSES=y 29 | CONFIG_DNS_SERVER1="fdaa:bb:1::2" 30 | 31 | # OpenThread 32 | CONFIG_OPENTHREAD_JOINER=y 33 | CONFIG_OPENTHREAD_JOINER_AUTOSTART=y 34 | CONFIG_OPENTHREAD_MANUAL_START=n 35 | CONFIG_OPENTHREAD_SLAAC=y 36 | CONFIG_OPENTHREAD_JOINER_PSKD="J01NME" 37 | CONFIG_OPENTHREAD_MTD=y 38 | 39 | # MbedTLS and security 40 | CONFIG_MBEDTLS_LEGACY_CRYPTO_C=y 41 | CONFIG_MBEDTLS_CTR_DRBG_C=y 42 | CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED=y 43 | -------------------------------------------------------------------------------- /minimal/boards/nrf7002dk_nrf5340_cpuapp_ns.conf: -------------------------------------------------------------------------------- 1 | # anjay-zephyr-client 2 | CONFIG_ANJAY_ZEPHYR_DEVICE_MANUFACTURER="Nordic Semiconductor" 3 | CONFIG_ANJAY_ZEPHYR_MODEL_NUMBER="nRF7002DK" 4 | 5 | # Anjay Settings 6 | CONFIG_ANJAY_COMPAT_MBEDTLS=y 7 | CONFIG_ANJAY_COMPAT_NET=y 8 | CONFIG_ANJAY_LOG_LEVEL_INF=y 9 | CONFIG_ANJAY_WITH_NET_STATS=n 10 | CONFIG_ANJAY_WITH_SENML_JSON=y 11 | CONFIG_ANJAY_WITH_TRACE_LOGS=n 12 | CONFIG_ANJAY_WITH_ACCESS_CONTROL=n 13 | 14 | # General Settings 15 | CONFIG_MAIN_STACK_SIZE=2048 16 | CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096 17 | CONFIG_LOG_MAX_LEVEL=3 18 | CONFIG_POSIX_MAX_FDS=16 19 | 20 | # Networking 21 | CONFIG_NET_NATIVE=y 22 | CONFIG_NET_DHCPV4=y 23 | CONFIG_DNS_RESOLVER=y 24 | CONFIG_NET_IPV6=n 25 | 26 | # WiFi 27 | CONFIG_WIFI=y 28 | CONFIG_WIFI_NRF700X=y 29 | CONFIG_WPA_SUPP=y 30 | CONFIG_WPA_SUPP_CRYPTO_PSA=y 31 | CONFIG_PSA_WANT_ALG_HMAC=y 32 | CONFIG_NET_L2_WIFI_MGMT=y 33 | CONFIG_NET_L2_WIFI_MGMT_LOG_LEVEL_ERR=y 34 | CONFIG_NET_L2_ETHERNET=y 35 | 36 | # Clock synchronization 37 | CONFIG_DATE_TIME=y 38 | CONFIG_DATE_TIME_UPDATE_INTERVAL_SECONDS=600 39 | CONFIG_DATE_TIME_TOO_OLD_SECONDS=600 40 | CONFIG_DATE_TIME_NTP_QUERY_TIME_SECONDS=5 41 | 42 | # File system 43 | CONFIG_FLASH_PAGE_LAYOUT=y 44 | CONFIG_MPU_ALLOW_FLASH_WRITE=y 45 | 46 | # Heap 47 | CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=150000 48 | CONFIG_HEAP_MEM_POOL_SIZE=150000 49 | -------------------------------------------------------------------------------- /minimal/boards/nrf9160dk_nrf9160_ns.conf: -------------------------------------------------------------------------------- 1 | # Anjay Settings 2 | CONFIG_ANJAY_COMPAT_TIME=y 3 | CONFIG_ANJAY_COMPAT_ZEPHYR_TLS=y 4 | 5 | # General Settings 6 | CONFIG_MAIN_STACK_SIZE=8192 7 | CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096 8 | 9 | # Networking 10 | CONFIG_NET_IF_MAX_IPV4_COUNT=2 11 | CONFIG_NET_TCP_ISN_RFC6528=n 12 | 13 | # nRF LTE 14 | CONFIG_NRF_MODEM_LIB=y 15 | CONFIG_MODEM_INFO=y 16 | CONFIG_LTE_LINK_CONTROL=y 17 | CONFIG_LTE_NETWORK_MODE_LTE_M=y 18 | CONFIG_LTE_NETWORK_TIMEOUT=600 19 | 20 | # Logging 21 | CONFIG_LOG_BLOCK_IN_THREAD=y 22 | CONFIG_LOG_MODE_DEFERRED=y 23 | 24 | # Clock synchronization 25 | CONFIG_DATE_TIME=y 26 | CONFIG_DATE_TIME_UPDATE_INTERVAL_SECONDS=600 27 | CONFIG_DATE_TIME_TOO_OLD_SECONDS=600 28 | CONFIG_DATE_TIME_NTP_QUERY_TIME_SECONDS=5 29 | 30 | # File system 31 | CONFIG_FLASH_PAGE_LAYOUT=y 32 | CONFIG_MPU_ALLOW_FLASH_WRITE=y 33 | 34 | # Heap 35 | CONFIG_HEAP_MEM_POOL_SIZE=2048 36 | -------------------------------------------------------------------------------- /minimal/boards/qemu_x86.conf: -------------------------------------------------------------------------------- 1 | # Anjay Settings 2 | CONFIG_ANJAY_COMPAT_MBEDTLS=y 3 | 4 | # Kernel options 5 | CONFIG_MAIN_STACK_SIZE=8192 6 | CONFIG_POSIX_API=y 7 | CONFIG_ENTROPY_GENERATOR=y 8 | CONFIG_TEST_RANDOM_GENERATOR=y 9 | CONFIG_LOG_MODE_IMMEDIATE=y 10 | 11 | # Network application options and configuration 12 | CONFIG_NET_CONFIG_SETTINGS=y 13 | CONFIG_NET_CONFIG_NEED_IPV4=y 14 | CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.0.2.1" 15 | CONFIG_NET_CONFIG_MY_IPV4_GW="192.0.2.2" 16 | CONFIG_NET_CONFIG_MY_IPV4_NETMASK="255.255.0.0" 17 | CONFIG_NET_CONFIG_PEER_IPV4_ADDR="192.0.2.2" 18 | CONFIG_PCIE=y 19 | CONFIG_ETH_E1000=y 20 | CONFIG_DNS_RESOLVER=y 21 | CONFIG_DNS_SERVER_IP_ADDRESSES=y 22 | CONFIG_DNS_SERVER1="8.8.8.8" 23 | CONFIG_NET_MAX_CONTEXTS=10 24 | CONFIG_NET_L2_ETHERNET=y 25 | CONFIG_NET_QEMU_ETHERNET=y 26 | 27 | # Network buffers 28 | CONFIG_NET_PKT_RX_COUNT=16 29 | CONFIG_NET_PKT_TX_COUNT=16 30 | CONFIG_NET_BUF_RX_COUNT=64 31 | CONFIG_NET_BUF_TX_COUNT=64 32 | CONFIG_NET_CONTEXT_NET_PKT_POOL=y 33 | 34 | # MbedTLS and security 35 | CONFIG_MBEDTLS_CIPHER_CCM_ENABLED=y 36 | -------------------------------------------------------------------------------- /minimal/boards/thingy91_nrf9160_ns.conf: -------------------------------------------------------------------------------- 1 | # Anjay Settings 2 | CONFIG_ANJAY_COMPAT_TIME=y 3 | CONFIG_ANJAY_COMPAT_ZEPHYR_TLS=y 4 | 5 | # General Settings 6 | CONFIG_MAIN_STACK_SIZE=8192 7 | CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096 8 | 9 | # Networking 10 | CONFIG_NET_IF_MAX_IPV4_COUNT=2 11 | CONFIG_NET_TCP_ISN_RFC6528=n 12 | 13 | # nRF LTE 14 | CONFIG_NRF_MODEM_LIB=y 15 | CONFIG_MODEM_INFO=y 16 | CONFIG_LTE_LINK_CONTROL=y 17 | CONFIG_LTE_NETWORK_MODE_LTE_M=y 18 | CONFIG_LTE_NETWORK_TIMEOUT=600 19 | 20 | # Logging 21 | CONFIG_LOG_BLOCK_IN_THREAD=y 22 | CONFIG_LOG_MODE_DEFERRED=y 23 | 24 | # Clock synchronization 25 | CONFIG_DATE_TIME=y 26 | CONFIG_DATE_TIME_UPDATE_INTERVAL_SECONDS=600 27 | CONFIG_DATE_TIME_TOO_OLD_SECONDS=600 28 | CONFIG_DATE_TIME_NTP_QUERY_TIME_SECONDS=5 29 | 30 | # File system 31 | CONFIG_FLASH_PAGE_LAYOUT=y 32 | CONFIG_MPU_ALLOW_FLASH_WRITE=y 33 | 34 | # Heap 35 | CONFIG_HEAP_MEM_POOL_SIZE=2048 36 | -------------------------------------------------------------------------------- /minimal/boards/tmo_dev_edge.conf: -------------------------------------------------------------------------------- 1 | # anjay-zephyr-client 2 | CONFIG_ANJAY_ZEPHYR_DEVICE_MANUFACTURER="T-Mobile" 3 | CONFIG_ANJAY_ZEPHYR_MODEL_NUMBER="DevEdge" 4 | 5 | # Anjay Settings 6 | CONFIG_ANJAY_COMPAT_MBEDTLS=y 7 | CONFIG_ANJAY_COMPAT_NET=y 8 | CONFIG_ANJAY_COMPAT_TIME=y 9 | 10 | # MbedTLS and security 11 | CONFIG_MBEDTLS_CIPHER_CCM_ENABLED=y 12 | 13 | # Hardware Configuration 14 | CONFIG_SOC_GECKO_EMU_DCDC=y 15 | CONFIG_SOC_GECKO_EMU_DCDC_MODE_OFF=y 16 | CONFIG_CMU_HFCLK_HFXO=y 17 | 18 | # General settings 19 | CONFIG_NEWLIB_LIBC=y 20 | CONFIG_NEWLIB_LIBC_NANO=n 21 | CONFIG_MAIN_STACK_SIZE=16384 22 | 23 | # Hardware class support 24 | CONFIG_I2C=y 25 | CONFIG_LED=y 26 | CONFIG_LED_PWM=y 27 | CONFIG_PWM=y 28 | CONFIG_SENSOR=y 29 | CONFIG_SPI=y 30 | CONFIG_SPI_NOR=y 31 | CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096 32 | CONFIG_STREAM_FLASH_ERASE=y 33 | CONFIG_WIFI=y 34 | 35 | # Device Drivers 36 | CONFIG_PWM_GECKO=y 37 | CONFIG_LIS2DW12=y 38 | CONFIG_LPS22HH=y 39 | CONFIG_TMP108=y 40 | CONFIG_TSL2540=y 41 | CONFIG_COUNTER=y 42 | CONFIG_WIFI_RS9116W=y 43 | 44 | CONFIG_MODEM=y 45 | CONFIG_MODEM_SHELL=y 46 | CONFIG_MODEM_MURATA_1SC=y 47 | CONFIG_MODEM_MURATA_1SC_APN="iot.t-mobile.com" 48 | 49 | # OS Support library 50 | CONFIG_REBOOT=y 51 | CONFIG_POSIX_CLOCK=y 52 | 53 | # Logging 54 | CONFIG_LOG_MODE_DEFERRED=y 55 | CONFIG_LOG_BLOCK_IN_THREAD=y 56 | 57 | # Networking 58 | CONFIG_NET_L2_WIFI_MGMT=y 59 | 60 | # Offload TCP/IP stack to a co-processor 61 | CONFIG_RS9116W_TLS_OFFLOAD=y 62 | CONFIG_NET_NATIVE=n 63 | CONFIG_NET_OFFLOAD=y 64 | CONFIG_NET_SOCKETS_OFFLOAD=y 65 | 66 | # Clock synchronization 67 | CONFIG_SNTP=y 68 | -------------------------------------------------------------------------------- /minimal/prj.conf: -------------------------------------------------------------------------------- 1 | # Anjay Settings 2 | CONFIG_ANJAY=y 3 | CONFIG_ANJAY_COMPAT_NET=y 4 | CONFIG_ANJAY_WITH_ACCESS_CONTROL=n 5 | CONFIG_ANJAY_WITH_NET_STATS=n 6 | CONFIG_ANJAY_WITH_TRACE_LOGS=n 7 | CONFIG_ANJAY_LOG_LEVEL_INF=y 8 | 9 | # Anjay Client Settings 10 | CONFIG_ANJAY_ZEPHYR_FACTORY_PROVISIONING=n 11 | 12 | # General settings 13 | CONFIG_REBOOT=y 14 | CONFIG_FPU=y 15 | CONFIG_HWINFO=y 16 | CONFIG_SNTP=y 17 | CONFIG_SHELL=y 18 | 19 | # Generic networking options 20 | CONFIG_NETWORKING=y 21 | CONFIG_NET_UDP=y 22 | CONFIG_NET_TCP=n 23 | CONFIG_NET_IPV4=y 24 | CONFIG_NET_IPV6=n 25 | CONFIG_NET_SOCKETS=y 26 | CONFIG_POSIX_MAX_FDS=6 27 | CONFIG_NET_MGMT=y 28 | CONFIG_NET_MGMT_EVENT=y 29 | CONFIG_NET_MGMT_EVENT_INFO=y 30 | 31 | # Logging 32 | CONFIG_NET_LOG=y 33 | CONFIG_LOG=y 34 | CONFIG_PRINTK=y 35 | 36 | # Storage 37 | CONFIG_FLASH=y 38 | CONFIG_FLASH_MAP=y 39 | CONFIG_NVS=y 40 | CONFIG_SETTINGS=y 41 | CONFIG_FLASH_LOG_LEVEL_ERR=y 42 | -------------------------------------------------------------------------------- /minimal/src/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 AVSystem 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | int main(void) 24 | { 25 | anjay_zephyr_lwm2m_init_from_settings(); 26 | anjay_zephyr_lwm2m_start(); 27 | 28 | // Anjay runs in a separate thread and preceding function doesn't block 29 | // add your own code here 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /minimal/west-nrf.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2020-2025 AVSystem 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Manifest for sdk-nrf based samples 16 | manifest: 17 | remotes: 18 | - name: anjay 19 | url-base: https://github.com/AVSystem 20 | - name: ncs 21 | url-base: https://github.com/nrfconnect 22 | projects: 23 | - name: sdk-nrf 24 | path: nrf 25 | remote: ncs 26 | revision: v2.7.0 27 | import: true 28 | - name: Anjay-zephyr 29 | submodules: true 30 | remote: anjay 31 | revision: 3.10.0 32 | path: modules/lib/anjay 33 | -------------------------------------------------------------------------------- /minimal/west-t-mobile.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2020-2025 AVSystem 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Manifest for zephyr based samples 16 | manifest: 17 | remotes: 18 | - name: anjay 19 | url-base: https://github.com/AVSystem 20 | - name: t-mobile 21 | url-base: https://github.com/tmobile 22 | projects: 23 | - name: DevEdge-IoTDevKit-ZephyrRTOS 24 | path: zephyr 25 | remote: t-mobile 26 | revision: tmz-1.19.2-qa 27 | import: true 28 | - name: Anjay-zephyr 29 | submodules: true 30 | remote: anjay 31 | revision: 3.10.0 32 | path: modules/lib/anjay 33 | - name: DevEdge-IoTDevKit-ZephyrSDK 34 | path: modules/lib/t-mobile-sdk 35 | remote: t-mobile 36 | revision: tmz-sdk-1.19.2-qa 37 | -------------------------------------------------------------------------------- /minimal/west.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2020-2025 AVSystem 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Manifest for zephyr based samples 16 | manifest: 17 | remotes: 18 | - name: anjay 19 | url-base: https://github.com/AVSystem 20 | - name: zephyrproject-rtos 21 | url-base: https://github.com/zephyrproject-rtos 22 | projects: 23 | - name: zephyr 24 | path: zephyr 25 | remote: zephyrproject-rtos 26 | revision: v3.6.0 27 | import: true 28 | - name: Anjay-zephyr 29 | submodules: true 30 | remote: anjay 31 | revision: 3.10.0 32 | path: modules/lib/anjay 33 | -------------------------------------------------------------------------------- /tools/build_release_binaries.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | SCRIPT_DIR="$(dirname "$(readlink -f "$BASH_SOURCE")")" 6 | REPO_ROOT="$(dirname $SCRIPT_DIR)" 7 | DEMO_DIRECTORY="$REPO_ROOT/demo" 8 | BINARIES_PATH="$REPO_ROOT/release-binaries" 9 | PLATFORMS="tnrfl" 10 | 11 | print_help() { 12 | cat <&2 13 | NAME 14 | $0 - Prepare T-Mobile binaries for release. 15 | 16 | SYNOPSIS 17 | $0 [ OPTIONS... ] 18 | 19 | OPTIONS 20 | -v, --client-version CLIENT_VERSION 21 | - anjay-zephyr-client version. 22 | -a, --anjay-version ANJAY_VERSION 23 | - Anjay version. 24 | -c, --clean 25 | - clean the whole repository before building binaries. 26 | -z, --zephyrproject ZEPHYRPROJECT_PATH 27 | - absolute path to the zephyrproject/ directory. 28 | -p --platforms 29 | - platforms to build: (t)hingy91, (n)rf9160dk, n(r)f7002dk, nr(f)9151dk, 30 | (l)475. 31 | default: all 32 | -h, --help 33 | - print this message and exit. 34 | EOF 35 | } 36 | 37 | while [[ $# > 0 ]]; do 38 | case "$1" in 39 | -v|--version) CLIENT_VERSION="$2"; shift ;; 40 | -a|--anjay-version) ANJAY_VERSION="$2"; shift ;; 41 | -z|--zephyrproject) ZEPHYRPROJECT_PATH="$2"; shift ;; 42 | -p|--platforms) PLATFORMS="$2"; shift ;; 43 | -c|--clean) CLEAN_REPO=1 ;; 44 | -h|--help) 45 | print_help 46 | exit 0 47 | ;; 48 | *) 49 | echo "unrecognized option: $1; use -h or --help for help" 50 | exit 1 51 | ;; 52 | esac 53 | 54 | shift 55 | done 56 | 57 | set_west_manifest_path() { 58 | local WEST_PATH="$1" 59 | west config manifest.path $WEST_PATH 60 | } 61 | 62 | set_west_manifest_file() { 63 | local WEST_FILE="$1" 64 | west config manifest.file $WEST_FILE 65 | } 66 | 67 | update_west() { 68 | west update -n -o=--depth=1 || west update -n -o=--depth=1 69 | } 70 | 71 | set_anjay_version() { 72 | sed -i -e "s/25.05/$ANJAY_VERSION/g" $ANJAY_ZEPHYR_ROOT/deps/anjay/src/core/anjay_core.c 73 | } 74 | 75 | if [[ -z "$CLIENT_VERSION" || -z "$ANJAY_VERSION" || -z "$ZEPHYRPROJECT_PATH" ]]; then 76 | echo -e "\e[91mAnjay version, client version or zephyrproject/ path not specified.\e[0m" 77 | echo "Use $0 --help for more info." 78 | exit 1 79 | fi 80 | 81 | ANJAY_ZEPHYR_ROOT="$ZEPHYRPROJECT_PATH/modules/lib/anjay-internal" 82 | 83 | if [ -n "$CLEAN_REPO" ]; then 84 | git clean -ffdx && \ 85 | git submodule foreach --recursive git clean -ffdx && \ 86 | git submodule update --init --recursive && \ 87 | git submodule foreach --recursive git reset --hard && \ 88 | git checkout -- . 89 | fi 90 | 91 | MCUBOOT_VERSION="$("$SCRIPT_DIR/generate_mcuboot_version.py" "$CLIENT_VERSION")" 92 | sed -i -e "s/^# DEPLOY: CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION\$/CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION=\"$MCUBOOT_VERSION\"/" */boards/*.conf 93 | sed -i -e "s/^# DEPLOY: CONFIG_MCUBOOT_EXTRA_IMGTOOL_ARGS\$/CONFIG_MCUBOOT_EXTRA_IMGTOOL_ARGS=\"--version $MCUBOOT_VERSION\"/" */boards/*.conf 94 | 95 | mkdir -p "$BINARIES_PATH" 96 | 97 | # nRF9160DK #################################################################### 98 | if [[ "$PLATFORMS" == *n* ]]; then 99 | mkdir -p "$BINARIES_PATH/nRF9160DK" 100 | set_west_manifest_path $DEMO_DIRECTORY 101 | set_west_manifest_file "west-nrf.yml" 102 | update_west 103 | set_anjay_version 104 | 105 | pushd $DEMO_DIRECTORY 106 | west build -b nrf9160dk/nrf9160/ns -p -- \ 107 | -DCONFIG_ANJAY_ZEPHYR_VERSION="\"$CLIENT_VERSION.0\"" 108 | cp build/zephyr/merged.hex "$BINARIES_PATH/nRF9160DK/demo_nrf9160dk_merged.hex" 109 | popd 110 | fi 111 | 112 | # nRF7002DK #################################################################### 113 | if [[ "$PLATFORMS" == *r* ]]; then 114 | mkdir -p "$BINARIES_PATH/nRF7002DK" 115 | set_west_manifest_path $DEMO_DIRECTORY 116 | set_west_manifest_file "west-nrf.yml" 117 | update_west 118 | set_anjay_version 119 | 120 | pushd $DEMO_DIRECTORY 121 | west build -b nrf7002dk/nrf5340/cpuapp/ns -p -- \ 122 | -DCONFIG_ANJAY_ZEPHYR_VERSION="\"$CLIENT_VERSION.0\"" 123 | cp build/zephyr/merged.hex "$BINARIES_PATH/nRF7002DK/demo_nrf7002dk.hex" 124 | popd 125 | fi 126 | 127 | 128 | # Thingy:91 #################################################################### 129 | if [[ "$PLATFORMS" == *t* ]]; then 130 | mkdir -p "$BINARIES_PATH/Thingy91" 131 | set_west_manifest_path $DEMO_DIRECTORY 132 | set_west_manifest_file "west-nrf.yml" 133 | update_west 134 | set_anjay_version 135 | 136 | pushd $DEMO_DIRECTORY 137 | west build -b thingy91/nrf9160/ns -p -- \ 138 | -DCONFIG_ANJAY_ZEPHYR_VERSION="\"$CLIENT_VERSION.0\"" 139 | cp build/zephyr/merged.hex "$BINARIES_PATH/Thingy91/demo_thingy91_app_signed.hex" 140 | popd 141 | fi 142 | 143 | # nRF9151DK #################################################################### 144 | if [[ "$PLATFORMS" == *n* ]]; then 145 | mkdir -p "$BINARIES_PATH/nRF9151DK" 146 | set_west_manifest_path $DEMO_DIRECTORY 147 | set_west_manifest_file "west-nrf.yml" 148 | update_west 149 | set_anjay_version 150 | 151 | pushd $DEMO_DIRECTORY 152 | west build -b nrf9151dk/nrf9151/ns -p -- \ 153 | -DCONFIG_ANJAY_ZEPHYR_VERSION="\"$CLIENT_VERSION.0\"" 154 | cp build/zephyr/merged.hex "$BINARIES_PATH/nRF9151DK/demo_nrf9151dk_merged.hex" 155 | popd 156 | fi 157 | 158 | # L475 ######################################################################### 159 | if [[ "$PLATFORMS" == *l* ]]; then 160 | mkdir -p "$BINARIES_PATH/B-L475-IOT01A" 161 | set_west_manifest_path $DEMO_DIRECTORY 162 | set_west_manifest_file "west.yml" 163 | update_west 164 | set_anjay_version 165 | 166 | pushd $DEMO_DIRECTORY 167 | west build -b disco_l475_iot1 --sysbuild -p -- \ 168 | -DCONFIG_ANJAY_ZEPHYR_VERSION="\"$CLIENT_VERSION.0\"" 169 | cp build/demo/zephyr/zephyr.signed.bin "$BINARIES_PATH/B-L475-IOT01A/demo_B-L475E-IOT01A1_merged.bin" 170 | cp build/zephyr/merged.hex "$BINARIES_PATH/B-L475-IOT01A/demo_B-L475E-IOT01A1_merged.hex" 171 | popd 172 | fi 173 | -------------------------------------------------------------------------------- /tools/provisioning-tool/configs/cert_info.json: -------------------------------------------------------------------------------- 1 | { 2 | "countryName": "PL", 3 | "stateOrProvinceName": "Malopolska", 4 | "localityName": "Cracow", 5 | "organizationName": "AVSystem", 6 | "organizationUnitName": "Embedded", 7 | "serialNumber": 1, 8 | "validityOffsetInSeconds": 220752000 9 | } 10 | -------------------------------------------------------------------------------- /tools/provisioning-tool/configs/endpoint_cfg: -------------------------------------------------------------------------------- 1 | { 2 | OID.Security: { 3 | 1: { 4 | RID.Security.ServerURI : 'coaps://eu.iot.avsystem.cloud:5684', 5 | RID.Security.Bootstrap : False, 6 | RID.Security.Mode : 0, # 0: PSK, 2: Cert, 3: NoSec 7 | RID.Security.PKOrIdentity : b'reg-test-psk-identity', 8 | RID.Security.SecretKey : b'3x@mpl3P5K53cr3tK3y', 9 | RID.Security.ShortServerID : 1 10 | }, 11 | }, 12 | 13 | OID.Server: { 14 | 1: { 15 | RID.Server.ShortServerID : 1, 16 | RID.Server.Lifetime : 86400, 17 | RID.Server.NotificationStoring : False, 18 | RID.Server.Binding : 'U' 19 | }, 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tools/provisioning-tool/configs/endpoint_cfg_cert: -------------------------------------------------------------------------------- 1 | { 2 | OID.Security: { 3 | 1: { 4 | RID.Security.ServerURI : 'coaps://eu.iot.avsystem.cloud:5684', 5 | RID.Security.Bootstrap : False, 6 | RID.Security.Mode : 2, # 0: PSK, 2: Cert, 3: NoSec 7 | RID.Security.ShortServerID : 1 8 | }, 9 | }, 10 | 11 | OID.Server: { 12 | 1: { 13 | RID.Server.ShortServerID : 1, 14 | RID.Server.Lifetime : 86400, 15 | RID.Server.NotificationStoring : False, 16 | RID.Server.Binding : 'U' 17 | }, 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tools/provisioning-tool/configs/lwm2m_server.json: -------------------------------------------------------------------------------- 1 | { 2 | "url": "https://eu.iot.avsystem.cloud", 3 | "port": 8087, 4 | "domain": "/main//" 5 | } 6 | -------------------------------------------------------------------------------- /tools/provisioning-tool/final_overlay.conf: -------------------------------------------------------------------------------- 1 | # Anjay settings necessary to perform the device provisioning 2 | CONFIG_ANJAY_WITH_LWM2M11=y 3 | CONFIG_ANJAY_WITH_CBOR=y 4 | CONFIG_ANJAY_ZEPHYR_PERSISTENCE=y 5 | CONFIG_ANJAY_ZEPHYR_FACTORY_PROVISIONING=y 6 | CONFIG_ANJAY_ZEPHYR_FACTORY_PROVISIONING_INITIAL_FLASH=n 7 | -------------------------------------------------------------------------------- /tools/provisioning-tool/final_overlay_nrf9160dk.conf: -------------------------------------------------------------------------------- 1 | # Anjay settings necessary to perform the device provisioning 2 | CONFIG_ANJAY_WITH_LWM2M11=y 3 | CONFIG_ANJAY_WITH_CBOR=y 4 | CONFIG_ANJAY_ZEPHYR_PERSISTENCE=y 5 | CONFIG_ANJAY_ZEPHYR_FACTORY_PROVISIONING=y 6 | CONFIG_ANJAY_ZEPHYR_FACTORY_PROVISIONING_INITIAL_FLASH=n 7 | # Due to hardware limitations these shells must be disabled for nrf9160dk 8 | CONFIG_KERNEL_SHELL=n 9 | CONFIG_CLOCK_CONTROL_NRF_SHELL=n 10 | CONFIG_FLASH_SHELL=n 11 | -------------------------------------------------------------------------------- /tools/provisioning-tool/initial_overlay.conf: -------------------------------------------------------------------------------- 1 | # Anjay settings necessary to perform the device provisioning 2 | CONFIG_ANJAY_WITH_LWM2M11=y 3 | CONFIG_ANJAY_WITH_CBOR=y 4 | CONFIG_ANJAY_ZEPHYR_PERSISTENCE=y 5 | CONFIG_ANJAY_ZEPHYR_FACTORY_PROVISIONING=y 6 | CONFIG_ANJAY_ZEPHYR_FACTORY_PROVISIONING_INITIAL_FLASH=y 7 | -------------------------------------------------------------------------------- /tools/validate_fota_file_size.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # Copyright 2020-2025 AVSystem 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | import collections 17 | import os 18 | import sys 19 | 20 | # See: https://github.com/mcu-tools/mcuboot/blob/v1.10.0/scripts/imgtool/image.py#L569 21 | # This is calculated from default values for Image._trailer_size() 22 | # (write_size=4, max_sectors=128, max_align=8) 23 | # write_size and max_align may change if CONFIG_MCUBOOT_FLASH_WRITE_BLOCK_SIZE, 24 | # but it looks that nobody does that ;) 25 | MCUBOOT_TRAILER_SIZE = 1584 26 | 27 | 28 | def _split_path_into_components(path): 29 | result = [] 30 | while True: 31 | head, tail = os.path.split(path) 32 | if tail != '' or head != path: 33 | result.insert(0, tail) 34 | path = head 35 | else: 36 | result.insert(0, head) 37 | return result 38 | 39 | 40 | PartitionParams = collections.namedtuple('PartitionParams', ['size', 'sector_size']) 41 | 42 | 43 | def get_partition_params(dts_filename): 44 | from devicetree import dtlib 45 | dt = dtlib.DT(dts_filename) 46 | part = dt.label2node['slot0_partition'] 47 | size = part.props['reg'].to_nums()[1] 48 | sector_size = part.parent.parent.props['erase-block-size'].to_num() 49 | 50 | # nCS Partition Manager defines the partitions differently 51 | try: 52 | import yaml 53 | with open(os.path.join(os.path.dirname(os.path.dirname(dts_filename)), 'partitions.yml'), 54 | 'r') as f: 55 | partitions = yaml.load(f, yaml.SafeLoader) 56 | size = partitions['mcuboot_primary']['size'] 57 | except FileNotFoundError: 58 | pass 59 | 60 | return PartitionParams(size=size, sector_size=sector_size) 61 | 62 | 63 | def main(argv): 64 | assert len(argv) > 0 65 | if len(argv) != 2: 66 | sys.stderr.write(f'Usage: {argv[0]} FOTA_BINARY_FILE\n') 67 | return -1 68 | 69 | fota_binary_file = os.path.realpath(argv[1]) 70 | fota_binary_file_path = _split_path_into_components(fota_binary_file) 71 | 72 | if len(fota_binary_file_path) < 2 or fota_binary_file_path[-2] != 'zephyr': 73 | sys.stderr.write(f'The binary file is not in a Zephyr build tree\n') 74 | return -1 75 | 76 | zephyr_build_tree = os.path.join(*fota_binary_file_path[:-2]) 77 | 78 | with open(os.path.join(zephyr_build_tree, 'mcuboot', 'zephyr', '.config'), 'r') as f: 79 | lines = [line for line in f.readlines() if 'CONFIG_BOOT_SWAP_USING_MOVE' in line] 80 | mcuboot_uses_move = ( 81 | len(lines) == 1 and lines[0].strip() == 'CONFIG_BOOT_SWAP_USING_MOVE=y') 82 | 83 | if not mcuboot_uses_move: 84 | # Only the move algorithm requires free space; return success otherwise 85 | return 0 86 | 87 | # Find ZEPHYR_BASE 88 | with open(os.path.join(zephyr_build_tree, 'CMakeCache.txt'), 'r') as f: 89 | lines = [line for line in f.readlines() if line.startswith('ZEPHYR_BASE')] 90 | if len(lines) != 1: 91 | sys.stderr.write(f'Could not determine ZEPHYR_BASE') 92 | return -1 93 | zephyr_base = lines[0].strip().split('=', 1)[1] 94 | 95 | sys.path.append(os.path.join(zephyr_base, 'scripts', 'dts', 'python-devicetree', 'src')) 96 | params = get_partition_params(os.path.join(zephyr_build_tree, 'zephyr', 'zephyr.dts')) 97 | 98 | # At least one empty sector and space for the trailer is required for a successful FOTA 99 | max_allowed_size = params.size - params.sector_size 100 | max_allowed_size -= params.sector_size * ( 101 | (MCUBOOT_TRAILER_SIZE - 1 + params.sector_size) // params.sector_size) 102 | 103 | fota_binary_size = os.stat(fota_binary_file).st_size 104 | if fota_binary_size > max_allowed_size: 105 | sys.stderr.write( 106 | f'{argv[1]} is {fota_binary_size} bytes, but {max_allowed_size} is the maximum size with which FOTA using the move algorithm is possible (overflow by {fota_binary_size - max_allowed_size} bytes)') 107 | return -1 108 | 109 | return 0 110 | 111 | 112 | if __name__ == '__main__': 113 | sys.exit(main(sys.argv)) 114 | --------------------------------------------------------------------------------