Example10_SocketPingPong_MultipleUDP

# Example10_SocketPingPong_MultipleUDP

ESP-IDF version of the Arduino example [Example10_SocketPingPong_MultipleUDP.ino](../../examples/Example10_SocketPingPong_MultipleUDP/Example10_SocketPingPong_MultipleUDP.ino).

This example demonstrates how to ping-pong binary data with a UDP echo server using multiple UDP sockets.
Enter the IP address of the UDP echo server on the console.
This example uses LTE Cat M1. It selects the LTE Cat M1 RAT (setRAT) if required.

## The UDP echo server

This example needs a UDP echo server: e.g. [Multi_UDP_Echo.py](../../Utils/Multi_UDP_Echo.py), running on your computer. The server echoes back whatever it receives: the 9604 sends "Ping", gets "Ping" back and replies "Pong", gets "Pong" back and replies "Ping", and so on.

1. Install Python 3 on your computer.
2. Find your computer's local IP address (usually 192.168.x.x; on Windows, run `ipconfig`).
3. Log in to your router. In its Port Forwarding (or Virtual Server) settings, forward UDP ports 1200-1204 to your computer's local IP address. (Ports 1200-1204 are the defaults: the base port set in menuconfig, plus `numConnections` - 1. Add `--ports N` if you change `numConnections`.)
4. Start the server from the `Utils` folder: `python Multi_UDP_Echo.py`. Allow Python through your computer's firewall if it asks.
5. Find your public IP address: search for "what is my IP address".
6. Run this example, and enter your public IP address when asked.

Port forwarding exposes the server to the whole internet, not only to your Iridium 9604. Delete the forwarding rule when you are done. Use the server's `--allow` option to accept only your mobile operator's addresses. Run `python Multi_UDP_Echo.py --help` for all the options.

## Hardware

* An ESP32 (or other ESP-IDF target) connected to the Iridium 9604 via a UART
* Connect: ESP32 TX to 9604 RXD; ESP32 RX to 9604 TXD; GND to GND
* Optionally connect RTS / CTS (hardware flow control) and PWR_ON

## Building

```
idf.py set-target esp32
idf.py menuconfig      # "Example Configuration": UART port, baud rate and GPIO pins; set the port
idf.py -p PORT flash monitor
```

`main/idf_component.yml` points at the library in this repository (`override_path: "../../../"`).

To create a project from this example, run:

idf.py create-project-from-example "sparkfun/sparkfun_iridium_9604_library=1.0.0:Example10_SocketPingPong_MultipleUDP"

or download archive (~7.80 KB)