Thales IoT Developer Community
Concept Board: Internet Services - basics
Tutorial, March 25, 2014 - 1:07pm, 30102 views
This is part of tutorial series for Internet Services usage on Gemalto Concept Board:
- Concept Board: Internet Services - basics
- Concept Board: Internet Services - HTTP
- Concept Board: Internet Services - Transparent Socket
EHS6 has an embedded TCP/IP stack that is driven by AT commands and enables the host application to easily access the Internet. The advantage of this solution is that it eliminates the need for the application manufacturer to implement own TCP/IP and PPP stacks, thus minimizing cost and time to integrate Internet connectivity into a new or existing host application.
Please note that although other Gemalto products also offer Internet Services feature, the configuration and usage may vary. Feel free to inspire with this tutorial, but always refer to corresponding AT Command Set when configuring Internet Service for other products.
With EHS6 following Internet Services may be used:
- Non-Transparent/Transparent TCP client
- Non-Transparent/Transparent TCP listener
- Non-Transparent/Transparent UDP client
- Non-Transparent UDP endpoint
- FTP client
- HTTP client
- SMTP client
How to start?
As an example we will configure Non-Transparent TCP client accessing Internet over GPRS0. According to AT Command Set documentation there are generally two strategies in using Internet Services - polling **** and URC-driven ****. For example purposes URC-driven **** will be used, so before start, please make sure that AT^SCFG="Tcp/WithURCs" is set to "on".
All Internet Services are configured and used according to following scheme:
- Configuring Internet Connection and Internet Service
- Opening Internet Service
- Reading from/writing to internet service
- Closing Internet Service
Please find step by step instruction below.
Configuration of Internet Connection
Before Internet network resources can be accessed, connection profile must be configured.
Connection profile determines which access technology will be used for establishing Internet connection (for EHS6 only GPRS0 is available) and defines APN. User and password may also be passed if required.
Up to six connection profiles may be configured (under ids from range 0-5).
AT^SICS command is used to configure connection profile. General syntax for this command is as follows:
- <conProfileId> is the id of the connection,
- <conParmTag> is connection parameter name,
- <conParmValue> is value of above parameter.
Please input below AT commands to setup the connection:
Above command sets the 0th profile to access network over GPRS0.
Above command sets the 0th profile to use access point name equal "internet" (quotes omitted).
If network operator doesn't require passing user and password, after setting proper APN the connection should work. For other configuration options, please refer to description of <conParmTag> in AT command set.
Configuration of Internet Service
As Internet Connection has been already configured, you can setup Internet Service. As an example TCP client will be used. To setup Internet Service AT^SISS command is used. General syntax for this command is as follows:
- <srvProfileId> is the id of the service (don't mix up with connection id),
- <srvParmTag> is service parameter name,
- <srvParmValue> is value of above parameter.
First you need to define which type of Internet Service will be used:
Above command sets socket client to be accessible under service profile id equal 2.
Now let's setup the address of the server:
Above command sets destination address x.x.x.x and port p.
Finally you have to assign service profile to connection profile:
After above command execution, the service will be assigned to access the Internet using connection profile on id equal 0, which was configured in section "Configuration of Internet Connection".
It is worth mentioning that up to 10 services may be created (under ids from range 0-9). Various Internet Services may use the same Internet Connection.
Opening Internet Service
As configuration is over, Internet Service may be open with following command:
After above command Internet Connection will be established (if not established yet) and the service will start working. URCs will signalize that new data may be put or received.
Reading and writing
When the module is ready to accept new data, following URC appears:
Above URC notifies that Internet Service with id = 2 is ready for new data. Let's write 5 bytes to the service using:
After ^SISW: 2,10,0 intermediate result code the module waits for 10 bytes. 1500 bytes can be written at once.
When the module receives new data, following URC appears:
This means that there is new data in buffer waiting to be flushed. Use following command to read the data (log with answer):
AT^SISR command performs non-blocking query. It returns received data up to requested limit. If no sufficient amount of data is provided it will return all the data from the buffer. Intermediate return code informs how much data will be flushed.
Closing Internet Service
If Internet Service is no longer needed, it may be closed with:
After above command execution the socket will be closed and Internet Connection will be dropped after inactivity timeout's expiration if no other active Internet Services are assigned to this Connection.
Monitoring connection state
For connection and service monitoring following commands can be used:
AT^SICI? - monitoring state of Internet Connections,
AT^SISI? - monitoring state of Internet Services
AT^SISO? - as above
Monitoring commands report state with numerical codes. The values may be looked up in corresponding AT Command Set sections.
Internet Services may be powerful tool in developer's hands. With only few commands Internet Connection may be set to be used in embedded applications without the necessity of network stack implementation - hence application designer may focus on his strict goals. For more details refer to Concept Board documentation page in Knowledge Base, AT Command Set is especially helpful.