Skip to content

Commit

Permalink
Anjay-zephyr-client 23.09
Browse files Browse the repository at this point in the history
Features
- Added Bubblemaker app
- Added tmo_dev_edge board as a target for demo and minimal samples with the possibility to switch
  preferred network bearer and perform firmware update using the external flash
  • Loading branch information
Kucmasz committed Sep 7, 2023
1 parent a9472b5 commit d7caeec
Show file tree
Hide file tree
Showing 49 changed files with 3,399 additions and 30 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 23.09 (September 7th, 2023)

### Features
- Added Bubblemaker app
- Added tmo_dev_edge board as a target for demo and minimal samples with the possibility to switch
preferred network bearer and perform firmware update using the external flash

## 23.06 (June 23rd, 2023)

### Features
Expand All @@ -10,7 +17,7 @@
- Updated sdk-nrf to 2.3.0
- Updated Anjay-zephyr to 3.4.1
- Adjusted partition layout and MCUboot configuration on nRF9160DK builds to
support newer version of sdk-nrf
support the newer version of sdk-nrf
- Added overlay for nRF9160DK in demo application which enables experimental Advanced Firmware Update object (/33629)

### Bugfixes
Expand Down
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ The following examples are present:
<a href="https://www.nordicsemi.com/Products/Development-hardware/nrf52840-dk">nRF52840 Development kit</a><br>
<a href="https://www.nordicsemi.com/Products/Development-hardware/nRF7002-DK">nRF7002 Development kit</a><br>
<a href="https://store.arduino.cc/products/arduino-nano-33-ble-sense">Arduino Nano 33 BLE Sense Lite</a><br>
<a href="https://devedge.t-mobile.com/solutions/iotdevkit">DevEdge</a><br>
any other board of your choice (by adding appropriate <code>*.conf</code>/<code>*.overlay</code> files). FOTA support for selected boards.
</td>
</tr>
Expand All @@ -43,6 +44,7 @@ The following examples are present:
<a href="https://www.espressif.com/en/products/devkits/esp32-devkitc">ESP32-DevKitC</a><br>
<a href="https://www.nordicsemi.com/Products/Development-hardware/nrf52840-dk">nRF52840 Development kit</a><br>
<a href="https://store.arduino.cc/products/arduino-nano-33-ble-sense">Arduino Nano 33 BLE Sense Lite</a><br>
<a href="https://devedge.t-mobile.com/solutions/iotdevkit">DevEdge</a><br>
</td>
</tr>
<tr>
Expand All @@ -52,6 +54,14 @@ The following examples are present:
<a href="https://www.nordicsemi.com/Products/Development-hardware/Nordic-Thingy-91">Nordic Thingy:91 Prototyping kit</a>
</td>
</tr>
<tr>
<td>bubblemaker/</td>
<td>
An interactive example containing integration of water meters and different sensors with LwM2M protocol. Supported boards:<br>
<a href="https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF9160-DK">nRF9160 Development kit</a><br>
<a href="https://www.nordicsemi.com/Products/Development-hardware/nRF7002-DK">nRF7002 Development kit</a><br>
</td>
</tr>
</tbody>
</table>

Expand Down Expand Up @@ -137,6 +147,24 @@ multiple configurations for different targets). Choose your target and click
"Build Configuration" in order to build the application. Next builds can be
started by choosing Actions -> Build.

### Enabling GPS implementation (for nRF9160 targets)

Anjay-zephyr-client has the support for GPS implementation for nRF9160 targets
which can be enabled using `Kconfig` options. Some of the available options are:
- `CONFIG_ANJAY_ZEPHYR_GPS` - enables/disables support for GPS
- `CONFIG_ANJAY_ZEPHYR_GPS_NRF_A_GPS` - enables/disables A-GPS using Nordic
Location Services over LwM2M
- `CONFIG_ANJAY_ZEPHYR_GPS_NRF_PRIO_MODE_PERMITTED` - enables/disables support
for allowing temporary activation of the GPS priority mode
- if set, Anjay Zephyr will temporarily activate the GPS priority over LTE
idle mode **which shuts down LTE completely** and attempts to acquire the fix
in case GPS fix cannot be produced
- by default, this option is disabled and can be enabled using `Kconfig` or
shell commands (`anjay config set gps_prio_mode_permitted`)
- `CONFIG_ANJAY_ZEPHYR_GPS_NRF_PRIO_MODE_COOLDOWN` - determines (in seconds) how
much time must pass after a failed try to produce a GPS fix to enable GPS
priority mode again

## Connecting to the LwM2M Server

