Skip to content

Commit e1869c5

Browse files
committed
fix: fix
fix Signed-off-by: Simen S. Røstad <simen.rostad@nordicsemi.no>
1 parent 55dd832 commit e1869c5

4 files changed

Lines changed: 77 additions & 30 deletions

File tree

.github/actions/build-step/action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ runs:
6868
if [[ "${{ inputs.modem_trace }}" == "true" ]]; then
6969
params+=("-Dapp_SNIPPET=nrf91-modem-trace-uart")
7070
fi
71+
if [[ "${{ inputs.board }}" == "nrf9151dk"* ]]; then
72+
echo CONFIG_MODEM_ANTENNA_GNSS_EXTERNAL=y >> overlay-nrf9151dk.conf
73+
params+=("-DEXTRA_CONF_FILE=overlay-nrf9151dk.conf")
74+
fi
7175
west build -b ${{ inputs.board }} \
7276
-d build \
7377
-p --sysbuild -- \

app/src/modules/cloud/cloud.c

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <zephyr/net/coap.h>
1818
#include <app_version.h>
1919
#include <date_time.h>
20+
#include <modem/lte_lc.h>
2021

2122
#if defined(CONFIG_MEMFAULT)
2223
#include <memfault/ports/zephyr/http.h>
@@ -358,6 +359,60 @@ static void send_request_failed(void)
358359
}
359360
}
360361

