Libelium Waspmote 3G Plus GPS Networking Manual

Waspmote 3G + GPS
Networking Guide
-2-
v4.9
Document Version: v4.9 - 06/2015 © Libelium Comunicaciones Distribuidas S.L.
INDEX
1. General Considerations ...................................................................................................................... 6
1.1. Introduction ...................................................................................................................................................................................6
1.2. 3G vs GPRS ......................................................................................................................................................................................7
1.3. Hardware .........................................................................................................................................................................................8
1.4. Waspmote Libraries .................................................................................................................................................................. 10
1.4.1. Waspmote 3G Files .....................................................................................................................................................10
1.4.2. Constructor ...................................................................................................................................................................10
1.4.3. Working Modes ..........................................................................................................................................................10
1.4.4. Library fuses .................................................................................................................................................................11
1.4.5. Debug modes ..............................................................................................................................................................11
1.4.6. Special errors ...............................................................................................................................................................11
2. Initialization ....................................................................................................................................... 12
2.1. Initializing the 3G/GPRS module ......................................................................................................................................... 12
2.2. 3G power modes ....................................................................................................................................................................... 12
2.3. Closing communications with the 3G/GPRS module ................................................................................................. 12
2.4. Switching 3G o ........................................................................................................................................................................ 13
2.5. Checking the GSM connection ............................................................................................................................................ 13
2.6. Setting time and date from RTC ..........................................................................................................................................13
2.7. Setting operator parameters ................................................................................................................................................14
3. SIM related functions ........................................................................................................................ 15
3.1. Setting the PIN ........................................................................................................................................................................... 15
3.2. Changing PIN number.............................................................................................................................................................15
3.3. Getting IMSI ............................................................................................................................................................................... 15
3.4. Getting IMEI ...............................................................................................................................................................................16
4. GSM related functions ....................................................................................................................... 17
4.1. Setting information returned when receiving a call ....................................................................................................17
4.2. Making calls ................................................................................................................................................................................ 17
4.3. Making lost calls ....................................................................................................................................................................... 17
4.4. Hanging up calls ........................................................................................................................................................................ 18
4.5. Setting CLI presentation in incoming calls ...................................................................................................................... 18
4.6. Setting CLI restriction in outcoming calls ........................................................................................................................ 18
4.7. Gets the phone activity status .............................................................................................................................................. 19
4.8. Autoanswer ................................................................................................................................................................................. 19
4.9. Answer a call ............................................................................................................................................................................... 19
4.10. Generating DTMF tones ....................................................................................................................................................... 20
4.11. Ringer level ............................................................................................................................................................................... 21
-3-
v4.9
4.12. Setting Information returned when receiving an SMS ............................................................................................. 21
4.13. Setting Mode for SMS ........................................................................................................................................................... 21
4.14. Sending SMS ............................................................................................................................................................................ 22
4.15. Getting the number of SMS stored in SIM card ........................................................................................................... 22
4.16. Deleting SMS ............................................................................................................................................................................ 22
5. File system related functions ............................................................................................................ 23
5.1. Description .................................................................................................................................................................................. 23
5.2. Go to the root directory of desired unit ............................................................................................................................23
5.3. Changing directory .................................................................................................................................................................. 23
5.4. Getting le size ..........................................................................................................................................................................24
5.5. Deleting les ............................................................................................................................................................................... 24
5.6. MicroSD is present .................................................................................................................................................................... 24
5.7. List subdirectories/les in current directory ................................................................................................................... 25
5.8. Getting les from 3G/GPRS to Waspmote ........................................................................................................................ 25
6. Camera related functions .................................................................................................................. 26
6.1. Connecting the camera .......................................................................................................................................................... 26
6.2. Starting the camera ..................................................................................................................................................................26
6.3. Stopping the camera ............................................................................................................................................................... 27
6.4. Conguration of the camera ................................................................................................................................................. 27
6.4.1. Resolution .....................................................................................................................................................................27
6.4.2. Brightness .....................................................................................................................................................................28
6.4.3. Rotation .........................................................................................................................................................................28
6.4.4. FPS ...................................................................................................................................................................................29
6.4.5. Picture name ................................................................................................................................................................29
6.4.6. Adding time stamp on pictures ............................................................................................................................29
6.5. Taking pictures ........................................................................................................................................................................... 30
6.6. Recording videos ......................................................................................................................................................................30
6.7. Making videocalls ..................................................................................................................................................................... 31
6.8. Setting the video quality ........................................................................................................................................................ 32
6.9. Sending DMTF tones ...............................................................................................................................................................32
7. FTP and FTPS ...................................................................................................................................... 33
7.1. Creating your own FTP server ..............................................................................................................................................33
7.2. FTP related functions ............................................................................................................................................................... 34
7.2.1. Setting FTP parameters ............................................................................................................................................34
7.2.2. Uploading les from Waspmote ...........................................................................................................................35
7.2.3. Uploading les from 3G/GPRS module ..............................................................................................................35
7.2.4. Downloading les to Waspmote ..........................................................................................................................36
7.2.5. Downloading les to 3G/GPRS module .............................................................................................................36
7.3. FTPS related functions ............................................................................................................................................................37
7.3.1. Log into FTPS server ..................................................................................................................................................37
7.3.2. Uploading les from Waspmote ...........................................................................................................................37
7.3.3. Uploading les from 3G/GPRS module ..............................................................................................................38
-4-
v4.9
7.3.4. Downloading les to Waspmote ..........................................................................................................................38
7.3.5. Downloading les to 3G/GPRS module .............................................................................................................39
7.3.6. Log out the FTPS server ...........................................................................................................................................39
8. SMTP and POP3 related functions.................................................................................................... 40
8.1. Sending email with SMTP ...................................................................................................................................................... 40
8.1.1. Setting the SMTP server ...........................................................................................................................................40
8.1.2. Setting the sender address and name ................................................................................................................40
8.1.3. Setting the recipient address and name ............................................................................................................40
8.1.4. Setting the subject and the body.........................................................................................................................41
8.1.5. Attaching les ..............................................................................................................................................................41
8.1.6. Sending the email ......................................................................................................................................................41
8.2. Receiving emails with POP3 .................................................................................................................................................. 42
8.2.1. Setting the POP3 server parameters ...................................................................................................................42
8.2.2. Getting a list of emails ..............................................................................................................................................42
8.2.3. Getting the header of an email .............................................................................................................................42
8.2.4. Getting an email .........................................................................................................................................................43
8.2.5. Deleting an email .......................................................................................................................................................43
9. HTTP and HTTPS ................................................................................................................................ 44
9.1. HTTP connections ..................................................................................................................................................................... 44
9.1.1. GET method .................................................................................................................................................................44
9.1.2. POST method ...............................................................................................................................................................44
9.1.3. Server response ..........................................................................................................................................................45
9.2. Reading an URL ..........................................................................................................................................................................45
9.3. Sending a frame to Meshlium .............................................................................................................................................. 46
9.4. HTTPS connections .................................................................................................................................................................. 47
9.4.1. HTTPS function ...........................................................................................................................................................48
10. GPS .................................................................................................................................................... 49
10.1. Dierences between GPS modes .....................................................................................................................................49
10.2. Technical data from the GPS receiver .............................................................................................................................. 49
10.3. Starting GPS .............................................................................................................................................................................. 50
10.4. Stopping the GPS ...................................................................................................................................................................51
10.5. Managing GPS data ............................................................................................................................................................... 51
11. TCP and UDP connections ............................................................................................................... 53
11.1. Conguration of the 3G/GPRS module for TCP and UDP ......................................................................................... 53
11.2. Getting the IP assigned to the module ...........................................................................................................................54
11.3. Query a IP address from a domain name .......................................................................................................................54
11.4. Query a domain name from a IP address .......................................................................................................................55
11.5. Working in single client mode ........................................................................................................................................... 55
11.5.1. Creating a socket .....................................................................................................................................................55
11.5.2. Sending and receiving data .................................................................................................................................56
11.5.3. Closing the socket ...................................................................................................................................................56
-5-
v4.9
11.6. Working in multi client mode.............................................................................................................................................56
11.6.1. Enable the multi client mode ..............................................................................................................................57
11.6.2. Creating sockets .......................................................................................................................................................57
11.6.3. Sending and receiving data .................................................................................................................................57
11.6.4. Closing the socket ...................................................................................................................................................58
11.7. Working in TCP server mode ..............................................................................................................................................58
11.7.1. Creating the server ..................................................................................................................................................58
11.7.2. Listing the clients .....................................................................................................................................................59
11.7.3. Activate a client ........................................................................................................................................................59
11.7.4. Sending and receiving data .................................................................................................................................59
11.7.5. Disconnecting a client ...........................................................................................................................................60
11.7.6. Closing the server ....................................................................................................................................................60
12. Miscellaneous functions ................................................................................................................. 61
12.1. Managing incoming data .................................................................................................................................................... 61
12.2. Getting RSSI level ....................................................................................................................................................................61
12.3. Getting cell system information ........................................................................................................................................ 61
12.4. Getting cell channel information ..................................................................................................................................... 62
12.5. Getting serving cell radio parameters ............................................................................................................................63
12.6. Setting preferred service domain ..................................................................................................................................... 63
12.7. Scanning the network band channels ............................................................................................................................ 64
12.8. Getting UE system information ......................................................................................................................................... 65
12.9. Show network system mode .............................................................................................................................................. 66
12.10. Shows system information in WCDMA .........................................................................................................................66
12.11. Setting network system mode preference .................................................................................................................67
12.12. Setting the preferences for order of acquisitions .....................................................................................................67
12.13. Choosing the storage location ........................................................................................................................................ 68
12.14. Changing the baudrate ......................................................................................................................................................68
12.15. Sending AT commands to the 3G/GPRS module .....................................................................................................68
12.16. Choosing audio output ......................................................................................................................................................69
12.17. Setting the gain level of the microphone ................................................................................................................... 69
12.18. Setting the loudspeaker volume .................................................................................................................................... 69
12.19. Getting module information ...........................................................................................................................................70
13. Geolocation tracker application example ..................................................................................... 71
14. API changelog .................................................................................................................................. 74
15. Documentation changelog ............................................................................................................. 75
Apendix A. CME error codes ................................................................................................................. 76
Apendix B. CMS error codes .................................................................................................................. 77
-6-
v4.9
General Considerations
1. General Considerations
1.1. Introduction
The 3G/GPRS module for Waspmote allows sensor networks and M2M devices to connect to the Cloud by using high speed WCDMA and HSPA cellular networks in the same way as Smartphones do. This makes possible sensor nodes send not only discrete sensor information such as temperature or humidity (which can be encoded using just a single number) but also complex streams of information such as photos and videos. This feature allows developers the creation of new Smart Security applications.
The 3G/GPRS module for the Waspmote sensor platform oers speed rates of 7.2Mbps in download mode and 5.5Mbps when uploading information to the Cloud. This is a incredible increase compared with previous cellular technologies such as GPRS we rates were of 0.02Mbps and 0.01Mbps respectively.
Each Waspmote sensor node may integrate at the same time a medium range radio such as 802.15.4/ZigBee/Bluetooth/WiFi and one long range 3G radio. This way we can minimize costs by using the mobile network just when really needed.
The module counts also with an internal GPS what enables the location of the device outdoors and indoors combining standard NMEA frames with mobile cell ID triangulation using both assisted-mobile (A-GPS) and mobile-based (S-GPS) modes.
The 3G communicating module is specially oriented to work with Internet servers implementing internally several application layer protocols which make easier to send the information to the cloud. We can make HTTP and HTTPS (secure mode) navigation, downloading and uploading content to a web server. In the same way FTP and FTPS (secure mode) protocols are also available, which is really useful when your application requires handling les. You can even send and receive mails directly from Waspmote using the SMTP and POP3 clients implemented internally.
Coinciding with the release of the 3G/GPRS module and in order to take part of all the the capabilities Libelium launched the Video Camera Sensor board, which allows to each of the nodes of the sensor network to take photos (640x480), record videos (320x240) and upload them in real time to the Cloud. The Video Camera Sensor board includes 22 high power IR LED’s to implement a night vision mode.
The 3G/GPRS module comes with an internal SD Card of 2GB (extended up to 32GB) which is used to store the photos and videos taken by the Video Camera Sensor Board without the need of being handled by the MCU. This ensures we get real speed ranges (7.2Mbps download and 5.5Mbps upload) as the communication is direct between the SD and the 3G/GPRS module.
The GPS module also makes possible perform geolocation services even indoors as it can work in A-GPS and S-GPS modes, so the location given by the GPS through NMEA sentences is completed with the cell information provided by both the 3G/GPRS module and external Internet Geoposition Servers such as the ones oered by Google which helps you to get the most accurate location in real time.
-7-
v4.9
General Considerations
1.2. 3G vs GPRS
Comparative table between the 3G and the GPRS module for Waspmote:
Model 3G (SIM5218) GPRS (SIM900) GPRS+GPS (SIM928)
Download speed 7.2Mbps 0.02Mbps 0.02Mbps
Upload speed 5.5Mbps 0.01Mbps 0.01Mbps
FTP Yes Yes Yes
FTPS (Secure) Yes No No
HTTP Yes Yes Yes
HTTPS (Secure) Yes No No
TCP/UDP Sockets Yes Yes Yes
Mails Yes No No
GPS Yes (A-GPS + S-GPS + NMEA) No Yes, but only NMEA stand-
alone mode
Video Camera Yes (Photo + Video) No No
Video Calls Yes No No
Protocols 3G, WCDMA, HSPA, UMTS, GPRS, GSM GPRS/GSM GPRS/GSM
Frequency Bands 850, 900, 1800, 1900, 2100MHz 850, 900, 1800, 1900MHz 850, 900, 1800,1900MHz
SD Card Yes (up to 32GB) No No
Figure: Comparative table between 3G/GPRS module, GPRS and GPRS+GPS module.
-8-
v4.9
General Considerations
1.3. Hardware
GSM / GPRS / 3G module
Figure: 3G/GPRS board
Model: SIM5218E (SIMCom)
Tri-Band UMTS 2100/1900/900MHz
Quad-Band GSM/EDGE, 850/900/1800/1900 MHz
HSDPA up to 7.2Mbps
HSUPA up to 5.76Mbps
TX Power:
- UMTS 900/1900/2100 0,25W
- GSM 850MHz/900MHz 2W
- DCS1800MHz/PCS1900MHz 1W
Sensitivity: -106dBm
Antenna connector: UFL
External Antenna: 0dBi
Consumption in sleep mode: 1mA
Dimensions (3G/GPRS module): 33 x 62 x 12 mm
Dimensions (3G/GPRS module plugged on Waspmote): 73 x 62 x 20 mm
Note for USA users: We have tested the new 3G shield with the AT&T network which supports nativelly the GSM and 3G protocolos. With other carriers may also work although we haven’t tried and thus we can not ensure it. For this reason we recommend to use AT&T SIM cards.
-9-
v4.9
General Considerations
Actions:
Videocall, record video and take pictures available with Video Camera Sensor Board
Support microSD card up to 32GB
64MB of internal storage space
Making/Receiving calls
Making ‘x’ tone missed calls
MS-assisted (A-GPS), MS-based (S-GPS) or Stand-alone GPS positioning
Sending/Receiving SMS
Single connection and multiple connections TCP/IP and UDP/IP clients
TCP/IP server.
HTTP and HTTPS service
FTP and FTPS Service (downloading and uploading les)
Sending/receiving email (SMTP and POP3)
OTA feature can be performed now by Waspmote’s 3G/GPRS module. Refer to the Over the Air Programming Guide for more information:
http://www.libelium.com/development/waspmote/documentation/over-the-air-programming-guide-otap/
Figure: 3G/GPRS board in Waspmote
Figure: 3G/GPRS board top
-10-
v4.9
General Considerations
Figure: 3G/GPRS board bottom
1.4. Waspmote Libraries
1.4.1. Waspmote 3G Files
Wasp3G.h ; Wasp3G.cpp
1.4.2. Constructor
In order to start using Waspmote 3G library, an object from class ‘Wasp3G’ must be created. This object, called ‘_3G’, is created inside Waspmote 3G library and it is public to all libraries. It is used throughout the guide to show how the Waspmote 3G library works.
When creating this constructor, some variables are dened with a value by default, that can be modied later. These variables are:
_baudRate : species the baudrate used to communicate with the module (115200 by default).
_socket : species the socket used to communicate with the module (socket1 by default).
_pwrMode : species the power mode (_3G_ON by default).
1.4.3. Working Modes
Some constants have been dened to set the dierent working modes for the 3G/GPRS module.
1: _3G_ON. Module is powered on. Starts the module in full functionality.
2: _3G_FULL. Module is set in full functionality (power consumption around 50mA with peaks around 1-1’4A).
3: _3G_MINIMUM. Module deactivates RF and SIM (power consumption around 35mA).
4: _3G_RF_OFF. Module deactivates RF (power consumption around 35mA).
5: _3G_SLEEP. In this mode the 3G/GPRS module deactivates RF and SIM and enters in sleep mode when the when the periphery equipment stops working. The power consumption in this state is around 1mA.
0: _3G_OFF. Module is powered o. Supply from the battery are disconnected by the transistors.
When the module communicates with carrier, current peaks between 1-1’4A are produced.
-11-
v4.9
General Considerations
1.4.4. Library fuses
The library for this module is divided in 9 sections and other section with functions and constants that always are active. Each section is activated/deactivated by a fuse. This fuses are located in Wasp3G.h. By default this fuses have a ‘1’ allowing to use the functions. The Wasp3G.h have this fuses:
GSM_FUSE: Call and SMS related funtions and constants
CAMERA_FUSE: Camera related funtions and constants
FTP_FUSE: FTP related funtions and constants
MAIL_FUSE: SMTP and POP3 related funtions and constants
HTTP_FUSE: HTTP and HTTPS related funtions and constants
GPS_FUSE: GPS related funtions and constants
IP_FUSE: TCP and UDP related funtions and constants
TRANSMISION_FUSE: File transmission related funtions and constants
OTA_FUSE: OTA related funtions and constants (FTP_FUSE must be ‘1’ too)
For deactivate a section change the ‘1’ in the related fuse by ‘0’.
Note: If you use a function with the related fused with a value of ‘0’, the compiler will give you an error. Please, be carefully when you use the fuses.
Note: If you do not use the Videocamera Board, switch the Videocamera fuse to 0.
1.4.5. Debug modes
The library have two debug modes implemented that allows to the experimented user show the data transmitted and received between the Waspmote and the 3G/GPRS module. The value of the _3G_debug_mode constant selects the debug mode:
‘0’ Disables all debug messages
‘1’ Shows only the commands sent to the 3G/GPRS module and some extra messages
‘2’ Shows commands sent to the 3G/GPRS module, the data answered by the module and some extra messages
The constant _3G_debug_mode is located in Wasp3G.h le.
1.4.6. Special errors
Some functions can give an extra error code (CME or CMS error codes). This code is stored on _3G.CME_CMS_code. To know the description of the code see the appendix.
-12-
v4.9
Initialization
2. Initialization
2.1. Initializing the 3G/GPRS module
The 3G/GPRS module is connected to a multiplexer, since it is connected to the same microcontroller UART. To start using the 3G/GPRS module, this multiplexer must be switched on and choose the correct combination for the 3G to be selected. This selection is (1,1).
To open the UART and set the multiplexer to the correct combination, a function has been developed. This function powers on (_3G.setMode(_3G_ON)) the module too, but doesn’t congure the UART.
Example of use:
{
// Congures the Waspmote to work with 3G module and starts it:
_3G.ON(); }
2.2. 3G power modes
The 3G/GPRS module has ve dierent power modes: _3G_ON, _3G_FULL, _3G_MINIMUM, _3G_OFFLINE, _3G_SLEEP and _3G_
OFF.
The function setMode will set up the ‘pwrMode’ variable to one of the ve values, but also congures the Waspmote’s pins and sends the serial command to the 3G/GPRS module. It returns ‘1’ on success, ‘0’ and ‘-2’ if error and ‘-3’ when the module starts succesfully with low battery (in which case the user should expect future failures due to not enough power).
The function getMode() gets the power mode of the module.
Example of use:
{
uint8_t powerMode=0; // Sets the 3G in full functionality:
_3G.setMode(_3G_FULL);
// Get _3G power mode: powerMode=_3G.getMode ();
}
Related variables _3G.pwrMode stores 3G power mode
2.3. Closing communications with the 3G/GPRS module
It closes the UART to which the 3G/GPRS module is connected. It means disconnecting the internal UART drivers inside the ATMEGA1281 processor, but the power mode of the 3G/GPRS module don’t change.
Example of use:
{
// Closes UART: _3G.close();
}
-13-
v4.9
Initialization
2.4. Switching 3G o
It closes the UART to which the 3G/GPRS module is connected to and turns it o.
Example of use:
{
// Closes UART and turns it off:
_3G.OFF(); }
2.5. Checking the GSM connection
It checks if the module is connected to the network for a time desired by the input parameter.
If the 3G/GPRS module does not connect within these attempts, function exits with ‘0’.
Example of use:
{
// Waits 60 seconds for connection: _3G.check(60);
}
This function returns:
‘1’ if the module is connected to the carrier
‘0’ if not connected
According to Libelium experience, 60 seconds is the recommended timeout for connecting the 3G/GPRS network. The timeout may vary depending on the network range and quality of service. If the user detects this timeout does not allow his 3G/GPRS to connect, he can experiment with higher values. 120 seconds would be the maximum advised timeout: if the 3G/ GPRS module cannot connect in 2 minutes, it is better to stop trying and check again in the next loop.
Note for USA users: We have tested the new 3G shield with the AT&T network which supports nativelly the GSM and 3G protocols. With other carriers may also work although we haven’t tried and thus we can not ensure it. For this reason we recommend to use AT&T SIM cards.
2.6. Setting time and date from RTC
This function updates the time and the date of the 3G/GPRS module from the RTC.
Example of use:
{
// Updates time and date: _3G.setTime();
}
This function returns:
‘1’ on success
‘0’ if error
‘-2’ if error with CME error response
-14-
v4.9
Initialization
2.7. Setting operator parameters
When the 3G module uses some services like IP connections (TCP/UDP), HTTP services, SMTP/POP3 or FTP transfers, it’s mandatory to congure operator parameters like APN, login and password.
There are two ways to congure these settings. The rst one is to use the denitions into the le Wasp3G.h.
#dene _3G_APN “apn” #dene _3G_LOGIN “login” #dene _3G_PASSW “password”
The second one is to use the function set_APN().
Example of use:
{
// If only APN is necessary _3G.set_APN(“provider_APN”); // If APN, login and password are necessary _3G.set_APN(“provider_APN”, “login”, “password”);
}
-15-
v4.9
SIM related functions
3. SIM related functions
Some functions have been developed to congure some settings related with GSM, specically with managing calls and SMS.
3.1. Setting the PIN
It sets the PIN to the SIM card.
Example of use:
{
// Sets PIN=1234 to the SIM: _3G.setPIN(“1234”);
}
This function returns:
‘1’ on success
‘0’ if error
3.2. Changing PIN number
It changes PIN number of SIM card.
Example of use:
{
// Changes the PIN number from “1234” to “4321”: _3G.changePIN(“1234”, “4321”);
}
This function returns:
‘1’ on success
‘0’ if error
‘-1’ if CME code are available
3.3. Getting IMSI
It gets the IMSI from the SIM card and it stores the IMSI into buffer_3G variable.
Example of use:
{ _3G.getIMSI(); }
This function returns:
‘1’ on success
‘0’ if error
-16-
v4.9
SIM related functions
3.4. Getting IMEI
It gets the IMEI from the SIM card and it stores the IMEI into buffer_3G variable.
Example of use:
{ _3G.getIMEI(); }
This function returns:
‘1’ on success
‘0’ if error
-17-
v4.9
GSM related functions
4. GSM related functions
The fuse GSM_FUSE is used to activate or deactivate the functions of this section. If you use a function of this section the fuse must be at ‘1’.
4.1. Setting information returned when receiving a call
This function congures the information returned by the module when a call is received. It is useful to generate interruptions or to store data from the incoming call.
Example of use:
{
// Sets information returned by the module when incoming call: _3G.setInfoIncomingCall();
}
This function returns:
‘1’ on success
‘0’ if error
‘-2’ if error with CME error code available
4.2. Making calls
It makes a call to the given telephone number.
Note: the number can be using the country code or only the phone number.
Example of use:
{
// Makes a call to the desired number: _3G.makeCall(“*********”);
}
This function returns:
‘1’ on success
‘0’ if error
‘-2’ if no carrier
4.3. Making lost calls
It makes a specied duration lost call to the given telephone number.
Note 1: the calling time includes the time to send the request to the carrier, so the receiving call time is a bit shorter than the input parameter.
Note 2: the number can be using the country code or only the phone number.
Example of use:
{
// Makes a lost call of 10 seconds to the desired number: _3G.makeLostCall(“*********”,10);
}
-18-
v4.9
GSM related functions
This function returns:
‘1’ on success
‘0’ if error
‘-2’ if no carrier
4.4. Hanging up calls
It hangs up all the active calls.
Example of use:
{
// Hangs all the active calls up: _3G.hangUp();
}
This function returns:
‘1’ on success
‘0’ if error
4.5. Setting CLI presentation in incoming calls
This function enables or disables the presentation of the incoming call.
Example of use:
{
_3G.setCLIPresentation(ENABLE);
}
This function returns:
‘1’ on success
‘0’ if error
‘-2’ if error with CME error code available
4.6. Setting CLI restriction in outcoming calls
This function restricts or enables the presentation of the CLI to the called party when originating a call. Allowed modes
DEFAULT_CLIR, INVOKE_CLIR or SUPPRESS_CLIR.
Example of use:
{
// Restricts the CLI for called party: _3G.setCLIRestriction(SUPPRESS_CLIR);
}
This function returns:
‘1’ on success
‘0’ if error
‘-2’ if error with CME error code available
-19-
v4.9
GSM related functions
4.7. Gets the phone activity status
This function gets the phone activity status.
Example of use:
{
uint8_t status=0; // Stores in ‘status’ the state of the phone: status=_3G.getPhoneActStatus();
}
This function returns:
‘0’ for error
‘1’= Ready
‘2’= Unknown
‘3’= Ringing
‘4’= Call in progress
4.8. Autoanswer
This function enables or disables the auto-answer function of the 3G/GPRS module. The function wait a number of “rings” and the answer the call. If the number of rings is 0, disables the autoanswer.
Example of use:
{
// Enables autoanswer for wait 2 rings: _3G.autoAnswer(2);
}
This function returns:
‘1’ on success
‘0’ if error
4.9. Answer a call
This function answers an incoming call.
Example of use:
{
// Answers an incomming call: _3G.answerCall();
}
This function returns:
‘1’ on success
‘0’ if error
‘-2’ if there isn’t an incoming call
-20-
v4.9
GSM related functions
4.10. Generating DTMF tones
This function generate a DTMF tone according the code listed below:
‘0’ - Stop the sound tone
‘1’ - DTMF tone for 1 key, duration 100ms
‘2’ - DTMF tone for 2 key, duration 100ms
‘3’ - DTMF tone for 3 key, duration 100ms
‘4’ - DTMF tone for 4 key, duration 100ms
‘5’ - DTMF tone for 5 key, duration 100ms
‘6’ - DTMF tone for 6 key, duration 100ms
‘7’ - DTMF tone for 7 key, duration 100ms
‘8’ - DTMF tone for 8 key, duration 100ms
‘9’ - DTMF tone for 9 key, duration 100ms
‘10’ - DTMF tone for 0 key, duration 100ms
‘11’ - DTMF tone for A key, duration 100ms
‘12’ - DTMF tone for B key, duration 100ms
‘13’ - DTMF tone for C key, duration 100ms
‘14’ - DTMF tone for D key, duration 100ms
‘15’ - DTMF tone for # key, duration 100ms
‘16’ - DTMF tone for * key, duration 100ms
‘17’ - Subscriber busy sound, duration always
‘18’ - Congestion sound, duration always
‘19’ - Error information sound, duration 1330*3ms
‘20’ - Number unobtainable sound, duration 1330*3ms
‘21’ - Authentication failure sound, duration 1330*3ms
‘22’ - Radio path acknowledgement sound, duration 700*1ms
‘23’ - Radio path not available sound, duration 400*4ms
‘24’ - CEPT call waiting sound, duration 4000*2ms
‘25’ - CEPT ringing sound, duration always
‘26’ - CEPT dial tone, duration always
Example of use:
{
// Generate subscriber busy sound: _3G.generateTone(17); delay(5000); // Stops the sound: _3G.generateTone(0);
}
This function returns:
‘1’ on success
‘0’ if error
-21-
v4.9
GSM related functions
4.11. Ringer level
This function controls the ringer level of the loudspeaker for incoming call alert. Allowed values: ‘0’ for mute and ‘1’ to ‘5’ for volume level.
Example of use:
{
// Answers an incomming call: _3G.ringerLevel(4);
}
This function returns:
‘1’ on success
‘0’ if error
4.12. Setting Information returned when receiving an SMS
This function congures the information returned by the module when an SMS is received. It is useful to generate interruptions or to store data from the incoming SMS.
Example of use:
{
//Sets information returned by the module when incoming SMS _3G.setInfoIncomingSMS();
}
This function returns:
‘1’ on success
‘0’ if error
‘-2’ if error with CMS error code available
‘-3’ if error setting the memory
‘-4’ if error setting the memory with CMS error code available
4.13. Setting Mode for SMS
It sets the text mode for the SMS.
Example of use:
{
//Sets text mode for sms:
_3G.setTextModeSMS(); }
This function returns:
‘1’ on success
‘0’ if error
-22-
v4.9
GSM related functions
4.14. Sending SMS
It sends an SMS to the specied number.
Note: the maximum length is 160 Bytes (160 characters).
Example of use:
{
// Sends this text in a SMS to the desired number _3G.sendSMS(“Hello World!”,“6********”);
}
This function returns:
‘1’ on success
‘0’ if error
‘-2’ if error with CMS error code available
4.15. Getting the number of SMS stored in SIM card
This function gets the number of total SMS stored in the SIM card.
Example of use:
{
uint8_t total_SMS=0; // Gets the total SMS in SIM card: total_SMS=_3G.getTotalSMS();
}
This function returns:
‘1’ on success
‘0’ if error
‘-2’ if error with CMS error code available
4.16. Deleting SMS
This function deletes an SMS stored in the SIM card. It’s advisable use rst the function getTotalSMS() in order to know the number of SMS.
Example of use:
{
// Deletes the SMS in the 2 index: total_SMS=_3G.getTotalSMS();
}
This function returns:
‘1’ on success
‘0’ if error
‘-2’ if error with CMS error code available
-23-
v4.9
File system related functions
5. File system related functions
5.1. Description
The le system is used to store les in a hierarchical (tree) structure, and there are some denitions and conventions to use the Module.
Local storage space is mapped to “C:”, and storage space of present storage card is mapped to “D:”. In both “C:” and “D:” directories, module creates four directories named “Picture”, “Audio”, “Video” and “VideoCall” automatically; “Picture” is used to store static image when taking picture by camera, “Audio” is used to store audio le, “Video” is used to store video le when recording by camera, and “VideoCall” is used to store media le which is recorded during a video call.
The size of the C: unit is 64MB. The microSD card store up to32GBof information.
Some functions have been developed to work with this le system.
5.2. Go to the root directory of desired unit
The function goRoot(unit) selects the ‘unit’ to work (‘0’ for C: unit and ‘1’ for D:), not for save the les created by the module, and goes to the root directory (C: or D:).
Example of use:
{
// changes to microSD card and goes to the root _3G.goRoot(1);
}
This function returns:
‘1’ on success
‘0’ if error
5.3. Changing directory
It changes the directory in the working unit to the directory given as a parameter.
Example of use:
{
// changes to “Picture” directory _3G.cd(“Picture”);
}
This function returns:
‘1’ on success
‘0’ if error
-24-
v4.9
File system related functions
5.4. Getting le size
It gets the size of a le given as a parameter in the current directory.
Example of use:
{
int32_t sizeFile; // gets the size of “le.txt” sizeFile= _3G.getFileSize(“le.txt”);
}
This function returns:
The size of the le
‘-2’ if error
5.5. Deleting les
It deletes a le in the current directory.
Example of use:
{
// deletes “le.txt” _3G.del(“le.txt”);
}
This function returns:
‘1’ on success
‘0’ if error
5.6. MicroSD is present
It checks if the microSD card is present.
Example of use:
{
uint8_t present; // checks if microSD is present present=SD.isSD() ;
}
This function returns:
‘1’ if is present
‘’0’ if not present
Loading...
+ 53 hidden pages