Code Monkey home page Code Monkey logo

anjay's Introduction

Anjay LwM2M library

Build Status Coverity Status

New license notice

With release of Anjay 3.0, the library's license terms have changed. Please make sure that you have reviewed it before updating to the new major release. Previous versions of Anjay remain with the old, Apache 2.0 license.

What is Anjay?

Anjay is a C library that aims to be the reference implementation of the OMA Lightweight Machine-to-Machine (LwM2M) device management protocol. It eases development of fully-featured LwM2M client applications by taking care of protocol details, allowing the user to focus on device-specific aspects.

The project has been created and is actively maintained by AVSystem.

Supported features

This version includes full support for OMA LwM2M TS 1.1 features. Some features, such as support for EST, SMS binding or HSM's are available commercially.

  • LwM2M Bootstrap Interface:

    • Request
    • Discover
    • Read
    • Write
    • Delete
    • Finish
  • LwM2M Client Registration Interface:

    • Register
    • Update
    • De-register
  • LwM2M Device Management and Service Enablement Interface:

    • Discover
    • Read
    • Read-Composite
    • Write
    • Write-Composite
    • Execute
    • Write-Attributes
    • Create
    • Delete
    • Send
  • LwM2M Information Reporting Interface:

    • Observe
    • Observe-Composite
    • Cancel Observation
    • Cancel Observation-Composite
    • Notify
  • LwM2M Security modes:

    • DTLS with Certificates (if supported by backend TLS library)
    • DTLS with PSK (if supported by backend TLS library)
    • NoSec mode
  • Supported TLS backends:

    • mbed TLS
    • OpenSSL
    • tinydtls
  • Supported platforms:

  • CoAP data formats:

    • Plain Text
    • Opaque
    • CBOR
    • TLV
    • SenML JSON
    • SenML CBOR
    • LwM2M JSON (output only)
  • CoAP BLOCK transfers (for transferring data that does not fit in a single UDP packet):

    • Block1 (sending / receiving requests)
    • Block2 (sending responses)
  • Pre-implemented LwM2M Objects:

    • Access Control
    • Security
    • Server
    • Firmware Update
    • IPSO single and three-axis sensor objects
  • Stream-oriented persistence API

About OMA LwM2M

OMA LwM2M is a remote device management and telemetry protocol designed to conserve network resources. It is especially suitable for constrained wireless devices, where network communication is a major factor affecting battery life. LwM2M features secure (DTLS-encrypted) methods of remote bootstrapping, configuration and notifications over UDP or SMS.

More details about OMA LwM2M: Brief introduction to LwM2M

Quickstart guide

Dependencies

  • C compiler with C99 support,
  • avs_commons - included in the repository as a subproject,
  • If DTLS support is enabled, at least one of:
  • Optional dependencies (required for tests):
  • Optional dependencies (required for building documentation - more information in "Contributing" section):

Ubuntu 20.04 LTS / Raspbian Buster or later

sudo apt-get install git build-essential cmake libmbedtls-dev zlib1g-dev

CentOS 7 or later

# EPEL is required for mbedtls-devel and cmake3
sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum install -y which git make cmake3 mbedtls-devel gcc gcc-c++ zlib-devel

macOS Sierra or later, with Homebrew

brew install cmake mbedtls openssl

Python dependencies

In order to run integration tests or nsh_lwm2m server, some additional Python modules are required. To install them, you can use requirements.txt file by running the following command:

pip3 install -U -r requirements.txt

Running the demo client

For initial development and testing of LwM2M clients, we recommend using the Coiote IoT Device Management where you can use the basic LwM2M server functionality for free.

After setting up an account and adding the device entry, you can compile Anjay demo client and connect it to the platform by running:

git clone https://github.com/AVSystem/Anjay.git \
    && cd Anjay \
    && git submodule update --init \
    && cmake . \
    && make -j \
    && ./output/bin/demo --endpoint-name $(hostname) --server-uri coap://eu.iot.avsystem.cloud:5683

NOTE: On some older systems like CentOS 7, you may need to use cmake3 instead of cmake.

NOTE: We strongly recommend replacing $(hostname) with some actual unique hostname. Please see the documentation for information on preferred endpoint name formats. Note that with the Coiote IoT Device Management platform, you will need to enter the endpoint name into the server UI first.

Detailed compilation guide

First, make sure all necessary submodules are downloaded and up-to-date:

git submodule update --init

After that, you have several options to compile the library.

Building using CMake

The preferred way of building Anjay is to use CMake.

By default demo client compiles with DTLS enabled and uses mbedtls as a DTLS provider, but you may choose other DTLS backends currently supported by setting DTLS_BACKEND in a CMake invocation to one of the following DTLS backends: openssl, mbedtls or tinydtls:

cmake . -DDTLS_BACKEND="mbedtls" && make -j

Or, if a lack of security (not recommended) is what you need for some reason:

cmake . -DDTLS_BACKEND="" && make -j

Compiled executables, including demo client, can be found in output/bin subdirectory.

For a detailed guide on configuring and compiling the project (including cross-compiling), see Compiling client applications.

To start the demo client:

# uses plain CoAP
./output/bin/demo --endpoint-name $(hostname) --server-uri coap://eu.iot.avsystem.cloud:5683

# uses DTLS in PSK mode, with PSK identity "foo" and secret key "bar" (hex-encoded)
./output/bin/demo --endpoint-name $(hostname) --server-uri coaps://eu.iot.avsystem.cloud:5684 --security-mode psk --identity 666f6f --key 626172

NOTE: When establishing a DTLS connection, the URI MUST use "coaps://". In NoSec mode (default), the URI MUST use "coap://".

Alternative build systems

Alternatively, you may use any other build system. You will need to:

  • Prepare your avs_commons_config.h, avs_coap_config.h and anjay_config.h files.
  • Configure your build system so that:
    • At least all *.c and *.h files from src, include_public, deps/avs_coap/src, deps/avs_coap/include_public, deps/avs_commons/src and deps/avs_commons/include_public directories are preserved, with the directory structure intact.
      • It is also safe to merge contents of all include_public directories into one. Merging src directories should be safe, too, but is not explicitly supported.
    • All *.c files inside src, deps/avs_coap/src, deps/avs_commons/src, or any of their direct or indirect subdirectories are compiled.
    • deps/avs_commons/src and deps/avs_commons/include_public directories are included in the header search path when compiling avs_commons.
    • deps/avs_coap/src, deps/avs_coap/include_public and deps/avs_commons/include_public directories are included in the header search path when compiling avs_coap.
    • src, include_public, deps/avs_coap/include_public and deps/avs_commons/include_public directories are included in the header search path when compiling Anjay.
    • include_public, deps/avs_coap/include_public and deps/avs_commons/include_public directories, or copies of them (possibly merged into one directory) are included in the header search path when compiling dependent application code.

Below is an example of a simplistic build process, that builds all of avs_commons, avs_coap and Anjay from a Unix-like shell:

# configuration
cp -r example_configs/linux_lwm2m10 config
# you may want to edit the files in the "config" directory before continuing

# compilation
cc -Iconfig -Iinclude_public -Ideps/avs_coap/include_public -Ideps/avs_commons/include_public -Isrc -Ideps/avs_coap/src -Ideps/avs_commons/src -c $(find src deps/avs_coap/src deps/avs_commons/src -name '*.c')
ar rcs libanjay.a *.o

