#include <Arduino.h>
+#include <ESP8266WiFi.h>
#include <stdbool.h>
#include <stdint.h>
+#define SSID "ASUS_NDL"
+#define WPA2KEY "RT-AC66U"
+#define PORT 8123
+
+extern "C" unsigned long getmillis(void);
+extern "C" void pdie(char *, ...);
+extern "C" void die(char *, ...);
+extern "C" void debug(char *, ...);
+extern "C" void real_setup(void);
+extern "C" void write_byte(uint8_t);
+extern "C" uint8_t read_byte(void);
+extern "C" bool input_available(void);
+extern "C" void msdelay(unsigned long);
+
+WiFiServer server(PORT);
+WiFiClient client;
+
unsigned long getmillis(void)
{
return millis();
bool input_available(void)
{
- return Serial.available();
+ return client.available();
}
uint8_t read_byte(void)
{
- return Serial.read();
+ return client.read();
}
void write_byte(uint8_t b)
{
- Serial.write(b);
+ client.write(b);
}
void real_setup(void)
{
Serial.begin(115200);
- Serial.println("Hello world!");
+ Serial.print("Connecting to ");
+ Serial.println(SSID);
+ WiFi.begin(SSID, WPA2KEY);
+ while (WiFi.status() != WL_CONNECTED) {
+ delay(500);
+ Serial.print(".");
+ }
+ Serial.println("");
+ Serial.println("WiFi connected");
+ Serial.println("IP address: ");
+ Serial.println(WiFi.localIP());
+ server.begin();
+ Serial.print("Server started on port: ");
+ Serial.println(PORT);
+
+ Serial.print("Waiting for a client to connect.");
+ while(true){
+ client = server.available();
+ if(client){
+ break;
+ }
+ }
+ Serial.print("Client connected: ");
+ Serial.println(client.connected());
+ Serial.println("");
}
void debug(char *fmt, ...)
{
Serial.print(fmt);
while(1){
- msdelay(100);
+ msdelay(1000);
Serial.print("die");
}
}