Skip to content

Commit

Permalink
Add VGS ESP8266 UDP to UART transparent bridge
Browse files Browse the repository at this point in the history
  • Loading branch information
jonpas committed Jan 16, 2019
1 parent 08a4270 commit 06e532e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
8 changes: 8 additions & 0 deletions VGS_ESP8266_Bridge_UDP-UART/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Transparent UDP to UART bridge for ESP8266 (ESP-01 with 1MB flash) using MicroPython.

### Setup

- Flash MicroPython to ESP8266 module
- Configure UDP and UART details in `main.py`
- Upload `main.py` to the file system (`ampy --port <port> put main.py`)
- Reboot ESP8266 module
32 changes: 32 additions & 0 deletions VGS_ESP8266_Bridge_UDP-UART/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import network
import socket
from machine import UART


# CONFIGURATION
AP_NAME = "PixRacer"
AP_PASS = "pixracer"
HOST = "0.0.0.0"
PORT = 14450
UART = 0
BAUDRATE = 115200


# Connect and transparently send raw data from UDP to UART
sta_if = network.WLAN(network.STA_IF)
ap_if = network.WLAN(network.AP_IF)

sta_if.active(True)
ap_if.active(False)

sta_if.connect(AP_NAME, AP_PASS)

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind((HOST, PORT))

uart = UART(UART, BAUDRATE)
uart.init(BAUDRATE)

while True:
data = s.recv(1024)
uart.write(data)

0 comments on commit 06e532e

Please sign in to comment.