1 | #include "Arduino.h"
|
2 |
|
3 | extern "C" {
|
4 | #include "fs/ff.h"
|
5 | }
|
6 |
|
7 | #include <ESP8266WiFi.h>
|
8 |
|
9 | const char* ssid = "SSID_OF_YOUR_NETWORK_HERE";
|
10 | const char* password = "WIFI_PASSWORD_GOES_HERE";
|
11 |
|
12 | // Create an instance of the server on Port 80
|
13 | WiFiServer server(80);
|
14 |
|
15 | unsigned long ulReqcount;
|
16 | unsigned long ulReconncount;
|
17 |
|
18 | void WiFiStart();
|
19 |
|
20 | //The setup function is called once at startup of the sketch
|
21 | void setup()
|
22 | {
|
23 | uint8_t work[512];
|
24 | f_mkfs("", FM_SFD, 0, work, 512);
|
25 |
|
26 | // inital connect
|
27 | WiFi.mode(WIFI_STA);
|
28 | WiFiStart();
|
29 | // Add your initialization code here
|
30 | }
|
31 |
|
32 | // The loop function is called in an endless loop
|
33 | void loop()
|
34 | {
|
35 | //Add your repeated code here
|
36 | }
|
37 |
|
38 |
|
39 | void WiFiStart()
|
40 | {
|
41 | ulReconncount++;
|
42 |
|
43 | // Connect to WiFi network
|
44 | Serial.println();
|
45 | Serial.println();
|
46 | Serial.print("Connecting to ");
|
47 | Serial.println(ssid);
|
48 |
|
49 | WiFi.begin(ssid, password);
|
50 |
|
51 | while (WiFi.status() != WL_CONNECTED) {
|
52 | delay(500);
|
53 | Serial.print(".");
|
54 | }
|
55 | Serial.println("");
|
56 | Serial.println("WiFi connected");
|
57 |
|
58 | // Start the server
|
59 | server.begin();
|
60 | Serial.println("Server started");
|
61 |
|
62 | // Print the IP address
|
63 | Serial.println(WiFi.localIP());
|
64 | }
|