-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add VGS ESP8266 UDP to UART transparent bridge
- Loading branch information
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |