
-58-
v4.9
TCP and UDP connections
This function returns:
•
‘1’ on success
•
‘0’ if error
•
‘-2’ if error with IP error code available
For receive data Waspmote must execute the function
manageIncomingData()
. This function executes the proper functions
and returns a number with the type of data. For IP data this function returns ‘3’. The IP address of the sender is stored in
IP_dir
and the data in
buffer_3G
. For more information about the function
manageIncomingData()
, see the description of the
function at this guide.
11.6.4. Closing the socket
To close an opened connection the function
closeMultiSocket()
must be used. This function needs number of the
connection to close.
Example of use:
{
// Closes the specify socket:
_3G.closeMultiSocket(2);
}
This function returns:
•
‘1’ on success
•
‘0’ if error
•
‘-2’ if error with IP error code available
11.7. Working in TCP server mode
The 3G/GPRS module can be used as a TCP server. In this working mode, the 3G/GPRS module can accept up to 10 TCP clients.
11.7.1. Creating the server
A TCP server can be created with the function
createSocket()
. The parameters needed are the working mode
TCP_SERVER
and the port of the server.
Example of use:
{
// Creates a TCP server:
_3G.createSocket(TCP_SERVER, 80);
}
This function returns:
•
‘1’ on success
•
‘-2’ if error opening the network
•
‘-3’ if error opening the network with CME error code available
•
‘-4’ if error opening the network with IP error code available
•
‘-5’ if error opening the TCP connection or starting the TCP server
•
‘-6’ if error opening the TCP connection or starting the TCP server with IP error code available
Содержание Waspmote 3G Plus GPS
Страница 1: ...Waspmote 3G GPS Networking Guide ...