Wifi server udp

Wireless communications in Waspmote, topologies, node types...
Post Reply
gp1972
Posts: 4
Joined: Tue Jun 10, 2014 5:46 pm

Wifi server udp

Post by gp1972 » Fri Mar 15, 2019 5:52 pm

Hi,
I use the waspmote devices,version v12, with different radio modules.
I would like know how it is possible to use the wifi server to answer to specific request.
I mean if I configure a waspmote as a server udp, for example, and I use another client udp to send a message can I receive a response from server?

In a scenario IoT wifi, I would like do a request for a specific measure of a sensor. I guess a gases board, with different sensors, installed on a waspmote board, so I do a request, for example a temperature request, and the waspmote responds with this measure.
I don't know if I was clear.

Thank you in advance

Pino

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: Wifi server udp

Post by libelium-dev » Mon Mar 18, 2019 9:57 am

Hi,

Yes, you can create a tcp/udp server using a wifi module. It can wait for incoming data and send the requested data. You can see the example codes to create an udp server in the following links
http://www.libelium.com/v12/development ... dp-server/ (old wifi module for waspmote v12)
http://www.libelium.com/development/was ... -listener/ (new wifi pro module)

Regards

gp1972
Posts: 4
Joined: Tue Jun 10, 2014 5:46 pm

Re: Wifi server udp

Post by gp1972 » Mon Mar 18, 2019 4:32 pm

Thank you for the response...
I know, I used it (only the old wifi module)...My question is other...
I would know if when I send a message to the server,udp or tcp, the server can answer at the message(request) with a response message.
Example: I send the message "temperature" to server, and server respond me with the measure of temperature.
I checked the sdk but no API for this purpose I found
To better explain, in the following code of the server application I can read the message from client to server, but where is the answer from server to client, if it is possible to do that????
previous=millis();
while( millis()-previous<TIMEOUT )
{
// Reads from the UDP connection
WIFI.read(NOBLO);

if(WIFI.length>0)
{
USB.print(F("RX: "));
for( int k=0; k<WIFI.length; k++)
{
USB.print(WIFI.answer[k],BYTE);
}
USB.println();
}
// Condition to avoid an overflow (DO NOT REMOVE)
if (millis() < previous)
{
previous = millis();
}

}

// Exits from UDP sending data mode.
USB.println(F("Close UDP socket"));
WIFI.close();
}
else
{
USB.println(F("UDP server NOT set"));
}
}

Thank you

Pino

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: Wifi server udp

Post by libelium-dev » Tue Mar 19, 2019 10:13 am

Hi,

You can send a response to the client using send function.

Code: Select all

WIFI.send("Hi!"); 
Did you test the send function? Does it work?

Regards

gp1972
Posts: 4
Joined: Tue Jun 10, 2014 5:46 pm

Re: Wifi server udp

Post by gp1972 » Tue Apr 02, 2019 9:17 am

Hi,
Before to open this post I tested the function WIFI.send(), but it doesn't works

Regards

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: Wifi server udp

Post by libelium-dev » Wed Apr 03, 2019 8:41 am

Hi,

What output do you get through the serial monitor when you use the example codes?

Is the node the sever or the client?

Regards

gp1972
Posts: 4
Joined: Tue Jun 10, 2014 5:46 pm

Re: Wifi server udp

Post by gp1972 » Tue Apr 16, 2019 12:09 pm

Hello, I am solved the problem. It was an eof that blocked my communication :-(.
Now it work fine by using the send command, but I would like know how to delete the *hello* string from my message.
Moreover I would like know how create a adhoc network, I tried but with unsuccessfully. I would like know the steps to create it, I don't find example for adhoc network.

Best regards and thank you very much for the support

Pino

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: Wifi server udp

Post by libelium-dev » Wed Apr 17, 2019 9:37 am

Hi,

What do you mean with "I would like know how to delete the *hello* string from my message"?

The old WiFi module can't create a WiFi AP. It doesn't have this feature.

Regards

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest