Skip to content

Commit 99cbbe1

Browse files
committed
app: Remove support for nRF Cloud MQTT
Use more lightweight CoAP protocol instead of MQTT. Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
1 parent 18a7a6f commit 99cbbe1

File tree

8 files changed

+61
-365
lines changed

8 files changed

+61
-365
lines changed

app/Kconfig

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,16 @@ config SM_NRF_CLOUD
253253
config SM_NRF_CLOUD_LOCATION
254254
bool "nRF Cloud Location support"
255255
depends on SM_NRF_CLOUD
256-
select NRF_CLOUD_LOCATION if NRF_CLOUD_MQTT
256+
help
257+
Enable the nRF Cloud Location service for cloud-assisted geolocation.
258+
Supports A-GNSS, P-GPS, and Wi-Fi positioning:
259+
260+
- A-GNSS: Reduces GNSS time-to-first-fix by downloading assistance data from nRF Cloud.
261+
- P-GPS: Enables predicted GPS ephemerides for offline or intermittent connectivity scenarios.
262+
- Wi-Fi: Uses Wi-Fi access point scanning for positioning without GNSS.
263+
264+
A-GNSS and P-GPS data are sourced from the modem's GNSS subsystem; Wi-Fi data from the Wi-Fi scanner.
265+
A-GNSS and P-GPS can be enabled independently at compile time using NRF_CLOUD_AGNSS and NRF_CLOUD_PGPS.
257266

258267
config SM_MQTTC
259268
bool "MQTT client support"

app/overlay-nrf_cloud-coap.conf

Lines changed: 0 additions & 17 deletions
This file was deleted.

app/prj.conf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ CONFIG_NVS=y
9292
# nRF Cloud
9393
CONFIG_SM_NRF_CLOUD_LOCATION=y
9494
CONFIG_NRF_CLOUD=y
95-
CONFIG_NRF_CLOUD_MQTT=y
95+
CONFIG_NRF_CLOUD_COAP=y
96+
CONFIG_NRF_CLOUD_COAP_DOWNLOADS=n
9697
CONFIG_NRF_CLOUD_FOTA=n
9798
CONFIG_NRF_CLOUD_AGNSS=y
9899
CONFIG_NRF_CLOUD_AGNSS_FILTERED=n
@@ -105,6 +106,12 @@ CONFIG_DATE_TIME=y
105106
CONFIG_MODEM_INFO=y
106107
CONFIG_MODEM_INFO_ADD_DATE_TIME=n
107108

109+
# CoAP client settings
110+
CONFIG_COAP_CLIENT_BLOCK_SIZE=1024
111+
CONFIG_COAP_CLIENT_THREAD_PRIORITY=0
112+
CONFIG_COAP_EXTENDED_OPTIONS_LEN_VALUE=96
113+
CONFIG_COAP_CLIENT_STACK_SIZE=2048
114+
108115
# UUID and JWT
109116
CONFIG_MODEM_JWT=y
110117

app/src/sm_at_gnss.c

Lines changed: 24 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,9 @@ static struct k_work agnss_req_work;
6161
#endif
6262
#if defined(CONFIG_NRF_CLOUD_PGPS)
6363
static struct k_work pgps_req_work;
64-
#if defined(CONFIG_NRF_CLOUD_COAP)
6564
static struct k_work pgps_coap_req_work;
6665
static struct gps_pgps_request pgps_coap_request;
6766
#endif
68-
#endif
6967

7068
#endif /* CONFIG_SM_NRF_CLOUD */
7169

@@ -320,31 +318,17 @@ static void agnss_requestor(struct k_work *)
320318
{
321319
int err;
322320
struct nrf_modem_gnss_agnss_data_frame req;
321+
static char agnss_rest_data_buf[NRF_CLOUD_AGNSS_MAX_DATA_SIZE];
322+
struct nrf_cloud_rest_agnss_request request = {
323+
NRF_CLOUD_REST_AGNSS_REQ_CUSTOM,
324+
&req,
325+
};
323326

324327
err = read_agnss_req(&req);
325328
if (err) {
326329
LOG_ERR("Failed to read A-GNSS request (%d).", err);
327330
return;
328331
}
329-
#if defined(CONFIG_NRF_CLOUD_MQTT)
330-
err = nrf_cloud_agnss_request(&req);
331-
if (err) {
332-
LOG_ERR("Failed to request A-GNSS data (%d).", err);
333-
} else {
334-
LOG_INF("A-GNSS data requested.");
335-
/* When A-GNSS data is received it gets injected in the background by
336-
* nrf_cloud_agnss_process() without notification. In the case where
337-
* CONFIG_NRF_CLOUD_PGPS=y, nrf_cloud_pgps_inject() (called on PGPS_EVT_AVAILABLE)
338-
* plays a role as A-GNSS expects P-GPS to process some of the data.
339-
*/
340-
}
341-
#endif
342-
#if defined(CONFIG_NRF_CLOUD_COAP)
343-
static char agnss_rest_data_buf[NRF_CLOUD_AGNSS_MAX_DATA_SIZE];
344-
struct nrf_cloud_rest_agnss_request request = {
345-
NRF_CLOUD_REST_AGNSS_REQ_CUSTOM,
346-
&req,
347-
};
348332

349333
struct nrf_cloud_rest_agnss_result result = {agnss_rest_data_buf,
350334
sizeof(agnss_rest_data_buf), 0};
@@ -369,7 +353,6 @@ static void agnss_requestor(struct k_work *)
369353
return;
370354
}
371355
LOG_INF("A-GNSS data received via CoAP.");
372-
#endif
373356
}
374357
#endif /* CONFIG_NRF_CLOUD_AGNSS */
375358

