-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAP_Mode_Client.cpp
More file actions
55 lines (45 loc) · 1.41 KB
/
AP_Mode_Client.cpp
File metadata and controls
55 lines (45 loc) · 1.41 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
#include <Arduino.h>
#include <WiFi.h>
const char ssid[] = "ESP32";
const char password[] = "";
byte mac[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
WiFiClient client;
char server_ip[] = "192.168.4.1";
const uint16_t port = 8888;
void setup()
{
Serial.begin(115200);
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(200);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected with Router");
if (client.connect(server_ip,port))
{
Serial.println("client connected server");
client.print("Hello I'm Client from ");
client.println(WiFi.localIP());
client.println();
}
Serial.print("Local ip is : ");
Serial.println(WiFi.localIP());
Serial.print("Port is:"); Serial.println(port);
Serial.print("MAC Address is :"); WiFi.macAddress(mac);
Serial.print("MAC: "); Serial.print(mac[5],HEX); Serial.print(":"); Serial.print(mac[4],HEX);
Serial.print(":"); Serial.print(mac[3],HEX);
Serial.print(":"); Serial.print(mac[2],HEX);
Serial.print(":"); Serial.print(mac[1],HEX);
Serial.print(":"); Serial.println(mac[0],HEX);
}
void loop()
{
while(client.available()) {
char data = client.read(); Serial.write(data);
}
client.println("Hello"); delay(1000);
}