mirror of
https://github.com/sweidac/kidsbox.git
synced 2025-07-27 19:31:54 +02:00
Extracts networking.
This commit is contained in:
@@ -1,2 +1,2 @@
|
|||||||
idf_component_register(SRCS "main.cpp" "WebInterface.cpp"
|
idf_component_register(SRCS "Networking.cpp" "main.cpp" "WebInterface.cpp"
|
||||||
INCLUDE_DIRS ".")
|
INCLUDE_DIRS ".")
|
||||||
|
15
device/main/Networking.cpp
Normal file
15
device/main/Networking.cpp
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#include "Networking.hpp"
|
||||||
|
|
||||||
|
#include "WiFi.h"
|
||||||
|
|
||||||
|
void Networking::connectWifi() {
|
||||||
|
WiFi.begin(CONFIG_ESP_WIFI_SSID, CONFIG_ESP_WIFI_PASSWORD);
|
||||||
|
|
||||||
|
while (WiFi.status() != WL_CONNECTED) {
|
||||||
|
delay(1000);
|
||||||
|
Serial.println("Waiting for connection...");
|
||||||
|
}
|
||||||
|
|
||||||
|
Serial.println("Connected.");
|
||||||
|
Serial.println(WiFi.localIP());
|
||||||
|
}
|
9
device/main/Networking.hpp
Normal file
9
device/main/Networking.hpp
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#ifndef _NETWORKING_HPP
|
||||||
|
#define _NETWORKING_HPP
|
||||||
|
|
||||||
|
class Networking {
|
||||||
|
public:
|
||||||
|
void connectWifi();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@@ -2,24 +2,14 @@
|
|||||||
|
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
|
|
||||||
|
#include "Networking.hpp"
|
||||||
#include "WebInterface.hpp"
|
#include "WebInterface.hpp"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
void app_main();
|
void app_main();
|
||||||
}
|
}
|
||||||
|
|
||||||
void connectWifi() {
|
Networking networking;
|
||||||
WiFi.begin(CONFIG_ESP_WIFI_SSID, CONFIG_ESP_WIFI_PASSWORD);
|
|
||||||
|
|
||||||
while (WiFi.status() != WL_CONNECTED) {
|
|
||||||
delay(1000);
|
|
||||||
Serial.println("Waiting for connection...");
|
|
||||||
}
|
|
||||||
|
|
||||||
Serial.println("Connected.");
|
|
||||||
Serial.println(WiFi.localIP());
|
|
||||||
}
|
|
||||||
|
|
||||||
WebInterface webInterface;
|
WebInterface webInterface;
|
||||||
|
|
||||||
void app_main(void) {
|
void app_main(void) {
|
||||||
@@ -27,7 +17,7 @@ void app_main(void) {
|
|||||||
|
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
|
||||||
connectWifi();
|
networking.connectWifi();
|
||||||
|
|
||||||
webInterface.start();
|
webInterface.start();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user