CellLocate Service-to-Service access

Introduction

Service-to-Service access allows to access to the service requesting the location estimation directly from your application platform instead of from your devices. This approach is preferred, for example,  whenever you need the position information directly on server side  and not in the device or when your fleet does not have access to the public internet and cannot reach directly the CellLocate end-points reported in the Getting started guide.

This documentation will guide you through the process of setting up your Thingstream account for service-to-service access using the REST API

Prerequisites

The prerequisites to complete the procedure are:

Procedure overview

The mains steps of this procedure are


Create a CellLocate S2S Thing

The first step is to create a CellLocate S2S things that provides you all the parameters to issue the API:

The Thing let also you to:

Sign-in into the Thingstream portal and select the Location Things item from the Location Services section. Click the button to create a new Location Thing and browse to the CellLocate section from where you can select the wizard to create CellLocate S2S Thing.  

During the creation steps you are suggested to assign a price plan. If you skip this step the Thing will not be automatically activated and cannot be used. When you are ready to assign a plan, open the Thing panel and assign the preferred one. 

Module configuration

The module can be configured using  the same AT command reported in the Getting started guide

AT+UGSRV="primaryServer","secondaryServer","optional_device_ID"

where:

This ID is for your internal use and you do not need to forward it to CellLocate endpoint

Setup your application platform

The picture below displays the flow of data to obtain a position estimation:

/CellGetOnlineData.ashx?celltype=gsm;token=XXXXXXXXXXXXXXXXXX;datatype=pos;format=mga;

where the token parameter is the information configured through the UGSRV command  described in the previous section and can represent a device identifier

Dummy response format

A dummy response is required to close the loop, and acknowledge the CEL module request so that it stop listening for the answer.

The http response  to be sent by your application server to the device (CEL module) , shall contain:

B5621340180010000012E507051B0C1F0F00C01E6B2400000000801A0600E045

In this way the device stops the +ULOC procedure, used to request the position, and print out

+UULOC: 27/05/2021,14:42:38.000,0.0000000,0.0000000,0,20000000,0,0,0,0,0,0,0

NOTE: since it's a dummy response, it shall be ignored by the device application


UBX-MGA-INI-TIME_UTC  frame structure

Send a measurement and get a position

As explained above, to trigger on the module the generation of the measurements used to get a position estimation you can use the +ULOC AT command exactly in the same way described in the Getting started guide.

Once you have received the measurement on your application server, to obtain a position you need to use the API

https://locationapi.services.u-blox.com/v1/celllocate/s2s/location/get

as described in the CellLocate API documentation where:

can be retrieved in the credential section of your just created CellLocate S2S thing

API request after converting the binary payload to base64 format:

{

  "Payload":"R1NNQ0VMczKzT3YjSzADcAQAAAMDcAQB1gCvsiA7HgADAALJAJKwGzwoAALWAG2xGjMsAA LJAGOxGCsrAALWAIq9FiEyAIEaU0FSQS1HMzQwL1NhcmEzNDBfMDguOTAuMDMA"

}

The API response is in JSON format as reported below

{

  "Location": {

    "Lat": 51.6387347,

    "Lon": 0.1121669,

    "Unc68": 20.1

  },

  "DateTime": "2020-08-17T20:18:12",

  "DeviceID": "357861090015763",

  "DeviceType": "SARA-R510S-00B-00/01.02,A00.01",

  "UBXResponse":"tWITQBgAEAAAEuYHCBAHHREAQBO5IAAAAACAGgYAk/G1YhNAFAABAAAA7IcgH66h9P 8AAAAAxQwAAC0atWIIBhwAiuyHIB+uofT/FIsAAAAAEREAMosAAAAAEREAX6e8",

  "LocationSource": "Cell"

}

If you need to send back the position to the device remind that UBXResponse  is base64 encoded string so before sending back to the device you need to decode the string in bytes and send the binary payload to device. Also you need to include the status code in the http reply.

Self Reporting API

Thingstream provides a rich Customer API to allow you to carry out the majority of functions that can be done in the portal in addition to providing the ability to Report Usage on your S2S devices.