Skip to content
This repository has been archived by the owner on Jul 9, 2024. It is now read-only.

Commit

Permalink
fix: update from upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored and coderbyheart committed Feb 19, 2024
1 parent ecdbc8a commit 6c63aa4
Show file tree
Hide file tree
Showing 12 changed files with 90 additions and 109 deletions.
1 change: 0 additions & 1 deletion doc/app_behavior.rst
Original file line number Diff line number Diff line change
Expand Up @@ -136,5 +136,4 @@ To enable support for P-GPS, add the parameter ``-DOVERLAY_CONFIG=overlay-pgps.c
To ensure that the resulting binary can be deployed using FOTA, you must make sure that the new partition layout is compatible with layout of the old image.
See :ref:`static partitioning <ug_pm_static_providing>` for more details.

.. note::
|gps_tradeoffs|
2 changes: 1 addition & 1 deletion doc/asset_tracker_v2_description.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ See the :ref:`nRF_asset_tracker` section for more details.
Carrier library support
***********************

See the section :ref:`using_the_lwm2m_carrier_library` for steps on how to connect to a operator's device management platform, necessary in some LTE networks.
See the section :ref:`using_the_lwm2m_carrier_library` for steps on how to connect to an operator's device management platform, necessary in some LTE networks.

.. _atv2_application_configuration:

Expand Down
21 changes: 11 additions & 10 deletions doc/location_module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,18 @@ The default configuration for the location request is set as follows:

The location module receives configuration updates as payload in the following two events:

* ``DATA_EVT_CONFIG_INIT`` - The event contains the value configured at build time or received from cloud and stored to flash.
* :c:enum:`DATA_EVT_CONFIG_INIT` - The event contains the value configured at build time or received from cloud and stored to flash.
The event is distributed from the data module as part of the application initialization.
* ``DATA_EVT_CONFIG_READY`` - The event is received when the data module has processed an incoming message from cloud with a configuration update.
* :c:enum:`DATA_EVT_CONFIG_READY` - The event is received when the data module has processed an incoming message from cloud with a configuration update.

The module sends the following events based on the outcome of the location request:
* ``LOCATION_MODULE_EVT_GNSS_DATA_READY``: GNSS position has been acquired
* ``LOCATION_MODULE_EVT_CLOUD_LOCATION_DATA_READY``: neighbor cell measurements or Wi-Fi access points (or both) have been obtained
* ``LOCATION_MODULE_EVT_DATA_NOT_READY``: Location request failed
* ``LOCATION_MODULE_EVT_TIMEOUT``: Timeout occurred
* ``LOCATION_MODULE_EVT_AGPS_NEEDED``: A-GPS request should be sent to cloud
* ``LOCATION_MODULE_EVT_PGPS_NEEDED``: P-GPS request should be sent to cloud

* :c:enum:`LOCATION_MODULE_EVT_GNSS_DATA_READY`: GNSS position has been acquired
* :c:enum:`LOCATION_MODULE_EVT_CLOUD_LOCATION_DATA_READY`: Neighbor cell measurements or Wi-Fi access points (or both) have been obtained
* :c:enum:`LOCATION_MODULE_EVT_DATA_NOT_READY`: Location request failed
* :c:enum:`LOCATION_MODULE_EVT_TIMEOUT`: Timeout occurred
* :c:enum:`LOCATION_MODULE_EVT_AGPS_NEEDED`: A-GPS request should be sent to cloud
* :c:enum:`LOCATION_MODULE_EVT_PGPS_NEEDED`: P-GPS request should be sent to cloud

GNSS LNA configuration
======================
Expand All @@ -59,7 +60,7 @@ GPS assistance data
===================

The location module receives requests for GPS assistance data from the :ref:`lib_location` library.
When the module receives an A-GPS request, it distributes it to the other modules as a ``LOCATION_MODULE_EVT_AGPS_NEEDED`` event that contains information about the type of assistance data needed.
When the module receives an A-GPS request, it distributes it to the other modules as a :c:enum:`LOCATION_MODULE_EVT_AGPS_NEEDED` event that contains information about the type of assistance data needed.
Providing the requested A-GPS data typically reduces significantly the time it takes to acquire a GNSS fix.

