Sony Ericsson RC function, Use of the RC function for remote script download Application Note

Page 1
Application Note
Use of the RC function
for remote script download
Page 2
Second edition (February 2004)
Sony Ericsson Mobile Communications. publishes this manual without making any warranty as to the
content contained herein. Further Sony Ericsson Mobile Communications. reserves the right to make modifications, additions and deletions to this manual due to typographical errors, inaccurate information, or improvements to programs and/or equipment at any time and without notice. Such changes will, nevertheless be incorporated into new editions of this manual.
All rights reserved.
© Sony Ericsson Mobile Communications., 2004
Page 3
Remote script download using RC intrinsic function
LZT 123 7799 R1B 3
Contents
1
INTRODUCTION ................................................................................................................ 4
2 OVERVIEW ........................................................................................................................5
2.1 GENERAL.......................................................................................................................... 5
2.2 CONTROL PC SETUP ......................................................................................................... 5
2.3 REMOTE GR47 SETUP ...................................................................................................... 6
2.4 SECURITY ASPECTS........................................................................................................... 6
2.4.1 SMS ......................................................................................................................... 6
2.4.2 CLIP......................................................................................................................... 6
3 FUNCTIONAL DESCRIPTION OF THE EMBEDDED APPLICATION ............................. 7
3.1 FLOW CHART OF REMOTE CONTROL APPLICATION................................................................ 7
3.2 FUNCTIONAL DESCRIPTION ................................................................................................ 8
3.3 EMBEDDED APPLICATION CODE ......................................................................................... 9
Page 4
Remote script download using RC intrinsic function
LZT 123 7799 R1B 4
1 Introduction
The GR47 has been designed so that scripts embedded within the device can be updated either through a serial interface on UART1 or where this is not feasible, due to location, remotely using the air interface. The script resident in the device must be written in a way that makes remote access permissible and preferably with some form of authentication of the calling party.
Page 5
Remote script download using RC intrinsic function
LZT 123 7799 R1B 5
2 Overview
2.1 General
The remote script download is dependant on the currently active script within the GR47 having the remote control (RC) intrinsic function capability written in such a way that once a circuit switch data (CSD) call is received, the remote control (RC) intrinsic function is called and the remote script download takes place. Once the script is down loaded into GR47 memory and all checksums are verified, the GR47 is reset and on completion of the power up routine the new downloaded script is activated.
It is imperative that the new script downloaded using the over the air routine also has the RC functionality written into it as once the new script is activated and running, then without having the remote control (RC) functionality active, the script will not be able to be updated again.
The remote download process takes care of script number allocation and will use whatever script number is not being used by the activated script. This ensures that the original script is not lost and can be activated again if the new script is not functioning as expected.
Note: It is very important that the new script to be downloaded using the remote download facility has been checked thoroughly for possible bugs or run time errors. As once the script is downloaded and activated, it is not possible to gain remote access again if the script has crashed and is not running.
2.2 Control PC setup
The remote PC will require the latest integrators development environment (IDE) to be installed.
Connection via UART1 to a GSM modem, with a script ready to be downloaded needs to be opened in the IDE screen.
Select the yellow telephone icon next to the main script download button in the tools menu. A pop up box will ask for the data telephone number of the GR47 you are going to download a script to. Enter the number and select OK and wait for the remote download pop up to appear.
Once the remote download popup appears select download and the script will be downloaded to the remote device. Progress can be monitored on the download bar as a percentage to completion. Once the download has finished, you must select the EXIT button on the download popup which will reset the remote device and the new script will be run on power up.
Page 6
Remote script download using RC intrinsic function
LZT 123 7799 R1B 6
2.3 Remote GR47 Setup
The GR47 that is to have its script updated by using the RC function must have a script with the RC functionality active as part of the main loop within the script structure (example Section 3.3). The remote GR47 must also have a SIM card with a data number to allow the setup of a CSD call. Progress of the remote script download can be monitored on UART2 as part of the debug data. This is done with the use of prtf statements within the RC function and with PRS(0) set to turn off normal debug.
2.4 Security aspects
When implementing the code, some thought should be given to ensuring that no unauthorized entity can dial into the module and perform an unauthorised download.
Two methods are described below which are easy to implement and secure in their operation.
2.4.1 SMS
The script attached to this application note relies upon a data call being received then switching the RC function on. This can also be done in reverse i.e. the application can be made to dial a target server and then switched on the RC function.
This operation could be triggered by an incoming SMS, the format of which is recognised by the script i.e. the text of the SMS could be
‘Update required: code 1234 call service centre’.
This should be sent from a known number.
2.4.2 CLIP
Alternatively the script below could be adjusted to activate CLIP (Caller Line Presentation) and only answer the call if it recognised that the call was from its service centre..
Page 7
Remote script download using RC intrinsic function
LZT 123 7799 R1B 7
3 Functional Description of the Embedded Application
3.1 Flow chart of remote control application
Script download occurs between, check call status steps.
Execute My Script
Main
Update required
Setup data
Check call status
Call
A
ctive
Check call status
Call
Online
Restart Modem
Call
A
ctive
a
a
Page 8
Remote script download using RC intrinsic function
LZT 123 7799 R1B 8
3.2 Functional Description
This Function or something very similar has to be running in the target module to ensure that the download function will answer the data call made to establish a data download connection. Establishment of a data call is dealt with above.
The first consideration in the script is to establish a data channel. It is possible to establish two instances of a data channel within a script (instance one can only be used for data calls). Thus consideration of
data channels use within the script needs careful consideration if remote download is to be used. Although auto answer (ATS0) is
defined within the function it could be set in the initialization section of the script as a default parameter.
Regardless of how auto answer is set, a data channel instance 1 has to be opened. Channel instance 1 can be used for either data or at commands instance 0 can only be used for at commands.
In this example the channel status is being tested by waiting for data carrier detect (DCD) to be asserted this is tested with a value which is incremented every second to check the data call is connected.
The call connects and the script is ready to send data over the data link.
Data is sent using file transfer method called X Modem. X Modem uses a CRC check of data sent and control characters sent, this method is used to ensure the data is not corrupted over the air. If a block does fail then the block is resent, the maximum number of retries allowed per block transferred is 3. This is sufficient to allow a script to be transferred. If 3 retries is exceeded then the download will fail.
The script will be downloaded with the attributes set “start from power up” and “activate slot n“ set. The slot chosen to download to and activate would be the slot not currently active. This means on a power cycle, if the original script has, start from power up enabled it will start if the down load fails. Otherwise if the download is successful the new script will take control.
Page 9
Remote script download using RC intrinsic function
LZT 123 7799 R1B 9
3.3 Embedded Application Code
The following code sample (using Sony Ericsson’s M2mpower help file) can be used to set-up the RC functionality within a script.
/* This example shows how simple Over the Air Download can work using the RC function. */
int Rslt;
RemoteMode () { int st = 0; int first; int num; int cnt;
st = 0; cnt = 0;
chcrt (1); prtf("\nRemote Mode\n");
/* auto answer on data channel */ chw (1, "ATS0=1\n\r", 8);
/* wait for data mode */ st = 0; first = 1;
while (st == 0 && cnt < 60) { /* check status of call every second */ dlys (1); cnt++; st = chsts (1);
/* check for DCD */ st = st & 0x02; }
/* setup remote control */ while (st != 0) { if (first == 1) { st = rc (1); prtf ("rc status NUMBER 1 = %d\n", st); first = 0; }
Page 10
Remote script download using RC intrinsic function
LZT 123 7799 R1B 10
else { /* check status of call every second */ dlys (1);
prtf ("online status NUMBER 1 = %d\n", st);
st = chsts(1); st = st & 0x02; } }
if (first == 0) { /* disable remote control and reset the module */ prtf ("disable rc\n"); rc(0); rst(0); } }
ExecuteMyScript() { return(0); }
main () { int chlerr; char chlsts; int APPS_NETWORK_STATUSBYTE = 10; int AT_NET_REGISTERED = 1;
prs(0); prtf("\r\n Waiting for Network registration...");
while(gtb(APPS_NETWORK_STATUSBYTE) != AT_NET_REGISTERED) { dlys(1); } prtf("\r\n Now registered!");
while (1) {
prtf ("\r\n - Executing My Script..."); Rslt = ExecuteMyScript (); prtf ("\r\n >>> ExecuteMyScript result: %d", Rslt);
if (Rslt == 0) { prtf ("\r\nOK!"); } else
Page 11
Remote script download using RC intrinsic function
LZT 123 7799 R1B 11
{ prtf ("\r\nFAILED!"); }
RemoteMode (); prtf ("\r\n\nScript Complete!");
} }
Loading...