Skip to content

Commit 3ba32ac

Browse files
committed
Anjay 3.8.0
BREAKING CHANGES: - Timeout in case of sending a Confirmable Notification does not cancel the observation anymore by default. Features: - Added a ``connection_error_is_registration_failure`` configuration option that allows handling connection errors as Register failures, including the automatic retry mechanism - Added experimental server connection status API. Improvements: - (commercial version only) Changed MSISDN matching method in SMS binding feature to allow handling messages with Short Codes as originating number Bugfixes: - Fixed a corner case in which a connection error during a non-first Register attempt could cause uncontrolled infinite retries - Fixed a bug in demo of Advanced Firmware Update module that prevented proper handling of security config for targets other than APP - Fixed a bug that caused anjay_next_planned_notify_trigger family APIs to return an invalid value after canceling observations
1 parent fc26744 commit 3ba32ac

File tree

59 files changed

+1223
-206
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1223
-206
lines changed

CHANGELOG.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,33 @@
11
# Changelog
22

3+
## 3.8.0 (May 28th, 2024)
4+
5+
### BREAKING CHANGES
6+
7+
- Timeout in case of sending a Confirmable Notification does not cancel the
8+
observation anymore by default.
9+
10+
### Features
11+
12+
- Added a ``connection_error_is_registration_failure`` configuration option that
13+
allows handling connection errors as Register failures, including the
14+
automatic retry mechanism
15+
- Added experimental server connection status API.
16+
17+
### Improvements
18+
19+
- (commercial version only) Changed MSISDN matching method in SMS binding
20+
feature to allow handling messages with Short Codes as originating number
21+
22+
### Bugfixes
23+
24+
- Fixed a corner case in which a connection error during a non-first Register
25+
attempt could cause uncontrolled infinite retries
26+
- Fixed a bug in demo of Advanced Firmware Update module that prevented
27+
proper handling of security config for targets other than APP
28+
- Fixed a bug that caused anjay_next_planned_notify_trigger family APIs to
29+
return an invalid value after canceling observations
30+
331
## 3.7.0 (February 16th, 2024)
432

533
### Features

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
cmake_minimum_required(VERSION 3.6.0)
99

1010
project(anjay C)
11-
set(ANJAY_VERSION "3.7.0" CACHE STRING "Anjay library version")
11+
set(ANJAY_VERSION "3.8.0" CACHE STRING "Anjay library version")
1212
set(ANJAY_BINARY_VERSION 1.0.0)
1313

1414
set(ANJAY_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
@@ -210,6 +210,7 @@ else()
210210
endif()
211211

212212
option(WITH_AVS_COAP_TCP "Enable CoAP over TCP support" "${WITH_LWM2M11}")
213+
option(WITH_CONN_STATUS_API "Enable support for the experimental anjay_get_server_connection_status() API and related callback." ON)
213214

214215

215216

@@ -557,6 +558,7 @@ set(ANJAY_WITH_SECURITY_STRUCTURED "${WITH_SECURITY_STRUCTURED}")
557558
set(ANJAY_WITH_SEND "${WITH_SEND}")
558559
set(ANJAY_WITH_SENML_JSON "${WITH_SENML_JSON}")
559560
set(ANJAY_WITHOUT_QUEUE_MODE_AUTOCLOSE "${WITHOUT_QUEUE_MODE_AUTOCLOSE}")
561+
set(ANJAY_WITH_CONN_STATUS_API "${WITH_CONN_STATUS_API}")
560562

561563
configure_file(include_public/anjay/anjay_config.h.in
562564
include_public/anjay/anjay_config.h)

demo/advanced_firmware_update.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,7 @@ int advanced_firmware_update_install(
12061206
(int) state.result);
12071207
result = advanced_firmware_update_additional_image_install(
12081208
anjay, fw_logic_add_inst->iid, fw_table, &state,
1209-
ADD_IMG_NAMES[i]);
1209+
security_info, ADD_IMG_NAMES[i]);
12101210

