Applicable Products
Part number | Description |
ZETA-GEP-LTE4 (EU) | Low Power LTE Cat 4 European Modem with GPIO and GNSS |
ZETA-G-GPRS | Entry Level GPRS Modem with GNSS (GL) |
ZETA-N2-GPRS | Entry Level GPRS Modem (GL) |
ZETA-NEP-LTE4 (EU) | Low Power LTE Cat 4 European Modem with GPIO |
ZETA-NEP-LTEM (GL) | Low Power Global LTE Cat M Modem with GPIO |
ZETA-NLP-LTE1 (EU) | Ultra Low Power European LTE Cat 1 Modem |
ZETA-NLP-LTEM (GL) | Ultra Low Power Global LTE Cat M Modem |
ZETA-N-LTE (EU) | High Performance LTE Cat 4 Modem with GPIO |
ZETA-NSP-LTE1 (EU) | Low Power European LTE Cat 1 Modem |
Objective
To connect embedded systems together using the internet requires the use of data sockets to send information from one location to another. This process has been around for a long time and there are methods available to communicate with servers and devices using sockets to establish a bi-directional communication link between two endpoints.
In general, there is a listening device and a dialling device. Servers are generally setup as listening devices and remote modems as dialling devices, but this is not always the case and there are many examples which differ from this generalisation.
There are certain requirements with both the listening devices and dialling devices which must be taken into consideration when setting up a communication link between two endpoints. This application note will discuss these points in more detail.
Solution
Listening Device Requirements
The listening device must be accessible on the network and be able to accept incoming data socket requests from remote devices. This usually means having a firewall with a few specific open ports to allow incoming requests to be accepted through the accessible ports. Devices on the internet which have open ports are immediately susceptible to attack from hackers, spammers, viruses and bots which exploit specific vulnerabilities in the listening device’s operating system. As a result, many security measures have been developed to prevent unauthorised access, but care must be taken to ensure that these measures are effectively managed.
For a device listening on the internet, it would usually have a fixed IP address which does not change over time. This IP address can then be used by any remote device to communicate with the listening device in a comparable way to a phone number is used on a telephone.
This fixed IP address would be publicly available and any device legitimate or otherwise would be able to communicate with it. On a HTTP webserver, the server would have a fixed IP address and would be listening for incoming data traffic on port 80. Mapped to this IP address would be a domain name such as ‘www.example.com’. When the user types in ‘www.example.com’ to their web browser, the web browser looks up the IP address using DNS and it returns the IP address of the server. The web browser then contacts the server’s IP address directly on port 80 and the https webserver responds with the web page.
The exact same process can be applied to data socket connections using mobile devices.
- The mobile device uses a fixed IP address SIM card.
- The mobile device is setup to listen on a specific port i.e. 1024.
- The mobile device opens its firewall to specific devices.
- The mobile device waits for an incoming data socket connection.
- The dialling device attempts to open a socket on the IP address of the fixed IP address SIM card on the listening port i.e. 1024
Dialling Device Requirements
The dialling device can use any standard SIM card and does not require a specific setup or fixed IP address SIM card. As the dialling device is dialling out to the server it is not listening for incoming data connections and therefore does not need to be as concerned about security as the listening device.
Demonstration of Solution
Resources:
- PC with an installed ‘Terminal Emulator’ program: A Windows 10 laptop installed with Tera Term was used for the purpose of this guide.
- Siretta Part Number: 61057 -ZETA-GEP-LTE4 (EU) Starter Kit (any ZETA starter Kit is suitable for this application)
- Insert SIM card to the modem
- Power on the modem
- Connect the supplied serial port cable to the PC
- Connect the antenna
- As described in the Starter Kit Quick Start Guide
- Open Hyperterminal on the PC (or your preferred terminal emulator: PuTTY, TeraTerm).
- Select new connection. Name the new connection for reference in the future.
- Name your port.
- Choose the correct COM port. From the drop-down list, select the correct COM port your modem is connected to.
- Configure the port with the following settings (These settings are standard for all of the ZETA Siretta modems):
- Bits per second: 115200
- Data bits: 8
- Parity: None
- Stop bits: 1
- Flow control: Hardware
Note: The above procedure is set out in Initial Modem Set Up application note
GPRS Connection
COM3 – Tera Term VT |
File Edit Setup Control Window Help |
//Set extended error messages AT+CMEE=2//Set GPRS APN Name AT+CGDCONT=1,” IP”,” APN Name” |
Outgoing Connection
COM3 – Tera Term VT |
File Edit Setup Control Window Help |
//Set packet size and timeouts on context 1-6
AT#SCFG=1,1,300,90,600,50 //Open GPRS context 1-6 with GPRS Username and GPRS Password. (This will return your ISP assigned IP address) AT#SGACT=1,1,” username”,” password” //Open Socket on Port Number at IP Address AT#SD=1,0, Port Number,” IP Address”,255,0 // Close GPRS context 1-6 AT#SGACT=1,0 AT+CGDCONT=1,” IP”,” APN Name” AT#SGACT=1,1,” username”,” password” AT#SD=1,0,1024,”080.080.080.081”,255,0
|
Incoming Connection
COM3 – Tera Term VT |
File Edit Setup Control Window Help |
//Open GPRS context 1-6 with GPRS Username and GPRS Password
AT#SGACT=1,1,” username”, “password” //Setup Firewall AT#FRWL=1,” IP Address”,” Subnet Mask” //Allow all: AT#FRWL=1,”0.0.0.0”,”0.0.0.0” //Socket listen 1-6 AT#SL=1,1,” Port Number” |
Socket Status
//Check status of each socket from 1-6
AT#SS
Application Example
Modem A (Local): IP Address – 80.80.80.80, Port Number – 1024
Modem B (Remote): IP Address – 80.80.80.81, Port Number – 1024
Modem A Config
COM3 – Tera Term VT |
File Edit Setup Control Window Help |
AT+CMEE=2
AT+CGDCONT=1,” IP”,” APN Name” AT#SGACT=1,1,” username”,” password” AT#SD=1,0,1024,”080.080.080.081”,255,0 |
Modem B Config
COM3 – Tera Term VT |
File Edit Setup Control Window Help |
AT+CMEE=2
AT+CGDCONT=1,” IP”,” APN Name” AT#SGACT=1,1,” username”,” password” AT#FRWL=1,”80.80.80.80”,”255.255.255.255” AT#SL=1,1,1024,255 |
Successful Connection
Upon success modem A (80.80.80.80) will show: CONNECT.
Upon success modem B (80.80.80.81) will show: SRING:1 Showing a connection is requested on connection context 1.
Type AT#SA=1 to allow the connection and you will get the response below: CONNECT
Either modem can close the connection using the closure command +++
Up to 6 active socket connections can be stored at any time, however only 1 active connection can be maintained on a single channel (COM Port).
Additional Reading
Description | Author |
ZETA Hardware user’s manual | Siretta |
AT command manual | Telit |