-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathesp8266.c
55 lines (50 loc) · 1.17 KB
/
esp8266.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "esp.h"
#include "uart.h"
#include "gpio.h"
#include "rpi.h"
#include "str.h"
void flicker2(unsigned pin, unsigned delay, unsigned delay2) {
delay_ms(delay);
gpio_write(pin, 1);
delay_ms(delay2);
gpio_write(pin, 0);
}
void flicker(unsigned pin) {
flicker2(pin, 1000, 3000);
}
void notmain(void) {
unsigned green = GPIO_PIN16;
unsigned blue = GPIO_PIN20;
unsigned red = GPIO_PIN21;
uart_init();
gpio_set_output(green);
gpio_set_output(blue);
gpio_set_output(red);
gpio_write(green, 1);
gpio_write(blue, 1);
gpio_write(red, 1);
delay_ms(1000);
gpio_write(green, 0);
gpio_write(blue, 0);
gpio_write(red, 0);
const char *SSID = "WiPi";
const char *PWD = "WiPi1234";
while (1) {
signed ret_init = esp_init();
assert(ret_init >= 0);
flicker(green);
signed ret_mode = esp_mode(1);
assert(ret_mode >= 0);
flicker(blue);
signed ret_connect = esp_connect(SSID, PWD);
assert(ret_connect >= 0);
flicker(red);
signed ret_ip = esp_checkip();
assert(ret_ip >= 0);
flicker(green);
signed ret_client = esp_connection_mode(1); //multi connection
flicker(blue);
signed ret_socket = esp_listen(80); //listen on port 80
flicker(red);
}
}