-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwifi.c
More file actions
84 lines (72 loc) · 1.23 KB
/
wifi.c
File metadata and controls
84 lines (72 loc) · 1.23 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include <led_task.h>
#include <uart2.h>
#include <intrins.h>
void delays(unsigned int m);
void wifistart(void)
{unsigned char i;
while (!checkok()){
Uart2SendStr("AT\r\n");
delays(50);
}
EA=0;
for (i=0;i<=5;i++) WS2812WR(120,0,120);
EA=1;
while (!checkok()){
Uart2SendStr("AT+CWMODE=1\r\n");
delays(50);
}
EA=0;
for (i=0;i<=7;i++) WS2812WR(120,0,120);
EA=1;
}
void wificonnect(char * name,char * password)
{unsigned char i;
while (!checkok()){
Uart2SendStr("AT+CWJAP=\"");
Uart2SendStr(name);
Uart2SendStr("\",\"");
Uart2SendStr(password);
Uart2SendStr("\"\r\n");
delays(1000);
}
EA=0;
for (i=0;i<=9;i++) WS2812WR(120,0,120);
EA=1;
}
void wificipstart(char *ip)
{unsigned char i;
while (!checkok()){
Uart2SendStr("\"AT+CIPSTART=\"TCP\",\"");
Uart2SendStr(ip);
Uart2SendStr("\r\n");
delays(500);
}
EA=0;
for (i=0;i<=11;i++) WS2812WR(120,0,120);
EA=1;
}
void wifisend(char *msg)
{
while (!checkok()){
Uart2SendStr("AT+CIPSEND=8\r\n");
delays(50);
}
while (!checkok()){
Uart2SendMsg(msg);
delays(50);
}
}
void delays(unsigned int m)
{
do{
unsigned char i, j;
_nop_();
_nop_();
i = 15;
j = 90;
do
{
while (--j);
} while (--i);
} while (--m);
}