Skip to content

Commit 3a2f5d2

Browse files
committed
Anjay-zephyr 3.6.1
Bugfixes: - Added zero initialization for /6 Location Object Resources for the state before catching the first fix in favor of blocking the Read operation Improvements: - Fixed compatibility with newest versions of Zephyr and nRF Connect SDK
1 parent 7363492 commit 3a2f5d2

File tree

13 files changed

+148
-22
lines changed

13 files changed

+148
-22
lines changed

CHANGELOG.md

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

3+
## 3.6.1 (November 21st, 2023)
4+
5+
### Bugfixes
6+
- Added zero initialization for /6 Location Object Resources for the state
7+
before catching the first fix in favor of blocking the Read operation
8+
9+
### Improvements
10+
- Fixed compatibility with newest versions of Zephyr and nRF Connect SDK
11+
312
## 3.5.0 (September 7th, 2023)
413

514
### Features

Kconfig.anjay_zephyr

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ config ANJAY_ZEPHYR_MODEL_NUMBER
2424

2525
config ANJAY_ZEPHYR_VERSION
2626
string "Client Version"
27-
default "3.5.0"
27+
default "3.5.1"
2828

2929
config ANJAY_ZEPHYR_AUTOGENERATE_ENDPOINT_NAME
3030
bool "Autogenerate endpoint name"
@@ -238,6 +238,7 @@ menu "GPS on nRF9160-based devices"
238238
config ANJAY_ZEPHYR_GPS_NRF_A_GPS
239239
bool "Enable A-GPS using Nordic Location Services over LwM2M"
240240
depends on ANJAY_ZEPHYR_GPS_NRF
241+
select NRF_CLOUD_AGNSS
241242
select NRF_CLOUD_AGPS
242243
help
243244
Attempt to retrieve A-GPS data using Nordic Location Services over LwM2M.
@@ -372,6 +373,9 @@ config ANJAY_ZEPHYR_FACTORY_PROVISIONING_INITIAL_FLASH
372373
select MCUMGR_CMD_FS_MGMT
373374
select MCUMGR_SMP_SHELL
374375
select UART_CONSOLE_MCUMGR
376+
select NET_BUF
377+
select ZCBOR
378+
select CRC
375379
help
376380
This option should be used with specially tailored version of the application that
377381
will not perform any normal LwM2M client operation, but instead it will allow to

compat/mbedtls_compat.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@
1515
*/
1616

1717
#include <mbedtls/entropy.h>
18+
#include <mbedtls/platform.h>
1819
#include <mbedtls/timing.h>
1920

2021
#include <avsystem/commons/avs_defs.h>
2122
#include <avsystem/commons/avs_errno.h>
23+
#include <avsystem/commons/avs_memory.h>
2224
#include <avsystem/commons/avs_time.h>
2325

2426
#include <zephyr/drivers/entropy.h>
@@ -108,3 +110,22 @@ void anjay_zephyr_mbedtls_entropy_init__(mbedtls_entropy_context *ctx) {
108110
(void) result;
109111
AVS_ASSERT(!result, "Failed to add entropy source");
110112
}
113+
114+
#if defined(MBEDTLS_PLATFORM_MEMORY) \
115+
&& !(defined(MBEDTLS_PLATFORM_CALLOC_MACRO) \
116+
&& defined(MBEDTLS_PLATFORM_FREE_MACRO)) \
117+
&& !(defined(MBEDTLS_PLATFORM_STD_CALLOC) \
118+
&& defined(MBEDTLS_PLATFORM_STD_FREE)) \
119+
&& !defined(CONFIG_MBEDTLS_ENABLE_HEAP)
120+
static int mbedtls_alloc_init(void) {
121+
mbedtls_platform_set_calloc_free(avs_calloc, avs_free);
122+
return 0;
123+
}
124+
125+
SYS_INIT(mbedtls_alloc_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE);
126+
#endif // defined(MBEDTLS_PLATFORM_MEMORY) &&
127+
// !(defined(MBEDTLS_PLATFORM_CALLOC_MACRO) &&
128+
// defined(MBEDTLS_PLATFORM_FREE_MACRO)) &&
129+
// !(defined(MBEDTLS_PLATFORM_STD_CALLOC) &&
130+
// defined(MBEDTLS_PLATFORM_STD_FREE)) &&
131+
// !defined(CONFIG_MBEDTLS_ENABLE_HEAP)