@@ -387,7 +370,6 @@ static void pgps_requestor(struct k_work *)
387370
}
388371
}
389372

390-
#if defined(CONFIG_NRF_CLOUD_COAP)
391373
static void pgps_coap_requestor(struct k_work *)
392374
{
393375
int err;
@@ -428,7 +410,6 @@ static void pgps_coap_requestor(struct k_work *)
428410

429411
LOG_INF("P-GPS predictions requested");
430412
}
431-
#endif
432413

433414
static void pgps_event_handler(struct nrf_cloud_pgps_event *event)
434415
{
@@ -481,10 +462,8 @@ static void pgps_event_handler(struct nrf_cloud_pgps_event *event)
481462
break;
482463
case PGPS_EVT_REQUEST:
483464
LOG_INF("PGPS_EVT_REQUEST");
484-
#if defined(CONFIG_NRF_CLOUD_COAP)
485465
memcpy(&pgps_coap_request, event->request, sizeof(pgps_coap_request));
486466
k_work_submit_to_queue(&sm_work_q, &pgps_coap_req_work);
487-
#endif
488467
break;
489468
}
490469
}
@@ -540,24 +519,11 @@ static int do_cloud_send_obj(struct nrf_cloud_obj *const obj)
540519
{
541520
int err;
542521

543-
#if defined(CONFIG_NRF_CLOUD_MQTT)
544-
struct nrf_cloud_tx_data msg = {
545-
.obj = obj,
546-
.topic_type = NRF_CLOUD_TOPIC_MESSAGE,
547-
.qos = MQTT_QOS_0_AT_MOST_ONCE
548-
};
549-
550-
err = nrf_cloud_send(&msg);
551-
if (err) {
552-
LOG_ERR("nrf_cloud_send failed, error: %d", err);
553-
}
554-
#endif
555-
#if defined(CONFIG_NRF_CLOUD_COAP)
556522
err = nrf_cloud_coap_obj_send(obj, false);
557523
if (err) {
558524
LOG_ERR("nrf_cloud_send failed, error: %d", err);
559525
}
560-
#endif
526+
561527
(void)nrf_cloud_obj_free(obj);
562528

563529
return err;
@@ -567,12 +533,27 @@ static void send_location(struct nrf_modem_gnss_pvt_data_frame * const pvt_data)
567533
{
568534
static int64_t last_ts_ms = NRF_CLOUD_NO_TIMESTAMP;
569535
int err;
536+
537+
/* Map modem PVT data to nRF Cloud PVT structure */
538+
struct nrf_cloud_gnss_pvt pvt = {
539+
.lat = pvt_data->latitude,
540+
.lon = pvt_data->longitude,
541+
.accuracy = pvt_data->accuracy,
542+
.alt = pvt_data->altitude,
543+
.has_alt = 1,
544+
.speed = pvt_data->speed,
545+
.has_speed = 1,
546+
.heading = pvt_data->heading,
547+
.has_heading = 1,
548+
};
549+
570550
struct nrf_cloud_gnss_data gnss = {
571551
.ts_ms = NRF_CLOUD_NO_TIMESTAMP,
572-
.type = NRF_CLOUD_GNSS_TYPE_MODEM_PVT,
573-
.mdm_pvt = pvt_data
552+
.type = NRF_CLOUD_GNSS_TYPE_PVT,
553+
.pvt = pvt,
574554
};
575-
NRF_CLOUD_OBJ_JSON_DEFINE(msg_obj);
555+
556+
NRF_CLOUD_OBJ_COAP_CBOR_DEFINE(msg_obj);
576557
/* On failure, NRF_CLOUD_NO_TIMESTAMP is used and the timestamp is omitted */
577558
(void)date_time_now(&gnss.ts_ms);
578559

@@ -903,9 +884,7 @@ static int sm_at_gnss_init(void)
903884
#endif
904885
#if defined(CONFIG_NRF_CLOUD_PGPS)
905886
k_work_init(&pgps_req_work, pgps_requestor);
906-
#if defined(CONFIG_NRF_CLOUD_COAP)
907887
k_work_init(&pgps_coap_req_work, pgps_coap_requestor);
908-
#endif
909888
#endif /* CONFIG_NRF_CLOUD_PGPS */
910889
#endif /* CONFIG_SM_NRF_CLOUD */
911890
k_work_init(&gnss_fix_send_work, gnss_fix_sender);

0 commit comments

Comments
 (0)