ESP8266 UART to TCP socket absolutely transparent bridge
Posted: Mon Dec 15, 2014 11:49 am
https://github.com/beckdac/ESP8266-transparent-bridge
Many thanks to petgit on github for some nice new features...
Also, many thanks to jvandenbroek for the GPIO2 features that can be used to reset an arduino for remote bootloading.
This is really basic firmware for the ESP that creates a totally transparent TCP socket to ESP UART0 bridge. Characters come in on one interface and go out the other. The totally transparent bridge mode is something that has been missing and is available on higher priced boards.
Pros:
Cons:
Many thanks to petgit on github for some nice new features...
Also, many thanks to jvandenbroek for the GPIO2 features that can be used to reset an arduino for remote bootloading.
This is really basic firmware for the ESP that creates a totally transparent TCP socket to ESP UART0 bridge. Characters come in on one interface and go out the other. The totally transparent bridge mode is something that has been missing and is available on higher priced boards.
Pros:
- It works. Do you already have a serial project to which you just want to add WiFi? This is your ticket. No more dealing with the AT command set.
- You can program your Arduino over WiFi. Just hit the reset button and upload your sketch using avrdude's socket port, e.g.Code: Select all
avrdude -c avrisp -p m328p -P net:169.254.4.1:23 -F -U flash:w:mySketch.hex:i
- Optional by compile time defines:
- Static configuration each time the unit boots from values defined in user/config.h. Uncomment the following line in user/config.h:Code: Select all
#define CONFIG_STATIC
- Dynamic configuration by remote telnet using +++AT prefixed commands. Enabled by default. To disable, comment the following line in user
/config.h:Code: Select all#define CONFIG_DYNAMIC
Telnet into the module and issue commands prefixed by +++AT to escape each command from bridge mode. The dynamic configuration commands are:Code: Select allUpon success, all commands send back "OK" as their final output. Note that passwords may not contain spaces.+++AT # do nothing, print OK
+++AT MODE # print current opmode
+++AT MODE <mode: 1= STA, 2= AP, 3=both> # set current opmode
+++AT STA # print current ssid and password connected to
+++AT STA <ssid> <password> # set ssid and password to connect to
+++AT AP # print the current soft ap settings
+++AT AP <ssid> # set the AP as open with specified ssid
+++AT AP <ssid> <pw> [<authmode> [<ch>]]]# set the AP ssid and password, authmode:1= WEP,2= WPA,3= WPA2,4= WPA+WPA2 , channel: 1..13
+++AT BAUD # print current UART settings
+++AT BAUD <baud> [data [parity [stop]]] # set current UART baud rate and optional data bits = 5/6/7/8 , parity = N/E/O, stop bits = 1/1.5/2
+++AT PORT # print current incoming TCP socket port
+++AT PORT <port> # set current incoming TCP socket port (restarts ESP)
+++AT FLASH # print current flash settings
+++AT FLASH <1|0> # 1: The changed UART settings (++AT BAUD ...) are saved ( Default after boot), 0= no save to flash.
+++AT RESET # software reset the unit
+++AT GPIO2 <0|1|2 100> # 1: pull GPIO2 pin up (HIGH) 0: pull GPIO2 pin down (LOW) 2: reset GPIO2, where 100 is optional to specify reset delay time in ms (default 100ms)
The settings are saved after the commands +++AT PORT +++AT BAUD ...
After +++AT FLASH 0 the parameter of command +++AT BAUD ... are NOT saved to the flash memory. The new settings are applied to the UART and saved only in RAM. But a following +++AT PORT need to flash the settings for the necessary reboot. Then also the changed UART setting are saved to flash.
The disable of flash the settings is for devices with baud rate changes to avoid permanently flash of the setting sector.
- Static configuration each time the unit boots from values defined in user/config.h. Uncomment the following line in user/config.h:
Cons:
- Limited buffered TCP writes. The first buffer is the UART FIFO. The second buffer is to collect new uart chars until the previous packet is sent. From SDK 0.9.4 the next espconn_sent must after espconn_sent_callback of the pre-packet. All incoming UART characters in the FIFO gets sent immediately via the tx-buffer. The resulting TCP packet has only some bytes.