To connect to [Coiote IoT Device
Expand Down
110 changes: 110 additions & 0 deletions bubblemaker/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Copyright 2020-2023 AVSystem <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

cmake_minimum_required(VERSION 3.13.1)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(anjay_zephyr_demo)
set(root_dir ${ANJAY_ZEPHYR_CLIENT_DIR})

if(CONFIG_PARTITION_MANAGER_ENABLED)
# defined in nrf/cmake/partition_manager.cmake
if(NOT EXISTS "${static_configuration_file}")
set(pm_missing_message "Missing static partition manager file for board: ${BOARD}")

if(ACTIVE_BOARD_REVISION)
set(pm_missing_message "${pm_missing_message}, rev: ${ACTIVE_BOARD_REVISION}")
endif()

if(CONF_FILE_BUILD_TYPE)
set(pm_missing_message "${pm_missing_message}, build type: ${CONF_FILE_BUILD_TYPE}")
endif()

message(FATAL_ERROR "${pm_missing_message}")
endif()
elseif(CONFIG_ANJAY_CLIENT_BUILD_MCUBOOT_AUTOMATICALLY)
if("${CONFIG_MCUBOOT_SIGNATURE_KEY_FILE}" STREQUAL "")
if(NOT CONFIG_MCUBOOT_GENERATE_UNSIGNED_IMAGE)
message(FATAL_ERROR "Either MCUBOOT_SIGNATURE_KEY_FILE or MCUBOOT_GENERATE_UNSIGNED_IMAGE need to be set in Kconfig")
endif()
else()
set(MCUBOOT_SIGNATURE_KEY_FILE "${CONFIG_MCUBOOT_SIGNATURE_KEY_FILE}")
if(NOT IS_ABSOLUTE "${MCUBOOT_SIGNATURE_KEY_FILE}")
set(MCUBOOT_SIGNATURE_KEY_FILE "${WEST_TOPDIR}/${MCUBOOT_SIGNATURE_KEY_FILE}")
endif()
endif()
make_directory("${CMAKE_CURRENT_BINARY_DIR}/mcuboot")
execute_process(COMMAND "${CMAKE_COMMAND}"
-GNinja
"-DAPPLICATION_CONFIG_DIR=${CMAKE_CURRENT_SOURCE_DIR}/child_image/mcuboot"
"-DBOARD=${BOARD}"
"-DCONF_FILE=${ZEPHYR_BASE}/../bootloader/mcuboot/boot/zephyr/prj.conf"
"-DCONF_FILE_INCLUDE_FRAGMENTS=ON"
"-DCONFIG_BOOT_SIGNATURE_KEY_FILE=\"${MCUBOOT_SIGNATURE_KEY_FILE}\""
"-DDTC_OVERLAY_FILE=${CMAKE_CURRENT_SOURCE_DIR}/child_image/mcuboot/boards/${BOARD}.overlay"
"${ZEPHYR_BASE}/../bootloader/mcuboot/boot/zephyr"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/mcuboot"
RESULT_VARIABLE MCUBOOT_CMAKE_RESULT)
if(NOT MCUBOOT_CMAKE_RESULT EQUAL 0)
message(FATAL_ERROR "Configuring MCUboot failed")
endif()

add_custom_target(mcuboot COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_CURRENT_BINARY_DIR}/mcuboot")

# NOTE: This is largely copied from CMakeLists.txt in Zephyr itself.
# However, using that would require setting HEX_FILES_TO_MERGE *before*
# find_package(Zephyr), and we can't do that because we need to examine
# Kconfig variables, which are populated by find_package(Zephyr).
# That's why we do it ourselves here...
set(MERGED_HEX_NAME "${CMAKE_CURRENT_BINARY_DIR}/zephyr/merged.hex")
# In Zephyr 3.2, mergehex.py has been moved
# from scripts/mergehex.py to scripts/build/mergehex.py
set(MERGEHEX_SCRIPT "${ZEPHYR_BASE}/scripts/build/mergehex.py")
if(NOT EXISTS "${MERGEHEX_SCRIPT}")
set(MERGEHEX_SCRIPT "${ZEPHYR_BASE}/scripts/mergehex.py")
endif()
add_custom_command(OUTPUT "${MERGED_HEX_NAME}"
COMMAND "${PYTHON_EXECUTABLE}"
"${MERGEHEX_SCRIPT}"
-o "${MERGED_HEX_NAME}"
"${CMAKE_CURRENT_BINARY_DIR}/mcuboot/zephyr/zephyr.hex"
"${CMAKE_CURRENT_BINARY_DIR}/zephyr/zephyr.signed.hex"
DEPENDS mcuboot zephyr_final)
add_custom_target(mergehex ALL DEPENDS "${MERGED_HEX_NAME}")

if(TARGET runners_yaml_props_target)
get_target_property(RUNNERS_YAML_CONTENTS runners_yaml_props_target yaml_contents)
string(REGEX REPLACE "zephyr[a-zA-Z0-9._-]*[.]hex" "merged.hex" RUNNERS_YAML_CONTENTS "${RUNNERS_YAML_CONTENTS}")
set_property(TARGET runners_yaml_props_target PROPERTY yaml_contents "${RUNNERS_YAML_CONTENTS}")
endif()
endif()

set(app_sources
src/main_app.c
src/sensors.c
src/sensors.h
src/status_led.c
src/status_led.h
src/peripherals.h
src/bubblemaker.c
src/bubblemaker.h
src/led_strip.c
src/led_strip.h
src/water_meter.c
src/water_meter.h
src/water_pump.c
src/water_pump.h)

target_sources(app PRIVATE
${app_sources})
12 changes: 12 additions & 0 deletions bubblemaker/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
menu "anjay-zephyr-client-app"

config ANJAY_CLIENT_BUILD_MCUBOOT_AUTOMATICALLY
bool "Build MCUboot as part of the main build process"
depends on BOOTLOADER_MCUBOOT
depends on !PARTITION_MANAGER_ENABLED
select MCUBOOT_GENERATE_CONFIRMED_IMAGE
default y

endmenu

source "Kconfig.zephyr"
55 changes: 55 additions & 0 deletions bubblemaker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Bubblemaker [<img align="right" height="50px" src="https://avsystem.github.io/Anjay-doc/_images/avsystem_logo.png">](http://www.avsystem.com/)

## Supported hardware and overview
This folder contains support for the following targets:
- [nrf9160dk_nrf9160_ns](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/ug_nrf9160.html)
- [nrf7002dk_nrf5340_cpuapp](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/device_guides/working_with_nrf/nrf70/gs.html)

The following LwM2M Objects are supported:
- Security (/0)
- Server (/1)
- Device (/3)
- Connectivity Monitoring (/4)
- Firmware Update (/5)
- Sensors:
- Temperature (/3303) with multiple DS18B20 sensors on single 1Wire line
- Pressure (/3323)
- Acidity (/3326)
- On/Off switch (/3342)
- Push button (/3347)
- Water meter (/3424)

The Bubblemaker contains an example smart water meter demo with basic IPSO
sensor support. It is possible to use a single water meter with an electrical or
hand pump as well as two water meters with two hand pumps. When using two water
meters, two players can compete and the winner is indicated through led strip
light.

To exclude sensor in a build, it is enough to comment or delete it's name in
the `aliases` section or it's name and corresponding io-channel in the
`zephyr,user` section in the `boards/<board_name>.overlay` file. For example,
if the final configuration for `nRF9160 DK` should not contain temperature
sensor #1, water pump and pressure sensors, the
`boards/nrf9160dk_nrf9160_ns.overlay` file should look like this:
```
/ {
aliases {
push-button-0 = &button0;
push-button-1 = &button1;
switch-0 = &button2;
switch-1 = &button3;
status-led = &led0;
temperature-0 = &ds18b200;
//temperature-1 = &ds18b201;
led-strip = &led_strip;
water-meter-0 = &water_meter0;
water-meter-1 = &water_meter1;
//water-pump-0 = &water_pump0;
};
zephyr,user {
/* these settings act as aliases for ADC sensors */
io-channels = <&adc 2>, <&adc 3>;
io-channel-names = "acidity0", "acidity1";
};
/* rest of the file */
```
57 changes: 57 additions & 0 deletions bubblemaker/boards/nrf7002dk_nrf5340_cpuapp.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# anjay-zephyr-client
CONFIG_ANJAY_ZEPHYR_DEVICE_MANUFACTURER="Nordic Semiconductor"
CONFIG_ANJAY_ZEPHYR_MODEL_NUMBER="nRF7002DK"

# Anjay Settings
CONFIG_ANJAY_COMPAT_MBEDTLS=y
CONFIG_ANJAY_COMPAT_NET=y
CONFIG_ANJAY_COMPAT_TIME=y
CONFIG_ANJAY_LOG_LEVEL_INF=y
CONFIG_ANJAY_WITH_NET_STATS=n
CONFIG_ANJAY_WITH_SENML_JSON=y
CONFIG_ANJAY_WITH_TRACE_LOGS=n
CONFIG_ANJAY_WITH_ACCESS_CONTROL=n

# General Settings
CONFIG_MAIN_STACK_SIZE=2048
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
CONFIG_LOG_MAX_LEVEL=3
CONFIG_POSIX_MAX_FDS=16

# Networking
CONFIG_NET_NATIVE=y
CONFIG_NET_DHCPV4=y
CONFIG_DNS_RESOLVER=y

# WiFi
CONFIG_WIFI=y
CONFIG_WIFI_NRF700X=y
CONFIG_WPA_SUPP=y
CONFIG_NET_L2_WIFI_MGMT=y
CONFIG_NET_L2_WIFI_MGMT_LOG_LEVEL_ERR=y
CONFIG_NET_L2_ETHERNET=y

# Clock synchronization
CONFIG_DATE_TIME=y
CONFIG_DATE_TIME_UPDATE_INTERVAL_SECONDS=600
CONFIG_DATE_TIME_TOO_OLD_SECONDS=600
CONFIG_DATE_TIME_NTP_QUERY_TIME_SECONDS=5
CONFIG_DATE_TIME_THREAD_STACK_SIZE=16384

# File system
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y

# Heap
CONFIG_HEAP_MEM_POOL_SIZE=200000

# Bubblemaker
CONFIG_SENSOR=y
CONFIG_ADC=y
CONFIG_W1=y

CONFIG_LED_STRIP=y
CONFIG_WS2812_STRIP=y
CONFIG_SPI=y

CONFIG_GPIO=y
Loading

0 comments on commit d7caeec

Please sign in to comment.