12111211
if (result) {
12121212
demo_log(ERROR, "AFU instance %u install failed",
@@ -1261,3 +1261,17 @@ void advanced_firmware_update_uninstall(advanced_fw_update_logic_t *fw_table) {
12611261
afu_logic_destroy(&fw_table[i]);
12621262
}
12631263
}
1264+
1265+
int advanced_firmware_update_get_security_config(
1266+
anjay_iid_t iid,
1267+
void *fw_,
1268+
anjay_security_config_t *out_security_config,
1269+
const char *download_uri) {
1270+
(void) iid;
1271+
advanced_fw_update_logic_t *fw_table = (advanced_fw_update_logic_t *) fw_;
1272+
advanced_fw_update_logic_t *fw = &fw_table[FW_UPDATE_IID_APP];
1273+
(void) download_uri;
1274+
memset(out_security_config, 0, sizeof(*out_security_config));
1275+
out_security_config->security_info = fw->security_info;
1276+
return 0;
1277+
}

demo/advanced_firmware_update.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ int advanced_firmware_update_additional_image_install(
102102
anjay_iid_t iid,
103103
advanced_fw_update_logic_t *fw_table,
104104
anjay_advanced_fw_update_initial_state_t *init_state,
105+
const avs_net_security_info_t *security_info,
105106
const char *component_name);
106107

107108
const char *
@@ -143,6 +144,12 @@ int fw_update_common_perform_upgrade(
143144
size_t requested_supplemental_iids_count);
144145
int fw_update_common_maybe_create_firmware_file(advanced_fw_update_logic_t *fw);
145146

147+
int advanced_firmware_update_get_security_config(
148+
anjay_iid_t iid,
149+
void *fw_,
150+
anjay_security_config_t *out_security_config,
151+
const char *download_uri);
152+
146153
typedef struct {
147154
anjay_advanced_fw_update_state_t inst_states[FW_UPDATE_IID_IMAGE_SLOTS];
148155
anjay_advanced_fw_update_result_t inst_results[FW_UPDATE_IID_IMAGE_SLOTS];

demo/advanced_firmware_update_addimg.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ static int update(advanced_fw_update_logic_t *fw) {
9292
return 0;
9393
}
9494

95-
static const anjay_advanced_fw_update_handlers_t handlers = {
95+
static anjay_advanced_fw_update_handlers_t handlers = {
9696
.stream_open = fw_stream_open,
9797
.stream_write = fw_update_common_write,
9898
.stream_finish = fw_update_common_finish,
@@ -107,10 +107,19 @@ int advanced_firmware_update_additional_image_install(
107107
anjay_iid_t iid,
108108
advanced_fw_update_logic_t *fw_table,
109109
anjay_advanced_fw_update_initial_state_t *init_state,
110+
const avs_net_security_info_t *security_info,
110111
const char *component_name) {
111112
advanced_fw_update_logic_t *fw_logic = &fw_table[iid];
112113
memcpy(fw_logic->current_ver, VER_DEFAULT, sizeof(VER_DEFAULT));
113114
fw_global = fw_logic;
115+
if (security_info) {
116+
memcpy(&fw_logic->security_info, security_info,
117+
sizeof(fw_logic->security_info));
118+
handlers.get_security_config =
119+
advanced_firmware_update_get_security_config;
120+
} else {
121+
handlers.get_security_config = NULL;
122+
}
114123
int result =
115124
anjay_advanced_fw_update_instance_add(anjay, fw_logic->iid,
116125
component_name, &handlers,

demo/advanced_firmware_update_app.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -189,19 +189,6 @@ static anjay_advanced_fw_update_handlers_t handlers = {
189189
.perform_upgrade = fw_update_common_perform_upgrade
190190
};
191191

192-
static int fw_get_security_config(anjay_iid_t iid,
193-
void *fw_,
194-
anjay_security_config_t *out_security_config,
195-
const char *download_uri) {
196-
(void) iid;
197-
advanced_fw_update_logic_t *fw_table = (advanced_fw_update_logic_t *) fw_;
198-
advanced_fw_update_logic_t *fw = &fw_table[FW_UPDATE_IID_APP];
199-
(void) download_uri;
200-
memset(out_security_config, 0, sizeof(*out_security_config));
201-
out_security_config->security_info = fw->security_info;
202-
return 0;
203-
}
204-
205192
int advanced_firmware_update_application_install(
206193
anjay_t *anjay,
207194
advanced_fw_update_logic_t *fw_table,
@@ -215,7 +202,8 @@ int advanced_firmware_update_application_install(
215202
if (security_info) {
216203
memcpy(&fw_logic->security_info, security_info,
217204
sizeof(fw_logic->security_info));
218-
handlers.get_security_config = fw_get_security_config;
205+
handlers.get_security_config =
206+
advanced_firmware_update_get_security_config;
219207
} else {
220208
handlers.get_security_config = NULL;
221209
}

demo/demo.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,21 @@ static void reschedule_notify_time_dependent(anjay_demo_t *demo) {
498498
}
499499
}
500500

501+
// !defined(ANJAY_WITH_CONN_STATUS_API)
502+
503+
#ifdef ANJAY_WITH_CONN_STATUS_API
504+
static void
505+
server_connection_status_change_callback(void *demo_,
506+
anjay_t *anjay,
507+
anjay_ssid_t ssid,
508+
anjay_server_conn_status_t status) {
509+
(void) demo_;
510+
(void) anjay;
511+
demo_log(INFO, "Current status of the server with SSID %d is: %s", ssid,
512+
translate_server_connection_status_enum_to_str(status));
513+
}
514+
#endif // ANJAY_WITH_CONN_STATUS_API
515+
501516
static int demo_init(anjay_demo_t *demo, cmdline_args_t *cmdline_args) {
502517
demo->allocated_buffers = cmdline_args->allocated_buffers;
503518
cmdline_args->allocated_buffers = NULL;
@@ -544,6 +559,8 @@ static int demo_init(anjay_demo_t *demo, cmdline_args_t *cmdline_args) {
544559
.update_immediately_on_dm_change =
545560
cmdline_args->update_immediately_on_dm_change,
546561
.enable_self_notify = cmdline_args->enable_self_notify,
562+
.connection_error_is_registration_failure =
563+
cmdline_args->connection_error_is_registration_failure,
547564
.default_tls_ciphersuites = {
548565
.ids = cmdline_args->default_ciphersuites,
549566
.num_ids = cmdline_args->default_ciphersuites_count
@@ -555,6 +572,10 @@ static int demo_init(anjay_demo_t *demo, cmdline_args_t *cmdline_args) {
555572
#if defined(ANJAY_WITH_LWM2M11) && defined(WITH_AVS_COAP_TCP)
556573
.coap_tcp_request_timeout = cmdline_args->tcp_request_timeout,
557574
#endif // defined(ANJAY_WITH_LWM2M11) && defined(WITH_AVS_COAP_TCP)
575+
#ifdef ANJAY_WITH_CONN_STATUS_API
576+
.server_connection_status_cb = server_connection_status_change_callback,
577+
.server_connection_status_cb_arg = demo,
578+
#endif // ANJAY_WITH_CONN_STATUS_API
558579
};
559580

560581
#ifdef ANJAY_WITH_LWM2M11

demo/demo_args.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ static const cmdline_args_t DEFAULT_CMDLINE_ARGS = {
131131
.prefer_hierarchical_formats = false,
132132
.update_immediately_on_dm_change = false,
133133
.enable_self_notify = false,
134+
.connection_error_is_registration_failure = false,
134135
.prefer_same_socket_downloads = false,
135136
};
136137

@@ -594,6 +595,9 @@ static void print_help(const struct option *options) {
594595
"over CoAP+TCP and HTTP" },
595596
# endif // ANJAY_WITH_DOWNLOADER
596597
#endif // ANJAY_WITH_MODULE_SW_MGMT
598+
{ 348, NULL, NULL,
599+
"Treat failures of the \"connect\" socket operation (e.g. (D)TLS "
600+
"handshake failures) as a failed LwM2M Register operation." },
597601
};
598602

599603
const size_t screen_width = get_screen_width();
@@ -994,6 +998,7 @@ int demo_parse_argv(cmdline_args_t *parsed_args, int argc, char *argv[]) {
994998
{ "sw-mgmt-tcp-request-timeout", required_argument, 0, 347 },
995999
# endif // ANJAY_WITH_DOWNLOADER
9961000
#endif // ANJAY_WITH_MODULE_SW_MGMT
1001+
{ "connection-error-is-registration-failure", no_argument, 0, 348 },
9971002
{ 0, 0, 0, 0 }
9981003
// clang-format on
9991004
};
@@ -2001,6 +2006,9 @@ int demo_parse_argv(cmdline_args_t *parsed_args, int argc, char *argv[]) {
20012006
}
20022007
# endif // ANJAY_WITH_DOWNLOADER
20032008
#endif // ANJAY_WITH_MODULE_SW_MGMT
2009+
case 348:
2010+
parsed_args->connection_error_is_registration_failure = true;
2011+
break;
20042012
case 0:
20052013
goto process;
20062014
}

demo/demo_args.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ typedef struct cmdline_args {
168168
bool prefer_hierarchical_formats;
169169
bool update_immediately_on_dm_change;
170170
bool enable_self_notify;
171+
bool connection_error_is_registration_failure;
171172
bool use_connection_id;
172173
bool start_offline;
173174

demo/demo_cmds.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,6 +1430,24 @@ static void cmd_last_communication_time(anjay_demo_t *demo,
14301430
}
14311431
#endif // ANJAY_WITH_COMMUNICATION_TIMESTAMP_API
14321432

1433+
#ifdef ANJAY_WITH_CONN_STATUS_API
1434+
static void cmd_get_server_connection_status(anjay_demo_t *demo,
1435+
const char *args_string) {
1436+
anjay_ssid_t ssid = ANJAY_SSID_ANY;
1437+
anjay_server_conn_status_t result;
1438+
1439+
if (*args_string && parse_ssid(args_string, &ssid)) {
1440+
demo_log(ERROR, "invalid Short Server ID: %s", args_string);
1441+
return;
1442+
}
1443+
1444+
result = anjay_get_server_connection_status(demo->anjay, ssid);
1445+
1446+
demo_log(INFO, "Current server connection status: %s",
1447+
translate_server_connection_status_enum_to_str(result));
1448+
}
1449+
#endif // ANJAY_WITH_CONN_STATUS_API
1450+
14331451
static void cmd_help(anjay_demo_t *demo, const char *args_string);
14341452

14351453
struct cmd_handler_def {
@@ -1665,6 +1683,12 @@ static const struct cmd_handler_def COMMAND_HANDLERS[] = {
16651683
"no argument specified) or a given server (if numeric SSID "
16661684
"argument given)."),
16671685
#endif // ANJAY_WITH_COMMUNICATION_TIMESTAMP_API
1686+
#ifdef ANJAY_WITH_CONN_STATUS_API
1687+
CMD_HANDLER("get-server-connection-status", "[SSID]",
1688+
cmd_get_server_connection_status,
1689+
"Displays current connection status for the server with SSID "
1690+
"specified by the argument."),
1691+
#endif // ANJAY_WITH_CONN_STATUS_API
16681692
CMD_HANDLER("help", "", cmd_help, "Prints this message")
16691693
// clang-format on
16701694
};

0 commit comments

Comments
 (0)