SingingCat 0
application
esp8266.h
1#ifndef ESP_H_
2#define ESP_H_ 1
3
4#include "decode_esp_packet.h"
5#include "proto-esp-usart.h"
6
7#define WIFIMODE_NORMAL 0
8#define WIFIMODE_FLASH 1
9#define ESPRETRYDELAY 180
10
11#define PIN_ESP8266_CHPD 1
12#define PIN_ESP8266_GPIO0 208
13#define PIN_ESP8266_GPIO4 200
14
15#define ESP8266_MCULIBHANDLE 2
16
21#define ESP_AP_NAME_SIZE (100 * 5)
22
23typedef struct ipv4address {
24 byte ip1;
25 byte ip2;
26 byte ip3;
27 byte ip4;
29
31long esp8266_get_time_of_last_ip();
32// esp.c
33
35//void enter_esp_passthrough_mode();
36void esp8266_bridge();
37void esp8266_event_loop();
38
39void esp8266_got_packet(const byte *buf, int size);
40void esp8266_test();
41void esp8266_reset();
42void setup_esp8266();
43void esp_init();
44
45void wifi_send_data(const PACKET_TYPE type, const byte *buf, const int len);
46void esp8266_add_ap(const char *ssid, const char *pw);
47int enable_esp_listener();
48int esp_get_needs_retry();
49
51int esp_get_mac(char *buf, int bufsize);
52int esp_read_mac();
53//int send_at_with_answer(const char *at, char *buf, int bufsize)
54void esp_enable_flash_mode();
55int print_wifi_ip_on_serial(void);
56int get_wifi_ip_address(struct ipv4address *adr);
57int wifi_set_to_station_mode();
58
59#define ESP8266_USART_PASSTHROUGH 1
60#define ESP8266_USART_SMART 2
61#define ESP8266_USART_PACKET_ONLY 3
62#define ESP8266_USART_AFTERRESET 4
63#define ESP8266_USART_IGNORE 5
65int get_esp8266_usart_mode();
66void set_esp8266_debug(byte b);
67//int esp8266_isready();
68
70void set_esp8266_usart_mode(int i);
71
73
74int esp8266_is_irq_enabled();
75void esp8266_enable_irq();
76void esp8266_disable_irq();
80void esp8266_disable();
84void esp8266_enable();
85
86void esp8266_reset_command_validity_ctrs();
87long esp8266_get_valid_commands();
88long esp8266_get_invalid_commands();
89int esp8266_get_operational_baudrate();
90void esp8266_set_operational_baudrate(int baudrate);
91void print_esp_core_info();
92void esp8266_dodebug(const char *paras);
93const char *esp_get_last_ssid();
94const char *esp_get_last_pw();
95int write_char_to_console(char b);
97void esp8266_wififlash_usb_bridge();
98
99int esp8266_get_firmware_version();
100int esp8266_get_chip(); // 1==esp8266,2=esp32
101int esp8266_get_firmware_repo();
102uint64_t esp8266_get_firmware_base();
103
105void esp8266_ota();
106int get_esp_reboot_ctr();
107void start_wifi_scan();
108void esp8266_wifi_scan(struct command *com);
109void esp8266_send_config();
110int esp8266_is_enabled();
111
112/*
113\* brief deal with a bt-ble-set-char command. return 0 if ok
114*/
115int esp32_bt_set_characteristic_com(struct command *com);
116int esp32_bt_trigger_read_characteristic_com(struct command *com);
117/*
118\* brief read peers from last scan
119*/
120int esp32_bt_peers(struct command *com);
121
122/*
123\* brief send an instruction to esp32
124*/
125void cat_send_local_instruction(const PACKET_TYPE type, const uint8_t *buf, const int len);
126
127
128#endif
void esp8266_enable()
enable the esp8266 (switch it on)
Definition: esp8266.c:1442
void esp8266_wififlash_bridge(void)
set esp8266 to flash mode, sync and then bridge ("startflash")
Definition: esp8266.c:675
int esp_read_mac()
Definition: esp8266.c:948
char * esp8266_status_string()
returns a human readable status string of the wifi connection
Definition: esp8266.c:859
void esp8266_read_byte_from_serialport(int val)
this is called directly from the usart IRQ. be quick. and do not use printf()
Definition: esp8266.c:1262
void wifi_send_data(const PACKET_TYPE type, const byte *buf, const int len)
send a command via wifi
Definition: esp8266.c:617
void esp8266_ota()
tell the esp to do an OTA
Definition: esp8266.c:1328
void esp8266_reset()
reset state machine and esp8266
Definition: esp8266.c:387
int esp8266_is_accespoint()
returns !=0 if we are currently an accesspoint
Definition: esp8266.c:583
void cat_send_local_instruction(const PACKET_TYPE type, const uint8_t *buf, const int len)
send a packet to the esp8266 wifi chip
Definition: esp8266.c:1343
void esp8266_got_packet(const byte *buf, int size)
Definition: esp8266.c:1069
int esp_get_mac(char *buf, int bufsize)
get the esp8266 mac address.
Definition: esp8266.c:931
void esp8266_disable()
disable the esp8266 (switch it off)
Definition: esp8266.c:1446
void esp_init()
call this ONCE before calling anything else
Definition: esp8266.c:883
void esp8266_test()
Definition: esp8266.c:256
struct ipv4address * esp8266_get_current_ip()
return last ip (null if none)
Definition: esp8266.c:1229
void esp8266_add_ap(const char *ssid, const char *pw)
add an ap to the list of known ap
Definition: esp8266.c:424
void esp8266_bridge()
bridge debug serialport and esp8266 (e.g. "wifidebug")
Definition: esp8266.c:791
void esp8266_cloud_connection_failed()
called if the cloud connection failed
Definition: esp8266.c:1661
void esp8266_send_instructions()
send our nodeid and other goodies to the esp8266 chip
Definition: esp8266.c:1311