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