Skip to content

Commit

Permalink
Anjay 3.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Kwiatkowski committed Oct 9, 2023
1 parent 0acafc4 commit 67e0d5a
Show file tree
Hide file tree
Showing 64 changed files with 1,009 additions and 281 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/anjay-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on: [push]
jobs:
ubuntu1804-compilers-test:
runs-on: ubuntu-latest
container: avsystemembedded/anjay-travis:ubuntu-18.04-1.2
container: avsystemembedded/anjay-travis:ubuntu-18.04-2.0
env:
CC: ${{ matrix.CC }}
CXX: ${{ matrix.CXX }}
Expand All @@ -37,7 +37,7 @@ jobs:

ubuntu2004-compilers-test:
runs-on: ubuntu-latest
container: avsystemembedded/anjay-travis:ubuntu-20.04-1.2
container: avsystemembedded/anjay-travis:ubuntu-20.04-2.0
env:
CC: ${{ matrix.CC }}
CXX: ${{ matrix.CXX }}
Expand Down Expand Up @@ -68,7 +68,7 @@ jobs:

ubuntu2204-compilers-test:
runs-on: ubuntu-latest
container: avsystemembedded/anjay-travis:ubuntu-22.04-1.2
container: avsystemembedded/anjay-travis:ubuntu-22.04-2.0
env:
CC: ${{ matrix.CC }}
CXX: ${{ matrix.CXX }}
Expand Down Expand Up @@ -110,7 +110,7 @@ jobs:

rockylinux9-compilers-test:
runs-on: ubuntu-latest
container: avsystemembedded/anjay-travis:rockylinux-9-1.2
container: avsystemembedded/anjay-travis:rockylinux-9-2.0
env:
CC: ${{ matrix.CC }}
CXX: ${{ matrix.CXX }}
Expand Down Expand Up @@ -153,7 +153,7 @@ jobs:
# NOTE: try the brew install command twice to work around "brew link" errors
- run: INSTALL_CMD="brew install openssl mbedtls $COMPILER_VERSION"; $INSTALL_CMD || $INSTALL_CMD
# NOTE: The above command may have installed a new version of Python, that's why we launch it weirdly
- run: /usr/bin/env python3 -m pip install sphinx sphinx-rtd-theme linuxdoc cbor2 aiocoap cryptography packaging requests wheel
- run: /usr/bin/env python3 -m pip install -r requirements.txt
- run: env JAVA_HOME="$JAVA_HOME_17_X64" ./devconfig --with-asan --without-analysis --no-examples -DWITH_VALGRIND_TRACK_ORIGINS=OFF -DWITH_URL_CHECK=OFF -DWITH_IPV6=OFF
- run: LC_ALL=en_US.UTF-8 make -j
- run: LC_ALL=en_US.UTF-8 make check
Expand Down
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# Changelog

## 3.6.0 (October 9th, 2023)

### Features

- Added APIs for setting custom timeouts for downloads performed over CoAP+TCP
and HTTP, including firmware update downloads
- Added `requirements.txt` file to manage Python dependencies more efficiently

### Improvements
- Clarified documentation on behavior of Firmware Update and Advanced Firmware
Update modules when ``anjay_fw_update_get_security_config_t`` and
``anjay_advanced_fw_update_perform_upgrade_t`` callbacks, respectively, are
not defined.
- Added compilation flag that disables all composite operations

### Bugfixes

- Updated integration tests so that they pass on macOS
- Fix abort scenario in Advanced Firmware Update module

## 3.5.0 (September 7th, 2023)

### BREAKING CHANGES
Expand Down Expand Up @@ -32,6 +52,7 @@
require extra care to maintain thread safety
- Removed ``const`` qualifier from ``MAKE_URI_PATH()`` compound literal which
triggers a plausible compiler bug on IAR EWARM v9.30
- Reading SNI from the Security Object for the FOTA download connection

### Bugfixes

Expand Down
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
cmake_minimum_required(VERSION 3.6.0)

project(anjay C)
set(ANJAY_VERSION "3.5.0" CACHE STRING "Anjay library version")
set(ANJAY_VERSION "3.6.0" CACHE STRING "Anjay library version")
set(ANJAY_BINARY_VERSION 1.0.0)

