
-56-
v4.9
TCP and UDP connections
11.5.2. Sending and receiving data
sendData()
is the function for send data to an opened socket. For send data to a TCP socket you only needs the string of data
to send. For send data to a UDP socket, you need the string of data to send, the IP address and the port.
Example of use:
{
// Sending data to a TCP socket:
_3G.sendData(“TCP test string”);
// Sending data to a UDP socket:
_3G.sendData(“UDP test string”, “90.12.54.132”, 5566);
}
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.5.3. Closing the socket
To close an opened socket the function
closeSocket()
must be used. This function doesn’t need parameters.
Example of use:
{
// Closes the socket:
_3G.closeSocket();
}
This function returns:
•
‘1’ on success
•
‘0’ if error
•
‘-2’ if error with IP error code available
11.6. Working in multi client mode
In the multi client mode, the 3G/GPRS module can establish up to 10 connections with different servers. These connections can
be TCP or UDP.
The steps to work in this mode are the next:
•
1. Enable the multi client mode
•
2. Create a socket
•
3. Send and receive data
•
4. Close the socket
Содержание Waspmote 3G Plus GPS
Страница 1: ...Waspmote 3G GPS Networking Guide ...