Static IP for door
This commit is contained in:
@@ -15,8 +15,8 @@ framework = arduino
|
||||
board_build.f_cpu = 26000000L
|
||||
board_build.ldscript = eagle.flash.1m.ld
|
||||
;board_build.flash_mode = dout
|
||||
upload_protocol = espota
|
||||
upload_port = 192.168.1.25
|
||||
;upload_protocol = espota
|
||||
;upload_port = 192.168.1.25
|
||||
lib_deps =
|
||||
# RECOMMENDED
|
||||
# Accept new functionality in a backwards compatible manner and patches
|
||||
|
||||
@@ -7,6 +7,13 @@
|
||||
#include <PCF8574.h>
|
||||
#include <leds.h>
|
||||
|
||||
// Set your Static IP address
|
||||
IPAddress local_IP(192, 168, 1, 154);
|
||||
// Set your Gateway IP address
|
||||
IPAddress gateway(192, 168, 1, 1);
|
||||
|
||||
IPAddress subnet(255, 255, 255, 0);
|
||||
|
||||
const char* ssid = "wf-home";
|
||||
const char* password = "0ndthnrf";
|
||||
const char* mqtt_server = "192.168.1.111";
|
||||
@@ -47,7 +54,7 @@ bool l_m = false;
|
||||
void trim(char *s);
|
||||
|
||||
void connectToWifi() {
|
||||
Serial.println("Connecting to Wi-Fi...");
|
||||
Serial.printf("Millis %lu, Connecting to Wi-Fi...", millis());
|
||||
WiFi.begin(ssid, password);
|
||||
}
|
||||
|
||||
@@ -57,7 +64,7 @@ void connectToMqtt() {
|
||||
}
|
||||
|
||||
void onWifiConnect(const WiFiEventStationModeGotIP& event) {
|
||||
Serial.println("Connected to Wi-Fi.");
|
||||
Serial.printf_P("Millis %lu, Connected to Wi-Fi.", millis());
|
||||
Serial.print("IP: ");
|
||||
Serial.println(WiFi.localIP());
|
||||
digitalWrite(L_WIFI, HIGH);
|
||||
@@ -131,15 +138,18 @@ void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties
|
||||
}
|
||||
|
||||
void onMqttPublish(uint16_t packetId) {
|
||||
Serial.println("Publish acknowledged.");
|
||||
Serial.print(" packetId: ");
|
||||
Serial.println(packetId);
|
||||
//Serial.println("Publish acknowledged.");
|
||||
//Serial.print(" packetId: ");
|
||||
//Serial.println(packetId);
|
||||
msg.start();
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
Serial.println("Begin");
|
||||
if (!WiFi.config(local_IP, gateway, subnet)) {
|
||||
Serial.println("STA Failed to configure");
|
||||
}
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFi.hostname("Door-Koridor");
|
||||
ArduinoOTA.onStart([]() {
|
||||
@@ -242,7 +252,7 @@ void loop() {
|
||||
// uint8_t dC = digitalRead(L_DOWN);
|
||||
// uint8_t sC = digitalRead(L_SMALL);
|
||||
uint8_t tC, iC, dC, sC;
|
||||
char v[10];
|
||||
//char v[10];
|
||||
msg.tick();
|
||||
//door = digitalRead(DOOR);
|
||||
if(l_m && (l_run + 100) < millis()){
|
||||
@@ -361,7 +371,7 @@ void loop() {
|
||||
void trim(char *s)
|
||||
{
|
||||
// удаляем пробелы и табы с начала строки:
|
||||
int i=0,j;
|
||||
unsigned int i=0,j;
|
||||
while((s[i]==' ')||(s[i]=='\t'))
|
||||
{
|
||||
i++;
|
||||
|
||||
Reference in New Issue
Block a user