69 lines
1.1 KiB
C++
69 lines
1.1 KiB
C++
#include "Arduino.h"
|
|
#include "net.h"
|
|
#include <WiFi.h>
|
|
#include <esp_wifi.h>
|
|
#include "display.h"
|
|
|
|
|
|
// Replace with your network credentials
|
|
const char *ssid = "poes";
|
|
const char *password = "Rijnstraat214";
|
|
|
|
void netInit(void)
|
|
{
|
|
Serial.print("Net: init ");
|
|
WiFi.begin(ssid, password);
|
|
delay(10);
|
|
int counter = 30;
|
|
while (WiFi.status() != WL_CONNECTED && counter--)
|
|
{
|
|
Serial.print(".");
|
|
delay(500);
|
|
}
|
|
if(WiFi.status() != WL_CONNECTED)
|
|
{
|
|
WiFi.mode(WIFI_OFF);
|
|
Serial.println("done");
|
|
displayWriteLine("Network: Init Done");
|
|
}
|
|
else
|
|
{
|
|
Serial.println("FAILED");
|
|
displayWriteLine("Network: Init FAILED");
|
|
}
|
|
}
|
|
|
|
bool netIsConnected( void )
|
|
{
|
|
return (WiFi.status() == WL_CONNECTED);
|
|
}
|
|
|
|
const char* netGetSSID( void )
|
|
{
|
|
return ssid;
|
|
}
|
|
|
|
bool netConnect(void)
|
|
{
|
|
return WiFi.mode(WIFI_STA);
|
|
WiFi.begin(ssid,password);
|
|
if(WiFi.status() != WL_CONNECTED)
|
|
{
|
|
WiFi.mode(WIFI_OFF);
|
|
Serial.println("Net: reconnected");
|
|
}
|
|
else
|
|
{
|
|
Serial.println("FAILED");
|
|
displayWriteLine("Net: reconncet FAILED");
|
|
}
|
|
}
|
|
|
|
bool netDisconnect(void)
|
|
{
|
|
return WiFi.mode(WIFI_OFF);
|
|
}
|
|
|
|
|
|
|