Skip to content

Commit

Permalink
Added new script to demonstrate SpotNow (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
rebatoma committed May 3, 2024
1 parent 1e92202 commit c181fbf
Show file tree
Hide file tree
Showing 3 changed files with 198 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

The latest version of m-center release can be downloaded from [here](https://www.u-blox.com/en/product/m-center).

Visit the [Wiki page](https://github.com/u-blox/m-center/wiki) for further instuctions and details on the scripts use.

![m-center_Main_01](https://user-images.githubusercontent.com/6113690/194055231-b26950f1-14fb-48bf-b230-da8ef966e819.png)


Expand Down
194 changes: 194 additions & 0 deletions at_scripts/location_features/location_saraR52_SpotNowDemo_advanced.atl
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
/*******************************************************************************
* Copyright (c) 2020 u-blox AG, Thalwil, Switzerland.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************
* Synopsis: location_saraR52_SpotNowDemo_advanced.atl
* Topic: location_features
* Version: 1.0
* Author: dtro
* Description:
* This script has the purpose to demonstrate the use of SpotNow.
* The script send a SpotNow position request counter_spotnow times
* every pause_between_spotnow_request ms.
* The script needs a valid SpotNow ZTP set that can be set with the
* +UGLAASZTP AT command (info in UBX-22003096).
* To setup the EVK-R5 double UART please refer to the EVK user
* guide (UBX-19042592).
* In addition, the SpotNow tunneling is enabled in the AUX UART
* port to inspect the UBX strings provided by the sensor.
* The script configures the baudrate to 115200.
* m-center AT interface must be configured to 115200.
******************************************************************************
* Modules: SARA-R520
* Tested on: SARA-R520
******************************************************************************/

// defined global variable
string command, resp, resp1;

int generic_timeout = 10000; //[ms]
int spotnow_timeout = 30; //[s]
int spotnow_accuracy = 10; //[m]
int pause_between_spotnow_request = 3600000; //[ms]
int counter_spotnow = 10;
int max_number_retry_registration = 30; //max number of retry for registration
int max_number_uuloc_urc = 10; //max number of received +UULOC

string greeting_text = "Start!";

string spotnow_command = "AT+ULOC=2,16,1," + spotnow_timeout + "," + spotnow_accuracy; //script created for mode and response_type 2


void init()
{
ECHO("*************************************************************************************************************");
ECHO("This script needs an internet connection and a valid SpotNow token");
ECHO("*************************************************************************************************************");

command = "AT&V";
resp = SENDAT(command, generic_timeout, "OK");

command = "AT+CSGT?";
resp = resp + SENDAT(command, generic_timeout, "OK");

if (FIND(resp, "IPR:" + baudrate) == -1 || resp.findFirst(greeting_text) == -1) {

command = "AT+CSGT=1,\""+ greeting_text + "\"";
resp = SENDAT(command, generic_timeout, "OK");

command = "AT+IPR=115200";
resp = SENDAT(command, generic_timeout, "OK");

command = "AT&W";
resp = SENDAT(command, generic_timeout, "OK");

command = "AT+CFUN=16";
resp = SENDAT(command, generic_timeout, "OK");

resp = WAIT(greeting_text, generic_timeout * 10);
PAUSE(500);
}

command = "AT+USIO?";
resp = SENDAT(command, generic_timeout, "OK");

command = "AT+UGPRF?";
resp = resp + SENDAT(command, generic_timeout, "OK");

if (FIND(resp, "4,*4") == -1 || resp.findFirst("+UGPRF: 1") == -1) {

command = "AT+USIO=4";
resp = SENDAT(command, generic_timeout, "OK");

command = "AT+UGPRF=1";
resp = SENDAT(command, generic_timeout, "OK");

command = "AT+CFUN=16";
resp = SENDAT(command, generic_timeout, "OK");

resp = WAIT(greeting_text, generic_timeout * 10);
PAUSE(500);
}

// enable LOC URCs
command = "AT+ULOCIND=1";
resp = SENDAT(command, generic_timeout, "OK");

// enable network URCs
command = "AT+CEREG=2;+CREG=2;+CGREG=2;+CSCON=1;+CGEREP=2,1;+CMEE=2";
resp = SENDAT(command, generic_timeout, "OK");
}


void wait_for_registration_polling(void)
{
string command, command_creg, command_cereg, command_cgreg, resp;
ECHO("Waiting for registration");

int counter_cycle = 0;
bool registered = false;
command_cereg = "AT+CEREG?";
command_cgreg = "AT+CGREG?";

while (!registered) {
string status;
int stat;

resp = SENDAT(command_cereg, generic_timeout, "OK");
status = resp.split(": ")[1];
status = status.split("\r\nOK")[0];
stat = parseInt(status.split(",")[1]);

if (stat == 1 || stat == 5) {
registered = true;
ECHO("*************************************************************************************************************");
ECHO("Registered in PS domain");
ECHO("*************************************************************************************************************");
break;
}

resp = SENDAT(command_cgreg, generic_timeout, "OK");
status = resp.split(": ")[1];
status = status.split("\r\nOK")[0];
stat = parseInt(status.split(",")[1]);

if (stat == 1 || stat == 5) {
registered = true;
ECHO("*************************************************************************************************************");
ECHO("Registered in PS domain");
ECHO("*************************************************************************************************************");
break;
}

if (counter_cycle < max_number_retry_registration) {
counter_cycle++;
} else {
ECHO("*************************************************************************************************************");
ECHO("Registration status to be checked, stopping the script...");
STOP("*************************************************************************************************************");
}

PAUSE(5000);
}
}


void main()
{
ECHO("*************************************************************************************************************");
ECHO("REMEMBER TO HAVE ALREADY SET THE ZTP SERVICE with +UGLAASZTP AT command!");
ECHO("*************************************************************************************************************");
init();

for (int i = 0; i < counter_spotnow; i++) {
wait_for_registration_polling();
command = spotnow_command;
resp = SENDAT(command, generic_timeout, "OK");

bool uuloc_found = false;
int counter = 0;
//worst case scenario
while (!uuloc_found && counter < max_number_uuloc_urc) {
resp = WAIT("+UULOC", spotnow_timeout * 1000);
if (FIND(resp, "+UULOC: ") != -1) {
uuloc_found = true;
ECHO("*************************************************************************************************************");
ECHO("ULOC position received!");
ECHO("*************************************************************************************************************");
}
counter++;
}
PAUSE(pause_between_spotnow_request);
}
}
3 changes: 2 additions & 1 deletion at_scripts/location_features/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ This directory contains scripts for interfacing with u-blox GNSS modules, GNSS a
| `location_saraR5_saraR42_CellLocateFixOverTcp_basic` | This script has the purpose to demonstrate the use of CellLocate and sockets to send the received CellLocate location to a server using TCP connection. Script needs a valid CellLocate thingstream token and an activated internal context. Also a server_ip address is needed. | All products | LARA-R6, LARA-L6, SARA-R5, SARA-R42 |
| `location_saraR5_saraR42_aiding_advanced` | This script has the purpose to demonstrate the use of the GNSS chip Integrated into the modules. This script needs a "Start!" greeting message active on boot. The greeting text can be activated using the command AT+CSGT=1,"Start!" and using a fixed baud rate. | SARA-R510M8S, SARA-R422M8S | SARA-R510M8S, SARA-R422M8S |
| `location_saraR5_saraR42_aiding_advanced` | This script has the purpose to demonstrate the use of the GNSS chip Integrated into the modules. This script needs a "Start!" greeting message active on boot. The greeting text can be activated using the command AT+CSGT=1,"Start!" and using a fixed baud rate. | SARA-R510M8S, SARA-R422M8S | SARA-R510M8S, SARA-R422M8S |
| `location_saraR5_saraR42_gnssFixOverMQTT_basic` | This script has the purpose to demonstrate the use of the GNSS chip Integrated into the modules. This script needs a "+STARTUP" greeting message active on boot. The greeting text can be activated using the command AT+CSGT=1,"+STARTUP" and using a fixed baud rate. | All products | SARA-R510M8S, SARA-R422M8S, SARA-R422M10S, SARA-R510S |
| `location_saraR5_saraR42_gnssFixOverMQTT_basic` | This script has the purpose to demonstrate the use of the GNSS chip Integrated into the modules. This script needs a "+STARTUP" greeting message active on boot. The greeting text can be activated using the command AT+CSGT=1,"+STARTUP" and using a fixed baud rate. | All products | SARA-R510M8S, SARA-R422M8S, SARA-R422M10S, SARA-R510S |
| `location_saraR5_saraR42_laraR6_gnssCellInfo_advanced` | The script retrives info about the mobile network status together with the GNSS position in which the info are collected. The script encapsuletes the info with two set strings in order to make the results easy to parse. | SARA-R5, SARA-R42, LARA-R6 | SARA-R5, SARA-R42, LARA-R6 |
| `location_saraR52_lexiR52_SpotNowDemo_advanced` | The script retrives a GPS position using the SpotNow sensor. The script needs the configured SpotNow ZTP service (info in UBX-22003096). | SARA-R520, LEXI-R520 | SARA-R520 |

0 comments on commit c181fbf

Please sign in to comment.