estructura basica del proecto + wifi
This commit is contained in:
1
hardware/src/json.cpp
Normal file
1
hardware/src/json.cpp
Normal file
@@ -0,0 +1 @@
|
||||
#include "json.hpp"
|
||||
@@ -1,16 +1,12 @@
|
||||
#include "main.hpp"
|
||||
|
||||
const char* ssid = "SiempreHome";
|
||||
const char* password = "d7?a35D9EnaPepXY?c!4";
|
||||
const char* mqtt_server = "192.168.0.155";
|
||||
|
||||
WiFiClient espClient;
|
||||
PubSubClient client(espClient);
|
||||
long lastMsg = 0;
|
||||
char msg[50];
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
if(setup_wifi() != 0)
|
||||
{
|
||||
Serial.print("Error connecting to WiFI");
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
1
hardware/src/mqtt.cpp
Normal file
1
hardware/src/mqtt.cpp
Normal file
@@ -0,0 +1 @@
|
||||
#include "mqtt.hpp"
|
||||
1
hardware/src/rest.cpp
Normal file
1
hardware/src/rest.cpp
Normal file
@@ -0,0 +1 @@
|
||||
#include "rest.hpp"
|
||||
1
hardware/src/test.cpp
Normal file
1
hardware/src/test.cpp
Normal file
@@ -0,0 +1 @@
|
||||
#include "test.hpp"
|
||||
35
hardware/src/wifi.cpp
Normal file
35
hardware/src/wifi.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#include <wifi.hpp>
|
||||
|
||||
WiFiClient espClient;
|
||||
PubSubClient client(espClient);
|
||||
|
||||
int setup_wifi()
|
||||
{
|
||||
Serial.println();
|
||||
Serial.print("Connecting to ");
|
||||
Serial.println(SSID);
|
||||
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFi.begin(SSID, PASSWORD);
|
||||
|
||||
while (WiFi.status() != WL_CONNECTED)
|
||||
{
|
||||
delay(500);
|
||||
Serial.print(".");
|
||||
}
|
||||
|
||||
Serial.println("");
|
||||
Serial.println("WiFi connected");
|
||||
Serial.println("IP address: ");
|
||||
Serial.println(WiFi.localIP());
|
||||
Serial.println("Setup!");
|
||||
|
||||
if(WiFi.status() == WL_CONNECTED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user