set(ANJAY_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
Expand Down Expand Up @@ -268,6 +268,7 @@ option(WITH_LWM2M_JSON "Enable support for LwM2M 1.0 JSON (output only)" ON)
option(WITHOUT_PLAINTEXT "Disable support for Plain Text content format" OFF)
option(WITHOUT_DEREGISTER "Disable use of the Deregister message" OFF)
option(WITHOUT_IP_STICKINESS "Disable support for IP stickiness" OFF)
option(WITHOUT_COMPOSITE_OPERATIONS "Disable composite operations" OFF)
cmake_dependent_option(WITH_SENML_JSON "Enable support for SenML JSON content format" ON WITH_LWM2M11 OFF)
cmake_dependent_option(WITH_CBOR "Enable support for CBOR and SenML CBOR content formats" ON WITH_LWM2M11 OFF)
cmake_dependent_option(WITH_SEND "Enable support for LwM2M 1.1 Send operation" ON "WITH_CBOR OR WITH_SENML_JSON" OFF)
Expand Down Expand Up @@ -524,6 +525,7 @@ set(ANJAY_WITHOUT_TLV "${WITHOUT_TLV}")
set(ANJAY_WITHOUT_PLAINTEXT "${WITHOUT_PLAINTEXT}")
set(ANJAY_WITHOUT_DEREGISTER "${WITHOUT_DEREGISTER}")
set(ANJAY_WITHOUT_IP_STICKINESS "${WITHOUT_IP_STICKINESS}")
set(ANJAY_WITHOUT_COMPOSITE_OPERATIONS "${WITHOUT_COMPOSITE_OPERATIONS}")
set(ANJAY_WITH_MODULE_ACCESS_CONTROL "${WITH_MODULE_access_control}")
set(ANJAY_WITH_MODULE_IPSO_OBJECTS "${WITH_MODULE_ipso_objects}")
set(ANJAY_WITH_MODULE_FW_UPDATE "${WITH_MODULE_fw_update}")
Expand Down
9 changes: 5 additions & 4 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,11 @@ Make use of the `coverage script <tools/coverage>`_ to generate a code coverage

Before submitting your code, run the whole test suite (``make check``) to ensure that it does not introduce regressions. Use ``valgrind`` and Address Sanitizer to check for memory corruption errors.

Running tests on Ubuntu 16.04 or later: ::
Running tests on Ubuntu 20.04 or later: ::

# Install these for tests:
sudo apt-get install libpython3-dev libssl-dev python3 python3-cryptography python3-jinja2 python3-sphinx python3-requests clang valgrind clang-tools
sudo apt-get install python3-pip git libmbedtls-dev libssl-dev zlib1g-dev python3 libpython3-dev wget valgrind curl cmake build-essential tshark
pip3 install -U -r requirements.txt
# Configure and run check target
./devconfig && make check

Expand All @@ -119,7 +120,7 @@ Running tests on CentOS 7 or later: ::
# Use update-alternatives to create a /usr/bin/python3 symlink with priority 0
# (lowest possible)
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 0
sudo python3 -m pip install cryptography jinja2 requests sphinx sphinx_rtd_theme
sudo python3 -m pip install -r requirements.txt

# Configure and run check target
# NOTE: clang-3.4 static analyzer (default version for CentOS) gives false
Expand All @@ -130,7 +131,7 @@ Running tests on macOS Sierra or later: ::

# Install these for tests:
brew install python3 openssl llvm
pip3 install cryptography sphinx sphinx_rtd_theme requests
pip3 install -r requirements.txt

# Configure and run check target:
# if the scan-build script is located somewhere else, then you need to
Expand Down
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ The project has been created and is actively maintained by [AVSystem](https://ww
* [About OMA LwM2M](#about-oma-lwm2m)
* [Quickstart guide](#quickstart-guide)
* [Dependencies](#dependencies)
* [Ubuntu 18.04 LTS / Raspbian Buster or later](#ubuntu-1804-lts--raspbian-buster-or-later)
* [Ubuntu 20.04 LTS / Raspbian Buster or later](#ubuntu-2004-lts--raspbian-buster-or-later)
* [CentOS 7 or later](#centos-7-or-later)
* [macOS Sierra or later, with Homebrew](#macos-sierra-or-later-with-homebrew)
* [Python dependencies](#python-dependencies)
* [Running the demo client](#running-the-demo-client)
* [Detailed compilation guide](#detailed-compilation-guide)
* [Building using CMake](#building-using-cmake)
Expand Down Expand Up @@ -145,7 +146,7 @@ More details about OMA LwM2M: [Brief introduction to LwM2M](https://AVSystem.git
- [Doxygen](http://www.doxygen.nl/),
- [Sphinx](https://www.sphinx-doc.org/en/master/).

#### Ubuntu 18.04 LTS / Raspbian Buster or later
#### Ubuntu 20.04 LTS / Raspbian Buster or later

<!-- deps_install_begin -->
``` sh
Expand All @@ -167,6 +168,15 @@ sudo yum install -y which git make cmake3 mbedtls-devel gcc gcc-c++ zlib-devel
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:
```sh
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](https://www.avsystem.com/products/coiote-iot-device-management-platform/) where you can use the basic LwM2M server functionality for free.
Expand Down Expand Up @@ -287,12 +297,14 @@ docker run -it anjay

## Embedded operating systems ports

If you want to use Anjay on Mbed OS, Zephyr OS, FreeRTOS or ESP-IDF check our demo
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:
- [Anjay-mbedos-client](https://github.com/AVSystem/Anjay-mbedos-client) (uses [Anjay-mbedos](https://github.com/AVSystem/Anjay-mbedos) integration layer)
- [Anjay-zephyr-client](https://github.com/AVSystem/Anjay-zephyr-client) (uses [Anjay-zephyr](https://github.com/AVSystem/Anjay-zephyr) integration layer)
- [Anjay-freertos-client](https://github.com/AVSystem/Anjay-freertos-client)
- [Anjay-esp32-client](https://github.com/AVSystem/Anjay-esp32-client)
- [Anjay-stm32-azurertos-client](https://github.com/AVSystem/Anjay-stm32-azurertos-client)
- [Anjay-esp32-client](https://github.com/AVSystem/Anjay-esp32-client) (uses [Anjay-esp-idf](https://github.com/AVSystem/Anjay-esp-idf) integration layer)
- [Anjay-pico-client](https://github.com/AVSystem/Anjay-pico-client) (uses FreeRTOS Kernel)

## Raspberry Pi client

Expand Down
3 changes: 2 additions & 1 deletion demo/advanced_firmware_update.c
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,7 @@ int advanced_firmware_update_install(
const char *persistence_file,
const avs_net_security_info_t *security_info,
const avs_coap_udp_tx_params_t *tx_params,
avs_time_duration_t tcp_request_timeout,
anjay_advanced_fw_update_result_t delayed_result,
bool prefer_same_socket_downloads,
const char *original_img_file_path,
Expand Down Expand Up @@ -1173,7 +1174,7 @@ int advanced_firmware_update_install(
}
result = advanced_firmware_update_application_install(
anjay, fw_table, &state, security_info, tx_params,
auto_suspend);
tcp_request_timeout, auto_suspend);
if (result) {
demo_log(ERROR, "AFU instance %u install failed",
FW_UPDATE_IID_APP);
Expand Down
3 changes: 3 additions & 0 deletions demo/advanced_firmware_update.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ struct advanced_fw_update_logic {
FILE *stream;
avs_net_security_info_t security_info;
avs_coap_udp_tx_params_t coap_tx_params;
avs_time_duration_t tcp_request_timeout;
bool auto_suspend;
int (*check_yourself)(struct advanced_fw_update_logic *);
int (*update_yourself)(struct advanced_fw_update_logic *);
Expand All @@ -88,6 +89,7 @@ int advanced_firmware_update_application_install(
anjay_advanced_fw_update_initial_state_t *init_state,
const avs_net_security_info_t *security_info,
const avs_coap_udp_tx_params_t *tx_params,
avs_time_duration_t tcp_request_timeout,
bool auto_suspend);
int advanced_firmware_update_app_perform(advanced_fw_update_logic_t *fw);
const char *advanced_firmware_update_app_get_pkg_version(anjay_iid_t iid,
Expand Down Expand Up @@ -115,6 +117,7 @@ int advanced_firmware_update_install(
const char *persistence_file,
const avs_net_security_info_t *security_info,
const avs_coap_udp_tx_params_t *tx_params,
avs_time_duration_t tcp_request_timeout,
anjay_advanced_fw_update_result_t delayed_result,
bool prefer_same_socket_downloads,
const char *original_img_file_path,
Expand Down
18 changes: 18 additions & 0 deletions demo/advanced_firmware_update_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,16 @@ static avs_coap_udp_tx_params_t fw_get_coap_tx_params(
return fw->coap_tx_params;
}

static avs_time_duration_t fw_get_tcp_request_timeout(
anjay_iid_t iid, void *user_ptr, const char *download_uri) {
(void) iid;
(void) download_uri;
advanced_fw_update_logic_t *fw_table =
(advanced_fw_update_logic_t *) user_ptr;
advanced_fw_update_logic_t *fw = &fw_table[FW_UPDATE_IID_APP];
return fw->tcp_request_timeout;
}

static anjay_advanced_fw_update_handlers_t handlers = {
.stream_open = fw_stream_open,
.stream_write = fw_update_common_write,
Expand Down Expand Up @@ -198,6 +208,7 @@ int advanced_firmware_update_application_install(
anjay_advanced_fw_update_initial_state_t *init_state,
const avs_net_security_info_t *security_info,
const avs_coap_udp_tx_params_t *tx_params,
avs_time_duration_t tcp_request_timeout,
bool auto_suspend) {
advanced_fw_update_logic_t *fw_logic = &fw_table[FW_UPDATE_IID_APP];

Expand All @@ -221,6 +232,13 @@ int advanced_firmware_update_application_install(
handlers.get_coap_tx_params = NULL;
}

if (avs_time_duration_valid(tcp_request_timeout)) {
fw_logic->tcp_request_timeout = tcp_request_timeout;
handlers.get_tcp_request_timeout = fw_get_tcp_request_timeout;
} else {
handlers.get_tcp_request_timeout = NULL;
}

fw_global = fw_logic;
int result = anjay_advanced_fw_update_instance_add(anjay,
fw_logic->iid,
Expand Down
2 changes: 2 additions & 0 deletions demo/demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,7 @@ static int demo_init(anjay_demo_t *demo, cmdline_args_t *cmdline_args) {
cmdline_args->fwu_tx_params_modified
? &cmdline_args->fwu_tx_params
: NULL,
cmdline_args->fwu_tcp_request_timeout,
cmdline_args->fw_update_delayed_result,
cmdline_args->prefer_same_socket_downloads,
# ifdef ANJAY_WITH_SEND
Expand All @@ -764,6 +765,7 @@ static int demo_init(anjay_demo_t *demo, cmdline_args_t *cmdline_args) {
cmdline_args->advanced_fwu_tx_params_modified
? &cmdline_args->advanced_fwu_tx_params
: NULL,
cmdline_args->advanced_fwu_tcp_request_timeout,
cmdline_args->advanced_fw_update_delayed_result,
cmdline_args->prefer_same_socket_downloads,
cmdline_args->original_img_file_path,
Expand Down
47 changes: 47 additions & 0 deletions demo/demo_args.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,13 @@ static const cmdline_args_t DEFAULT_CMDLINE_ARGS = {
#ifdef ANJAY_WITH_MODULE_FW_UPDATE
.fwu_tx_params_modified = false,
.fwu_tx_params = ANJAY_COAP_DEFAULT_UDP_TX_PARAMS,
.fwu_tcp_request_timeout = { 0, -1 },
// AVS_TIME_DURATION_INVALID
#endif // ANJAY_WITH_MODULE_FW_UPDATE
#ifdef ANJAY_WITH_MODULE_ADVANCED_FW_UPDATE
.advanced_fwu_tx_params_modified = false,
.advanced_fwu_tx_params = ANJAY_COAP_DEFAULT_UDP_TX_PARAMS,
.advanced_fwu_tcp_request_timeout = { 0, -1 },
#endif // ANJAY_WITH_MODULE_ADVANCED_FW_UPDATE
#ifdef ANJAY_WITH_LWM2M11
.lwm2m_version_config = {
Expand Down Expand Up @@ -504,6 +507,16 @@ static void print_help(const struct option *options) {
"with the specified key (provided as hexlified string); this "
"argument is used by Advanced Firmware Update and must be used "
"together with --afu-psk-identity" },
#endif // ANJAY_WITH_MODULE_ADVANCED_FW_UPDATE
#ifdef ANJAY_WITH_MODULE_FW_UPDATE
{ 333, "TIMEOUT", NULL,
"Request timeout (in seconds) to use for firmware updates performed "
"over CoAP+TCP and HTTP" },
#endif // ANJAY_WITH_MODULE_FW_UPDATE
#ifdef ANJAY_WITH_MODULE_ADVANCED_FW_UPDATE
{ 334, "TIMEOUT", NULL,
"Request timeout (in seconds) to use for Advanced Firmware Update "
"downloads performed over CoAP+TCP and HTTP" },
#endif // ANJAY_WITH_MODULE_ADVANCED_FW_UPDATE
};

Expand Down Expand Up @@ -879,6 +892,12 @@ int demo_parse_argv(cmdline_args_t *parsed_args, int argc, char *argv[]) {
{ "afu-auto-suspend", no_argument, 0, 330 },
{ "afu-psk-identity", required_argument, 0, 331 },
{ "afu-psk-key", required_argument, 0, 332 },
#endif // ANJAY_WITH_MODULE_ADVANCED_FW_UPDATE
#ifdef ANJAY_WITH_MODULE_FW_UPDATE
{ "fwu-tcp-request-timeout", required_argument, 0, 333 },
#endif // ANJAY_WITH_MODULE_FW_UPDATE
#ifdef ANJAY_WITH_MODULE_ADVANCED_FW_UPDATE
{ "afu-tcp-request-timeout", required_argument, 0, 334 },
#endif // ANJAY_WITH_MODULE_ADVANCED_FW_UPDATE
{ 0, 0, 0, 0 }
// clang-format on
Expand Down Expand Up @@ -1689,6 +1708,34 @@ int demo_parse_argv(cmdline_args_t *parsed_args, int argc, char *argv[]) {
avs_crypto_psk_key_info_from_buffer(psk_buf, psk_size);
break;
}
#endif // ANJAY_WITH_MODULE_ADVANCED_FW_UPDATE
#ifdef ANJAY_WITH_MODULE_FW_UPDATE
case 333: {
double timeout_s;
if (parse_double(optarg, &timeout_s) || !isfinite(timeout_s)
|| timeout_s <= 0.0) {
demo_log(ERROR, "Expected TCP request timeout to be a positive "
"floating point number");
goto finish;
}
parsed_args->fwu_tcp_request_timeout =
avs_time_duration_from_fscalar(timeout_s, AVS_TIME_S);
break;
}
#endif // ANJAY_WITH_MODULE_FW_UPDATE
#ifdef ANJAY_WITH_MODULE_ADVANCED_FW_UPDATE
case 334: {
double timeout_s;
if (parse_double(optarg, &timeout_s) || !isfinite(timeout_s)
|| timeout_s <= 0.0) {
demo_log(ERROR, "Expected TCP request timeout to be a positive "
"floating point number");
goto finish;
}
parsed_args->advanced_fwu_tcp_request_timeout =
avs_time_duration_from_fscalar(timeout_s, AVS_TIME_S);
break;
}
#endif // ANJAY_WITH_MODULE_ADVANCED_FW_UPDATE
case 0:
goto process;
Expand Down
2 changes: 2 additions & 0 deletions demo/demo_args.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ typedef struct cmdline_args {
*/
bool fwu_tx_params_modified;
avs_coap_udp_tx_params_t fwu_tx_params;
avs_time_duration_t fwu_tcp_request_timeout;
#endif // ANJAY_WITH_MODULE_FW_UPDATE
#ifdef ANJAY_WITH_MODULE_ADVANCED_FW_UPDATE
/**
Expand All @@ -123,6 +124,7 @@ typedef struct cmdline_args {
*/
bool advanced_fwu_tx_params_modified;
avs_coap_udp_tx_params_t advanced_fwu_tx_params;
avs_time_duration_t advanced_fwu_tcp_request_timeout;
#endif // ANJAY_WITH_MODULE_ADVANCED_FW_UPDATE
#ifdef ANJAY_WITH_LWM2M11
anjay_lwm2m_version_config_t lwm2m_version_config;
Expand Down
Loading

0 comments on commit 67e0d5a

Please sign in to comment.