Skip to content

Commit

Permalink
Added new scripts (#45)
Browse files Browse the repository at this point in the history
Those are:
- usbRebootExample
- gnssFixOverMqtt
- awsExpressLinkDemo
- tobyL2-Fota
  • Loading branch information
rebatoma committed Sep 23, 2022
1 parent 6271afd commit 7de6a10
Show file tree
Hide file tree
Showing 7 changed files with 595 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// all hidden files and folder

.*
7 changes: 7 additions & 0 deletions at_scripts/common_lib/library.atl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ void date_time_print(datetime d)
ECHO(d.get_year()+":"+d.get_month()+":"+d.get_day()+"-"+d.get_hour()+":"+d.get_minute()+":"+d.get_second());
}

// This function returns a string with the current date time variable into a standard format.
string get_date_time_now()
{
datetime now;
return now.get_year()+":"+now.get_month()+":"+now.get_day()+"-"+now.get_hour()+":"+now.get_minute()+":"+now.get_second();
}

// This function gets the information regarding modem via selected commands.
void get_modem_identity(void)
{
Expand Down
83 changes: 83 additions & 0 deletions at_scripts/firmware_update/fwUpdate_tobyL2-Fota_advance.atl
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/******************************************************************************
* 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: fwUpdate_tobyL2-Fota_advance.atl
* Topic: firmware_update
* Version: 1.0
* Author: rmcn
* Description:
* This scrip can be used to perform the FOTA update on TOBY-L2 modules.
******************************************************************************
* Modules: TOBY-L2
* Tested on: TOBY-L2
******************************************************************************/

// Initialization
ECHO("*************************************************************************************************************");
ECHO("This script requires to set some configurable parameters.");
ECHO("Be sure those are correctly configured before the initialization of this.");
ECHO("*************************************************************************************************************");

// Configurable parameters
string file_md5 = '';
string ftp_address = '';
string ftp_name = '';
string ftp_password = '';
string ftp_file_path = '';

// Other variables
string resp;
string command;

// Initial commands
ATI
ATI9
AT+CGDCONT?

// PDP context activation
AT+UPSD=0,0,0
AT+UPSD=0,100,4
AT+UPSDA=0,3

// FTP configuration
command = 'AT+UFTP=1,"' + ftp_address + '"';
SENDAT(command,6000,'OK');
command = 'AT+UFTP=2,"' + ftp_name + '"';
SENDAT(command,6000,'OK');
command = 'AT+UFTP=3,"' + ftp_password + '"';
SENDAT(command,6000,'OK');
AT+UFTP=6,1

resp = SENDAT('AT+UFTPC=1',60000,'+UUFTPCR:');
if (FIND(resp,'+UUFTPCR: 1,1') == -1)
{
STOP('Failed to connect to server');
}

command = 'AT+UFTPC=100,"' + ftp_file_path + '"';
resp = SENDAT(command,180000,'+UUFTPCR:');
if (FIND(resp,'+UUFTPCR: 100,1') == -1)
{
STOP('Failed to download image');
}

resp = SENDAT('AT+UFTPC=0',60000,'+UUFTPCR:');
if (FIND(resp,'+UUFTPCR: 0,1') == -1)
{
STOP('Failed to disconnect from server');
}

command = 'AT+UFWINSTALL=' + file_md5;
SENDAT(command,400,'+UUFTPCR:');
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*******************************************************************************
* 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: ipApp_saraR5_awsExpressLinkDemo_basic.atl
* Topic: internet_application
* Version: 1.0
* Author: mreb
* Description:
* This script has the purpose to demonstrate the MQTT use for
* communication between the u-blox SARA-R510AWS module and the AWS
* server. As an application's example, it simply sends 10 times
* the time to the AWS server.
* Product page:
* https://www.u-blox.com/en/product/SARA-R510AWS-module
******************************************************************************
* Modules: SARA-R510AWS
* Tested on: SARA-R510AWS
******************************************************************************/


// fixed variables
string command, resp, data_message;
int wait_ten_minutes = 600000;
int wait_one_minute = 60000;
int wait_five_seconds = 5000;
int times = 10;

// variable settings
string apn_address = "jtm2m";
int topic_id = 1;
string topic_name = "/example_topic_name";


// specific AWS AT command function to handle OK or ERROR response
void send_aws_at_command(string aws_command, int waiting_time){

aws_command = aws_command + "\r\n";
SENDTEXT(aws_command);
resp = "ERR Timeout"; // this error is used in case waiting_time expires
resp = WAIT("OK", "ERR", waiting_time);
if(FIND(resp, "ERR") != -1)
{
STOP("Command: " + aws_command + " is failing with error: " + resp);
}
}


void main(){
// Initialization
ECHO("*************************************************************************************************************");
ECHO("This script requires to set some configurable parameters.");
ECHO("Moreover the script can be used once the module providion has been already completed.");
ECHO("Be sure parameters and AWS end-point address are correctly configured before the initialization of this.");
ECHO("*************************************************************************************************************");

ECHO("Configuring...");
if (apn_address != "")
{
command = "AT+CONF APN=" + apn_address;
send_aws_at_command(command, wait_five_seconds);
}

ECHO("Performing the connection.");
send_aws_at_command("AT+CONNECT", 3*wait_ten_minutes);

command = "AT+CONF Topic" + topic_id + "=" + topic_name;
send_aws_at_command(command, wait_one_minute);

command = "AT+SUBSCRIBE" + topic_id;
send_aws_at_command(command, wait_one_minute);

int count = 0;
while (count < times)
{
data_message = "The time now is " + get_date_time_now();
command = "AT+SEND" + topic_id + " " + data_message;
send_aws_at_command(command, wait_one_minute);
PAUSE(wait_one_minute);
count++;
}

ECHO("Performing the disconnection.");
SENDAT("AT+DISCONNECT", wait_ten_minutes,"OK");
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
******************************************************************************
* Synopsis: location_saraR5_saraR42_aiding_advanced.atl
* Topic: location_features
* Version: 1.0
* Version: 1.1
* Author: mace
* Description:
* This script has the purpose to demonstrate the use of the GNSS chip
Expand All @@ -28,11 +28,8 @@
* Tested on: SARA-R510M8S, SARA-R422M8S
******************************************************************************/

// to check if it is the first round
bool first_round = true;

// iteration cycles
int iteration_number = 500;
int max_iteration = 200;

// modem type
// 0 - SARA-R510M8S
Expand Down Expand Up @@ -70,7 +67,7 @@ string apn_initial_def_bearer = "";

// function to wait for AT interface ready
// it looks for the string 'Start!'
void wait_for_at_ready(void)
void wait_for_at_ready()
{
string command = "Start!";
string resp = WAIT(command, 60000);
Expand All @@ -86,34 +83,34 @@ void wait_for_at_ready(void)
}
}

void modem_initialization (void)
void modem_initialization ()
{
string command, resp;

ECHO("Waiting for registration");
command = "AT+CFUN=4";
resp = SENDAT(command, 200, "OK");
PAUSE 20
PAUSE 20;
command = "AT+CMEE=2";
resp = SENDAT(command, 200, "OK");
PAUSE 20
PAUSE 20;
command = "AT+CREG=2";
resp = SENDAT(command, 200, "OK");
PAUSE 20
PAUSE 20;
command = "AT+CGREG=2";
resp = SENDAT(command, 200, "OK");
PAUSE 20
PAUSE 20;
command = "AT+CEREG=2";
resp = SENDAT(command, 200, "OK");
PAUSE 200
PAUSE 200;
command = "AT+CGDCONT=1,\"IP\",\"" + apn_initial_def_bearer + "\"";
resp = SENDAT(command, 200, "OK");
PAUSE 20
PAUSE 20;
command = "AT+CFUN=1";
resp = SENDAT(command, 200, "OK");
}

void wait_for_registration(void)
void wait_for_registration()
{
string command, resp;
int registration = 0;
Expand All @@ -128,33 +125,33 @@ void wait_for_registration(void)
if(FIND(resp1, "+CREG: 1") != -1)
{
ECHO("Registered on network (HPLMN)");
registration=1;
registration = 1;
}
else if(FIND(resp1, "+CREG: 5") != -1)
{
ECHO("Registered on roaming (VPLMN)");
registration=1;
registration = 1;
}
else if(FIND(resp1, "+CEREG: 1") != -1)
{
ECHO("Registered on network (HPLMN)");
registration=1;
registration = 1;
}
else if(FIND(resp1, "+CEREG: 5") != -1)
{
ECHO("Registered on roaming (VPLMN)");
registration=1;
registration = 1;
}
else
{
ECHO("Registration status to be checked (not HPLMN)");
}
}


command = "AT+CGACT=1,1";
resp = SENDAT(command, 10000, "OK");
if (modem_type == 0)
{
command = "AT+CGACT=1,1";
resp = SENDAT(command, 10000, "OK");
command = "AT+UPSD=0,0,0";
resp = SENDAT(command, 10000, "OK");
command = "AT+UPSD=0,100,1";
Expand All @@ -169,9 +166,6 @@ void wait_for_registration(void)
void main()
{
string command, resp;
int aiding_online;
int max_iteration = 200;
int aiding = aiding_type;

ECHO("*************************************************************************************************************");
ECHO("This script needs 'Start!' greeting message active on boot");
Expand All @@ -197,15 +191,8 @@ void main()
command ="AT+ULOCIND=1";
resp = SENDAT(command, 1000, "OK");

/*
if (first_round)
{
aiding = 15;
first_round = false;
}
*/

if ((aiding & 4) == 4 || (aiding & 2) == 2)
if ((aiding_type & 4) == 4 || (aiding_type & 2) == 2)
{
ECHO("AIDING CONFIGURED REQUIRES DATA CONNECTION");
wait_for_registration();
Expand All @@ -218,45 +205,34 @@ void main()
ECHO("*************************************************************************************************************");
ECHO("STARTING GNSS");
ECHO("*************************************************************************************************************");
gnss_command ="AT+UGPS=1," + aiding + "," + gnss_system;
gnss_command ="AT+UGPS=1," + aiding_type + "," + gnss_system;
resp = SENDAT(gnss_command, 6000, "OK");
PAUSE 2000;

for (int i = 0; i < max_iteration; i++)
{
command ="AT+UGRMC?";
resp = SENDAT(command, 1000, "OK");
PAUSE 200
PAUSE 200;
}

// read twice TTFF value from UBX-NAV-STATUS
// read TTFF value from UBX-NAV-STATUS
command = "AT+UGUBX=\"B56201030000040D\"";
resp = SENDAT(command, 1000, "OK");
PAUSE 200
PAUSE 200;
resp = resp.substr(37,8);
// ECHO("TTFF in UBX-NAV-STATUS is " + resp);
resp = SWAPENDIAN(resp);
ECHO("TTFF in UBX-NAV-STATUS is " + resp);
float ttff = parseUInt(resp, 16);
ttff = ttff / 1000;
ECHO("TTFF in UBX-NAV-STATUS is " + ttff +" s");
PAUSE 1000
command = "AT+UGUBX=\"B56201030000040D\"";
resp = SENDAT(command, 1000, "OK");
PAUSE 200
resp = resp.substr(37,8);
//ECHO("TTFF in UBX-NAV-STATUS is " + resp);
resp = SWAPENDIAN(resp);
ECHO("TTFF in UBX-NAV-STATUS is " + resp);
ttff = parseUInt(resp, 16);
ttff = ttff / 1000;
ECHO("TTFF in UBX-NAV-STATUS is " + ttff +" s");
PAUSE 1000
PAUSE 1000;


command ="AT+UGPS=0";
resp = SENDAT(command, 5000, "OK");
PAUSE 1000
PAUSE 1000;
command ="AT+CPWROFF";
resp = SENDAT(command, 10000, "OK");
}
Loading

0 comments on commit 7de6a10

Please sign in to comment.