Connect to wifi
This commit is contained in:
parent
e48cbc986a
commit
3ba6b311c2
25
src/main.cpp
25
src/main.cpp
@ -1,8 +1,14 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
#include <WiFi.h>
|
||||||
|
|
||||||
#include "body.h"
|
#include "body.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
//! --- Start of onfiguration ---
|
||||||
|
const char* hostname = "Hexapod";
|
||||||
|
//! --- End of configuration ---
|
||||||
|
|
||||||
|
|
||||||
Body body = Body::instance();
|
Body body = Body::instance();
|
||||||
|
|
||||||
Config config;
|
Config config;
|
||||||
@ -15,6 +21,21 @@ void servoTest() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void connectWiFi()
|
||||||
|
{
|
||||||
|
Serial.printf("Connecting to %s\n", config.data().wifiSSID);
|
||||||
|
WiFi.begin(config.data().wifiSSID, config.data().wifiPass);
|
||||||
|
WiFi.setHostname(hostname);
|
||||||
|
while (WiFi.status() != WL_CONNECTED) {
|
||||||
|
delay(500);
|
||||||
|
Serial.print(".");
|
||||||
|
}
|
||||||
|
Serial.println("");
|
||||||
|
Serial.println("WiFi connected");
|
||||||
|
Serial.println("IP address: ");
|
||||||
|
Serial.println(WiFi.localIP());
|
||||||
|
}
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
|
|
||||||
@ -27,6 +48,10 @@ void setup() {
|
|||||||
Serial.printf("SSID: %s\n", config.data().wifiSSID);
|
Serial.printf("SSID: %s\n", config.data().wifiSSID);
|
||||||
Serial.printf("pass: %s\n", config.data().wifiPass);
|
Serial.printf("pass: %s\n", config.data().wifiPass);
|
||||||
|
|
||||||
|
connectWiFi();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Only to save as a test
|
// Only to save as a test
|
||||||
/*
|
/*
|
||||||
config.setSSID("testSSID");
|
config.setSSID("testSSID");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user