# installation
cp libanjay.a /usr/local/lib/
cp -r include_public/avsystem /usr/local/include/
cp -r deps/avs_coap/include_public/avsystem /usr/local/include/
cp -r deps/avs_commons/include_public/avsystem /usr/local/include/
cp -r config/* /usr/local/include/

Use a Dockerfile

For some cases you may find it comfortable to use Docker image. In this case, the only dependency is Docker, which you can install with your favorite package manager. If Docker is already installed, you can clone the repo and build the Docker image:

git clone --recurse-submodules https://github.com/AVSystem/Anjay.git
cd Anjay
docker build --no-cache --tag anjay .

Then, you can launch the built image and run the demo client:

docker run -it anjay
./output/bin/demo -e $(hostname) -u coap://eu.iot.avsystem.cloud:5683

Embedded operating systems ports

If you want to use Anjay on Mbed OS, Zephyr OS, FreeRTOS, Azure RTOS or ESP-IDF check our demo applications available in other repositories:

Raspberry Pi client

LwM2M Client for Raspberry Pi, with a feature allowing for implementing LwM2M Objects in Python, is available in Svetovid-raspberry-client repository.

Java bindings

Maven Central repository contains anjay-java and anjay-android artifacts which allow to use Anjay in Java applications.

In case of using anjay-java, check Anjay-java repository for details how to compile the native library. This step isn't required if you want to use anjay-android in your Android application.

License

See LICENSE file.

Commercial support

Anjay LwM2M library comes with the option of full commercial support, provided by AVSystem.

The list of features available commercially is available here.

If you're interested in LwM2M Server, be sure to check out the Coiote IoT Device Management platform by AVSystem. It also includes the interoperability test module that you can use to test your LwM2M client implementation. Our automated tests and testing scenarios enable you to quickly check how interoperable your device is with LwM2M.

Contributing

Contributions are welcome! See our contributing guide.

Building documentation

Make sure, both Doxygen and Sphinx are installed on your system, then type:

cmake . && make doc

the documentation will be available under output/doc/doxygen and output/doc/sphinx.

anjay's People

Contributors

cerkiewny avatar dextero avatar inimin avatar jzimnol avatar kfyatek avatar kucmasz avatar kylo avatar mierunski avatar panekk avatar piotrroszkowski avatar scop avatar sznaider avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

anjay's Issues

How to make "APN connection profile" instance automatically?

Hi,

When I connect lwm2m server, server add "LwM2M Access Control, APN connection profile & Porfolio" object but does not add instance.
(LwM2M Server, Device, Firmware Update, Location, Connectivity Statics & Cellular connectivity Object/Instance is added well.)

Has anyone had a experience before?

Regards,
Sean

Storing bootstrapped connection info

I have a client app derived from the 'demo client', which I am using with bootstrapping. I'm trying to figure out if there is a way to 'hook' the response from the Bootstrap Server so that I can save the Server connection info to use on next reboot (i.e. instead of just re-bootstrap each time).
Has anyone done this, and know where/how to grab the info?

Wrong CoAP endpoint path for send update

Hi,

I'm trying to implement a basic Anjay client on a STM32F437 with FreeRTOS and lwip.
I've implemented your BC3 example, which simply register the client to the server and update periodically. I'm using STML32CubeIDE and I've imported and built the Anjay library following the instructions you provided. I'm using the Leshan demo server for testing purpose.

I managed to have the connection between the server and the client working, but the update part doesn't work. By looking at CoAP traces with Wireshark, I've noticed that Anjay send an incorrect endpoint path to the server:
POST, TKN:2e d0 54 01 65 20 ae d2, /rd/../Middlewares/Anjay/src/core/servers/anjay_reload.c/
while it should send something like:
POST, TKN:2e d0 54 01 65 20 ae d2, /rd/c0k6tG2QsY

The server replies with a 4.00 "Bad URI" error because of the '/' in the path.
I've tried the BC3 example from an Ubuntu VM and there isn't any issue, Anjay send a correct endpoint path when updating:
POST, TKN:b4 dc c3 ba 23 63 29 72, /rd/r7OOav9dIP
This is something handled by the Anjay lib so I don't see why it should not work on an embedded environment.

You can find both traces attached: coap_traces.zip

The embedded client also crash when sending this update, but I'm not certain that this is related to the wrong endpoint path. Here's the stacktrace when the hardfault occurs:
image

Do you have any idea why a C file filepath ends up in the CoAP request? Do you think this is related to the hardfault also occuring during the update?

I already had to tweak a few things on the Anjay lib in order to avoid crashes related to memory management on the STM32, I'll report them later after reviewing, I think that might be of interest for you.

Thanks for your help

'binding_str' may be used uninitialized warning

Below line has build issue when compile with riscv32 gcc.
https://github.com/AVSystem/Anjay/blob/master/src/modules/server/anjay_server_persistence.c#L286

anjay/deps/avs_commons/include_public/avsystem/commons/avs_log_impl.h:63:9: error: 'binding_str' may be used uninitialized in this function [-Werror=maybe-uninitialized]
avs_log_internal_##Variant##__(Level, ModuleStr, FILE, LINE,
^~~~~~~~~~~~~~~~~
anjay/src/modules/server/anjay_server_persistence.c:286:17: note: 'binding_str' was declared here
const char *binding_str;
^~~~~~~~~~~

DTLS session resumption

Hello,

I am trying to use DTLS session resumption feature with Anjay C demo client.
If I understand well AVS_COMMONS_NET_WITH_TLS_SESSION_PERSISTENCE and AVS_NET_SOCKET_OPT_SESSION_RESUMED are responsible for that.

My test environment:

  • Ubuntu 20.04 @x86_64,
  • MbedTLS 2.28.1,
  • Anjay demo client 3.1.2 (LwM2M 1.1, PSK),
  • Leshan demo server (leshan.eclipseprojects.io),
  • my test scenario:
    • client connects to a server performing full DTLS handshake and successfully sends a registration,
    • I block traffic to Leshan server on my router,
    • when client is starting to reconnect DTLS session, I unblock traffic to Leshan server on my router,
    • client reconnects to server performing full DTLS handshake and successfully sends a registration.

In fact, in the last step of my scenario client performing FULL handshake during reconnection, but I expected ABBREVIATED handshake (see attached screenshot). For me, it means that resumption of DTLS session feature does not work.
Maybe I am doing something wrong... What do I need to do to have resumption of DTLS session?
Thanks for help.

Anjay_DTLS

Best regards
Tomasz

Getting segmentation fault after executing find_instance function

I included a humidity instance OID = 3304 in the demo. When running the demo, client connects with the DMP and when executing a read on /3304/0/5700 the demo crashes because find_instance returns null

This line:

humidity_instance_t *inst = find_instance(obj, iid);

static humidity_instance_t *find_instance(const humidity_t *obj,
anjay_iid_t iid) {
AVS_LIST(humidity_instance_t) it;
AVS_LIST_FOREACH(it, obj->instances) {
if (it->iid == iid) {
return it;
} else if (it->iid > iid) {
break;
}
}

return NULL;

}

Always returning NULL

Am I missing something?

Connection by using security mode cert

I'm trying to use demo to test a connection to a Leshan server using X.509 certified client authentication. I've run the following command:

./output/bin/demo -s cert --server-uri coaps://192.168.56.1:5684 -e test -C output/certs/client.crt.der -K output/certs/client.key.der

but I get the following error:

2019-10-22 10:47:43.403180 DEBUG [security] [/home/vte/Progetti/Anjay/modules/security/src/security_utils.c:64]: Invalid SMS Security Mode
2019-10-22 10:47:43.403457 INFO [security] [/home/vte/Progetti/Anjay/modules/security/src/mod_security.c:169]: Added instance 1 (SSID: 1, URI: coaps://192.168.56.1:5684)
2019-10-22 10:47:43.404269 INFO [server] [/home/vte/Progetti/Anjay/modules/server/src/mod_server.c:117]: Added instance 1 (SSID: 1)
2019-10-22 10:47:43.404841 INFO [demo] [/home/vte/Progetti/Anjay/demo/demo.c:616]: *** ANJAY DEMO STARTUP FINISHED ***
2019-10-22 10:47:43.405111 WARNING [fw_update] [/home/vte/Progetti/Anjay/modules/fw_update/src/fw_update.c:891]: Firmware Update Result change to 0 not allowed in State 0
2019-10-22 10:47:43.409705 INFO [anjay] [/home/vte/Progetti/Anjay/src/servers/reload.c:165]: servers reloaded
2019-10-22 10:47:43.411625 DEBUG [anjay] [/home/vte/Progetti/Anjay/src/servers/connection_udp.c:164]: server /0/1: UDP security mode = 2
2019-10-22 10:47:43.412816 DEBUG [avs_net] [/home/vte/Progetti/Anjay/avs_commons/git/net/src/mbedtls/mbedtls.c:814]: Server authentication disabled
2019-10-22 10:47:43.413558 DEBUG [avs_net] [/home/vte/Progetti/Anjay/avs_commons/git/net/compat/posix/compat_addrinfo.c:220]: getaddrinfo() error: Address family for hostname not supported; family == (avs_net_af_t) 2
2019-10-22 10:47:43.414281 WARNING [avs_net] [/home/vte/Progetti/Anjay/avs_commons/git/net/src/mbedtls/mbedtls.c:561]: Could not restore session; performing full handshake
2019-10-22 10:47:43.416854 ERROR [avs_net] [/home/vte/Progetti/Anjay/avs_commons/git/net/src/mbedtls/mbedtls.c:598]: handshake failed: -30208
2019-10-22 10:47:43.418440 ERROR [anjay] [/home/vte/Progetti/Anjay/src/servers/connection_udp.c:342]: could not connect to 192.168.56.1:5684
2019-10-22 10:47:43.418902 DEBUG [anjay] [/home/vte/Progetti/Anjay/src/servers/activate.c:55]: Non-Bootstrap Server 1: not reachable.

Error code -30208 corresponds to error mbedtls MBEDTLS_ERR_SSL_PRIVATE_KEY_REQUIRED . I then tried to change the private key parameter by specifying client.key instead of client.key.der.

In this case the error is:

2019-10-22 10:50:04.784528 DEBUG [security] [/home/vte/Progetti/Anjay/modules/security/src/security_utils.c:64]: Invalid SMS Security Mode
2019-10-22 10:50:04.784823 INFO [security] [/home/vte/Progetti/Anjay/modules/security/src/mod_security.c:169]: Added instance 1 (SSID: 1, URI: coaps://192.168.56.1:5684)
2019-10-22 10:50:04.785614 INFO [server] [/home/vte/Progetti/Anjay/modules/server/src/mod_server.c:117]: Added instance 1 (SSID: 1)
2019-10-22 10:50:04.786022 INFO [demo] [/home/vte/Progetti/Anjay/demo/demo.c:616]: *** ANJAY DEMO STARTUP FINISHED ***
2019-10-22 10:50:04.786259 WARNING [fw_update] [/home/vte/Progetti/Anjay/modules/fw_update/src/fw_update.c:891]: Firmware Update Result change to 0 not allowed in State 0
2019-10-22 10:50:04.790632 INFO [anjay] [/home/vte/Progetti/Anjay/src/servers/reload.c:165]: servers reloaded
2019-10-22 10:50:04.792926 WARNING [anjay] [/home/vte/Progetti/Anjay/src/servers/connection_udp.c:136]: read /0/1/5 failed
2019-10-22 10:50:04.794119 DEBUG [anjay] [/home/vte/Progetti/Anjay/src/servers/connections.c:211]: could not get UDP connection info for server /0/1
2019-10-22 10:50:04.795000 DEBUG [anjay] [/home/vte/Progetti/Anjay/src/servers/activate.c:55]: Non-Bootstrap Server 1: not reachable.

Can anyone tell me what I'm doing wrong?

Thank you

Requesting new parameter on demo app

Please add a new flag --is or --identitystring or similar to accept ASCII identities without requiring the user to use external tools to hexify a string based identity.

Compile in Centos

When I running cmake in centos, EC Factory support issue has occured in keytool command.
I solved this problem by install oracle jdk locally. And it also can be solved by editing security.properties in openjdk directory of centos.

Hope centos installation be added in guide.

Using 'demo' with *only* a bootstrap server

I am working on an embedded system (STM32F7 + ThreadX + lwIP + mbedTLS) into which I am integrating Anjay.
I've adapted the 'demo' to become my LWM2M client thread. Because it is an embedded system, I don't use demo_args.c but instead I am just hard-coding values into DEFAULT_CMDLINE_ARGS.
I am using Leshan servers (192.168.10.86), just for simple connection testing. I can set .servers[0] with URI for my server, and it connects and communicates correctly.
Now I want to try bootstrap server functionality (again, using the Leshan bootstrap server).
What I have found is that if I configure with a 'fictional' server then Anjay tries it, fails, and falls back to the bootstrap server. It can then get the real server info from the bootstrap, and can connect as before.
BUT I can't configure DEFAULT_CMDLINE_ARGS with only the bootstrap server.
In other words this succeeds [using info given by bootstrap server]:

    {
        .servers[0] = 
        {
            .security_iid = ANJAY_IID_INVALID,
            .server_iid = ANJAY_IID_INVALID,
            .id = 1,
            .uri = "coap://192.168.10.86:5700",
            .is_bootstrap = true
        },
        .servers[1] = 
        {
            .security_iid = ANJAY_IID_INVALID,
            .server_iid = ANJAY_IID_INVALID,
            .id = 2,
            .uri = "coap://99.99.99.99:5683",
            .is_bootstrap = false
        },
        ....

But this - servers[0] only - doesn't:

    {
        .servers[0] = 
        {
            .security_iid = ANJAY_IID_INVALID,
            .server_iid = ANJAY_IID_INVALID,
            .id = 1,
            .uri = "coap://192.168.10.86:5700",
            .is_bootstrap = true
        },
        ....

The rest of the config is

        .bootstrap_holdoff_s = 5,
        .bootstrap_timeout_s = 10,
        .lifetime = 120,
        .binding_mode = "U",
        .security_mode = ANJAY_UDP_SECURITY_NOSEC,
    },
    .inbuf_size = 4000,
    .outbuf_size = 4000,
    .msg_cache_size = 0,
    .fw_updated_marker_path = "/tmp/anjay-fw-updated",
    .fw_security_info =     { .mode = (avs_net_security_mode_t) -1 },
    .attr_storage_file = NULL,
    .disable_server_initiated_bootstrap = true,
    .tx_params = ANJAY_COAP_DEFAULT_UDP_TX_PARAMS,
    .dtls_hs_tx_params = ANJAY_DTLS_DEFAULT_UDP_HS_TX_PARAMS,
    .fwu_tx_params_modified = false,
    .fwu_tx_params = ANJAY_COAP_DEFAULT_UDP_TX_PARAMS

I'm puzzled why it can't be given just a bootstrap server, and work from there?
Watching in Wireshark, I see nothing being sent to the bootstrap server; and the client logs only report:

2018-11-23 16:49:40 INFO [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/anjay_core.c:171]: Initializing Anjay 1.13.1
2018-11-23 16:49:40 INFO [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/dm_core.c:129]: successfully registered object /2
2018-11-23 16:49:40 INFO [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/dm_core.c:129]: successfully registered object /0
2018-11-23 16:49:40 INFO [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/dm_core.c:129]: successfully registered object /1
2018-11-23 16:49:40 DEBUG [client] [C:\Projects\AmPlatform-Development_TCPIP\Transceiver\lwm2m\objects\device.c:407]: manufacturer: Atronic; serial number: 000001
2018-11-23 16:49:40 INFO [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/dm_core.c:129]: successfully registered object /3
2018-11-23 16:49:40 INFO [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/dm_core.c:129]: successfully registered object /11111
2018-11-23 16:49:40 INFO [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/dm_core.c:129]: successfully registered object /1337
2018-11-23 16:49:40 INFO [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/dm_core.c:129]: successfully registered object /16
2018-11-23 16:49:40 DEBUG [security] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/modules/security/src/security_utils.c:64]: Invalid SMS Security Mode
2018-11-23 16:49:40 INFO [security] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/modules/security/src/mod_security.c:166]: Added instance 0 (bootstrap, URI: coap://192.168.10.86:5700)
2018-11-23 16:49:40 INFO [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/servers/reload.c:165]: servers reloaded
2018-11-23 16:49:40 DEBUG [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/servers/connection_udp.c:164]: server /0/0: UDP security mode = 3
2018-11-23 16:49:40 DEBUG [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/servers/connection_udp.c:350]: bound to port 52720
2018-11-23 16:49:40 DEBUG [avs_net] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/avs_commons/git/net/compat/posix/net_impl.c:1891]: get_opt_net: unknown or unsupported option key: (avs_net_socket_opt_key_t) 5
2018-11-23 16:49:40 INFO [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/servers/connections.c:161]: reconnected
2018-11-23 16:49:40 DEBUG [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/interface/bootstrap_core.c:890]: scheduling Client Initiated Bootstrap
2018-11-23 16:49:40 DEBUG [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/servers_utils.c:105]: Registration session changed for SSID = 65535, forcing re-register
2018-11-23 16:49:45 DEBUG [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/servers/servers_internal.c:390]: servers_foreach_ssid: break on 65535
2018-11-23 16:49:45 DEBUG [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/interface/bootstrap_core.c:828]: Bootstrap already started on the same connection

With the fictional server included:

2018-11-23 17:03:10 DEBUG [client] [C:\Projects\AmPlatform-Development_TCPIP\Transceiver\lwm2m\objects\device.c:407]: manufacturer: Atronic; serial number: 000001
2018-11-23 17:03:10 INFO [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/dm_core.c:129]: successfully registered object /3
2018-11-23 17:03:10 INFO [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/dm_core.c:129]: successfully registered object /11111
2018-11-23 17:03:10 INFO [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/dm_core.c:129]: successfully registered object /1337
2018-11-23 17:03:10 INFO [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/dm_core.c:129]: successfully registered object /16
2018-11-23 17:03:10 DEBUG [security] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/modules/security/src/security_utils.c:64]: Invalid SMS Security Mode
2018-11-23 17:03:10 INFO [security] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/modules/security/src/mod_security.c:166]: Added instance 0 (bootstrap, URI: coap://192.168.10.86:5700)
2018-11-23 17:03:10 DEBUG [security] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/modules/security/src/security_utils.c:64]: Invalid SMS Security Mode
2018-11-23 17:03:10 INFO [security] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/modules/security/src/mod_security.c:169]: Added instance 1 (SSID: 2, 2018-11-23 17:03:12 ERROR [avs_coap] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/avs_commons/git/coap/src/ctx.c:125]: receive failed: errno = 110
2018-11-23 17:03:12 ERROR [coap] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/coap/stream/in.c:43]: recv returned -1505 (unknown error)
2018-11-23 17:03:12 DEBUG [coap] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/coap/stream/client_internal.c:296]: timeout reached, next: 8589934592.090 s
2018-11-23 17:03:12 DEBUG [avs_coap] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/avs_commons/git/coap/src/ctx.c:191]: send: 0.02 Post, CONFIRMABLE, id 23429, token e8e732392cfb56ad (8B)
2018-11-23 17:03:18 ERROR [avs_coap] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/avs_commons/git/coap/src/ctx.c:125]: receive failed: errno = 110
2018-11-23 17:03:18 ERROR [coap] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/coap/stream/in.c:43]: recv returned -1505 (unknown error)
2018-11-23 17:03:18 DEBUG [coap] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/coap/stream/client_internal.c:296]: timeout reached, next: 21474836480.090 s
2018-11-23 17:03:18 DEBUG [avs_coap] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/avs_commons/git/coap/src/ctx.c:191]: send: 0.02 Post, CONFIRMABLE, id 23429, token e8e732392cfb56ad (8B)
2018-11-23 17:03:28 ERROR [avs_coap] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/avs_commons/git/coap/src/ctx.c:125]: receive failed: errno = 110
2018-11-23 17:03:28 ERROR [coap] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/coap/stream/in.c:43]: recv returned -1505 (unknown error)
2018-11-23 17:03:28 DEBUG [coap] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/coap/stream/client_internal.c:296]: timeout reached, next: 42949672960.090 s
2018-11-23 17:03:28 DEBUG [avs_coap] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/avs_commons/git/coap/src/ctx.c:191]: send: 0.02 Post, CONFIRMABLE, id 23429, token e8e732392cfb56ad (8B)
2018-11-23 17:03:48 ERROR [avs_coap] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/avs_commons/git/coap/src/ctx.c:125]: receive failed: errno = 110
2018-11-23 17:03:48 ERROR [coap] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/coap/stream/in.c:43]: recv returned -1505 (unknown error)
2018-11-23 17:03:48 DEBUG [coap] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/coap/stream/client_internal.c:296]: timeout reached, next: 85899345920.090 s
2018-11-23 17:03:48 DEBUG [avs_coap] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/avs_commons/git/coap/src/ctx.c:191]: send: 0.02 Post, CONFIRMABLE, id 23429, token e8e732392cfb56ad (8B)
2018-11-23 17:04:28 ERROR [avs_coap] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/avs_commons/git/coap/src/ctx.c:125]: receive failed: errno = 110
2018-11-23 17:04:28 ERROR [coap] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/coap/stream/in.c:43]: recv returned -1505 (unknown error)
2018-11-23 17:04:28 DEBUG [coap] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/coap/stream/client_internal.c:296]: timeout reached, next: 171798691840.090 s
2018-11-23 17:04:28 ERROR [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/interface/register.c:189]: could not send Register message
2018-11-23 17:04:28 ERROR [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/interface/register.c:387]: could not register to server 2
2018-11-23 17:04:28 DEBUG [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/servers/register_internal.c:260]: re-registration timed out
2018-11-23 17:04:28 DEBUG [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/servers_utils.c:105]: Registration session changed for SSID = 2, forcing re-register
2018-11-23 17:04:28 DEBUG [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/servers/connection_udp.c:164]: server /0/0: UDP security mode = 3
2018-11-23 17:04:28 DEBUG [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/servers/connection_udp.c:350]: bound to port 52721
2018-11-23 17:04:28 DEBUG [avs_net] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/avs_commons/git/net/compat/posix/net_impl.c:1891]: get_opt_net: unknown or unsupported option key: (avs_net_socket_opt_key_t) 5
2018-11-23 17:04:28 INFO [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/servers/connections.c:161]: reconnected
2018-11-23 17:04:28 DEBUG [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/interface/bootstrap_core.c:890]: scheduling Client Initiated Bootstrap
2018-11-23 17:04:28 DEBUG [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/servers_utils.c:105]: Registration session changed for SSID = 65535, forcing re-register
2018-11-23 17:04:33 DEBUG [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/servers/servers_internal.c:390]: servers_foreach_ssid: break on 65535
2018-11-23 17:04:33 DEBUG [coap] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/coap/stream/out.c:57]: Buffer size: 4004; socket MTU: 1464
2018-11-23 17:04:33 DEBUG [avs_coap] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/avs_commons/git/coap/src/ctx.c:191]: send: 0.02 Post, CONFIRMABLE, id 23430, token 30cf3ae1f463ded5 (8B)
2018-11-23 17:04:33 DEBUG [avs_coap] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/avs_commons/git/coap/src/ctx.c:281]: recv: 2.04 Changed, ACKNOWLEDGEMENT, id 23430, token 30cf3ae1f463ded5 (8B)
2018-11-23 17:04:33 INFO [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/interface/bootstrap_core.c:709]: Request Bootstrap sent
2018-11-23 17:04:33 DEBUG [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/servers/servers_internal.c:390]: servers_foreach_ssid: break on 65535
2018-11-23 17:04:33 DEBUG [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/anjay_core.c:725]: bootstrap server
2018-11-23 17:04:33 DEBUG [avs_coap] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/avs_commons/git/coap/src/ctx.c:281]: recv: 0.04 Delete, CONFIRMABLE, id 47203, token 92c8d88e568ae039 (8B)
2018-11-23 17:04:33 DEBUG [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/anjay_core.c:476]: LwM2M action: Delete
2018-11-23 17:04:33 DEBUG [coap] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/coap/stream/out.c:57]: Buffer size: 4004; socket MTU: 1464
2018-11-23 17:04:33 DEBUG [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/interface/bootstrap_core.c:415]: Bootstrap Delete /
2018-11-23 17:04:33 ERROR [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/dm/dm_handlers.c:188]: instance_remove handler not set for object /3
2018-11-23 17:04:33 ERROR [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/interface/bootstrap_core.c:368]: delete_instance: cannot delete /3/0: -133
2018-11-23 17:04:33 ERROR [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/dm/dm_handlers.c:367]: transaction_begin handler not set for object /11111
2018-11-23 17:04:33 ERROR [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/interface/bootstrap_core.c:368]: delete_instance: cannot delete /11111/0: -133
2018-11-23 17:04:33 DEBUG [avs_coap] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/avs_commons/git/coap/src/ctx.c:191]: send: 2.02 Delers_internal.c:390]: servers_foreach_ssid: break on 65535
2018-11-23 17:04:33 DEBUG [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anja2018-11-23 17:04:43 DEBUG [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/servers/servers_internal.c:390]: servers_foreach_ssid: break on 123
2018-11-23 17:04:43 INFO [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/servers/connections.c:141]: socket already connected
2018-11-23 17:04:43 DEBUG [coap] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/coap/stream/out.c:57]: Buffer size: 4004; socket MTU: 1464
2018-11-23 17:04:43 DEBUG [avs_coap] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/avs_commons/git/coap/src/ctx.c:191]: send: 0.02 Post, CONFIRMABLE, id 23432, token c09f4a318433ee25 (8B)
2018-11-23 17:04:43 DEBUG [avs_coap] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/avs_commons/git/coap/src/ctx.c:281]: recv: 2.04 Changed, ACKNOWLEDGEMENT, id 23432, token c09f4a318433ee25 (8B)
2018-11-23 17:04:43 INFO [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/interface/register.c:465]: Update sent
2018-11-23 17:04:43 INFO [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/interface/register.c:482]: registration successfully updated
2018-11-23 17:04:43 DEBUG [anjay] [C:/Projects/AmPlatform-Development_TCPIP/Anjay/source/src/servers/register_internal.c:86]: scheduling update for SSID 123 after 0.537333492

anjay_ongoing_registration_exists() remains true when a bootstrapping is used.

Expected anjay_ongoing_registration_exists() to return false when bootstrapping is done and client registered to the lwm2m server.

Testcase

Run the demo with a bootstrap server. After the client is connected to the lwm2m server, anjay_ongoing_registration_exists() returns true.

output/bin/demo -e test_anjay_ongoing_registration_exists -b -u coap://leshan.eclipseprojects.io:5783
(DEMO)>ongoing-registration-exists
ONGOING_REGISTRATION==true

When a lwm2m server is used directly without bootstrapping, anjay_ongoing_registration_exists() will return false as expected when the client is connected.

output/bin/demo -e test_anjay_ongoing_registration_exists -u coap://leshan.eclipseprojects.io:5683
(DEMO)>ongoing-registration-exists
ONGOING_REGISTRATION==false

Version

Anjay 2.13.0

Configuration of DTLS

Hello,

I would like to configure DTLS in my project and looking at the Anjay documentation it seems that the recommended way is to use the Security Object.
Unfortunately in my project I am not allowed to expose Private key of the system and have some OpenSSL extension to be able to use this private key.
We are using "Certificate mode" as Security Mode and not using the private key send by server as it is pre-provisionned in our system. The Security Object defines as Resource#5 (Secret Key) the private key of the client which I cannot expose as mention above.

So my questions are:

  1. How to configure DTLS without using Security Object (if it is really the only recommended way to do it which I understood from documentation)?
  2. Is this solution valid for both use cases: Bootstrap and Device Management? By the way why using Security Object to configure DTLS in bootstrap case as server is not even know and Security Object not yet written by server

Thanks for your support.

Regards,
Olivier PAVE.

Format issue with Read on multi-resource

I observed strange behavior when reading empty multi-resources. Here is the flow:

  1. LWM2M server sent GET /4/0/7; Accept "application/vnd.oma.lwm2m+json"
  2. Anjay client responded with ACK-2.05, content: {"bn":"/4/0/7","e":[{"sv":""}]}

It seems to me that client response is not correct, or at least ambiguous, because it indicates that /4/0/7 is single value resource.

Spec says:

Each entry of the JSON format is a Resource Instance, where the Name attribute need to be prepended by the Base Name attribute to form the unique identifier of this Resource instance

I think client should have sent either:
a) If there is a single value then {"bn":"/4/0/7/0","e":[{"sv":""}]} or {"bn":"/4/0/7","e":[{"n": "/0", "sv":""}]}
b) {"bn":"/4/0/7","e":[]} when values are absent. Maybe more appropriate would be to send 4.04 Not Found in this situation.

Anjay docker'ization with Leshan fails

Hi,
I tried to run Anjay with Leshan server in docker-compose environment. I succeeded to run Leshan server and Leshan client in docker-compose environment. Then I tried to replace Leshan client with Anjay in docker-compose environment. It failed with:

anjay_1 | 2020-04-01 11:52:26.609954 INFO [demo] [/Anjay/demo/demo.c:663]: *** ANJAY DEMO STARTUP FINISHED ***
anjay_1 | 2020-04-01 11:52:26.610001 WARNING [fw_update] [/Anjay/modules/fw_update/src/fw_update.c:962]: Firmware Update Result change to 0 not allowed in State 0
anjay_1 | 2020-04-01 11:52:26.610089 TRACE [anjay] [/Anjay/src/anjay_core.c:177]: deleting anjay object
anjay_1 | 2020-04-01 11:52:26.610108 TRACE [anjay] [/Anjay/src/servers/servers_internal.c:70]: cleaning up 0 servers
anjay_1 | 2020-04-01 11:52:26.610137 DEBUG [avs_sched] [/Anjay/deps/avs_commons/sched/src/sched.c:224]: Scheduler "Anjay": shutting down
anjay_1 | 2020-04-01 11:52:26.610148 DEBUG [avs_sched] [/Anjay/deps/avs_commons/sched/src/sched.c:241]: Scheduler "Anjay": shut down
anjay_1 | 2020-04-01 11:52:26.610164 DEBUG [avs_sched] [/Anjay/deps/avs_commons/sched/src/sched.c:224]: Scheduler "eventlog": shutting down
anjay_1 | 2020-04-01 11:52:26.610174 DEBUG [avs_sched] [/Anjay/deps/avs_commons/sched/src/sched.c:241]: Scheduler "eventlog": shut down
leshandemo_anjay_1 exited with code 0

Is there any hint why this fails?

This is the change I did to introduce Anjay:
ehirdoy/leshandemo@b09a466

Here's console log:
https://asciinema.org/a/7XNembCsXwBlNgk3U7wKD3OHb

handshake failed with Orange Live Objects

Tying to run Anjay-freertos-client-B-L462E-CELL1-TYPE1SC.bin with Orange Live Objects but I keep getting handshake failed: -26624

I can see on my Orange Live Objects dashboard a Handshake Client Key Exchange event:

Capture d’écran 2023-06-08 à 13 48 25

I'm out of idea to make this working.

Here's a complete trace from my B-L462E-CELL1 board:

===== X-Cube-Cellular version : X-CUBE-CELLULAR-7.0.0 =====



TYPE1SC UART config: BaudRate=115200 / HW flow ctrl=1

INFO [anjay] [/home/soutys/work/clients/anjay-freertos-client/Middlewares/Third_Party/Anjay/src/core/anjay_core.c:417]: Initializing Anjay ##version##

INFO [anjay_dm] [/home/soutys/work/clients/anjay-freertos-client/Middlewares/Third_Party/Anjay/src/core/anjay_dm_core.c:159]: successfully registered object /0

INFO [security] [/home/soutys/work/clients/anjay-freertos-client/Middlewares/Third_Party/Anjay/src/modules/security/anjay_mod_security.c:392]: Added instance 0 (SSID: 1, URI: coaps://lwm2m.liveobjects.orange-business.com:5684)

INFO [anjay_dm] [/home/soutys/work/clients/anjay-freertos-client/Middlewares/Third_Party/Anjay/src/core/anjay_dm_core.c:159]: successfully registered object /1

INFO [server] [/home/soutys/work/clients/anjay-freertos-client/Middlewares/Third_Party/Anjay/src/modules/server/anjay_mod_server.c:279]: Added instance 0 (SSID: 1)

INFO [anjay_dm] [/home/soutys/work/clients/anjay-freertos-client/Middlewares/Third_Party/Anjay/src/core/anjay_dm_core.c:159]: successfully registered object /3

INFO [anjay_dm] [/home/soutys/work/clients/anjay-freertos-client/Middlewares/Third_Party/Anjay/src/core/anjay_dm_core.c:159]: successfully registered object /3303

INFO [anjay_dm] [/home/soutys/work/clients/anjay-freertos-client/Middlewares/Third_Party/Anjay/src/core/anjay_dm_core.c:159]: successfully registered object /3304

INFO [anjay_dm] [/home/soutys/work/clients/anjay-freertos-client/Middlewares/Third_Party/Anjay/src/core/anjay_dm_core.c:159]: successfully registered object /3315

INFO [anjay_dm] [/home/soutys/work/clients/anjay-freertos-client/Middlewares/Third_Party/Anjay/src/core/anjay_dm_core.c:159]: successfully registered object /3313

INFO [anjay_dm] [/home/soutys/work/clients/anjay-freertos-client/Middlewares/Third_Party/Anjay/src/core/anjay_dm_core.c:159]: successfully registered object /3314

INFO [gyrometer_driver] [/home/soutys/work/clients/anjay-freertos-client/Projects/B-L462E-CELL1/UserApp/app_compat/gyrometer_driver.c:13]: Gyrometer not supported

INFO [app] [/home/soutys/work/clients/anjay-freertos-client/Application/Src/lwm2m.c:75]: cellular configuration is updated

Modem Boot OK, sim slot nb 0

Modem Boot OK, sim slot nb 0

INFO [app] [/home/soutys/work/clients/anjay-freertos-client/Application/Src/lwm2m.c:75]: cellular configuration is updated

INFO [app] [/home/soutys/work/clients/anjay-freertos-client/Application/Src/lwm2m.c:75]: cellular configuration is updated

Modem Boot OK, sim slot nb 1

Modem Boot OK, sim slot nb 1

INFO [app] [/home/soutys/work/clients/anjay-freertos-client/Application/Src/lwm2m.c:75]: cellular configuration is updated

Network is up with IP 10.138.233.100

INFO [app] [/home/soutys/work/clients/anjay-freertos-client/Application/Src/lwm2m.c:63]: network is up

INFO [anjay] [/home/soutys/work/clients/anjay-freertos-client/Middlewares/Third_Party/Anjay/src/core/servers/anjay_reload.c:148]: servers reloaded

INFO [anjay] [/home/soutys/work/clients/anjay-freertos-client/Middlewares/Third_Party/Anjay/src/core/servers/anjay_connections.c:850]: server /0/0: transport change: (none) -> U (uri: coaps://lwm2m.liveobjects.orange-business.com:5684)

WARNING [avs_net] [/home/soutys/work/clients/anjay-freertos-client/Middlewares/Third_Party/Anjay/deps/avs_commons/src/net/mbedtls/avs_mbedtls_socket.c:1172]: Could not restore session; performing full handshake

ERROR [avs_net] [/home/soutys/work/clients/anjay-freertos-client/Middlewares/Third_Party/Anjay/deps/avs_commons/src/net/mbedtls/avs_mbedtls_socket.c:1296]: handshake failed: -26624

ERROR [anjay] [/home/soutys/work/clients/anjay-freertos-client/Middlewares/Third_Party/Anjay/src/core/servers/anjay_connection_ip.c:122]: could not connect to lwm2m.liveobjects.orange-business.com:5684

get string resource length in resource_write callback

Hello,

In resource_write, when resource is a string, how to get resource length?
I have a string resource, I don't know its length and I don't want to guess and do multiple malloc/realloc until anjay_get_string does not fail.
The goal is to do something like that (I did not compile this code):

static int resource_write(anjay_t *anjay,
                          const anjay_dm_object_def_t *const *obj_ptr,
                          anjay_iid_t iid,
                          anjay_rid_t rid,
                          anjay_riid_t riid,
                          anjay_input_ctx_t *ctx) {
    (void) anjay;

    time_object_t *obj = get_obj(obj_ptr);
    assert(obj);
    time_instance_t *inst = find_instance(obj, iid);
    assert(inst);

    switch (rid) {
    case RID_APPLICATION_TYPE:
        assert(riid == ANJAY_ID_INVALID);
        length = anjay_get_string_length(ctx);
        if (inst->application_type)
            free(inst->application_type);
        inst->application_type = malloc(length + 1);
        return anjay_get_string(ctx, inst->application_type, length+1);

    default:
        return ANJAY_ERR_METHOD_NOT_ALLOWED;
    }
}

But I didn't see any equivalent to "anjay_get_string_length" in Anjay code. Am I missing something obvious?

Best Regards,

Christophe Ronco

Float serialization bug?

Running the demo client (built on CentOS 7 or Ubuntu 16.04) from current git master against the Leshan demo server and watching the output in its web ui for location shows garbage for latitude, longitude, altitude, and uncertainty values. I haven't noticed the problem with any other clients (e.g. wakaama's example lwm2mclient), and I don't see issues with any other data from Anjay, so I'm wondering if there's an issue with Anjay serializing floats? To reproduce:

$ ./output/bin/demo --server-uri coap://leshan.eclipse.org:5683

Go to http://leshan.eclipse.org/#/clients/urn:dev:os:0023C7-000001 and click the Read button in Location instance 0. Attached is a screenshot what it shows me at the moment.

location

[yocto] How can i build anjay in yocto?

How can i build anjay in yocto?

I am bring up anjay in yocto.

but did occur the build error.
[Work Flow]

  1. create recipe for anjay
  2. do git clone to custom directory in yocto
  3. do start build for bitbake

[Error]
243 src/mbedtls/mbedtls_persistence.c:18:30: fatal error: mbedtls/platform.h: No such file or directory
244 #include <mbedtls/platform.h>
245 ^
246 compilation terminated.
247 make[2]: *** [avs_commons/git/net/CMakeFiles/avs_net.dir/src/mbedtls/mbedtls_persistence.c.o] Error 1
248 make[2]: *** Waiting for unfinished jobs....
249 src/mbedtls/mbedtls.c:18:30: fatal error: mbedtls/platform.h: No such file or directory
250 #include <mbedtls/platform.h>
251 ^
252 compilation terminated.
253 make[2]: *** [avs_commons/git/net/CMakeFiles/avs_net.dir/src/mbedtls/mbedtls.c.o] Error 1
254 In file included from src/mbedtls/data_loader.c:23:0:
255 src/mbedtls/data_loader.h:19:25: fatal error: mbedtls/ssl.h: No such file or directory
256 #include <mbedtls/ssl.h>

[Request]

  1. Did you try to bring up the anjay in yocto?
    If you did it, please share the guide.

  2. I checked the makefile in the av system, but it was complicated,
    please share the guide for "mbedtls" lib.

many thanks
shinkook

Not able to register to bootstrap server

In the Anjay documentation, it is mentioned as below.

To start the demo client:

uses plain CoAP
./output/bin/demo --server-uri coap://127.0.0.1:5683

Is there local/test (127.0.0.1:5683) bootstarp server available in the code base? if yes do we have to start before running the demo client?

Connecting to Leshan fails

When I try to connect to the public Leshan server (https://leshan.eclipseprojects.io) with the example in examples/tutorial/read-only I can see the device registered in the Leshan Server successfully and the Server also acknowledges the registration with an ACK message but still the LOG outputs show "Failure while receiving Register Response: timeout":

INFO [anjay] [/Users/a80482327/CLionProjects/Anjay/src/core/anjay_core.c:176]: Initializing Anjay 2.6.1
INFO [anjay_dm] [/Users/a80482327/CLionProjects/Anjay/src/core/anjay_dm_core.c:119]: successfully registered object /0
INFO [security] [/Users/a80482327/CLionProjects/Anjay/src/modules/security/anjay_mod_security.c:181]: Added instance 0 (SSID: 1, URI: coap://leshan.eclipseprojects.io:5683)
INFO [anjay_dm] [/Users/a80482327/CLionProjects/Anjay/src/core/anjay_dm_core.c:119]: successfully registered object /1
INFO [server] [/Users/a80482327/CLionProjects/Anjay/src/modules/server/anjay_mod_server.c:141]: Added instance 0 (SSID: 1)
INFO [anjay_dm] [/Users/a80482327/CLionProjects/Anjay/src/core/anjay_dm_core.c:119]: successfully registered object /1234
INFO [anjay] [/Users/a80482327/CLionProjects/Anjay/src/core/servers/anjay_reload.c:175]: servers reloaded
INFO [anjay] [/Users/a80482327/CLionProjects/Anjay/src/core/servers/anjay_connections.c:161]: reconnected
INFO [anjay] [/Users/a80482327/CLionProjects/Anjay/src/core/servers/anjay_register.c:712]: Attempting to register with LwM2M version 1.0
INFO [anjay] [/Users/a80482327/CLionProjects/Anjay/src/core/servers/anjay_register.c:680]: Register sent
WARNING [anjay] [/Users/a80482327/CLionProjects/Anjay/src/core/servers/anjay_register.c:593]: failure while receiving Register response: timeout
WARNING [anjay] [/Users/a80482327/CLionProjects/Anjay/src/core/servers/anjay_register.c:544]: could not register to server 1

I can see the messages arriving in Wireshark but still Anjay does not seem to handle the Register response. Am I doing something wrong?

Bildschirmfoto 2020-10-15 um 15 02 37

Thanks for the help!

Cannot interact with Anjay's UDP port

Hello,

I'd like to interact directly with Anjay instead of going through an LwM2M server. I've set the --port option to 5685 in Anjay, so I have a static port. Every time I try to read a resource via a CoAP packet, I get a "port unreachable" error. Moreover, I also dont see any UDP port open on port 5685.

If I run Wireshark I can see the requests from an LwM2M server (Leshan in my case) do work however. I'm not sure why the same UDP requests to the same port would not work? There's no error in the console, no message from Anjay at all.

I'm guessing there is a port unreachable error because Anjay doesn't reply to the ICMP's echo message, but shouldn't I still be able to send some CoAP requests to it?

Thank you in advance!

Can't cmake on macOS 12.6

I've play around with this repo using my mac on macOS 13 without any trouble a month ago.

And now I wanted to give it another go using my older Mac stuck on macOS 12.6 and I can't cmake . anymore. Didn't tried on my most recent Mac running Ventura to see if it still can compile the lib but it would be strange if that would be the case. I didn't see any version limitation of this lib for macOS versions.

cmake mbedtls and openssl are installed

➜  ~ brew install cmake mbedtls openssl

Warning: Treating cmake as a formula. For the cask, use homebrew/cask/cmake
Warning: cmake 3.27.0 is already installed and up-to-date.
To reinstall 3.27.0, run:
  brew reinstall cmake
Warning: mbedtls 3.4.0 is already installed and up-to-date.
To reinstall 3.4.0, run:
  brew reinstall mbedtls
Warning: openssl@3 3.1.1_1 is already installed and up-to-date.
To reinstall 3.1.1_1, run:
  brew reinstall openssl@3

cmake output:

➜  Anjay git:(master) cmake .
-- Looking for dlsym() in library:
-- Looking for dlsym
-- Looking for dlsym - found
-- Checking if IN6_IS_ADDR_V4MAPPED is usable - yes
-- DTLS backend: mbedtls
CMake Warning (dev) at deps/avs_commons/CMakeLists.txt:167 (set):
  implicitly converting 'INTEGER' to 'STRING' type.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Checking if IN6_IS_ADDR_V4MAPPED is usable - yes
-- Could NOT find MbedTLS (missing: MBEDTLS_INCLUDE_DIR MBEDTLS_LIBRARY MBEDTLS_CRYPTO_LIBRARY MBEDTLS_X509_LIBRARY MBEDTLS_LIBRARIES MBEDTLS_VERSION)
-- Could NOT find TinyDTLS (missing: TINYDTLS_INCLUDE_DIR TINYDTLS_LIBRARIES TINYDTLS_VERSION)
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
-- Configuring done
CMake Error in CMakeLists.txt:
  Target "avs_coap" contains relative path in its
  INTERFACE_INCLUDE_DIRECTORIES:

    "MBEDTLS_INCLUDE_DIR-NOTFOUND"


CMake Error in CMakeLists.txt:
  Target "avs_coap" contains relative path in its
  INTERFACE_INCLUDE_DIRECTORIES:

    "MBEDTLS_INCLUDE_DIR-NOTFOUND"


CMake Error in deps/avs_commons/src/net/CMakeLists.txt:
  Target "avs_crypto_mbedtls" contains relative path in its
  INTERFACE_INCLUDE_DIRECTORIES:

    "MBEDTLS_INCLUDE_DIR-NOTFOUND"


CMake Error in deps/avs_commons/src/net/CMakeLists.txt:
  Target "avs_crypto_mbedtls" contains relative path in its
  INTERFACE_INCLUDE_DIRECTORIES:

    "MBEDTLS_INCLUDE_DIR-NOTFOUND"


CMake Error in deps/avs_commons/src/stream/md5/CMakeLists.txt:
  Target "avs_crypto_mbedtls" contains relative path in its
  INTERFACE_INCLUDE_DIRECTORIES:

    "MBEDTLS_INCLUDE_DIR-NOTFOUND"


CMake Error in deps/avs_commons/src/stream/md5/CMakeLists.txt:
  Target "avs_crypto_mbedtls" contains relative path in its
  INTERFACE_INCLUDE_DIRECTORIES:

    "MBEDTLS_INCLUDE_DIR-NOTFOUND"


CMake Error in deps/avs_commons/src/crypto/CMakeLists.txt:
  Imported target "mbedtls" includes non-existent path

    "MBEDTLS_INCLUDE_DIR-NOTFOUND"

  in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:

  * The path was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and references files it does not
  provide.



CMake Error in deps/avs_commons/src/crypto/CMakeLists.txt:
  Imported target "mbedtls" includes non-existent path

    "MBEDTLS_INCLUDE_DIR-NOTFOUND"

  in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:

  * The path was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and references files it does not
  provide.



CMake Error in deps/avs_coap/CMakeLists.txt:
  Target "avs_net_mbedtls" contains relative path in its
  INTERFACE_INCLUDE_DIRECTORIES:

    "MBEDTLS_INCLUDE_DIR-NOTFOUND"


CMake Error in deps/avs_coap/CMakeLists.txt:
  Target "avs_net_mbedtls" contains relative path in its
  INTERFACE_INCLUDE_DIRECTORIES:

    "MBEDTLS_INCLUDE_DIR-NOTFOUND"


CMake Error in demo/CMakeLists.txt:
  Target "anjay" contains relative path in its INTERFACE_INCLUDE_DIRECTORIES:

    "MBEDTLS_INCLUDE_DIR-NOTFOUND"


CMake Error in demo/CMakeLists.txt:
  Target "anjay" contains relative path in its INTERFACE_INCLUDE_DIRECTORIES:

    "MBEDTLS_INCLUDE_DIR-NOTFOUND"


-- Generating done
CMake Generate step failed.  Build files cannot be regenerated correctly.

How to make tinydtls

hi,
when I want to use tinydtls, but when i try to compile.I got following errors in cmake.
My environment: Ubuntu 16.04LTS

cmake . -DDTLS_BACKEND="tinydtls"
-- Looking for dlsym() in library:
-- Looking for dlsym
-- Looking for dlsym - not found
-- Looking for dlsym() in library: dl
-- Looking for dlsym
-- Looking for dlsym - found
-- Checking if IN6_IS_ADDR_V4MAPPED is usable
-- Checking if IN6_IS_ADDR_V4MAPPED is usable - no
-- DTLS backend: tinydtls
-- Checking if IN6_IS_ADDR_V4MAPPED is usable
-- Checking if IN6_IS_ADDR_V4MAPPED is usable - no
-- Could NOT find tinyDTLS (missing: TINYDTLS_INCLUDE_DIR TINYDTLS_LIBRARIES TINYDTLS_VERSION)
-- Configuring done
CMake Error in CMakeLists.txt:
Target "avs_coap" contains relative path in its
INTERFACE_INCLUDE_DIRECTORIES:

"TINYDTLS_INCLUDE_DIR-NOTFOUND"

CMake Error in CMakeLists.txt:
Target "avs_coap" contains relative path in its
INTERFACE_INCLUDE_DIRECTORIES:

"TINYDTLS_INCLUDE_DIR-NOTFOUND"

How to session with lwm2m server using mbedtls?

Hi,

I want to session with server using mbedtls.

//Source code
result = mbedtls_ssl_handshake(get_context(socket));
LOG(ERROR, "mbedtls_ssl_handshake retun : %d", result); //(I added log for debugging.)

// Error log
result is -26880
result is -26880
result is -26880
result is -26880
result is -26880
result is -26880
result is -26624

//#define MBEDTLS_ERR_SSL_WANT_READ -0x6900 /< No data of requested type currently available on underlying transport. */
//#define MBEDTLS_ERR_SSL_TIMEOUT -0x6800 /
< The operation timed out. */

  1. Has anyone had a experience before?
  2. Do I need to add more code?

