Code Monkey home page Code Monkey logo

anjay-zephyr-client's Introduction

Anjay-zephyr-client

Overview

This repository contains LwM2M Client samples based on open-source Anjay Zephyr Module and Zephyr OS.

More information and step-by-step instruction can be found in the Anjay integration IoT Developer Zone.

The following examples are present:

Directory Description
demo/ Showcase example implementing all features and sensors available on board. Supports experimental factory provisioning feature of Anjay 3.0. Supported boards:
B-L475E-IOT01A Discovery kit
nRF9160 Development kit
Nordic Thingy:91 Prototyping kit
ESP32-DevKitC
nRF52840 Development kit
nRF7002 Development kit
Arduino Nano 33 BLE Sense Lite
DevEdge
any other board of your choice (by adding appropriate *.conf/*.overlay files). FOTA support for selected boards.
minimal/ Minimalistic client samples which may serve as a base for specific application. Supported boards/targets:
qemu_x86
B-L475E-IOT01A Discovery kit
nRF9160 Development kit
Nordic Thingy:91 Prototyping kit
ESP32-DevKitC
nRF52840 Development kit
Arduino Nano 33 BLE Sense Lite
DevEdge
ei_demo/ An example containing motion recognition model, built with Edge Impulse. Supported boards/targets:
Nordic Thingy:91 Prototyping kit
bubblemaker/ An interactive example containing integration of water meters and different sensors with LwM2M protocol. Supported boards:
nRF9160 Development kit
nRF7002 Development kit

Getting started

First of all, get Zephyr, SDK and other dependencies, as described in Zephyr's Getting Started Guide (first 4 steps).

After navigating to Zephyr workspace (~/zephyrproject is default after following Getting Started Guide), clone Anjay Zephyr client repository.

git clone https://github.com/AVSystem/Anjay-zephyr-client

If you want to compile for nRF9160 targets, additional GNU Arm Embedded Toolchain is necessary, to install it follow installing the toolchain for NCS guide. Also for flashing nRF Command Line Tools have to be installed.

For further instructions, check README.md in the folder with the example in which you are interested.

Setting up Visual Studio Code (for nRF9160 targets)

The nRF Connect SDK has a set of plugins for Visual Studio Code (VSC). They can be used to simplify the build process for the nRF boards. To do that we need to set up VSC first.

NOTE: On a Linux system, first make sure that GNUARMEMB_TOOLCHAIN_PATH variable is set in the scope that Visual Studio Code is run.

You can set this permanently by adding a line similar to the following (adjusted to your toolchain installation directory) to your ~/.profile file (or ~/.bash_profile or ~/.zprofile etc., depending on your shell and preferences):

export GNUARMEMB_TOOLCHAIN_PATH="$HOME/gcc-arm-none-eabi-10.3-2021.10"

Open VSC and, on the Extensions tab, install the "nRF Connect for VS Code" plugin or the "nRF Connect Extension Pack" (which includes the former). After the installation, the "Welcome to nRF Connect" window should appear. In case it doesn't, you can open it from the nRF Connect tab -> Welcome -> Open Welcome page. Set nRF Connect SDK to the folder where west initialized Zephyr (~/zephyrproject is the default suggested in the Getting Started Guide). The "nRF Connect Toolchain" setting should point to the gnuarmemb toolchain installation folder, or in case of Linux, it should be set as "PATH" (it will use the setting from GNUARMEMB_TOOLCHAIN_PATH to find it).

If the environment was not set up earlier, go to the Source Control tab, open the Terminal tab (Ctrl+Shift+`). In case it opens in a wrong directory, navigate to where you have initialized Zephyr and its dependencies (e.g. ~/zephyrproject). Then run:

west config manifest.path Anjay-zephyr-client/demo
west config manifest.file west-nrf.yml
west update

NOTE: If building a project other than demo, please adjust the path in the above commands accordingly.

NOTE: West manifest folder can be changed in Source Control by clicking "Select manifest" on the root of the Zephyr repository and choosing a different folder. If the manifest is different a "west update" icon will show up next to the manifest file name. Clicking it will update the repository. If the manifest you want to change to has a different name (and not only a different path) then it must be changed directly using the west config command in the terminal.

This is why using the command line is necessary to choose the manifest for this project - the nRF-specific manifests are called west-nrf.yml, which is not supported by the plugin's GUI at the moment.

Now we can add the application to VSC workspace. Click on nRF Connect tab -> Application -> Add Application. Open the folder containing the prj.conf file (e.g. Anjay-zephyr-client/demo). In the Application section the demo application should show up. Click on "No build configuration" to add a configuration for the desired target, e.g. nrf9160dk_nrf9160_ns (you can have 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 Management LwM2M Server, please register at https://eu.iot.avsystem.cloud/. Then have a look at the example configuration to configure security credentials and other necessary settings (like Wi-Fi SSID etc.).

Guide showing basic usage of Coiote DM is available on IoT Developer Zone.

NOTE: You may use any LwM2M Server compliant with LwM2M 1.0 TS. The server URI can be changed in the example configuration options.

anjay-zephyr-client's People

Contributors

coderbyheart avatar jzimnol avatar kfyatek avatar kucmasz avatar micholek avatar mierunski avatar panekk avatar piotrroszkowski avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

anjay-zephyr-client's Issues

Lost Connection ERROR

I managed to successfully connect an Nordic Thingy:91 with the latest Anjay LwM2M Client stack to the CoioteDM platform.

But then it suddenly lost the connection with the following error.

<wrn> anjay_zephyr_gps_nrf: GPS was interrupted multiple times by the LTE modem when producing a fix
	<inf> anjay_zephyr_lwm2m: Anjay is now offline
	<inf> anjay: [anjay] servers reloaded
<wrn> anjay: [anjay] transport required for protocol coaps is not supported or offline

After rebooting the device, the connection worked again, but I would like to know what happened and if this is reliable?

I'm using: A coaps URI, with PSK, and no bootstrap with default GNSS settings:

anjay config set lifetime 50
anjay config set bootstrap n
anjay config set security_mode psk
anjay config set gps_prio_mode_timeout 300
anjay config set gps_prio_mode_cooldown 1800

Any ideas of potential issues?

Maybe it would be a good idea to be able to disable BT and GPS from anjay when not in use?

handshake error when running demo example for nRF7002 DK

Currently, the demo version is not working for the board nrf7002dk_nrf5340_cpuapp at version 23.11.

Steps to reproduce:

git clone [email protected]:AVSystem/Anjay-zephyr-client.git
cd Anjay-zephyr-client/demo
west init -l .
west config manifest.path demo
west config manifest.file west-nrf.yml
west update -o=--depth=1 -n
west build -p always -b nrf7002dk_nrf5340_cpuapp
west flash --erase
minicom -D /dev/ttyACM1
anjay stop
anjay config set wifi_ssid 'SSID'
anjay config set wifi_password 'PSSWD'
anjay start

Result:

Attempt to start Anjay
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
Anjay started
[00:01:04.525,665] <inf> anjay_zephyr_lwm2m: Saving config
[00:01:04.529,266] <inf> anjay_zephyr_config: Configuration successfully saved
[00:01:04.529,266] <inf> anjay_zephyr_lwm2m: Starting Anjay
[00:01:04.530,181] <inf> anjay_zephyr_lwm2m: Connecting to the network...
[00:01:10.786,651] <inf> net_dhcpv4: Received: 192.168.1.110
[00:01:10.787,719] <inf> anjay_zephyr_lwm2m: Connected to network
[00:01:11.010,101] <inf> anjay_zephyr_lwm2m: Time synchronized
[00:01:11.010,162] <inf> anjay: [anjay] Initializing Anjay 3.6.1
[00:01:11.012,176] <inf> anjay: [anjay_dm] successfully registered object /0
[00:01:11.012,298] <inf> anjay: [anjay_dm] successfully registered object /1
[00:01:11.012,359] <inf> anjay: [anjay_dm] successfully registered object /3
[00:01:11.012,481] <inf> anjay: [anjay_dm] successfully registered object /3347
[00:01:11.012,756] <inf> anjay: [anjay_dm] successfully registered object /3311
[00:01:11.013,000] <inf> anjay: [security] Added instance 0 (SSID: 1, URI: coaps://eu.iot.avsystem.cloud:5684)
[00:01:11.013,153] <inf> anjay: [server] Added instance 0 (SSID: 1)
[00:01:11.013,214] <inf> anjay_zephyr_lwm2m: Successfully created thread
[00:01:11.013,214] <inf> anjay_zephyr_lwm2m: Anjay is now online on bearer 0
[00:01:11.014,282] <inf> anjay: [anjay] servers reloaded
[00:01:11.014,770] <inf> anjay: [anjay] server /0/0: transport change: (none) -> U (uri: coaps://eu.iot.avsystem.cloud:5684)
[00:01:11.172,607] <wrn> anjay: [avs_net] Could not restore session; performing full handshake
[00:01:11.172,637] <err> anjay: [avs_net] handshake failed: -60
[00:01:11.176,910] <err> anjay: [anjay] could not connect to eu.iot.avsystem.cloud:5684
[00:01:11.177,612] <inf> anjay: [anjay] servers reloaded

Expected (same as version 23.09.1):

[00:00:09.763,275] <inf> anjay: [anjay] Register sent
[00:00:12.726,470] <wrn> anjay: [anjay] server responded with 4.00 Bad Request (expected 2.01 Created)
[00:00:12.726,470] <wrn> anjay: [anjay] could not register to server 1
[00:00:12.731,414] <inf> anjay: [anjay] servers reloaded

Provide video or screenshots of the different demos offered

There are 4 sub-directories with apparently (?) different demo clients, but no description to what the different demos actually does.

  1. Can you please provide a video for each demo and how to use it.
  2. Can you please add some screenshots to the readme's in those directories.

Request to improve the Anjay Demo Client?

Hi,

I was just trying out the latest Anjay Demo client on a Nordic Thingy:91.
However, I found it very non-intuitive and hard to work with from the terminal, compared to other solutions.

For an example of a great working terminal shell, please flash the latest Nordic "Modem Shell" called:
thingy91_modem_shell_2023-06-01_0677b099.hex from [1].

Some of the issues I encounter and would like to help fix/improve are:

  • Improve the help command info and formatting.
  • More clear and better formatted anjay config show info.
  • Enable the LED colors for providing links status!
    At the moment the LED is OFF and not used at all, so you can't even tell if the device is on!
  • Enable terminal ANSI coloring from within anjay shell.
  • Enable disable local echo (as it's missing in Nordic AT command set.)
  • Being able to enable/disable GNSS/GPS from the anjay shell. (Similar to link funmode --gnssoff in [1].)
  • Being able to also select between: NB-IoT and LTE-M from the anjay shell.
  • Being able to enable/disable Bluetooth from within the anjay shell.
  • Make a more informative anjay status command mimicking the "link status" command from [1].
  • Command completion doesn't work very well...making it hard to find all the command options.
  • Provide more info on undocumented anjay commands, such as: public_cert, private_key.
    (Are there more?)

References:
[1] - Nordic Thingy:91 Modem Downloads.
[2] - Lost LTE Connection due to LTE/GPS competition


How can I help you contribute to this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.