# Example10_SocketPingPong_BinaryTCP ESP-IDF version of the Arduino example [Example10_SocketPingPong_BinaryTCP.ino](../../examples/Example10_SocketPingPong_BinaryTCP/Example10_SocketPingPong_BinaryTCP.ino). This example demonstrates how to transfer binary data from one Iridium 9604 (or SARA-R5) to another using TCP sockets. Choose Ping or Pong, and enter the remote IP address, on the console. This example uses LTE Cat M1. It selects the LTE Cat M1 RAT (setRAT) if required. ## Testing with one module: the TCP echo server Most mobile operators give the Iridium 9604 a private IP address, behind their network address translation (NAT). Incoming TCP connections cannot reach it, so the "Pong" will usually not work. Instead, you can choose "Ping" and play ping-pong with a computer running [Multi_TCP_Echo.py](../../Utils/Multi_TCP_Echo.py). 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 TCP port 1200 to your computer's local IP address. (1200 is the default: use the port set in menuconfig.) 4. Start the server from the `Utils` folder: `python Multi_TCP_Echo.py --ports 1`. 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, choose "Ping", 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_TCP_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_BinaryTCP"