I wonder if you can help me.

Regards,
Sean

Anjay LwM2M & Quectel

I'm using Quectel BG96 and their evb (Quectel UMTS/LTE EVB KIT).
My goal is to build Anjay LwM2M Client and able to run it on current board.

From my quick research, it looks like Quectel is using LLVM to compile from Windows/Linux and need to follow their formats.
Beside follow their formats, is there way to compile Anjay with LLVM from Windows?
Kindly look into it.

Bootstrap Server: not reachable. Disabling all communication.

I Debugged the code and under function
static int send_request_bootstrap(anjay_t *anjay) {
const anjay_url_t *const connection_uri =_anjay_connection_uri(anjay->current_connection);
.
.
connection_uri is coming as blank.

And eventually i am getting connection time out to bootstrap server. Below are the debug logs.

2019-09-18 11:59:49.503384 ERROR [anjay] [/home/pi/Anjay/src/interface/bootstrap_core.c:754]: server responded with -1
2019-09-18 11:59:49.503428 ERROR [anjay] [/home/pi/Anjay/src/interface/bootstrap_core.c:755]: could not request bootstrap
2019-09-18 11:59:49.503491 ERROR [anjay] [/home/pi/Anjay/src/interface/bootstrap_core.c:849]: could not send Request Bootstrap
2019-09-18 11:59:49.503580 DEBUG [anjay] [/home/pi/Anjay/src/servers/activate.c:44]: Bootstrap Server: not reachable. Disabling all communication.

Note.
I am able to connect to same bootstrap server with my wakaama based lwm2m client.,however i tried every possible server configurations in demo_arg.c ,but its getting connection timed out.

Any kind of direction where to look for or suggestions would be greatly appreciated.

Thanks in advance for taking out the time to read.

Configuration of DTLS using MbedTLS

Hello,
I am interested in using Anjay library to define my LWM2M client, between the request that I have:

  • I want to configure the DTLS stack using mbedtls (configure. h & dtlsclients. h), so that I can use the PSK that is stored in the secure element. Far as I know the only way to configure the DTLS in Anjay is by using the security Object, and the security object use the MbedTLS to open the connection & insure the HandShake with the LWM2M server.
  • So my question is: how Anjay library implements the MbedTLS library?? And how can I modify DTLS stack in the MbedTLS using Anjay functions??

cmake warnings

Hi
Please find the cmake warnings.. I will be using DTLS in my bootstrap and device registration
But when i try to compile for Anjay simulator client , I got following warnings in cmake.
I doubt because of this reason the demo client could not create or connect CoAP sockets, etc.

I tried all DTLS backend option . In most of them the error /warning is like below. Pls suggest to solve the problem.
My environment: UbuntuVM installed in Oracle virtualbox+vagrant in local (Win OS)laptop , connected to Test server by public network

vagrant@vagrant:~/Anjay$ cmake . -DDTLS_BACKEND="openssl"
-- Looking for dlsym() in library:
-- Looking for dlsym
-- Looking for dlsym - not found
-- Looking for dlsym() in library: dl
-- Looking for dlsym
-- Looking for dlsym - found
-- Checking if IN6_IS_ADDR_V4MAPPED is usable
-- Checking if IN6_IS_ADDR_V4MAPPED is usable - no
-- DTLS backend: openssl
-- Could NOT find tinyDTLS (missing: TINYDTLS_INCLUDE_DIR TINYDTLS_LIBRARIES TINYDTLS_VERSION)
-- Checking if IN6_IS_ADDR_V4MAPPED is usable
-- Checking if IN6_IS_ADDR_V4MAPPED is usable - no
-- Configuring done
-- Generating done
-- Build files have been written to: /home/vagrant/Anjay

Rgds
Karthik M

Create C++ binding

It might be beneficial to create a modern C++ binding on top on Anjay, as an external layer.
This binding could have advanced features like:

  • Automatic management of resources, C callbacks etc
  • Delegates
  • entry/exit hooks in common lwm2m operations
  • support for std::function, lambdas etc everywhere
  • builder patterns
  • C++ exceptions, threads etc

I've done some prototyping in this area, and its quite easy to get this type on binding where you can create and register new lwm2m objects in just few lines. This however should be done so that its open source and commonly available.

Installation guide

Hi guys!
I've run into problems during Anjay installation.

First: apt-get libmbedtls-dev doesn't work for me. Potentially I have wrong configuration of apt-get, but I couldn't find any easy fix in google. Please check it.

Second: In https://github.com/AVSystem/Anjay#quickstart-guide there is information that it's possible to use one of three DTLS libraries. So I wanted to try OpenSSL. Unfortunately I couldn't find how to select it in the guide nor in full documentation.
After awhile of reading of some source codes I managed to guess proper command which is:
cmake . -DWITH_OPENSSL=true -DWITH_MBEDTLS=false
Please put this information into quick start guide or at least into documentation.

How to get higher notification frequency than 1 per second?

Dear Anjay team,

I am developing an Anjay based project which uses observes/notifications mechanism.
Sometimes those notifications need to be sent in high frequency.

Apparently, Anjay by default does not allow notifications to be sent in higher frequency than 1 notification per second.
Is there any way I can get around this limitation?
From my tests I can see that there is no problem with active pulling of a resource value in higher frequencies (read operation), but in case of notifications there is always minimum interval of 1 second.

I tried to quickly look through the library to find the place where this 1 second interval is located, but with no luck so far.
Thanks in advance.

Cheers,
Tom

Anjay LWM2M | Arduino Library

Dear Anjay LWM2M Team,

Hope you are doing well. Thank you for your awesome work on LWM2M. I was wondering if there's a way to compile the Anjay lwm2m library for the Arduino type devices? or a way to add the library via platformIO? Currently for lwm2m there's OpenHab Wakaama which is build on top of Eclipse Wakaama. However, both are kinda out-dated.

Is there a way to compile for Arduino. If not, what would be the way to do it? I would be happy to help to create one.

Let me know your thoughts.
Yours Sincerely,
Vijay

Adding recurrent task in anjay's main loop

Hello,
I want to execute a recurrent task each 30s. In this task, I might have to notify that some resources changed. My goal is to do that without creating a thread and integrated in anjay's framework.

I saw the tutorial BC6 about notify and it calls a time_object method each time it schedules anjay. That's not really what I want even if it is doable like that if we don't want to have a precision greater than 1 second on when the job is done

I tried to do that using AVS_SCHED macros and anjay scheduler. With a code like that:

AVS_SCHED_DELAYED(anjay->sched, &(obj->job_handle), duration, cellular_configuration_job, obj, sizeof(obj));

But I have no access to anjay_t internals in my code. I assume this is done on purpose and that's not the right way to do it. Did I miss an api that will allow me to add a task to anjay's scheduler?

I also tried to create my own scheduler inside my object (using avs_sched_new). And in my main_loop, I will have to compute minimal time between the two scheds (using avs_sched_time_of_next) and then call both avs_sched_run with my object scheduler and anjay_sched_run. I failed to do that (I have errors at runtime), maybe my code is bad. But maybe that's not the right way to do it, it is quite more complicated that the first solution and I don't see why I can't use anjay's scheduler.

So how should we add our own scheduled tasks to the tasks executed in the anjay's main loop?
Best Regards,

OMA version 1.1 support

Hi,

May i get following information related to OMA version 1.1 support in code ?

  1. COAP over SMS
  2. CBOR support
  3. TCP support
  4. OSCORE support

Using different cyphersuites with mbedtls

Hi gurus,

I don't think this question has been asked before but please point it out if it's the case.

I'm currently following the tutorial "Compiling Client Applications" and I would like to configure what cyphersuite is used by Anjay and this case mbed (since it's what I'm using).
I'm on a RPi but I don't think it matters.
I've followed these steps for compilation (and installation):
For mbed

$ cmake -DENABLE_TESTING=OFF -DCMAKE_INSTALL_PREFIX=/tmp/mbedtls/install .
$ make
$ make install

For Anjay

cmake -DDTLS_BACKEND="mbedtls" -DMBEDTLS_ROOT_DIR=/tmp/mbedtls/install .
make && make -j

And prior to all that I've replaced 'include/mbedtls/config.h' with 'configs/config-ccm-psk-tls1_2.h' as suggested in the 'config/README.txt' from mbedtls.

However, whenever my client connects it always offers 49 ciphersuites in the 'Client Hello' message and TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 is choosen by the server. I would like to use a ciphersuite which is easier to decrypt in Wireshark (like TLS_PSK_WITH_AES_128_CCM_8).

I've tried make clean on both projects to cleanup the cache...but it still doesn't work.

Could you please suggest what do to (differently)?

Thanks a lot in advance!

Non-varying source port

In conjunction with sorting out the problem I had with gettime/PRNG (#17), I was trying to understand how to catch the 'failure' this resulted in. (I think I've fixed it, but was concerned that my thread just sat forever waiting for response from bootstrap server - i.e. maybe something lacking in my error handling).
So I modified 'avs_rand_r()' on Linux , to always return a fixed value, to try to force the same behaviour that I was seeing with my hardware. However this build still worked - I think because although the Msg ID and Token are the same, the UDP source port is changing. But in my platform it always boots to use the same port [52720].
Where is the source port set? Is it generated by the TCP/IP stack? (I'm using lwIP)

Anjay + Coiote fails SET requests for Bootstrap-Awareness

I'm seeing an issue using the bootstrap-awareness example in Anjay where a Coiote specified bootstrap server is unable to SET parameters on a registered device. Attached are logs from the bootstrap server.

The client says "received packet is not a valid CoAP message" in addition to "Bootstrap Server misused Security Object". The client will then time out of the Bootstrap Finish. Logs on the bootstrap server seem to show a proper BootstrapWrite command being sent to the client, but the client returns a "4.00 BadRequest". The server logs are attached.

I was seeing issues with other examples, getting 4.03 CoAP errors. I would assume this has something to do with an underlying CoAP mishap, but I figured I'd post here. If it matters, I'm using the master branch of Anjay compiled onto an Arm architecture.

I'm having trouble using DTLS

When we try to connect to a Leshan server using DTLS, a timeout occurs and the handshake failed.
It's a failure in the DTLS library, but it's hard to think of as a bug in the DTLS side. Is there any setup or test method I didn't think of?
Below is how I tried.

$ export M2MROOT="$HOME/lwm2m"
$ cd $M2MROOT
$ git clone --recursive https://github.com/ARMmbed/mbedtls mbedtls
$ cd $M2MROOT/mbedtls
$ git checkout mbedtls-2.9.0 -b vmbedtls-2.9.0
$ git checkout mbedtls-2.16.3 -b vmbedtls-2.16.3
$ cd $M2MROOT/mbedtls/crypto
$ git checkout mbedcrypto-1.1.1 -b vmbedcrypto-1.1.1
$ cd $M2MROOT
$ git clone https://github.com/AVSystem/Anjay.git anjay
$ git submodule update --init
$ cd $M2MROOT/anjay
$ cd ..
$ mkdir -p $M2MROOT/build/mbedtls $M2MROOT/build/anjay
$ cd $M2MROOT/build/mbedtls
$ cmake -DUSE_SHARED_MBEDTLS_LIBRARY=ON -DCMAKE_INSTALL_PREFIX=$M2MROOT/build/ $M2MROOT/mbedtls/
$ make install
$ cd $M2MROOT/build/anjay
$ cmake $M2MROOT/anjay/ -DDTLS_BACKEND=mbedtls -DMBEDTLS_INCLUDE_DIR=$M2MROOT/build/include -DMBEDTLS_LIBRARY=$M2MROOT/build/lib/libmbedtls.so -DMBEDTLS_CRYPTO_LIBRARY=$M2MROOT/build/lib/libmbedcrypto.so -DMBEDTLS_X509_LIBRARY=$M2MROOT/build/lib/libmbedx509.so -DWITH_MBEDTLS_LOGS=ON
$ make
$ M2MROOT/build/anjay/output/bin/demo -e jungssl --server-uri coaps://leshan.eclipseprojects.io:5684 --security-mode psk --identity 666f6f --key 626172

[Log Message]
2020-01-15 11:04:47.901025 TRACE [mbedtls] [/home001/moon.jung/anjay_master/mbedtls/library/ssl_tls.c:2536]: => fetch input
2020-01-15 11:04:47.901035 TRACE [mbedtls] [/home001/moon.jung/anjay_master/mbedtls/library/ssl_tls.c:2597]: in_left: 0, nb_want: 13
2020-01-15 11:04:47.901045 TRACE [mbedtls] [/home001/moon.jung/anjay_master/mbedtls/library/ssl_tls.c:2638]: f_recv_timeout: 60000 ms
2020-01-15 11:05:47.956252 TRACE [mbedtls] [/home001/moon.jung/anjay_master/mbedtls/library/ssl_tls.c:2646]: ssl->f_recv(_timeout)() returned -26624 (-0x6800)
2020-01-15 11:05:47.956287 TRACE [mbedtls] [/home001/moon.jung/anjay_master/mbedtls/library/ssl_tls.c:2654]: timeout
2020-01-15 11:05:47.956299 TRACE [mbedtls] [/home001/moon.jung/anjay_master/mbedtls/library/ssl_tls.c:81]: set_timer to 0 ms
2020-01-15 11:05:47.956308 TRACE [mbedtls] [/home001/moon.jung/anjay_master/mbedtls/library/ssl_tls.c:2661]: handshake timeout
2020-01-15 11:05:47.956318 TRACE [mbedtls] [/home001/moon.jung/anjay_master/mbedtls/library/ssl_tls.c:4973]: mbedtls_ssl_fetch_input() returned -26624 (-0x6800)
2020-01-15 11:05:47.956331 TRACE [mbedtls] [/home001/moon.jung/anjay_master/mbedtls/library/ssl_tls.c:4344]: ssl_get_next_record() returned -26624 (-0x6800)
2020-01-15 11:05:47.956343 TRACE [mbedtls] [/home001/moon.jung/anjay_master/mbedtls/library/ssl_tls.c:5906]: mbedtls_ssl_read_record() returned -26624 (-0x6800)
2020-01-15 11:05:47.956355 TRACE [mbedtls] [/home001/moon.jung/anjay_master/mbedtls/library/ssl_tls.c:8094]: <= handshake
2020-01-15 11:05:47.956379 ERROR [avs_net] [/home001/moon.jung/anjay_master/anjay/deps/avs_commons/net/src/mbedtls/mbedtls.c:743]: handshake failed: -26624
2020-01-15 11:05:47.956395 TRACE [mbedtls] [/home001/moon.jung/anjay_master/mbedtls/library/ssl_tls.c:8934]: => free
2020-01-15 11:05:47.956438 TRACE [mbedtls] [/home001/moon.jung/anjay_master/mbedtls/library/ssl_tls.c:8999]: <= free
2020-01-15 11:05:47.956461 ERROR [anjay] [/home001/moon.jung/anjay_master/anjay/src/servers/connection_ip.c:86]: could not connect to leshan.eclipseprojects.io:5684
2020-01-15 11:05:47.956476 DEBUG [coap_stream] [/home001/moon.jung/anjay_master/anjay/deps/avs_coap/src/streaming/streaming_client.c:81]: coap_stream state: UNINITIALIZED -> UNINITIALIZED
2020-01-15 11:05:47.956489 TRACE [anjay] [/home001/moon.jung/anjay_master/anjay/src/servers/activate.c:120]: could not initialize sockets for SSID 1
2020-01-15 11:05:47.958036 DEBUG [anjay] [/home001/moon.jung/anjay_master/anjay/src/servers/activate.c:60]: Non-Bootstrap Server 1: not reachable.

Support for mbed-os?

Hi, I want to use this library to connect a microcontroller running mbed-os to a generic lwm2m server (e.g Leshan). Do you have any plan of making this library works with mbed-os? Thank you!

Segmentation fault due to 'use after free' caused by on_network_error()

The following flow triggers "Segmentation fault":
trigger_observe()->flush_next_unsent()->on_entry_flushed()->on_network_error()->_anjay_server_on_failure()

anjay_observe_connection_entry_t pointer is not valid anymore after _anjay_server_on_failure(). This routine calls _anjay_observe_cleanup_connection() which in turn releases allocated memroy for currently used anjay_observe_connection_entry_t structure.

In my case I have segmentation fault in cleanup_serialization_state()->_anjay_output_ctx_destroy() because conn->serialization_state.out_ctx points to invalid memory.

This segmentation fault is sporadic because released memory can be partially valid after free() some time. However, it can be reproduced every time if the following libc feature was enabled:
export MALLOC_PERTURB_=255

I can reproduce it on 2.2.1, but most probably 2.4.2 has this issue as well.

Cannot build Anjay 1.15.2 for STM32

Hi! I'm not sure if I'm doing something wrong, but I can't build Anjay with version 1.15.2 for STM32 on Mac. Basically the problem is with avs_commons:

[  6%] Built target avs_utils
[  8%] Built target avs_rbtree
[  9%] Built target avs_list
[  9%] Building C object avs_commons/git/compat/threading/src/atomic_spinlock/CMakeFiles/avs_compat_threading_atomic_spinlock.dir/condvar.c.obj
In file included from /Users/kamildoleglo/CLionProjects/Anjay/avs_commons/git/compat/threading/src/atomic_spinlock/condvar.c:17:
/Users/kamildoleglo/CLionProjects/Anjay/avs_commons/git/config/avs_commons_posix_config.h:88:11: fatal error: sys/socket.h: No such file or directory
 # include <sys/socket.h>
           ^~~~~~~~~~~~~~

I use a toolchain with arm-none-eabi-gcc compiler. The toolchain is almost the same as in your tutorial but the target is CortexM4.

Anjay version 1.14.2 compiles successfully, that's why I file this issue.
There's probably some option for disabling POSIX support but I can't find it nor the documentation for disabling it

How to use NUCLEO-L476rg

Hello there,

I am a beginner in using Anjay and I have a NUCLEO-L476 board with FreeRTOS and also a wiznet5100 board. How can I use Anjay on it?

Thank you for your support.

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.