1#include "main-header.h"
4#include "espressif/esp8266_flash.h"
5#include "proto-esp-usart.h"
6#include "platform-header.h"
7#include "wireless_state_machine.h"
18void esp8266_usb_byte_received(
byte b) {
19 write_serial_char(USART_ESP8266, b);
20 reset_delay_counter(DELAY_ESP2SERIAL);
24void esp8266_wififlash_usb_bridge() {
25 mculib_usb_set_received_callback(MAIN_MCULIBHANDLE, esp8266_usb_byte_received);
27 printf(
"Bridging esp2866 & usb...\r\n");
28 int res = espflash_sync();
31 printf(
"FAIL: failed to sync to esp8266. Is it connected and powered up?\r\n");
37 led_indicate(LED_WIFI_BRIDGE);
38 printf(
"Entering passthrough mode\r\n");
39 printf(
"[BRIDGE ACTIVE]\r\n");
41 reset_delay_counter(DELAY_ESP2SERIAL);
42 reset_delay_counter(DELAY_DEFAULT);
49 if ((i = ringbuffer_get_byte(&esp_ringbuffer)) < 256) {
50 mculib_usb_send(MAIN_MCULIBHANDLE, 1, (uint8_t *)&i);
52 if ((contbridge == 0) && (get_delay_counter(DELAY_ESP2SERIAL) > 500)) {
53 printf(
"Leaving passthrough mode.\r\n");
55 printf(
"[BRIDGE MODE FINISHED]\r\n");
61 led_indicate(LED_WIFI_BRIDGE2);
void esp8266_reset()
reset state machine and esp8266