init playground files to test
This commit is contained in:
parent
d8a578c4b5
commit
b2f13e3619
7 changed files with 177 additions and 0 deletions
46
ESPTest/src/main.cpp
Normal file
46
ESPTest/src/main.cpp
Normal file
|
@ -0,0 +1,46 @@
|
|||
#include <Arduino.h>
|
||||
#include "WiFi.h"
|
||||
#include "theSecrets.h"
|
||||
|
||||
void connectToWifi()
|
||||
{
|
||||
WiFi.begin(ssid, psk);
|
||||
while (WiFi.status() != WL_CONNECTED)
|
||||
{
|
||||
delay(200);
|
||||
}
|
||||
}
|
||||
|
||||
void handle_wifi_events(WiFiEvent_t event, WiFiEventInfo_t info)
|
||||
{
|
||||
Serial.print("[WiFi] ");
|
||||
switch (event)
|
||||
{
|
||||
case ARDUINO_EVENT_WIFI_STA_START:
|
||||
Serial.printf("Attempting to connect to WPA SSID: %s\n", ssid);
|
||||
break;
|
||||
case ARDUINO_EVENT_WIFI_STA_CONNECTED:
|
||||
Serial.println("connected");
|
||||
break;
|
||||
case ARDUINO_EVENT_WIFI_STA_DISCONNECTED:
|
||||
Serial.println("disconnected");
|
||||
break;
|
||||
case ARDUINO_EVENT_WIFI_STA_GOT_IP:
|
||||
Serial.print("IP address: ");
|
||||
Serial.println(WiFi.localIP());
|
||||
break;
|
||||
default:
|
||||
Serial.println(event);
|
||||
}
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFi.onEvent(handle_wifi_events, ARDUINO_EVENT_MAX);
|
||||
connectToWifi();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
}
|
Reference in a new issue