diff --git a/CommandStation-EX.ino b/CommandStation-EX.ino index 4872375..dbce4e7 100644 --- a/CommandStation-EX.ino +++ b/CommandStation-EX.ino @@ -69,7 +69,7 @@ void setup() // Start the WiFi interface on a MEGA, Uno cannot currently handle WiFi #if WIFI_ON - WifiInterface::setup(WIFI_SERIAL_LINK_SPEED, F(WIFI_SSID), F(WIFI_PASSWORD), F(WIFI_HOSTNAME), IP_PORT); + WifiInterface::setup(WIFI_SERIAL_LINK_SPEED, F(WIFI_SSID), F(WIFI_PASSWORD), F(WIFI_HOSTNAME), 2560); #endif // WIFI_ON #if ETHERNET_ON diff --git a/DCCTimer.cpp b/DCCTimer.cpp index af10f8f..f1f3ba2 100644 --- a/DCCTimer.cpp +++ b/DCCTimer.cpp @@ -54,12 +54,16 @@ INTERRUPT_CALLBACK interruptHandler=0; TCB0.INTFLAGS = TCB_CAPT_bm; interruptHandler(); } - + + void DCCTimer::getSimulatedMacAddress(byte mac[6]) { + memcpy(mac,&SIGROW.SERNUM0,6); // serial number + } + #else - // Arduino nano, uno, mega etc + // Arduino nano, uno, mega etc void DCCTimer::begin(INTERRUPT_CALLBACK callback) { interruptHandler=callback; - noInterrupts(); + noInterrupts(); ADCSRA = (ADCSRA & 0b11111000) | 0b00000100; // speed up analogRead sample time TCCR1A = 0; ICR1 = CLOCK_CYCLES; @@ -71,4 +75,10 @@ INTERRUPT_CALLBACK interruptHandler=0; // ISR called by timer interrupt every 58uS ISR(TIMER1_OVF_vect){ interruptHandler(); } + + #include + void DCCTimer::getSimulatedMacAddress(byte mac[6]) { + for (byte i=0; i<6; i++) mac[i]=boot_signature_byte_get(0x0E + i); + } + #endif diff --git a/DCCTimer.h b/DCCTimer.h index a388349..1d17789 100644 --- a/DCCTimer.h +++ b/DCCTimer.h @@ -7,6 +7,7 @@ typedef void (*INTERRUPT_CALLBACK)(); class DCCTimer { public: static void begin(INTERRUPT_CALLBACK interrupt); + static void getSimulatedMacAddress(byte mac[6]); private: }; diff --git a/EthernetInterface.cpp b/EthernetInterface.cpp index 42d1bbb..2061aa6 100644 --- a/EthernetInterface.cpp +++ b/EthernetInterface.cpp @@ -17,12 +17,18 @@ * along with CommandStation. If not, see . * */ - +#if __has_include ( "config.h") + #include "config.h" +#else + #warning config.h not found. Using defaults from config.example.h + #include "config.example.h" +#endif #include "defines.h" #if ETHERNET_ON == true #include "EthernetInterface.h" #include "DIAG.h" #include "CommandDistributor.h" +#include "DCCTimer.h" EthernetInterface * EthernetInterface::singleton=NULL; /** @@ -44,10 +50,15 @@ void EthernetInterface::setup() */ EthernetInterface::EthernetInterface() { - byte mac[]=MAC_ADDRESS; + byte mac[6]; + DCCTimer::getSimulatedMacAddress(mac); + DIAG(F("\n+++++ Ethernet Setup. Simulatd mac=")); + for (byte i=0;i