forked from aetios50/PincabLedStrip
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathWifiDebug.cpp
57 lines (46 loc) · 1.15 KB
/
WifiDebug.cpp
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
#include "WifiDebug.h"
#if defined(ESP8266)
WiFiUDP Udp;
unsigned int serverUdpPort = 4210;
const char* ssid = "XYZ";
const char* password = "XYZ";
const char* server = "192.168.4.254";
WifiDebug::WifiDebug() {
}
void WifiDebug::begin(void) {
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
}
debug_send_msg("Started\n");
}
void WifiDebug::debug_send_msg(char* message) {
Udp.beginPacket(server, serverUdpPort);
Udp.write(message);
Udp.endPacket();
}
void WifiDebug::debug_send_byte(byte b) {
Udp.beginPacket(server, serverUdpPort);
Udp.write((int)b);
Udp.endPacket();
}
void WifiDebug::debug_send_int(int c) {
char tampon[25];
sprintf(tampon, "%d", c);
Udp.beginPacket(server, serverUdpPort);
Udp.write(tampon);
Udp.endPacket();
}
void WifiDebug::debug_send_word(word w) {
char tampon[25];
Udp.beginPacket(server, serverUdpPort);
byte low = w & 0xFF; // Take just the lowest 8 bits.
byte high = w >> 8; // Shift the integer right 8 bits.
sprintf(tampon, "%d", high);
Udp.write(tampon);
sprintf(tampon, "%d", low);
Udp.write(tampon);
Udp.endPacket();
}
#endif