diff --git a/hardware/MySensors/samd/variants/mysensors_gw/variant.h b/hardware/MySensors/samd/variants/mysensors_gw/variant.h index a90e711..cc5db9d 100644 --- a/hardware/MySensors/samd/variants/mysensors_gw/variant.h +++ b/hardware/MySensors/samd/variants/mysensors_gw/variant.h @@ -189,6 +189,12 @@ static const uint8_t SCK = PIN_SPI_SCK ; #define MYSX_A1 #define MYSX_A2 + +#define MY_SIGNING_ATSHA204_PIN 17 +#define MY_DEFAULT_ERR_LED_PIN LED_RED +#define MY_DEFAULT_RX_LED_PIN LED_YELLOW +#define MY_DEFAULT_TX_LED_PIN LED_GREEN + /*---------------------------------------------------------------------------- * Arduino objects - C++ only *----------------------------------------------------------------------------*/ @@ -226,11 +232,12 @@ extern Uart Serial1; // // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX // pins are NOT connected to anything by default. -#define SERIAL_PORT_USBVIRTUAL SerialUSB -#define SERIAL_PORT_MONITOR Serial +//#define SERIAL_PORT_USBVIRTUAL SerialUSB +//#define SERIAL_PORT_MONITOR Serial // Serial has no physical pins broken out, so it's not listed as HARDWARE port -#define SERIAL_PORT_HARDWARE Serial1 -#define SERIAL_PORT_HARDWARE_OPEN Serial1 +//#define SERIAL_PORT_HARDWARE Serial1 +//#define SERIAL_PORT_HARDWARE_OPEN Serial1 +#define Serial SerialUSB #endif /* _VARIANT_ARDUINO_ZERO_ */ diff --git a/libraries/MySensors/core/MyGatewayTransportEthernet.cpp b/libraries/MySensors/core/MyGatewayTransportEthernet.cpp index e58e88a..3bbeb3d 100644 --- a/libraries/MySensors/core/MyGatewayTransportEthernet.cpp +++ b/libraries/MySensors/core/MyGatewayTransportEthernet.cpp @@ -107,22 +107,22 @@ bool gatewayTransportInit() { while (WiFi.status() != WL_CONNECTED) { delay(500); - SERIALDEVICE.print("."); + MY_SERIALDEVICE.print("."); yield(); } - SERIALDEVICE.print(F("IP: ")); - SERIALDEVICE.println(WiFi.localIP()); + MY_SERIALDEVICE.print(F("IP: ")); + MY_SERIALDEVICE.println(WiFi.localIP()); #else #ifdef MY_IP_ADDRESS Ethernet.begin(_ethernetGatewayMAC, _ethernetGatewayIP); - SERIALDEVICE.print(F("IP: ")); - SERIALDEVICE.println(Ethernet.localIP()); + MY_SERIALDEVICE.print(F("IP: ")); + MY_SERIALDEVICE.println(Ethernet.localIP()); #else // Get IP address from DHCP Ethernet.begin(_ethernetGatewayMAC); - SERIALDEVICE.print(F("IP: ")); - SERIALDEVICE.println(Ethernet.localIP()); + MY_SERIALDEVICE.print(F("IP: ")); + MY_SERIALDEVICE.println(Ethernet.localIP()); #endif /* IP_ADDRESS_DHCP */ // give the Ethernet interface a second to initialize // TODO: use HW delay diff --git a/libraries/MySensors/core/MyGatewayTransportMQTTClient.cpp b/libraries/MySensors/core/MyGatewayTransportMQTTClient.cpp index 27f126c..d43091f 100644 --- a/libraries/MySensors/core/MyGatewayTransportMQTTClient.cpp +++ b/libraries/MySensors/core/MyGatewayTransportMQTTClient.cpp @@ -161,21 +161,21 @@ bool gatewayTransportInit() { while (WiFi.status() != WL_CONNECTED) { delay(500); - SERIALDEVICE.print("."); + MY_SERIALDEVICE.print("."); yield(); } - SERIALDEVICE.print(F("IP: ")); - SERIALDEVICE.println(WiFi.localIP()); + MY_SERIALDEVICE.print(F("IP: ")); + MY_SERIALDEVICE.println(WiFi.localIP()); #else #ifdef MY_IP_ADDRESS Ethernet.begin(_clientMAC, _clientIp); - SERIALDEVICE.print(F("IP: ")); - SERIALDEVICE.println(Ethernet.localIP()); + MY_SERIALDEVICE.print(F("IP: ")); + MY_SERIALDEVICE.println(Ethernet.localIP()); #else // Get IP address from DHCP Ethernet.begin(_clientMAC); - SERIALDEVICE.print(F("IP: ")); - SERIALDEVICE.println(Ethernet.localIP()); + MY_SERIALDEVICE.print(F("IP: ")); + MY_SERIALDEVICE.println(Ethernet.localIP()); #endif /* IP_ADDRESS_DHCP */ // give the Ethernet interface a second to initialize // TODO: use HW delay diff --git a/libraries/MySensors/core/MyGatewayTransportSerial.cpp b/libraries/MySensors/core/MyGatewayTransportSerial.cpp index 8538d15..ee8299b 100644 --- a/libraries/MySensors/core/MyGatewayTransportSerial.cpp +++ b/libraries/MySensors/core/MyGatewayTransportSerial.cpp @@ -31,7 +31,7 @@ MyMessage _serialMsg; bool gatewayTransportSend(MyMessage &message) { - SERIALDEVICE.print(protocolFormat(message)); + MY_SERIALDEVICE.print(protocolFormat(message)); // Serial print is always successful return true; } @@ -45,9 +45,9 @@ bool gatewayTransportInit() { bool gatewayTransportAvailable() { bool available = false; - while (SERIALDEVICE.available()) { + while (MY_SERIALDEVICE.available()) { // get the new byte: - char inChar = (char) SERIALDEVICE.read(); + char inChar = (char) MY_SERIALDEVICE.read(); // if the incoming character is a newline, set a flag // so the main loop can do something about it: if (_serialInputPos < MY_GATEWAY_MAX_RECEIVE_LENGTH - 1 && !available) { diff --git a/libraries/MySensors/core/MyHwATMega328.h b/libraries/MySensors/core/MyHwATMega328.h index e8a41fa..5f01c2d 100644 --- a/libraries/MySensors/core/MyHwATMega328.h +++ b/libraries/MySensors/core/MyHwATMega328.h @@ -36,7 +36,7 @@ #include #endif -#define SERIALDEVICE Serial +#define MY_SERIALDEVICE Serial #if defined __AVR_ATmega328P__ #ifndef sleep_bod_disable #define sleep_bod_disable() \ diff --git a/libraries/MySensors/core/MyHwESP8266.h b/libraries/MySensors/core/MyHwESP8266.h index 338b59d..b3a5bf0 100644 --- a/libraries/MySensors/core/MyHwESP8266.h +++ b/libraries/MySensors/core/MyHwESP8266.h @@ -30,7 +30,7 @@ //#include #endif -#define SERIALDEVICE Serial +#define MY_SERIALDEVICE Serial #define min(a,b) ((a)<(b)?(a):(b)) #define max(a,b) ((a)>(b)?(a):(b)) diff --git a/libraries/MySensors/core/MyHwSAMD.cpp b/libraries/MySensors/core/MyHwSAMD.cpp index 01fc802..017fc7a 100644 --- a/libraries/MySensors/core/MyHwSAMD.cpp +++ b/libraries/MySensors/core/MyHwSAMD.cpp @@ -99,8 +99,11 @@ void hwWriteConfig(int adr, uint8_t value) } void hwInit() { - SERIALDEVICE.begin(MY_BAUD_RATE); - while (!SERIALDEVICE) {} + MY_SERIALDEVICE.begin(MY_BAUD_RATE); + #ifndef MY_GATEWAY_W5100 + while (!MY_SERIALDEVICE) {} + #endif + Wire.begin(); } void hwWatchdogReset() { @@ -137,11 +140,12 @@ int8_t hwSleep(uint8_t interrupt1, uint8_t mode1, uint8_t interrupt2, uint8_t mo #ifdef MY_DEBUG void hwDebugPrint(const char *fmt, ... ) { + if (MY_SERIALDEVICE) { char fmtBuffer[300]; #ifdef MY_GATEWAY_FEATURE // prepend debug message to be handled correctly by controller (C_INTERNAL, I_LOG_MESSAGE) snprintf(fmtBuffer, 299, PSTR("0;255;%d;0;%d;"), C_INTERNAL, I_LOG_MESSAGE); - SERIALDEVICE.print(fmtBuffer); + MY_SERIALDEVICE.print(fmtBuffer); #endif va_list args; va_start (args, fmt ); @@ -155,9 +159,10 @@ void hwDebugPrint(const char *fmt, ... ) { vsnprintf(fmtBuffer, 299, fmt, args); #endif va_end (args); - SERIALDEVICE.print(fmtBuffer); -// SERIALDEVICE.flush(); + MY_SERIALDEVICE.print(fmtBuffer); +// MY_SERIALDEVICE.flush(); //Serial.write(freeRam()); + } } #endif diff --git a/libraries/MySensors/core/MyHwSAMD.h b/libraries/MySensors/core/MyHwSAMD.h index e8717ca..dc5f468 100644 --- a/libraries/MySensors/core/MyHwSAMD.h +++ b/libraries/MySensors/core/MyHwSAMD.h @@ -31,7 +31,7 @@ #endif #include -#define I2C_EEP_ADDRESS 55 +#define I2C_EEP_ADDRESS 0x50 #define min(a,b) ((a)<(b)?(a):(b)) #define max(a,b) ((a)>(b)?(a):(b)) @@ -52,7 +52,7 @@ void hwWriteConfigBlock(void* buf, void* adr, size_t length); void hwWriteConfig(int adr, uint8_t value); uint8_t hwReadConfig(int adr); -#define SERIALDEVICE SerialUSB +#define MY_SERIALDEVICE SerialUSB /* diff --git a/libraries/MySensors/core/MySigningAtsha204.cpp b/libraries/MySensors/core/MySigningAtsha204.cpp index d62c6a0..218c22f 100644 --- a/libraries/MySensors/core/MySigningAtsha204.cpp +++ b/libraries/MySensors/core/MySigningAtsha204.cpp @@ -63,7 +63,7 @@ static void DEBUG_SIGNING_PRINTBUF(const __FlashStringHelper* str, uint8_t* buf, #ifdef MY_GATEWAY_FEATURE // prepend debug message to be handled correctly by controller (C_INTERNAL, I_LOG_MESSAGE) snprintf_P(printBuffer, 299, PSTR("0;255;%d;0;%d;"), C_INTERNAL, I_LOG_MESSAGE); - SERIALDEVICE.print(printBuffer); + MY_SERIALDEVICE.print(printBuffer); #endif for (int i=0; i 0) { - SERIALDEVICE.print(printBuffer); + MY_SERIALDEVICE.print(printBuffer); } - SERIALDEVICE.println(""); + MY_SERIALDEVICE.println(""); } #else #define DEBUG_SIGNING_PRINTBUF(str, buf, sz) diff --git a/libraries/MySensors/core/MySigningAtsha204Soft.cpp b/libraries/MySensors/core/MySigningAtsha204Soft.cpp index 3c6ab67..c4152f6 100644 --- a/libraries/MySensors/core/MySigningAtsha204Soft.cpp +++ b/libraries/MySensors/core/MySigningAtsha204Soft.cpp @@ -66,7 +66,7 @@ static void DEBUG_SIGNING_PRINTBUF(const __FlashStringHelper* str, uint8_t* buf, #ifdef MY_GATEWAY_FEATURE // prepend debug message to be handled correctly by controller (C_INTERNAL, I_LOG_MESSAGE) snprintf_P(printBuffer, 299, PSTR("0;255;%d;0;%d;"), C_INTERNAL, I_LOG_MESSAGE); - SERIALDEVICE.print(printBuffer); + MY_SERIALDEVICE.print(printBuffer); #endif for (int i=0; i 0) { - SERIALDEVICE.print(printBuffer); + MY_SERIALDEVICE.print(printBuffer); } - SERIALDEVICE.println(""); + MY_SERIALDEVICE.println(""); } #else #define DEBUG_SIGNING_PRINTBUF(str, buf, sz) diff --git a/libraries/MySensors/examples/GatewaySerial/GatewaySerial.ino b/libraries/MySensors/examples/GatewaySerial/GatewaySerial.ino index 9eee4e8..21aee55 100644 --- a/libraries/MySensors/examples/GatewaySerial/GatewaySerial.ino +++ b/libraries/MySensors/examples/GatewaySerial/GatewaySerial.ino @@ -72,9 +72,11 @@ // Digital pin used for inclusion mode button #define MY_INCLUSION_MODE_BUTTON_PIN 3 +#ifndef MY_DEFAULT_ERR_LED_PIN #define MY_DEFAULT_ERR_LED_PIN 4 // Error led pin #define MY_DEFAULT_RX_LED_PIN 6 // Receive led pin #define MY_DEFAULT_TX_LED_PIN 5 // the PCB, on board LED +#endif #include #include diff --git a/libraries/MySensors/examples/GatewayW5100/GatewayW5100.ino b/libraries/MySensors/examples/GatewayW5100/GatewayW5100.ino index 902ae51..f02af0e 100644 --- a/libraries/MySensors/examples/GatewayW5100/GatewayW5100.ino +++ b/libraries/MySensors/examples/GatewayW5100/GatewayW5100.ino @@ -57,7 +57,7 @@ // Enable Soft SPI for NRF radio (note different radio wiring is required) // The W5100 ethernet module seems to have a hard time co-operate with // radio on the same spi bus. -#if !defined(MY_W5100_SPI_EN) +#if !defined(MY_W5100_SPI_EN) && !defined(ARDUINO_ARCH_SAMD) #define MY_SOFTSPI #define MY_SOFT_SPI_SCK_PIN 14 #define MY_SOFT_SPI_MISO_PIN 16 @@ -100,9 +100,11 @@ // Digital pin used for inclusion mode button #define MY_INCLUSION_MODE_BUTTON_PIN 3 +#ifndef MY_DEFAULT_ERR_LED_PIN #define MY_DEFAULT_ERR_LED_PIN 7 // Error led pin #define MY_DEFAULT_RX_LED_PIN 8 // Receive led pin #define MY_DEFAULT_TX_LED_PIN 9 // the PCB, on board LED +#endif #include diff --git a/libraries/MySensors/examples/GatewayW5100MQTTClient/GatewayW5100MQTTClient.ino b/libraries/MySensors/examples/GatewayW5100MQTTClient/GatewayW5100MQTTClient.ino index 770ed1f..9838ffd 100644 --- a/libraries/MySensors/examples/GatewayW5100MQTTClient/GatewayW5100MQTTClient.ino +++ b/libraries/MySensors/examples/GatewayW5100MQTTClient/GatewayW5100MQTTClient.ino @@ -57,7 +57,6 @@ * Make sure to fill in your ssid and WiFi password below for ssid & pass. */ -#include #include // Enable debug prints to serial monitor @@ -82,7 +81,7 @@ // Enable Soft SPI for NRF radio (note different radio wiring is required) // The W5100 ethernet module seems to have a hard time co-operate with // radio on the same spi bus. -#if !defined(MY_W5100_SPI_EN) +#if !defined(MY_W5100_SPI_EN) && !defined(ARDUINO_ARCH_SAMD) #define MY_SOFTSPI #define MY_SOFT_SPI_SCK_PIN 14 #define MY_SOFT_SPI_MISO_PIN 16