Waspmote 4G: Networking Guide
Waspmote 4G: Networking Guide
Networking Guide
Index
INDEX
1. Introduction........................................................................................................................... 4
2. 3G (SIM5215) vs 4G (LE910).................................................................................................... 5
3. Hardware................................................................................................................................ 6
3.1. Specifications...................................................................................................................................... 6
3.2. Versions............................................................................................................................................... 6
3.3. How to connect the module............................................................................................................. 7
3.4. Antennas............................................................................................................................................. 9
3.5. Power consumption........................................................................................................................ 10
3.6. Time consumption........................................................................................................................... 10
4. Software................................................................................................................................ 11
4.1. Waspmote library............................................................................................................................. 11
4.1.1. Waspmote 4G library...........................................................................................................11
4.1.2. Class constructor..................................................................................................................11
4.1.3. API constants........................................................................................................................11
4.1.4. API variables..........................................................................................................................12
4.1.5. API functions.........................................................................................................................13
4.1.6. Error codes............................................................................................................................13
4.2. Switching on..................................................................................................................................... 16
4.3. Switching off..................................................................................................................................... 16
4.4. SIM card............................................................................................................................................ 16
4.4.1. Entering PIN..........................................................................................................................16
4.4.2. Getting IMEI, IMSI and ICCID...............................................................................................17
4.5. Checking network connection status............................................................................................ 18
4.6. Setting operator parameters.......................................................................................................... 19
4.7. SMS.................................................................................................................................................... 19
4.7.1. Setting SMS configuration...................................................................................................19
4.7.2. Sending SMSs........................................................................................................................20
4.7.3. Reading SMSs........................................................................................................................20
4.7.4. Deleting SMSs.......................................................................................................................21
4.8. HTTP client........................................................................................................................................ 22
4.8.1. HTTP connections.................................................................................................................22
4.8.2. HTTP request methods........................................................................................................23
4.8.3. Sending Waspmote frames to Meshlium via HTTP..........................................................25
4.8.4. Sending Waspmote frames to Meshlium via HTTPS........................................................27
4.9. FTP client........................................................................................................................................... 28
-2- v7.3
Index
5. Certifications........................................................................................................................ 50
7. API changelog....................................................................................................................... 52
8. Documentation changelog................................................................................................. 53
-3- v7.3
Introduction
1. Introduction
This guide explains the features and use of the new 4G module. This module was specifically integrated for our
new product lines Waspmote v15, Plug & Sense! v15 and Meshlium v4.0, released on October 2016. The 4G module
is not compatible Waspmote v12, Plug & Sense! v12 or Meshlium 3.x.
If you are using previous versions of our products, please use the corresponding guides, available on our
Development website.
You can get more information about the generation change on the document “New generation of Libelium product
lines”. The 4G module has been integrated into the devices Waspmote OEM, Plug & Sense! and Meshlium.
The new 4G module enables the connectivity to high speed LTE, HSPA+, WCDMA cellular networks in order to
make possible the creation of the next level of worldwide compatible projects inside the new “Internet of Things”
era.
The new communication 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
navigation, downloading and uploading content to a web server. We can also set secure connections using SSL
certificates and setting TCP/IP private sockets. In the same way, the FTP protocol is also available which is really
useful when your application requires handling files.
The module includes a GPS/GLONASS receiver, able to perform geolocation services using NMEA sentences,
offering information such as latitude, longitude, altitude and speed; that makes it perfect to perform tracking
applications.
The new 4G module offers the maximum performance of the 4G network as it uses 2 different antennas (normal
+ diversity) for reception (MIMO DL 2x2), choosing the best received signal at any time and getting a maximum
download speed of 100 Mbps.
We chose the LE910 chipset family from Telit as it comprises the most complete 4G/LTE set of variants released
up to date. It counts with many different models, each one specifically designed for one market but all of them
with the same footprint:
Important note: The current stock of the LE910 4G radio that the manufacturer ‘Telit’ is distributing comprises
the v2 version which does not have GPS. The models are:
These v2 radios are similar to the v1 ones, but support more bands and do not have a GPS receiver.
Important:
•• All documents and any examples they contain are provided as-is and are subject to change without notice.
Except to the extent prohibited by law, Libelium makes no express or implied representation or warranty of
any kind with regard to the documents, and specifically disclaims the implied warranties and conditions of
merchantability and fitness for a particular purpose.
•• The information on Libelium’s websites has been included in good faith for general informational purposes
only. It should not be relied upon for any specific purpose and no representation or warranty is given as to its
accuracy or completeness.
-4- v7.3
3G (SIM5215) vs 4G (LE910)
2. 3G (SIM5215) vs 4G (LE910)
The new 4G module (specific for the new lines Waspmote v15, Plug & Sense! v15 and Meshlium 4.0) introduces
some changes with respect to the 3G module (available for the old lines Waspmote v12, Plug & Sense! v12,
Meshlium 3.5 and the new Waspmote v15):
•• The new 4G counts with many different models, one specifically designed for each market:
-- LE910-EU (Europe / Brazil): CE, GCF, ANATEL
-- LE910-NAG (US / Canada): FCC, IC, PTCRB, AT&T approved
-- LE910-AU V2 (Australia): RCM, Telstra approved
•• The GPS module also makes it possible to perform geo-location services using NMEA sentences, offering
information such as latitude, longitude, altitude and speed, what makes it perfect for tracking applications.
•• The new 4G module offers the maximum performance of the 4G network as it uses 2 different antennas
(normal + diversity) for reception (MIMO DL 2x2), choosing the best received signal at any time and getting a
maximum download speed of 100 Mbps.
Features comparison:
4G compatibility:
-5- v7.3
Hardware
3. Hardware
3.1. Specifications
The 4G module is based on the LE910 chipset, manufactured by Telit.
The module is managed by UART and it must be connected to socket
1 (direct connection, without Expansion Board). The main features of
the module are listed below:
•• Output power:
-- Class 4 (2 W, 33 dBm) @ GSM 850 / 900
-- Class 1 (1 W, 30 dBm) @ GSM 1800 / 1900
-- Class E2 (0.5 W, 27 dBm) @ EDGE 850 / 900
-- Class E2 (0.4 W, 26 dBm) @ EDGE 1800 /1900
-- Class 3 (0.25 W, 24 dBm) @ UMTS Figure : 4G module
-- Class 3 (0.2 W, 23 dBm) @ LTE
•• Data transmission:
-- LTE:
»» Uplink up to 50 Mbps
»» Downlink up to 100 Mbps
-- HSPA+:
»» Uplink up to 5.76 Mbps
»» Downlink up to 42.0 Mbps
-- UMTS:
»» Uplink/Downlink up to 384 kbps
•• Protocols:
-- TCP/UDP
-- HTTP
-- FTP
•• GPS receiver (in certain versions)
3.2. Versions
Telit has different versions of the LE910 chipset. Each one of them was especially designed to comply with the
RF and cellular regulations in different countries or regions of the world. Libelium has integrated the following
versions:
-6- v7.3
Hardware
Important note: The current stock of the LE910 4G radio that the manufacturer ‘Telit’ is distributing comprises
the v2 version which does not have GPS. The models are:
These v2 radios are similar to the v1 ones, but support more bands and do not have a GPS receiver.
-7- v7.3
Hardware
The SIM card used in the 4G module OEM version is a “standard SIM”, also known as “mini SIM”. The next picture
shows how the SIM card must be plugged in the 4G module.
On the other hand, Plug and Sense! models with 4G radio provide a special connector in order to plug both micro
USB wire and nano SIM card for the 4G module.
-8- v7.3
Hardware
3.4. Antennas
The 4G module comes with 2 cellular antennas for improving the signal reception: normal (main) antenna and
diversity antenna. Besides, a 3rd antenna is also included for the GPS receiver (when it is available in the 4G
module).
All these 3 antennas are the same model and can be used in any of the 4G sockets. The operating bands of
the dipole antenna go from 698 to 960 MHz and from 1710 to 2690 MHz. The maximum gain of the antenna is
observed at 2.6 GHz: 3.4 dBi.
To get the maximum performance, it is recommended to place the antennas like that:
•• The main cellular antenna should be in vertical position, pointing to the sky, in order to radiate better to the
cellular base stations around.
•• The diversity cellular antenna should be in horizontal position (orthogonal, 90º, to the main antenna). Besides,
the plane where the antenna is should be also orthogonal to the main antenna’s plain. Finally, it is advised to
place this 2nd cellular antenna as fas as possible from the main antenna. These 3 measures will maximize the
gain due to reception diversity.
•• The GPS antenna should be in horizontal position, because the GPS satellite signal will come from above.
-9- v7.3
Hardware
Mean power
State
consumption
On 100 mA
Transmitting data 400 mA
Receiving data 400 mA
Non-rechargeable batteries are not advised for the 4G module, because the high peaks of current consumption
could make the voltage of these batteries to go below 3.3 V so Waspmote would reset. The rechargeable battery
will not suffer this effect as long as its level is above 20%.
Some of these actions approximately have a fixed elapsed time like powering on the module. However, the actions
related to data transmission (HTTP, FTP, etc.) are dependent on external circumstances (MNO, coverage quality,
etc) and show more variability from the mean value.
-10- v7.3
Software
4. Software
4.1. Waspmote library
4.1.1. Waspmote 4G library
The files related to the 4G module library are:
/Wasp4G/Wasp4G.h
/Wasp4G/Wasp4G.cpp
/Wasp4G/utility/Wasp4G_constants.h
/Wasp4G/utility/Wasp4G_error_codes.h
It is mandatory to include the 4G library when using this module. So the following line must be added at the
beginning of the code:
#include <Wasp4G.h>
When using the class constructor, all variables are initialized to their default values.
Constant Description
This definition enables/disables the debug mode via USB
port:
DEBUG_WASP4G 0: No debug mode enabled
1: Debug mode enabled for error output messages
2: Debug mode enabled for both error and OK messages
LE910_RATE Module's communication baud rate
LE910_INCOMING_SMS Constant to set incoming data type when SMS received
LE910_INCOMING_IP Constant to set incoming data type when IP received
LE910_MAX_DL_PAYLOAD
Maximum data payload size to be stored in the data
buffer
The are several enumeration definitions for the function inputs. Please refer to the corresponding section in order
to know more about the functions input parameters.
-11- v7.3
Software
Variable Description
_buffer
The buffer of memory used for storing the responses from the module (512
bytes)
_length The length of the contents stored in _buffer
_def_delay The time to wait after sending every command until listen for a response
_baudrate The baudrate to be used when the module is switched on
_uart The selected UART (regarding the socket used: SOCKET0 or SOCKET1)
_errorCode
It stores the error code returned by the module when calling a function with
error response
_ip IP address assigned to the 4G module when it is connected to the network
_temp It stores temperature from the module
_tempInterval It stores temperature interval from the module
_rssi It stores the module's RSSI level
_networkType It stores the network type which module is connected to
_incomingType It stores the incoming data type to be read via serial
_smsIndex It stores the SMS index where the incoming message was saved
_smsStatus It stores the status of the SMS read from module's memory
_smsNumber It stores the phone number of the SMS read from module's memory
_smsDate It stores the date of the SMS read from module's memory
_smsTime It stores the time of the SMS read from module's memory
_socketIndex It stores the socket index which is getting data from UDP or TCP
_httpCode It stores the HTTP status code
_filesize It stores the size of the file when FTP upload/download is performed
_ftpWorkingDirectory It stores the current working directory of the FTP session
socketInfo Structure to define the info to be stored for all sockets
socketStatus Structure to define the status to be stored for all sockets
socketStatusSSL Structure to define the status to be stored for all sockets
_latitude It stores latitude from GPS
_latitudeNS It stores the north/south indicator from GPS
_longitude It stores longitude from GPS
_longitudeEW It stores east/west indicator
_altitude It stores altitude from GPS
_time It stores time from GPS
_date It stores date from GPS
_numSatellites It stores the number of satellites “in sight” of the GPS
_fixMode It stores fix mode set from GPS
_speedOG It stores speed over ground from GPS
_courseOG It stores course over ground from GPS
_hdop It stores the horizontal dilution of precision from GPS
-12- v7.3
Software
•• 0: OK
•• Otherwise: ERROR. See corresponding function error code
The possible module’s error codes are described by constants as the table below:
-13- v7.3
Software
-14- v7.3
Software
-15- v7.3
Software
4.2. Switching on
The ON() function switches on the 4G module and it opens the MCU UART for communicating with the module.
After this step, the module will be able to receive commands to manage it.
Example of use:
{
_4G.ON();
}
Example of use:
{
_4G.OFF();
}
{
_4G.enterPIN(“1234”);
}
Besides, there is another function prototype in order to set a new one. It is mandatory to specify the current PIN
number and the new one.
{
_4G.enterPIN(“1234”, ”1111”);
}
-16- v7.3
Software
Examples of use:
{
// get IMEI number
_4G.getInfo(Wasp4G::INFO_IMEI);
// get IMSI number
_4G.getInfo(Wasp4G::INFO_IMSI);
// get ICCID number
_4G.getInfo(Wasp4G::INFO_ICCID);
}
Related variables:
-17- v7.3
Software
The checkConnection() function checks the module’s network connection status and returns whether the module:
•• is connected to a network
•• is not connected to a network
•• is searching for a new operator to register to
•• registration was denied
This function will wait for the module to be connected to a network for the specified time in second units.
Example of use:
{
_4G.checkConnection(60);
}
The checkDataConnection() function checks the module’s network connection status, connects the module to
data service and returns whether the module:
•• is connected to data service
•• is not connected to a network
•• is searching for a new operator to register to
•• registration was denied
This function will wait for the module to be connected to a network for the specified time in second units.
Example of use:
{
_4G.checkDataConnection(60);
}
-18- v7.3
Software
The set_APN() function allows the user to save these parameters into Waspmote memory. Later, when data
connection functions are called, Waspmote will configure these parameters into the 4G module.
Example of use:
{
_4G.set_APN(“apn”, ”login”, ”password”);
}
The show_APN() function allows the user to display the current settings stored in Waspmote’s memory which are
used by the libraries when data connections are performed.
Example of use:
{
_4G.show_APN();
}
Related variable:
4.7. SMS
4.7.1. Setting SMS configuration
The configureSMS() function sets the SMS configuration to:
This function must be called before handling SMSs in the main code loop.
Example of use:
{
_4G.configureSMS();
}
-19- v7.3
Software
Example of use:
{
char phone_number[] = “*********”;
char text_message[] = “This_is_a_text_message”;
_4G.sendSMS(phone_number, text_message);
}
Example of use:
{
uint8_t index = 5;
_4G.readSMS(index);
}
The readNewSMS() function reads the last unread SMS received by the module. There are 2 function prototypes:
with or without timeout. If the user needs to wait for a new text message for a period of time, the timeout must
be specified as input. If no input is defined, the request for new text messages is instantly performed. In the case
a new SMS is received, all SMS related parameters are stored in the Waspmote’s library structures: index number,
status, sender number, date and time. The SMS text field can be found in _4G._buffer.
Example of use:
{
_4G.readNewSMS(30000);
}
-20- v7.3
Software
Related variables:
_4G._smsIndex → Stores the SMS index in memory storage
_4G._buffer → Stores SMS text field temporary, after calling the read function
Examples of use:
{
uint8_t index = 2;
_4G.deleteSMS(index);
}
There is a second deleteSMS() function prototype which deletes all the SMSs in the storage memory according to
several possibilities. For this function, 2 inputs are introduced: the SMS index number and the delete flag. If delete
flag is not set to delete one single message, then index is ignored and the module shall follow the rules for delete
flag shown below:
Example of use:
{
_4G.deleteSMS(index, Wasp4G::SMS_DELETE_ALL_1);
}
-21- v7.3
Software
Libelium has created a little web service in order to allow 4G, 3G, GPRS, GPRS+GPS or WiFi modules to test the
HTTP mode. This web service is a little code, written in PHP, which is continuously listening to the HTTP port (port
number 80) of our test server “pruebas.libelium.com”. This is a kind of RESTful service. These communication
modules can send HTTP instances to our web service.
HTTP instances should have the following structures so that our web service can understand.
GET method
In GET method the data are sent to the server append to the main URL with the ‘?’ character. The base sentence
to perform GET method is shown below:
pruebas.libelium.com/getpost_frame_parser.php?<variable1=value1>&<variable2=value2>&<...>&
view=html
Where:
All arguments must be separated by “&”. The variable name and value must be separated by “=”.
Some examples:
pruebas.libelium.com/getpost_frame_parser.php?var1=3.1415
pruebas.libelium.com/getpost_frame_parser.php?var1=3.1415&view=html
pruebas.libelium.com/getpost_frame_parser.php?var1=3.1415&var2=123456&var3=hello&view=html
POST method
Unlike GET method, with POST method the data are sent to the server into an extra data field. The URL only
includes the site name and the PHP direction:
pruebas.libelium.com/getpost_frame_parser.php
<variable1=value1>&<variable2=value2>&<...>&view=html
Where:
•• <variable1=value1> : It is a couple with the variable name and value which we want the web service to parse.
All arguments must be separated by “&”. The variable name and value must be separated by “=”.
-22- v7.3
Software
Server response
If the web service receives one instance with the appropriate format, some actions will happen:
•• The web service grabs the string and parses it. So the PHP code creates couples with the variables name and
value.
•• The web service responses to the sender device (to the sender IP) with an HTML-formatted reply.
Remember this PHP code is really simple and is offered with the only purpose of testing, without any warranty.
The source code is available here:
downloads.libelium.com/waspmote-html-get-post-php-parser-tester.zip
The user may find it interesting to copy this code and make it run on his own server (physical or virtual). If the user
wants to go further, he can complete the code. For example, once the couples are parsed, the user can modify the
PHP to save data into a txt file, or insert couples into a database, or include a timestamp...
This function needs several parameters to work properly depending on the method used. The first parameter
required by the function is the request method. User can choose among five methods: GET, HEAD, DELETE, POST
and PUT:
•• Wasp4G::HTTP_GET
•• Wasp4G::HTTP_HEAD
•• Wasp4G::HTTP_DELETE
•• Wasp4G::HTTP_POST
•• Wasp4G::HTTP_PUT
After choosing the method, the function needs the host URL, port and resource of the HTTP server requested. The
data field is only necessary when POST or PUT methods are performed.
-23- v7.3
Software
Once the request has been sent, the function waits for data from the server and stores it in _buffer. It also stores
the HTTP status code from the server in _httpCode.
Related variable:
-24- v7.3
Software
However, Meshlium Manager System v4.1.0 and greater versions allow the user to enable the HTTP service in
order to be able to receive HTTP non-secure requests. The user must go to: Manager System —› System —›
Security —› HTTP Service:
The sendFrameToMeshlium() function has been developed to send Waspmote frames from Waspmote to Meshlium
via non-secure HTTP request. Meshlium will parse (chop) the frame and will store it in its internal MySQL database.
This function requires the following parameters:
•• Meshlium’s IP address
•• Meshlium’s remote port
•• Data to send: frame.buffer will be used from the generated frame
•• Data length: frame.length will be used from the generated frame
-25- v7.3
Software
After calling the function, the response from Meshlium will be stored in _buffer. Besides, it will store the HTTP
status code from server in _httpCode. Please refer to the Data Frame Guide in order to know more about how to
create sensor frames with Waspmote libraries.
Example of use:
{
char host[] = “pruebas.libelium.com”;
uint16_t port = 80;
// after frame has been created
_4G.sendFrameToMeshlium(host, port, frame.buffer, frame.length);
}
Related variable:
-26- v7.3
Software
For HTTPS, the user must keep in mind that the Meshlium’s certificate has to be installed in the Waspmote or
Plug & Sense! radio prior to opening secure connections. The next picture shows how the user can download the
Meshlium’s certificate from Manager System —› System —› Users Manager —› Download Certificate:
The downloaded certificate must be installed following the steps explained in the “SSL sockets” section and the
proper library function. Also, the example linked at the end of this section shows how to perform the installation.
www.libelium.com/development/waspmote/examples/4g-08b-send-to-meshlium-https/
-27- v7.3
Software
Example of use:
{
char ftp_server[] = “pruebas.libelium.com”;
uint16_t ftp_port = 21;
char ftp_user[] = “[email protected]”;
char ftp_pass[] = “ftp1234”;
_4G.ftpOpenSession(ftp_server, ftp_port, ftp_user, ftp_pass);
}
-28- v7.3
Software
After successfully calling this function, it will be possible to manage the rest of FTP functions for uploading and
downloading files.
{
char sd_file[] = “FILE1.TXT”;
char server_file[] = “FILE2.TXT”;
_4G.ftpUpload(server_file, sd_file);
}
In the case the file should be uploaded into a subdirectory instead of the root directory, the server filename must
be accordingly defined. The user must keep in mind that subdirectories have to be already created in order to
upload files into them. In other words, it is not possible to create subdirectories in the FTP server.
{
char sd_file[] = “/FOLDER1/FILE1.TXT”;
char server_file[] = “/FOLDER2/FILE2.TXT”;
_4G.ftpUpload(server_file, sd_file);
}
-29- v7.3
Software
•• 1: if no SD present
•• 2: if file does not exist
•• 3: if error opening the file
•• 4: if error setting the pointer of the file
•• 5: if error getting the file size
•• 6: if error opening the PUT connection
•• 7: if error exiting from the data mode
•• 8: if error sending data
{
char sd_file[] = “FILE1.TXT”;
char server_file[] = “FILE2.TXT”;
_4G.ftpDownload(server_file, sd_file);
}
In the case the file should be downloaded into an SD card’s subdirectory instead of the root directory, the SD
filename must be accordingly defined. The user must keep in mind that subdirectories have to be already created
in the SD card in order to create files into them.
{
char sd_file[] = “/FOLDER1/FILE1.TXT”;
char server_file[] = “/FOLDER2/FILE2.TXT”;
_4G.ftpDownload(server_file, sd_file);
}
-30- v7.3
Software
{
_4G.ftpGetWorkingDirectory();
}
Related variable:
The ftpChangeWorkingDirectory() function allows the user to change the current working directory. The user
must keep in mind that the directory to access must be already created before attempting to call this function. The
function expects the name of the directory to access to as input parameter.
Example of changing the working directory:
{
_4G.ftpChangeWorkingDirectory(“NEWDIR”);
}
Related variable:
-31- v7.3
Software
Wasp4G::CONNECTION_1
Wasp4G::CONNECTION_2
Wasp4G::CONNECTION_3
Wasp4G::CONNECTION_4
Wasp4G::CONNECTION_5
Wasp4G::CONNECTION_6
The 4G libraries define different structures in order to store the information related to all socket identifiers. After
opening sockets or sending/receiving data, the structures are updated. So this is useful in order to manage the
most important settings of the connection.
•• Socket identifier
•• Total number of bytes sent since the socket was opened
•• Total number of bytes received since socket was opened
•• Total number of pending bytes to read which arrived through the socket
•• Total number of bytes sent and not yet acknowledged since the socket was opened
As there are six possible connections at the same time, the global variable is defined as follows:
SocketInfo_t socketInfo[6];
struct SocketInfo_t
{
uint8_t id;
uint16_t sent;
uint16_t received;
uint16_t size;
uint16_t ack;
};
The getSocketInfo() function allows the user to update the socket information structure from the 4G module. It
is mandatory to indicate the identifier of the socket to be updated.
Example of use:
{
uint8_t socketId = Wasp4G::CONNECTION_1;
_4G.getSocketInfo(socketId);
}
-32- v7.3
Software
Related variables:
•• Socket identifier
•• Current socket status. The API defines several constants to describe it:
-- Wasp4G::STATUS_CLOSED
-- Wasp4G::STATUS_ACTIVE
-- Wasp4G::STATUS_SUSPENDED
-- Wasp4G::STATUS_SUSPENDED_DATA
-- Wasp4G::STATUS_LISTENING
-- Wasp4G::STATUS_INCOMING
-- Wasp4G::STATUS_OPENING
•• Local IP address
•• Local port
•• Remote IP address
•• Remote port
SocketStatus_t socketStatus[6];
struct SocketStatus_t
{
uint8_t id;
uint8_t state;
char localIp[16];
uint16_t localPort;
char remoteIp[16];
uint16_t remotePort;
};
The getSocketStatus() function allows the user to update the socket status structure from the 4G module. It is
mandatory to indicate the identifier of the socket to be updated. It is possible to update all socket status by calling
the getAllSocketStatus() function which is faster than iterating through all different identifiers.
Example of use:
{
uint8_t socketId = Wasp4G::CONNECTION_1;
_4G.getSocketStatus(socketId);
}
Related variables:
-33- v7.3
Software
•• Socket ID: The first parameter indicates the identifier to be associated to the new TCP/UDP. connection. This
identifier is needed in order to send or receive data through the corresponding socket after creating it.
•• Protocol: This parameter indicates whether use TCP or UDP protocol for the new socket. The possibilities are:
-- Wasp4G::TCP
-- Wasp4G::UDP
•• Host: Address of the remote host, string type. This parameter can be either:
-- Any valid IP address in the format: “xxx.xxx.xxx.xxx”
-- Any host name to be solved with a DNS query
-- Any valid IPv6 address in the format: xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx or xxx.xxx.xxx.xxx.xxx.xxx.
xxx.xxx.xxx.xxx.xxx.xxx.xxx.xxx.xxx.xxx
•• Remote port: Remote host port to contact from 1 to 65535.
•• Local port: Parameter is valid for UDP connections only and has no effect (if used) for TCP connections. UDP
connections local port from 1 to 65535.
{
uint8_t socketId = Wasp4G::CONNECTION_1;
char host[] = “xxx.xxx.xxx.xxx”;
uint16_t remote_port = 15010;
_4G.openSocketClient(socketId, Wasp4G::TCP, host, remote_port);
}
{
uint8_t socketId = Wasp4G::CONNECTION_2;
char host[] = “xxx.xxx.xxx.xxx”;
uint16_t remote_port = 15010;
uint16_t local_port = 4000;
_4G.openSocketClient(socketId, Wasp4G::UDP, host, remote_port, local_port);
}
-34- v7.3
Software
•• Socket ID: The first parameter indicates the identifier to be associated to the new TCP/UDP connection. This
identifier is needed in order to send or receive data through the corresponding socket.
•• Protocol: This parameter indicates whether use TCP or UDP protocol for the new socket. The possibilities are:
-- Wasp4G::TCP
-- Wasp4G::UDP
•• Local port: Local listening port from 1 to 65535.
•• Keep-Alive: TCP keep-alive timer timeout -The interval between 2 keep-alive transmissions in idle condition:
-- 0 → TCP keep-alive timer is deactivated (default)
-- 1..240 → TCP keep-alive timer timeout in minutes
{
uint8_t socketId = Wasp4G::CONNECTION_1;
uint16_t local_port = 5000;
uint8_t keep_alive = 240;
_4G.openSocketServer(socketId, Wasp4G::TCP, local_port, keep_alive);
}
-35- v7.3
Software
{
uint8_t socketId = Wasp4G::CONNECTION_2;
uint16_t local_port = 5000;
_4G.openSocketServer(socketId, Wasp4G::UDP, local_port);
}
Once the server is created, the manageSockets() function permits the user to update all socket status and accept
connections if needed. So when setting up a server or listening socket in Waspmote 4G the best way to handle
with connections is directly calling this function. If no input parameter is defined the calling is executed instantly. If
the timeout is inserted as new input, the function will block until a new incoming connection needs to be managed
or timeout. This timeout must be specified in milliseconds units.
•• Socket ID: the socket identifier used for opening the connection.
•• Data: This is the stream of data to send to the TCP/UDP socket. This stream of data can be defined as a simple
string message. On the other hand, the data can be defined as an array of bytes, specifying a third input for
the length of the array of bytes to send.
{
_4G.send(Wasp4G::CONNECTION_1, “This_is_the_data_payload”);
}
-36- v7.3
Software
{
uint8_t data[] = {0x31, 0x32, 0x33, 0x34, 0x35}
_4G.send(Wasp4G::CONNECTION_1, data, 6);
}
All examples related to TCP/UDP sockets (both client and server) show how to send data:
www.libelium.com/development/waspmote/examples/4g-11-tcp-client
www.libelium.com/development/waspmote/examples/4g-12-tcp-server
www.libelium.com/development/waspmote/examples/4g-13-udp-client
www.libelium.com/development/waspmote/examples/4g-14-udp-server
•• Socket ID: the socket identifier used for opening the connection.
•• Timeout (optional input):
-- If no timeout input is specified, the receive function is a non-blocking function which answers if data has
been received.
-- If the timeout is inserted as new input, the function will block until a new packet is received or time is up in
the case no packet is received. This timeout must be specified in milliseconds units.
{
_4G.receive(Wasp4G::CONNECTION_1);
}
{
_4G.receive(Wasp4G::CONNECTION_1, 30000);
}
Related variables:
-37- v7.3
Software
•• 1: if no data received
•• 2: if error getting socket info
•• 3: if timeout waiting for data
•• 4: if error receiving data from module
•• 5: if error parsing length of data
•• 6: if error reading incoming bytes
The closeSocketServer() function allows the user to close a TCP/UDP server previously open. The function needs
2 inputs:
•• Socket ID: the socket identifier used for opening the connection.
•• Protocol: This parameter indicates the protocol used by the socket:
-- Wasp4G::TCP
-- Wasp4G::UDP
Currently, for SSL sockets only one single connection is permitted. So, regarding the socket identifiers the only
available option is: Wasp4G::CONNECTION_1.
The manageSSL() function allows the user to store, delete and read security data (Certificate, CA certificate, private
key) into the non volatile memory of the module. The function expects several inputs:
•• Socket ID: the socket identifier used for opening the connection.
•• Action: the action to perform:
-- Wasp4G::SSL_ACTION_DELETE: Delete data from memory
-- Wasp4G::SSL_ACTION_STORE: Store data into memory
-- Wasp4G::SSL_ACTION_READ: Read data from memory
•• Data type:
-- Wasp4G::SSL_TYPE_CERT: Certificate
-- Wasp4G::SSL_TYPE_CA_CERT: CA certificate
-- Wasp4G::SSL_TYPE_RSA: RSA Private key
•• Data (optional): this input is needed when the user selects to store a new security data into module’s memory.
-38- v7.3
Software
The openSocketSSL() function allows the user to open a remote connection via socket secured through SSL.
Several inputs are needed for calling this function:
•• Socket ID: the socket identifier used for opening the connection
•• Host: Remote SSL server address
•• Remote port: Remote TCP port to contact from 1 to 65535.
The sendSSL() function allows the user to send data through a secure socket. Several inputs are needed for
calling this function:
•• Socket ID: the socket identifier used for opening the connection.
•• Data: Data to send.
The receiveSSL() function allows the user to receive data through a secure socket. Several inputs are needed for
calling this function:
•• Socket ID: the socket identifier used for opening the connection.
•• Timeout (optional input):
-- If no timeout input is specified, the receive function is a non-blocking function which answers if data has
been received.
-- If the timeout is inserted as new input, the function will block until a new packet is received or time is up in
the case no packet is received. This timeout must be specified in milliseconds units.
-39- v7.3
Software
The closeSocketSSL() function allows the user to close a secure socket. The function needs an input parameter
for the socket identifier.
-40- v7.3
Software
4.11. GPS
Nowadays there are several positioning techniques to provide the localization to end devices. One of them is the
A-GPS positioning technique based on the help of a cellular network deploying an A-GPS server.
At this point, it is advisable to introduce the definition of Time to First Fix (TTFF): TTFF indicates the time and
process required for a GPS device to get adequate satellite signals and data to provide accurate navigation.
If a GPS device has been turned off for a long period of time, when it is turned on it will take longer to acquire
these data sets and get a “Time to First Fix”. One way to speed up TTFF is to use the A-GPS Positioning Technique.
A “cold” start indicates the scenario in which the GPS must get all data in order to start navigation, and may take
up to several minutes.
A “warm” start indicates the scenario in which the GPS has most of the data it needs in memory, and will start
quickly, a minute or less.
Before dealing with the A-GPS service, a Standalone GPS solution is described. The figure below shows an overview
of the involved functional entities.
-41- v7.3
Software
There are a couple of A-GPS standards. Waspmote libraries implement the Secure User Plane Location (SUPL)
architecture. This Location Service architecture is composed of 2 basic elements: a SUPL Enabled Terminal (SET)
and a SUPL Location Platform (SLP). The SET corresponds to the 4G module. The SLP manages several tasks:
authentication, location request, etc. This module supports the SUPL ver. 1.0.
Waspmote libraries manage the SET Initiated Session scenario where the module, on its initiative, connects to an
SLP Server through an IP network, 2 modes are available:
•• MS-Assisted
•• MS-Based
In MS-Assisted mode, the module receives acquisition assistance, reference time and other optional assistance
data from the network. The mobile service provider continuously logs GPS information (mainly the almanac) from
the GPS satellites using an A-GPS server in its system. With the help of this data, the A-GPS server calculates the
position and sends it back to the module.
In MS-Based mode, the module receives ephemeris, reference location, reference time and other optional
assistance data from the A-GPS server. With the help of this data, the module receives signals from the visible
satellites and calculates the position.
Note: if the required satellites visibility is not available, no GPS position is provided by the A-GPS receiver.
-42- v7.3
Software
The waitForSignal() function waits until GPS signal is received for valid data. The input parameter defines
the timeout to wait for signal in millisecond units. If the function returns a correct answer means that the GPS
attributes have been updated:
•• Latitude
•• Latitude indicator: North or South
•• Longitude
•• Longitude indicator: East or West
•• Time
•• Date
•• Number of satellites
•• HDOP: Horizontal Dilution of precision. If this value is less than 1 indicates the highest possible confidence
level to be used for applications.
The convert2Degrees() function performs the conversion from the latitude and latitude variables given by the 4G
module to degrees so it is more legible and intuitive. The input parameters must be the latitude/longitude and the
corresponding indicator. The returning value is the converted value in degrees units.
The gpsStop() function powers down the GPS engine of the 4G module. It is possible to switch from a SUPL session
to the autonomous GPS mode. Firstly, the GPS feature must be stopped, and then restart with the autonomous
mode.
-43- v7.3
Software
•• By helping obtain a faster “time to first fix” (TTFF). A-GPS acquires and stores information about the location of
satellites via the cellular network so the information does not need to be downloaded via satellite.
•• By helping position a phone or mobile device when GPS signals are weak or not available such as indoor
locations. GPS satellite signals may be impeded by tall buildings, and do not penetrate building interiors well.
A-GPS uses proximity to cellular towers to calculate position when GPS signals are not available.
In this section, the execution of the A-GPS in MS-Based mode is shown. For this purpose, the corresponding
example was used:
www.libelium.com/development/waspmote/examples/4g-18-agps-ms-based
In this example, the GPS is started in MS-based mode. Once location is acquired, the GPS is stopped and started
again in Standalone mode. In the following figures, it is possible to see how the GPS module gets its first position
41 seconds after switching on the 4G module. The green icon is the true device position. The red icon is the
position the 4G module returns along different iterations. Finally, we can see how the module achieves a great
location detection after 73 seconds.
Figure : First iteration (41 seconds after starting the 4G module). Distance error: 42 meters.
-44- v7.3
Software
Figure : Figure: Second iteration (53 seconds after starting the 4G module): Distance error: 28 meters.
Figure : Figure: Third iteration (63 seconds after starting the 4G module): Distance error: 28 meters.
-45- v7.3
Software
Figure : Fourth iteration (73 seconds after starting the 4G module): Distance error: 7 meters.
The location given by the A-GPS module may vary depending on the spot used to perform the test. The accuracy
will improve when the device is situated in a high density or poor cellular antennas area. The location accuracy
may vary from 10 to 100 meters so a real test in each case is mandatory before implementing a final application.
-46- v7.3
Software
Example:
{
_4G.emailReset();
}
Example:
{
_4G.emailSetServerSMTP(“smtp.mydomain.com”);
}
Example:
{
_4G.emailConfigureSMTP(Wasp4G::EMAIL_NONSSL, 25);
}
Note: some servers support an obsolete implementation of SMTPS on port 465. The module only supports the standard
implementation of SMTP over SSL/TLS described in RFC 3207. So do not use port 465 on servers with an obsolete
implementation of SMTPS: the module will not work properly. Use instead port 25 or port 587.
-47- v7.3
Software
Example:
{
char address[] = “[email protected]”;
char user[] = “[email protected]”;
char password[] = “myPassword”;
_4G.emailSetSender(address, user, password);
}
Example:
{
_4G.emailSave();
}
Example:
{
char address[] = “[email protected]”;
char subject[] = “Subject of email”;
char message[] = “This is an e-mail message from Waspmote”;
_4G.emailSend(address, subject, message);
}
Possible error codes for this function:
-48- v7.3
Software
-49- v7.3
Certifications
5. Certifications
Libelium offers 2 types of sensor platforms, Waspmote OEM and Plug & Sense!:
•• Waspmote OEM is intended to be used for research purposes or as part of a major product so it needs final
certification on the client side. More info at: http://www.libelium.com/products/waspmote/
•• Plug & Sense! is the line ready to be used out of the box. It includes market certifications. See below the
specific list of regulations passed. More info at: http://www.libelium.com/products/plug-sense/
•• CE (Europe)
•• FCC (US)
•• IC (Canada)
•• ANATEL (Brazil)
•• RCM (Australia)
•• PTCRB (US)
•• AT&T (US)
-50- v7.3
Code examples and extended information
-51- v7.3
API changelog
7. API changelog
Keep track of the software changes on this link:
www.libelium.com/development/waspmote/documentation/changelog/#4g
-52- v7.3
Documentation changelog
8. Documentation changelog
•• Added indications to send frames to Meshlium via HTTP or HTTPS (HTTPS is the default mode for Meshlium
Manager System version equal or greater than v4.0.9)
•• Added indications about the SIM card format for both OEM and Plug and Sense! product versions
•• Added a new section to show the user how to connect the module to waspmote
-53- v7.3