config/anjay/anjay_config.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,17 @@
739739
#ifdef CONFIG_ANJAY_WITH_MODULE_OSCORE
740740
# define ANJAY_WITH_MODULE_OSCORE
741741
#endif // CONFIG_ANJAY_WITH_MODULE_OSCORE
742+
743+
/**
744+
* If enable Anjay doesn't handle composite operation (read, observe and write).
745+
* Its use makes sense for LWM2M v1.1 upwards.
746+
*
747+
* This flag can be used to reduce the size of the resulting code.
748+
*
749+
* If active, anjay will respond with message code 5.01 Not Implemented to any
750+
* composite type request.
751+
*/
752+
/* #undef ANJAY_WITHOUT_COMPOSITE_OPERATIONS */
742753
/**@}*/
743754

744755
#endif // ANJAY_CONFIG_H

config/avsystem/commons/avs_commons_config.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,18 @@ void anjay_zephyr_mbedtls_entropy_init__(struct mbedtls_entropy_context *ctx);
491491
*/
492492
/* #undef AVS_COMMONS_WITH_MBEDTLS_PSA_ENGINE_PROTECTED_STORAGE */
493493

494+
/**
495+
* Enables use of the <c>psa_generate_random()</c> function as the default
496+
* random number generator when using the Mbed TLS crypto backend, instead of
497+
* CTR-DRBG seeded by the Mbed TLS entropy pool.
498+
*
499+
* It's meaningful only when @ref AVS_COMMONS_WITH_MBEDTLS is enabled. However,
500+
* it is independent from the above PSA engine settings.
501+
*/
502+
#ifdef CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG
503+
# define AVS_COMMONS_WITH_MBEDTLS_PSA_RNG
504+
#endif // CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG
505+
494506
/**
495507
* Is the <c>dlsym()</c> function available?
496508
*

deps/anjay

Submodule anjay updated 104 files

src/afu/nrf9160/afu_nrf9160_modem.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
#include <modem/modem_info.h>
2727
#include <modem/nrf_modem_lib.h>
2828

29+
#if __has_include("ncs_version.h")
30+
# include "ncs_version.h"
31+
#endif // __has_include("ncs_version.h")
32+
2933
#include "afu_nrf9160.h"
3034

3135
#include <pm_config.h>
@@ -230,7 +234,11 @@ void _anjay_zephyr_afu_nrf9160_full_modem_apply(void) {
230234
goto finish;
231235
}
232236

237+
# if NCS_VERSION_NUMBER >= 0x20400
238+
result = nrf_modem_lib_bootloader_init();
239+
# else // NCS_VERSION_NUMBER >= 0x20400
233240
result = nrf_modem_lib_init(BOOTLOADER_MODE);
241+
# endif // NCS_VERSION_NUMBER >= 0x20400
234242
if (result) {
235243
LOG_ERR("Could not initialize nrf_modem_lib in Bootloader (full DFU) "
236244
"mode: %d",
@@ -253,7 +261,11 @@ void _anjay_zephyr_afu_nrf9160_full_modem_apply(void) {
253261
goto finish;
254262
}
255263

264+
# if NCS_VERSION_NUMBER >= 0x20400
265+
result = nrf_modem_lib_init();
266+
# else // NCS_VERSION_NUMBER >= 0x20400
256267
result = nrf_modem_lib_init(NORMAL_MODE);
268+
# endif // NCS_VERSION_NUMBER >= 0x20400
257269
if (result) {
258270
LOG_ERR("Could not reinitialize nrf_modem_lib in normal mode: %d",
259271
result);

src/gps_impl/gps_nrf.c

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
# include "../objects/objects.h"
3737
#endif // CONFIG_ANJAY_ZEPHYR_GPS_NRF_A_GPS
3838

39+
#if __has_include("ncs_version.h")
40+
# include "ncs_version.h"
41+
#endif // __has_include("ncs_version.h")
42+
3943
LOG_MODULE_REGISTER(anjay_zephyr_gps_nrf);
4044

4145
#define INTERRUPTED_FIXES_WARN_THRESHOLD 10
@@ -185,35 +189,62 @@ static void incoming_pvt_work_handler(struct k_work *work) {
185189
}
186190

187191
#ifdef CONFIG_ANJAY_ZEPHYR_GPS_NRF_A_GPS
192+
# if NCS_VERSION_NUMBER < 0x20463
193+
# define nrf_modem_gnss_agnss_data_frame nrf_modem_gnss_agps_data_frame
194+
# define NRF_MODEM_GNSS_AGNSS_GPS_UTC_REQUEST \
195+
NRF_MODEM_GNSS_AGPS_GPS_UTC_REQUEST
196+
# define NRF_MODEM_GNSS_AGNSS_KLOBUCHAR_REQUEST \
197+
NRF_MODEM_GNSS_AGPS_KLOBUCHAR_REQUEST
198+
# define NRF_MODEM_GNSS_AGNSS_NEQUICK_REQUEST \
199+
NRF_MODEM_GNSS_AGPS_NEQUICK_REQUEST
200+
# define NRF_MODEM_GNSS_AGNSS_GPS_SYS_TIME_AND_SV_TOW_REQUEST \
201+
NRF_MODEM_GNSS_AGPS_SYS_TIME_AND_SV_TOW_REQUEST
202+
# define NRF_MODEM_GNSS_AGNSS_POSITION_REQUEST \
203+
NRF_MODEM_GNSS_AGPS_POSITION_REQUEST
204+
# define NRF_MODEM_GNSS_AGNSS_INTEGRITY_REQUEST \
205+
NRF_MODEM_GNSS_AGPS_INTEGRITY_REQUEST
206+
# define NRF_MODEM_GNSS_EVT_AGNSS_REQ NRF_MODEM_GNSS_EVT_AGPS_REQ
207+
# define NRF_MODEM_GNSS_DATA_AGNSS_REQ NRF_MODEM_GNSS_DATA_AGPS_REQ
208+
# endif // NCS_VERSION_NUMBER < 0x20463
209+
188210
static void
189-
handle_modem_agps_request_evt(struct nrf_modem_gnss_agps_data_frame req) {
211+
handle_modem_agps_request_evt(struct nrf_modem_gnss_agnss_data_frame req) {
190212
uint32_t request_mask = 0;
191213

192-
if (req.data_flags & NRF_MODEM_GNSS_AGPS_GPS_UTC_REQUEST) {
214+
if (req.data_flags & NRF_MODEM_GNSS_AGNSS_GPS_UTC_REQUEST) {
193215
request_mask |= LOC_SERVICES_A_GPS_MASK_UTC;
194216
}
195-
if (req.data_flags & NRF_MODEM_GNSS_AGPS_KLOBUCHAR_REQUEST) {
217+
if (req.data_flags & NRF_MODEM_GNSS_AGNSS_KLOBUCHAR_REQUEST) {
196218
request_mask |= LOC_SERVICES_A_GPS_MASK_KLOBUCHAR;
197219
}
198-
if (req.data_flags & NRF_MODEM_GNSS_AGPS_NEQUICK_REQUEST) {
220+
if (req.data_flags & NRF_MODEM_GNSS_AGNSS_NEQUICK_REQUEST) {
199221
request_mask |= LOC_SERVICES_A_GPS_MASK_NEQUICK;
200222
}
201-
if (req.data_flags & NRF_MODEM_GNSS_AGPS_SYS_TIME_AND_SV_TOW_REQUEST) {
223+
if (req.data_flags & NRF_MODEM_GNSS_AGNSS_GPS_SYS_TIME_AND_SV_TOW_REQUEST) {
202224
request_mask |=
203225
LOC_SERVICES_A_GPS_MASK_TOW | LOC_SERVICES_A_GPS_MASK_CLOCK;
204226
}
205-
if (req.data_flags & NRF_MODEM_GNSS_AGPS_POSITION_REQUEST) {
227+
if (req.data_flags & NRF_MODEM_GNSS_AGNSS_POSITION_REQUEST) {
206228
request_mask |= LOC_SERVICES_A_GPS_MASK_LOCATION;
207229
}
208-
if (req.data_flags & NRF_MODEM_GNSS_AGPS_INTEGRITY_REQUEST) {
230+
if (req.data_flags & NRF_MODEM_GNSS_AGNSS_INTEGRITY_REQUEST) {
209231
request_mask |= LOC_SERVICES_A_GPS_MASK_INTEGRITY;
210232
}
233+
# if NCS_VERSION_NUMBER >= 0x20463
234+
if (req.system[0].sv_mask_ephe) {
235+
request_mask |= LOC_SERVICES_A_GPS_MASK_EPHEMERIS;
236+
}
237+
if (req.system[0].sv_mask_alm) {
238+
request_mask |= LOC_SERVICES_A_GPS_MASK_ALMANAC;
239+
}
240+
# else // NCS_VERSION_NUMBER >= 0x20463
211241
if (req.sv_mask_ephe) {
212242
request_mask |= LOC_SERVICES_A_GPS_MASK_EPHEMERIS;
213243
}
214244
if (req.sv_mask_alm) {
215245
request_mask |= LOC_SERVICES_A_GPS_MASK_ALMANAC;
216246
}
247+
# endif // NCS_VERSION_NUMBER >= 0x20463
217248

218249
SYNCHRONIZED(anjay_zephyr_gps_read_last_mtx) {
219250
// We're reassigning the mask instead of ORing it with previous state,
@@ -242,11 +273,11 @@ static void gnss_event_handler(int event) {
242273
_anjay_zephyr_k_work_submit(&incoming_pvt_work);
243274
}
244275
#ifdef CONFIG_ANJAY_ZEPHYR_GPS_NRF_A_GPS
245-
if (event == NRF_MODEM_GNSS_EVT_AGPS_REQ) {
246-
struct nrf_modem_gnss_agps_data_frame req;
276+
if (event == NRF_MODEM_GNSS_EVT_AGNSS_REQ) {
277+
struct nrf_modem_gnss_agnss_data_frame req;
247278

248279
if (nrf_modem_gnss_read(
249-
&req, sizeof(req), NRF_MODEM_GNSS_DATA_AGPS_REQ)) {
280+
&req, sizeof(req), NRF_MODEM_GNSS_DATA_AGNSS_REQ)) {
250281
LOG_ERR("Failed to retrieve a A-GPS REQ event");
251282
return;
252283
}

src/location_services.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,10 +450,10 @@ static int send_agps_request(anjay_t *anjay, uint32_t request_mask) {
450450
}
451451
};
452452

453-
LOG_INF("Requesting following types of A-GPS data:");
453+
LOG_INF("Requesting A-GPS data");
454454
for (size_t i = 0; i < AVS_ARRAY_SIZE(agps_flag_names); i++) {
455455
if (agps_flag_names[i].req_flag & request_mask) {
456-
LOG_INF("%s", agps_flag_names[i].name);
456+
LOG_DBG("%s", agps_flag_names[i].name);
457457
}
458458
}
459459

src/network/network_nrf91.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
#include "../gps.h"
3030
#include "../utils.h"
3131

32+
#if __has_include("ncs_version.h")
33+
# include "ncs_version.h"
34+
#endif // __has_include("ncs_version.h")
35+
3236
LOG_MODULE_REGISTER(anjay_zephyr_network_nrf91);
3337

3438
static volatile atomic_int lte_nw_reg_status; // enum lte_lc_nw_reg_status
@@ -49,7 +53,11 @@ int _anjay_zephyr_network_internal_platform_initialize(void) {
4953
int ret;
5054

5155
#if defined(CONFIG_LTE_LINK_CONTROL) && !defined(CONFIG_NRF_MODEM_LIB_SYS_INIT)
56+
# if NCS_VERSION_NUMBER >= 0x20400
57+
ret = nrf_modem_lib_init();
58+
# else // NCS_VERSION_NUMBER >= 0x20400
5259
ret = nrf_modem_lib_init(NORMAL_MODE);
60+
# endif // NCS_VERSION_NUMBER >= 0x20400
5361
if (ret) {
5462
# ifdef CONFIG_ANJAY_ZEPHYR_ADVANCED_FOTA_NRF9160
5563
// nrf_modem_init (called indirectly) returns a positive code in case

0 commit comments

Comments
 (0)