Wi-Fi positioning
Expand Down Expand Up @@ -98,7 +99,7 @@ In this sense, it differs from many other modules.
All incoming events from other modules are handled in the context of the Application Event Manager callback, because they all complete fast enough to not require a separate thread.

The :ref:`lib_location` library handles cellular and Wi-Fi positioning together when the location request method list has them next to each other.
This means that LTE neighbor cell measurements and Wi-Fi scanning results are combined into the same ``LOCATION_EVT_CLOUD_LOCATION_EXT_REQUEST`` event.
This means that LTE neighbor cell measurements and Wi-Fi scanning results are combined into the same :c:enum:`LOCATION_EVT_CLOUD_LOCATION_EXT_REQUEST` event.
The location module responds to the :ref:`lib_location` library with unknown location resolution, because it does not request the location back from cloud service.

Configuration options
Expand Down
3 changes: 0 additions & 3 deletions doc/modem_module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,7 @@ Module states

The modem module has an internal state machine with the following states:

* ``STATE_INIT`` - The initial state of the module in which it awaits the modem to be initialized.
The module enters this state only if the :ref:`liblwm2m_carrier_readme` library is enabled because the modem is automatically initialized otherwise.
* ``STATE_DISCONNECTED`` - The module has performed all required initializations and is ready to establish an LTE connection.
This is the initial state for applications that do not use the :ref:`liblwm2m_carrier_readme` library.
* ``STATE_CONNECTING`` - The modem is currently searching for a suitable LTE network and attempting to establish a connection.
* ``STATE_CONNECTED`` - The device is connected to an LTE network.
* ``STATE_SHUTDOWN`` - The module has been shut down after receiving a request from the utility module.
Expand Down
7 changes: 4 additions & 3 deletions doc/sensor_module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Motion impact detection
=======================

Motion impact is detected when the magnitude (root sum squared) of acceleration exceeds the configured threshold value.
To enable motion impact detection, you must include :kconfig:option:`CONFIG_EXTERNAL_SENSORS_IMPACT_DETECTION` when building the application.
To enable motion impact detection, you must include :ref:`CONFIG_EXTERNAL_SENSORS_IMPACT_DETECTION <CONFIG_EXTERNAL_SENSORS_IMPACT_DETECTION>` when building the application.

The threshold is configured using the :kconfig:option:`CONFIG_ADXL372_ACTIVITY_THRESHOLD` option.
The accelerometer records acceleration magnitude when it is in the active mode and reports the peak magnitude once it reverts to the inactive mode.
Expand All @@ -114,7 +114,7 @@ Perform the following steps to enable BSEC:
#. Disable the Zephyr BME680 driver by setting :kconfig:option:`CONFIG_BME680` to false.
#. Enable the external sensors API BSEC integration layer by enabling :ref:`CONFIG_EXTERNAL_SENSORS_BME680_BSEC <CONFIG_EXTERNAL_SENSORS_BME680_BSEC>` option.

Air quality readings are provided with the :c:enumerator:`SENSOR_EVT_ENVIRONMENTAL_DATA_READY` event.
Air quality readings are provided with the :c:enum:`SENSOR_EVT_ENVIRONMENTAL_DATA_READY` event.

To check and configure the BSEC configuration options, see :ref:`external_sensor_API_BSEC_configurations` section.

Expand Down Expand Up @@ -172,7 +172,8 @@ Module states
The sensor module has an internal state machine with the following states:

* ``STATE_INIT`` - The initial state of the module in which it awaits its initial configuration from the data module.
* ``STATE_RUNNING`` - The module is initialized and can be queried for sensor data. It will also send :c:enum:`SENSOR_EVT_MOVEMENT_DATA_READY` on movement.
* ``STATE_RUNNING`` - The module is initialized and can be queried for sensor data.
It will also send :c:enum:`SENSOR_EVT_MOVEMENT_DATA_READY` on movement.
* ``STATE_SHUTDOWN`` - The module has been shut down after receiving a request from the utility module.

