@@ -61,11 +61,9 @@ static struct k_work agnss_req_work;
6161#endif
6262#if defined(CONFIG_NRF_CLOUD_PGPS )
6363static struct k_work pgps_req_work ;
64- #if defined(CONFIG_NRF_CLOUD_COAP )
6564static struct k_work pgps_coap_req_work ;
6665static 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 )
391373static 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
433414static 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