362+
static void print_lte_functional_mode(void)
363+
{
364+
int err;
365+
enum lte_lc_func_mode mode;
366+
367+
err = lte_lc_func_mode_get(&mode);
368+
if (err) {
369+
LOG_ERR("Failed to get LTE functional mode, error: %d", err);
370+
return;
371+
}
372+
373+
const char *mode_str;
374+
switch (mode) {
375+
case LTE_LC_FUNC_MODE_POWER_OFF:
376+
mode_str = "POWER_OFF";
377+
break;
378+
case LTE_LC_FUNC_MODE_NORMAL:
379+
mode_str = "NORMAL";
380+
break;
381+
case LTE_LC_FUNC_MODE_RX_ONLY:
382+
mode_str = "RX_ONLY";
383+
break;
384+
case LTE_LC_FUNC_MODE_OFFLINE:
385+
mode_str = "OFFLINE";
386+
break;
387+
case LTE_LC_FUNC_MODE_DEACTIVATE_LTE:
388+
mode_str = "DEACTIVATE_LTE";
389+
break;
390+
case LTE_LC_FUNC_MODE_ACTIVATE_LTE:
391+
mode_str = "ACTIVATE_LTE";
392+
break;
393+
case LTE_LC_FUNC_MODE_DEACTIVATE_GNSS:
394+
mode_str = "DEACTIVATE_GNSS";
395+
break;
396+
case LTE_LC_FUNC_MODE_ACTIVATE_GNSS:
397+
mode_str = "ACTIVATE_GNSS";
398+
break;
399+
case LTE_LC_FUNC_MODE_DEACTIVATE_UICC:
400+
mode_str = "DEACTIVATE_UICC";
401+
break;
402+
case LTE_LC_FUNC_MODE_ACTIVATE_UICC:
403+
mode_str = "ACTIVATE_UICC";
404+
break;
405+
case LTE_LC_FUNC_MODE_OFFLINE_UICC_ON:
406+
mode_str = "OFFLINE_UICC_ON";
407+
break;
408+
default:
409+
mode_str = "UNKNOWN";
410+
break;
411+
}
412+
413+
LOG_ERR("Current LTE functional mode: %s (%d)", mode_str, mode);
414+
}
415+
361416
static void nrf_provisioning_callback(const struct nrf_provisioning_callback_data *event)
362417
{
363418
int err;
@@ -425,11 +480,13 @@ static void nrf_provisioning_callback(const struct nrf_provisioning_callback_dat
425480
return;
426481
case NRF_PROVISIONING_EVENT_FAILED:
427482
LOG_ERR("Provisioning failed");
483+
print_lte_functional_mode();
428484

429485
msg = CLOUD_PROVISIONING_FAILED;
430486
break;
431487
case NRF_PROVISIONING_EVENT_FAILED_NO_VALID_DATETIME:
432488
LOG_ERR("Provisioning failed, no valid datetime reference");
489+
print_lte_functional_mode();
433490

434491
msg = CLOUD_PROVISIONING_FAILED;
435492
break;
@@ -438,6 +495,7 @@ static void nrf_provisioning_callback(const struct nrf_provisioning_callback_dat
438495
LOG_WRN("Claim the device using the device's attestation token on nrfcloud.com");
439496
LOG_WRN("\r\n\n%.*s.%.*s\r\n", event->token->attest_sz, event->token->attest,
440497
event->token->cose_sz, event->token->cose);
498+
print_lte_functional_mode();
441499
msg = CLOUD_PROVISIONING_FAILED;
442500
break;
443501
case NRF_PROVISIONING_EVENT_FAILED_WRONG_ROOT_CA:
@@ -837,11 +895,24 @@ static void state_connecting_provisioned_run(void *obj)
837895
static void state_connecting_provisioning_entry(void *obj)
838896
{
839897
int err;
840-
841898
struct cloud_state_object *state_object = obj;
899+
struct location_msg location_msg = {
900+
.type = LOCATION_SEARCH_CANCEL,
901+
};
842902

843903
LOG_DBG("%s", __func__);
844904

905+
/* Cancel any ongoing location search during provisioning to allow writing credentials,
906+
* which requires offline LTE functional mode.
907+
*/
908+
err = zbus_chan_pub(&LOCATION_CHAN, &location_msg, K_SECONDS(1));
909+
if (err) {
910+
LOG_ERR("zbus_chan_pub, error: %d", err);
911+
912+
SEND_FATAL_ERROR();
913+
return;
914+
}
915+
845916
state_object->provisioning_ongoing = true;
846917

847918
err = nrf_provisioning_trigger_manually();

tests/on_target/tests/test_gnss/test_gnss.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@ def test_gnss(dut_board, hex_file):
4444
assert abs(lat - 61.493219) < 0.1, f"Latitude {lat} is not within expected range of 61.493219"
4545
assert abs(lon - 23.771307) < 0.1, f"Longitude {lon} is not within expected range of 23.771307"
4646
assert acc > 0, f"Accuracy {acc} should be greater than 0"
47-
assert "Cellular" in method, f"Method '{method}' should be 'Cellular'"
47+
assert "GNSS" in method, f"Method '{method}' should be 'GNSS'"
4848

4949
logger.info(f"Got location: lat: {lat}, lon: {lon}, acc: {acc}, method: {method}")

tests/on_target/tests/test_provisioning/test_provisioning.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -145,32 +145,6 @@ def _wait_for_provisioning_completion_and_cloud_connection(
145145
logger.info("Device provisioned and connected to nRF Cloud.")
146146

147147

148-
def _verify_device_location_data(
149-
dut_cloud,
150-
expected_lat: float = 61.5,
151-
expected_lon: float = 10.5,
152-
lat_tolerance: float = 2.0,
153-
lon_tolerance: float = 1.0,
154-
timeout: int = 300,
155-
):
156-
logger.info("Verifying device location data...")
157-
158-
values = dut_cloud.uart.wait_for_str_re(
159-
r"Got location: lat: ([\d.-]+), lon: ([\d.-]+), acc: ([\d.-]+), method:",
160-
timeout=timeout
161-
)
162-
assert values, "Failed to get location data from device."
163-
164-
lat_str, lon_str, acc_str = values
165-
lat, lon = float(lat_str), float(lon_str)
166-
logger.info(f"Received location: Lat={lat}, Lon={lon}, Accuracy={acc_str}")
167-
168-
assert abs(lat - expected_lat) < lat_tolerance, f"Latitude {lat} out of range."
169-
assert abs(lon - expected_lon) < lon_tolerance, f"Longitude {lon} out of range."
170-
171-
logger.info("Device location data verified.")
172-
173-
174148
def _trigger_device_reprovisioning_with_new_credentials(dut_cloud, sec_tag: int):
175149
"""
176150
Initiates the reprovisioning process on the device by:
@@ -249,7 +223,6 @@ def _run_initial_provisioning(dut_cloud, hex_file):
249223
_connect_to_network_and_wait_for_claiming_prompt(dut_cloud)
250224
_claim_device_on_nrf_cloud(dut_cloud, attestation_token)
251225
_wait_for_provisioning_completion_and_cloud_connection(dut_cloud)
252-
_verify_device_location_data(dut_cloud)
253226

254227
logger.info("--- Phase 1: Initial Device Provisioning Completed Successfully ---")
255228

@@ -262,7 +235,6 @@ def _run_reprovisioning(dut_cloud):
262235
_trigger_device_reprovisioning_with_new_credentials(dut_cloud, SEC_TAG)
263236
# Wait for the device to process the command, reprovision, and reconnect
264237
_wait_for_provisioning_completion_and_cloud_connection(dut_cloud, timeout=300)
265-
_verify_device_location_data(dut_cloud)
266238

267239
logger.info(
268240
"--- Phase 2: Reprovisioning with New Credentials Completed Successfully ---"

0 commit comments

Comments
 (0)