State transitions take place based on events from other modules, such as the app module, data module, and utility module.
Expand Down
45 changes: 45 additions & 0 deletions nrf9160dk_with_ext_flash.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright (c) 2023 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

/* The mx25r64 definition would normally be included when specifying a nrf9160dk_nrf9160_ns
* board revision >= 0.14.0, but unfortunately twister has a bug that prevents the revision
* overlay to get loaded when testing the sample. */
&spi3 {
cs-gpios = <&arduino_header 16 GPIO_ACTIVE_LOW>, /* D10 */
<&gpio0 25 GPIO_ACTIVE_LOW>;
mx25r64: mx25r6435f@1 {
compatible = "jedec,spi-nor";
reg = <1>;
spi-max-frequency = <8000000>;
jedec-id = [c2 28 17];
sfdp-bfp = [
e5 20 f1 ff ff ff ff 03 44 eb 08 6b 08 3b 04 bb
ee ff ff ff ff ff 00 ff ff ff 00 ff 0c 20 0f 52
10 d8 00 ff 23 72 f5 00 82 ed 04 cc 44 83 68 44
30 b0 30 b0 f7 c4 d5 5c 00 be 29 ff f0 d0 ff ff
];
size = <67108864>;
mxicy,mx25r-power-mode = "high-performance";
};
};

/* Enable high drive mode for the SPI3 pins to get a square signal at 8 MHz */
&spi3_default {
group1 {
nordic,drive-mode = <NRF_DRIVE_H0H1>;
};
};

/ {
aliases {
ext-flash = &mx25r64;
};

/* Configure partition manager to use mx25r64 as the external flash */
chosen {
nordic,pm-ext-flash = &mx25r64;
};
};
4 changes: 0 additions & 4 deletions overlay-carrier.conf
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ CONFIG_DOWNLOAD_CLIENT_MAX_FILENAME_SIZE=230
# Modem info
CONFIG_MODEM_INFO_BUFFER_SIZE=512

# Disable AT host library as it's incompatible with the carrier library's
# requirement to initialize the modem library
CONFIG_AT_HOST_LIBRARY=n

# Credential management
CONFIG_MODEM_KEY_MGMT=y

Expand Down
1 change: 1 addition & 0 deletions sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ tests:
integration_platforms:
- nrf9160dk_nrf9160_ns
extra_args: OVERLAY_CONFIG=overlay-carrier.conf
DTC_OVERLAY_FILE=nrf9160dk_with_ext_flash.overlay
tags: ci_build
applications.asset_tracker_v2.lwm2m.low-power:
build_only: true
Expand Down
2 changes: 0 additions & 2 deletions src/events/modem_module_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ static char *get_evt_type_str(enum modem_module_event_type type)
return "MODEM_EVT_SHUTDOWN_READY";
case MODEM_EVT_ERROR:
return "MODEM_EVT_ERROR";
case MODEM_EVT_CARRIER_INITIALIZED:
return "MODEM_EVT_CARRIER_INITIALIZED";
case MODEM_EVT_CARRIER_EVENT_LTE_LINK_UP_REQUEST:
return "MODEM_EVT_CARRIER_EVENT_LTE_LINK_UP_REQUEST";
case MODEM_EVT_CARRIER_EVENT_LTE_LINK_DOWN_REQUEST:
Expand Down
7 changes: 0 additions & 7 deletions src/events/modem_module_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,6 @@ enum modem_module_event_type {
*/
MODEM_EVT_ERROR,

/** The carrier library has initialized the modem library and it is
* now ready to be used. When the carrier library is enabled, this
* event must be received before the modem module can proceed to initialize
* other dependencies and subsequently send MODEM_EVT_INITIALIZED.
* The event has no associated payload.
*/
MODEM_EVT_CARRIER_INITIALIZED,
/** Due to modem limitations for active TLS connections, the carrier
* library requires all other TLS connections in the system to
* be terminated while FOTA update is ongoing.
Expand Down
7 changes: 1 addition & 6 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -517,12 +517,7 @@ int main(void)
SEND_EVENT(app, APP_EVT_START);

#if defined(CONFIG_NRF_MODEM_LIB)
/* The carrier library will initialize the modem if enabled, if not,
* we initialize the modem in here, before the rest of the application is started.
*/
if (!IS_ENABLED(CONFIG_LWM2M_CARRIER)) {
modem_init();
}
modem_init();
#endif
}

