top of page

How to Implement Assisted GPS with nRF9160 and AWS IoT

 

A practical guide to reducing time-to-first-fix with Spectric’s example code.


 


What is assisted GPS and why do you need it?


GPS devices need to get three sets of data from the satellites before they can calculate a location: the current GPS time, the almanac data (i.e. coarse orbit and status for every satellite) and the ephemeris data (i.e. precise orbit for the transmitting satellite). When devices have been off for a long time or moved a lot while off, they need to search for all satellites and get the data before they can find a location. This can take several minutes and is called the "time-to-first-fix" (TTFF)


Many users want GPS locations to be available right away when they turn on their devices. In a cold-start state where the device needs to search all satellites and download GPS data, the TTFF can take multiple minutes causing user-frustration.  Even in a warm-start state, where some of the data has already been downloaded, the TTFF can take up to a minute. To reduce the TTFF, GPS data can be obtained over the Internet using a technique called assisted GPS (A-GPS). Given that many modern GPS devices, such as cell phones and IoT devices have Internet connectivity, A-GPS is commonly used to improve the user-experience.  In this article, Spectric will demonstrate how to implement A-GPS with the nRF9160 IoT device and AWS services.


How does A-GPS work with nRF9160 and AWS IoT?


Unfortunately, A-GPS is not standardized, and different vendors have different solutions, often tied to their specific devices. One popular device for making cellular-enabled IoT devices is the Nordic Semiconductor nRF9160, which can provide A-GPS via the nRF Cloud. When devices are connected to nRF Cloud, the A-GPS implementation only needs device-side software, but when devices are connected to other clouds (i.e. AWS IoT) then service-side software must also be implemented.


To show A-GPS using the nRF9160, Spectric has developed a simple example that focuses only on the core concepts of A-GPS. A full-fledged asset tracker implementation is provided by Nordic which should be used for real applications. In the example, the device does these steps:


1.      Connects to AWS IoT via the cellular network, then


How does Spectric’s example code implement A-GPS?


The A-GPS request requires the device report its current cellular network information. This information allows the nRF A-GPS service to determine the approximate location of the device.  The parameters necessary are: mobile country code, mobile network code, tracking area code, E-UTRA cell identifier, and reference signal received power.  By setting the filtered parameter to true, only information for satellites in current view of the device will be returned, thus reducing the amount of data to transfer. The mask value determines the angle for which satellites are filtered when considering view angle.  Once the payload is constructed and then sent to the MQTT topic via the aws_iot_send function.


// Generate the JSON request payload
struct agnss_request payload = {
		.mcc = modem_info.network.mcc.value,
		.mnc = modem_info.network.mnc.value,
		.tac = modem_info.network.area_code.value,
		.eci = modem_info.network.cellid_dec,
		.rsrp = modem_info.network.rsrp.value,
		.filtered = true,
		.mask = 5,
	};

json_agnss_req_construct(buf, sizeof(buf), &payload);
	
	// Create the JSON MQTT msg
struct aws_iot_data msg = {
		.ptr = buf,
		.len = strlen(buf),
		.message_id = 1,
		.qos = ack ? MQTT_QOS_1_AT_LEAST_ONCE : MQTT_QOS_0_AT_MOST_ONCE,
		.topic = pub_topics[AGNSS_REQUEST_TOPIC_IDX],
	};

	// Send the msg
aws_iot_send(&msg);

After the message has been received by AWS IoT, it needs to be routed and handled, which Spectric has handled via AWS Lambda.  This Lambda implementation can be used for any nRF-based device connected via AWS IoT.  The only change needed is to set the servicekey parameter to your nRF API Key.  This can be done either by editing the source-code or setting the “/nrfcloud/servicekey” AWS Parameter. The nRF A-GPS data is then passed back to the device and processed with the nrf_cloud_agnss_process call.  At the completion of this interaction the device will be able to directly acquire the GPS signal and determine its location without any further information.


This example demonstrates an end-to-end implementation of the nRF A-GPS functionality via AWS IoT.  Spectric’s example provides a reference AWS Lambda nRF A-GPS implementation that can be used in any nRF-based AWS IoT application to simplify A-GPS integration.


Spectric Labs Github: https://github.com/spectriclabs 


Heading Image created using Bing AI Image Creator 


For more information/questions contact info@spectric.com 

50 views

Comments


bottom of page