mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-25 20:26:41 +00:00
Small fixes
This commit is contained in:
parent
0a691c507e
commit
bc2f11053a
@ -18,6 +18,10 @@
|
|||||||
#define HASP_USE_WIFI (HASP_HAS_NETWORK)
|
#define HASP_USE_WIFI (HASP_HAS_NETWORK)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef HASP_USE_ETHERNET
|
||||||
|
#define HASP_USE_ETHERNET 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef HASP_USE_MQTT
|
#ifndef HASP_USE_MQTT
|
||||||
#define HASP_USE_MQTT 1
|
#define HASP_USE_MQTT 1
|
||||||
#endif
|
#endif
|
||||||
@ -102,6 +106,10 @@
|
|||||||
#include "hasp_wifi.h"
|
#include "hasp_wifi.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if HASP_USE_ETHERNET>0
|
||||||
|
#include "hasp_ethernet.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if HASP_USE_MQTT > 0
|
#if HASP_USE_MQTT > 0
|
||||||
#include "hasp_mqtt.h"
|
#include "hasp_mqtt.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -20,12 +20,11 @@ extra_configs =
|
|||||||
platformio_override.ini
|
platformio_override.ini
|
||||||
; -- Put active [env] files in this dir to be included in the build menu
|
; -- Put active [env] files in this dir to be included in the build menu
|
||||||
user_setups/active/*.ini
|
user_setups/active/*.ini
|
||||||
|
user_setups/*/*.ini
|
||||||
|
|
||||||
default_envs =
|
default_envs =
|
||||||
; Uncomment the needed environments in platformio_override.ini
|
; Uncomment the needed environments in platformio_override.ini
|
||||||
; You can also create new environments in in platformio_override.ini
|
; You can also create new environments in in platformio_override.ini
|
||||||
DevEBox_STM32F4xx
|
|
||||||
black_f407vg
|
|
||||||
${override.extra_default_envs}
|
${override.extra_default_envs}
|
||||||
|
|
||||||
; -- Location of the configuration files
|
; -- Location of the configuration files
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include "ArduinoLog.h"
|
#include "ArduinoLog.h"
|
||||||
#include "hasp_conf.h"
|
#include "hasp_conf.h"
|
||||||
|
|
||||||
#if HASP_USE_ETHERNET>0
|
#if HASP_USE_ETHERNET > 0
|
||||||
|
|
||||||
#if defined(W5500_MOSI) && defined(W5500_MISO) && defined(W5500_SCLK)
|
#if defined(W5500_MOSI) && defined(W5500_MISO) && defined(W5500_SCLK)
|
||||||
#define W5500_LAN
|
#define W5500_LAN
|
||||||
@ -22,71 +22,71 @@ void ethernetSetup()
|
|||||||
{
|
{
|
||||||
#ifdef W5500_LAN
|
#ifdef W5500_LAN
|
||||||
byte mac[6];
|
byte mac[6];
|
||||||
uint32_t baseUID = (uint32_t )UID_BASE;
|
uint32_t baseUID = (uint32_t)UID_BASE;
|
||||||
mac[0] = 0x00;
|
mac[0] = 0x00;
|
||||||
mac[1] = 0x80;
|
mac[1] = 0x80;
|
||||||
mac[2] = 0xE1;
|
mac[2] = 0xE1;
|
||||||
mac[3] = (baseUID & 0x00FF0000) >> 16;
|
mac[3] = (baseUID & 0x00FF0000) >> 16;
|
||||||
mac[4] = (baseUID & 0x0000FF00) >> 8;
|
mac[4] = (baseUID & 0x0000FF00) >> 8;
|
||||||
mac[5] = (baseUID & 0x000000FF);
|
mac[5] = (baseUID & 0x000000FF);
|
||||||
|
|
||||||
Ethernet.setCsPin(W5500_CS);
|
Ethernet.setCsPin(W5500_CS);
|
||||||
Ethernet.setRstPin(W5500_RST);
|
Ethernet.setRstPin(W5500_RST);
|
||||||
Ethernet.setHostname("HASP");
|
Ethernet.setHostname("HASP");
|
||||||
Log.notice(F("ETH: Begin Ethernet W5500"));
|
Log.notice(F("ETH: Begin Ethernet W5500"));
|
||||||
if (Ethernet.begin(mac) == 0) {
|
if(Ethernet.begin(mac) == 0) {
|
||||||
Log.notice(F("ETH: Failed to configure Ethernet using DHCP"));
|
Log.notice(F("ETH: Failed to configure Ethernet using DHCP"));
|
||||||
} else {
|
} else {
|
||||||
ip = Ethernet.localIP();
|
ip = Ethernet.localIP();
|
||||||
Log.notice(F("ETH: DHCP Success got IP=%d.%d.%d.%d"),ip[0], ip[1], ip[2], ip[3]);
|
Log.notice(F("ETH: DHCP Success got IP=%d.%d.%d.%d"), ip[0], ip[1], ip[2], ip[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
// start Ethernet and UDP
|
// start Ethernet and UDP
|
||||||
Log.notice(F("ETH: Begin Ethernet LAN8720"));
|
Log.notice(F("ETH: Begin Ethernet LAN8720"));
|
||||||
if (Ethernet.begin() == 0) {
|
if(Ethernet.begin() == 0) {
|
||||||
Log.notice(F("ETH: Failed to configure Ethernet using DHCP"));
|
Log.notice(F("ETH: Failed to configure Ethernet using DHCP"));
|
||||||
} else {
|
} else {
|
||||||
ip = Ethernet.localIP();
|
ip = Ethernet.localIP();
|
||||||
Log.notice(F("ETH: DHCP Success got IP=%d.%d.%d.%d"),ip[0], ip[1], ip[2], ip[3]);
|
Log.notice(F("ETH: DHCP Success got IP=%d.%d.%d.%d"), ip[0], ip[1], ip[2], ip[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t *mac;
|
uint8_t * mac;
|
||||||
mac = Ethernet.MACAddress();
|
mac = Ethernet.MACAddress();
|
||||||
Log.notice(F("ETH: MAC Address %x:%x:%x:%x:%x:%x"),*mac,*(mac+1),*(mac+2),*(mac+3),*(mac+4),*(mac+5));
|
Log.notice(F("ETH: MAC Address %x:%x:%x:%x:%x:%x"), *mac, *(mac + 1), *(mac + 2), *(mac + 3), *(mac + 4),
|
||||||
|
*(mac + 5));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ethernetLoop(void)
|
void ethernetLoop(void)
|
||||||
{
|
{
|
||||||
switch (Ethernet.maintain()) {
|
switch(Ethernet.maintain()) {
|
||||||
case 1:
|
case 1:
|
||||||
//renewed fail
|
// renewed fail
|
||||||
Log.notice(F("ETH: Error: renewed fail"));
|
Log.notice(F("ETH: Error: renewed fail"));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
//renewed success
|
// renewed success
|
||||||
ip = Ethernet.localIP();
|
ip = Ethernet.localIP();
|
||||||
Log.notice(F("ETH: DHCP Renew Success got IP=%d.%d.%d.%d"),ip[0], ip[1], ip[2], ip[3]);
|
Log.notice(F("ETH: DHCP Renew Success got IP=%d.%d.%d.%d"), ip[0], ip[1], ip[2], ip[3]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
//rebind fail
|
// rebind fail
|
||||||
Log.notice(F("Error: rebind fail"));
|
Log.notice(F("Error: rebind fail"));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
//rebind success
|
// rebind success
|
||||||
ip = Ethernet.localIP();
|
ip = Ethernet.localIP();
|
||||||
Log.notice(F("ETH: DHCP Rebind Success got IP=%d.%d.%d.%d"),ip[0], ip[1], ip[2], ip[3]);
|
Log.notice(F("ETH: DHCP Rebind Success got IP=%d.%d.%d.%d"), ip[0], ip[1], ip[2], ip[3]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
//nothing happened
|
// nothing happened
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
x
Reference in New Issue
Block a user