Expand Down
99 changes: 27 additions & 72 deletions src/modules/modem_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ struct modem_msg_data {

/* Modem module super states. */
static enum state_type {
/* Initialization state where all libraries that the module depends
* on need to be initialized before you can enter any other state.
*/
STATE_INIT,
STATE_DISCONNECTED,
STATE_CONNECTING,
STATE_CONNECTED,
Expand Down Expand Up @@ -90,6 +86,16 @@ NRF_MODEM_LIB_ON_INIT(asset_tracker_init_hook, on_modem_lib_init, NULL);

static void on_modem_lib_init(int ret, void *ctx)
{
int err;

if (ret == 0) {
/* LTE LC is uninitialized on every modem shutdown. */
err = lte_lc_init();
if (err) {
LOG_ERR("lte_lc_init, error: %d", err);
}
}

k_sem_give(&nrf_modem_initialized);
}

Expand All @@ -109,8 +115,6 @@ static inline int adjust_rsrp(int input);
static char *state2str(enum state_type state)
{
switch (state) {
case STATE_INIT:
return "STATE_INIT";
case STATE_DISCONNECTED:
return "STATE_DISCONNECTED";
case STATE_CONNECTING:
Expand Down Expand Up @@ -338,22 +342,12 @@ static void print_carrier_error(const lwm2m_carrier_event_t *evt)
"Failed to connect to the LTE network",
[LWM2M_CARRIER_ERROR_LTE_LINK_DOWN_FAIL] =
"Failed to disconnect from the LTE network",
[LWM2M_CARRIER_ERROR_FOTA_PKG] =
"Package refused from modem",
[LWM2M_CARRIER_ERROR_FOTA_PROTO] =
"Protocol error",
[LWM2M_CARRIER_ERROR_FOTA_CONN] =
"Connection to remote server failed",
[LWM2M_CARRIER_ERROR_FOTA_CONN_LOST] =
"Connection to remote server lost",
[LWM2M_CARRIER_ERROR_FOTA_FAIL] =
"Modem firmware update failed",
[LWM2M_CARRIER_ERROR_CONFIGURATION] =
"Illegal object configuration detected",
[LWM2M_CARRIER_ERROR_INIT] =
"Initialization failure",
[LWM2M_CARRIER_ERROR_INTERNAL] =
"Internal failure",
[LWM2M_CARRIER_ERROR_RUN] =
"Configuration failure",
};
Expand Down Expand Up @@ -400,11 +394,6 @@ int lwm2m_carrier_event_handler(const lwm2m_carrier_event_t *evt)
int err = 0;

switch (evt->type) {
case LWM2M_CARRIER_EVENT_INIT: {
LOG_INF("LWM2M_CARRIER_EVENT_INIT");
SEND_EVENT(modem, MODEM_EVT_CARRIER_INITIALIZED);
break;
}
case LWM2M_CARRIER_EVENT_LTE_LINK_UP: {
LOG_INF("LWM2M_CARRIER_EVENT_LTE_LINK_UP");
SEND_EVENT(modem, MODEM_EVT_CARRIER_EVENT_LTE_LINK_UP_REQUEST);
Expand Down Expand Up @@ -433,6 +422,9 @@ int lwm2m_carrier_event_handler(const lwm2m_carrier_event_t *evt)
SEND_EVENT(modem, MODEM_EVT_CARRIER_FOTA_PENDING);
break;
}
case LWM2M_CARRIER_EVENT_FOTA_SUCCESS:
LOG_INF("LWM2M_CARRIER_EVENT_FOTA_SUCCESS");
break;
case LWM2M_CARRIER_EVENT_REBOOT: {
LOG_INF("LWM2M_CARRIER_EVENT_REBOOT");
SEND_EVENT(modem, MODEM_EVT_CARRIER_REBOOT_REQUEST);
Expand All @@ -444,20 +436,17 @@ int lwm2m_carrier_event_handler(const lwm2m_carrier_event_t *evt)
*/
return 1;
}
case LWM2M_CARRIER_EVENT_MODEM_INIT:
LOG_INF("LWM2M_CARRIER_EVENT_MODEM_INIT");
err = nrf_modem_lib_init();
break;
case LWM2M_CARRIER_EVENT_MODEM_SHUTDOWN:
LOG_INF("LWM2M_CARRIER_EVENT_MODEM_SHUTDOWN");
err = nrf_modem_lib_shutdown();
break;
case LWM2M_CARRIER_EVENT_ERROR: {
const lwm2m_carrier_event_error_t *err = evt->data.error;

LOG_ERR("LWM2M_CARRIER_EVENT_ERROR");
print_carrier_error(evt);

bool fota_error = err->type == LWM2M_CARRIER_ERROR_FOTA_PKG ||
err->type == LWM2M_CARRIER_ERROR_FOTA_PROTO ||
err->type == LWM2M_CARRIER_ERROR_FOTA_CONN ||
err->type == LWM2M_CARRIER_ERROR_FOTA_CONN_LOST ||
err->type == LWM2M_CARRIER_ERROR_FOTA_FAIL;
if (fota_error) {
SEND_EVENT(modem, MODEM_EVT_CARRIER_FOTA_STOPPED);
}
break;
}
}
Expand Down Expand Up @@ -713,12 +702,6 @@ static int setup(void)
}
#endif

err = lte_lc_init();
if (err) {
LOG_ERR("lte_lc_init, error: %d", err);
return err;
}

/* Setup a callback for the default PDP context. */
err = pdn_default_ctx_cb_reg(pdn_event_handler);
if (err) {
Expand Down Expand Up @@ -748,20 +731,6 @@ static int setup(void)
return 0;
}

/* Message handler for STATE_INIT */
static void on_state_init(struct modem_msg_data *msg)
{
if (IS_EVENT(msg, modem, MODEM_EVT_CARRIER_INITIALIZED)) {
int err;

state_set(STATE_DISCONNECTED);

err = setup();
__ASSERT(err == 0, "Failed running setup()");
SEND_EVENT(modem, MODEM_EVT_INITIALIZED);
}
}

/* Message handler for STATE_DISCONNECTED. */
static void on_state_disconnected(struct modem_msg_data *msg)
{
Expand Down Expand Up @@ -857,13 +826,6 @@ static void on_all_states(struct modem_msg_data *msg)
if (IS_EVENT(msg, app, APP_EVT_START)) {
int err;

if (IS_ENABLED(CONFIG_LWM2M_CARRIER)) {
/* The carrier library handles the LTE connection
* establishment.
*/
return;
}

err = lte_connect();
if (err) {
LOG_ERR("Failed connecting to LTE, error: %d", err);
Expand Down Expand Up @@ -922,26 +884,19 @@ static void module_thread_fn(void)

k_sem_take(&nrf_modem_initialized, K_FOREVER);

if (IS_ENABLED(CONFIG_LWM2M_CARRIER)) {
state_set(STATE_INIT);
} else {
state_set(STATE_DISCONNECTED);
SEND_EVENT(modem, MODEM_EVT_INITIALIZED);
state_set(STATE_DISCONNECTED);
SEND_EVENT(modem, MODEM_EVT_INITIALIZED);

err = setup();
if (err) {
LOG_ERR("Failed setting up the modem, error: %d", err);
SEND_ERROR(modem, MODEM_EVT_ERROR, err);
}
err = setup();
if (err) {
LOG_ERR("Failed setting up the modem, error: %d", err);
SEND_ERROR(modem, MODEM_EVT_ERROR, err);
}

while (true) {
module_get_next_msg(&self, &msg);

switch (state) {
case STATE_INIT:
on_state_init(&msg);
break;
case STATE_DISCONNECTED:
on_state_disconnected(&msg);
break;
Expand Down

0 comments on commit 6c63aa4

Please sign in to comment.