WiFi - Set up UDP Server to Communicate
AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1
In this example, we connect Ameba to WiFi and use Ameba to be an UDP server. When Ameba receives a message from UDP client, it replies “acknowledged” message to client.
Open the WiFi Web Server example.
“File” → “Examples” → “WiFi” → “WiFiUdpSendReceiveString”
Modify the highlighted code section (ssid, password, keyindex) to connect to your WiFi network.
Compile the code and upload it to Ameba. After pressing the Reset button, Ameba connects to WiFi and starts the UDP server with port 2390. After the UDP server starts service, Ameba prints the “Starting connection to server” message and waits for client connection.
Choose client mode and fill in the IP of UDP server (which is the IP of Ameba) and port 2390, then click “UDP Connect”.
After the connection is established, fill in “Hello World” in the Buf 0 field in sokit and click “Send”. Then you can see the Ameba UDP server replies “acknowledged”.
Refer to the Arduino tutorial for detailed information about this example.
begin()to open an UDP port on Ameba.
parsePacket()to wait for data from client.
When a connection is established, use
remotePort()to get the IP and port of the client.
read()to read the data sent by client.
To send reply, use