diff --git a/MyConfig.h b/MyConfig.h index fc2eb21..cfba68f 100644 --- a/MyConfig.h +++ b/MyConfig.h @@ -31,28 +31,35 @@ * Serial and debug options ***********************************/ -// Enable MY_DEBUG in sketch to show debug prints. This option will add a lot to the size of the -// final sketch but is helpful to see what is actually is happening during development +/** +* @def MY_DEBUG +* @brief Enable MY_DEBUG in sketch to show debug prints. This option will add a lot to the size of the +* final sketch but is helpful to see what is actually is happening during development +*/ //#define MY_DEBUG -// Enable MY_SPECIAL_DEBUG in sketch to activate I_DEBUG messages if MY_DEBUG is disabled. -// I_DEBUG requests are: -// R: routing info (only repeaters): received msg XXYY (as stream), where XX is the node and YY the routing node -// V: CPU voltage -// F: CPU frequency -// M: free memory -// E: clear MySensors EEPROM area and reboot (i.e. "factory" reset) +/** +* @def MY_SPECIAL_DEBUG +* @brief Enable MY_SPECIAL_DEBUG in sketch to activate I_DEBUG messages if MY_DEBUG is disabled. +* I_DEBUG requests are: +* R: routing info (only repeaters): received msg XXYY (as stream), where XX is the node and YY the routing node +* V: CPU voltage +* F: CPU frequency +* M: free memory +* E: clear MySensors EEPROM area and reboot (i.e. "factory" reset) +*/ //#define MY_SPECIAL_DEBUG -// Enable MY_DEBUG_VERBOSE_SIGNING flag for verbose debug prints related to signing. -// Requires DEBUG to be enabled. -// This will add even more to the size of the final sketch! -//#define MY_DEBUG_VERBOSE_SIGNING - -// Enable this in sketch if you want to use TX(1), RX(0) as normal I/O pin +/** +* @def MY_DISABLED_SERIAL +* @brief Enable MY_DISABLED_SERIAL in sketch if you want to use TX(1), RX(0) as normal I/O pins +*/ //#define MY_DISABLED_SERIAL -// Enable MY_CORE_ONLY flag if you want to use core functions without loading the framework +/** +* @def MY_CORE_ONLY +* @brief Enable MY_CORE_ONLY flag if you want to use core functions without loading the framework +*/ //#define MY_CORE_ONLY // Turn off debug if serial pins is used for other stuff @@ -358,6 +365,12 @@ /********************************** * Message Signing Settings ***********************************/ +/** +* @def Enable MY_DEBUG_VERBOSE_SIGNING +* @brief Flag for verbose debug prints related to signing. Requires DEBUG to be enabled. This will add even more to the size of the final sketch! +*/ +//#define MY_DEBUG_VERBOSE_SIGNING + /** * @def MY_SIGNING_ATSHA204 * @brief Enables HW backed signing functionality in library. @@ -945,6 +958,9 @@ // Doxygen specific constructs, not included when built normally // This is used to enable disabled macros/definitions to be included in the documentation as well. #if DOXYGEN +#define MY_DEBUG +#define MY_SPECIAL_DEBUG +#define MY_DISABLED_SERIAL #define MY_SIGNING_ATSHA204 #define MY_SIGNING_SOFT #define MY_SIGNING_REQUEST_SIGNATURES diff --git a/core/MyCapabilities.h b/core/MyCapabilities.h index 3b45fec..21b0396 100644 --- a/core/MyCapabilities.h +++ b/core/MyCapabilities.h @@ -78,7 +78,13 @@ #define MY_CAP_RXBUF "-" #endif +#if defined(MY_RF24_ENABLE_ENCRYPTION) || defined(MY_RFM69_ENABLE_ENCRYPTION) +#define MY_CAP_ENCR "X" +#else +#define MY_CAP_ENCR "-" +#endif -#define MY_CAPABILITIES MY_CAP_RESET MY_CAP_RADIO MY_CAP_OTA_FW MY_CAP_TYPE MY_CAP_ARCH MY_CAP_SIGN MY_CAP_RXBUF + +#define MY_CAPABILITIES MY_CAP_RESET MY_CAP_RADIO MY_CAP_OTA_FW MY_CAP_TYPE MY_CAP_ARCH MY_CAP_SIGN MY_CAP_RXBUF MY_CAP_ENCR #endif /* MyCapabilities_h */ diff --git a/core/MyEepromAddresses.h b/core/MyEepromAddresses.h index 1150233..1bc8bea 100644 --- a/core/MyEepromAddresses.h +++ b/core/MyEepromAddresses.h @@ -6,7 +6,7 @@ * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad - * Copyright (C) 2013-2016 Sensnology AB + * Copyright (C) 2013-2017 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org diff --git a/core/MyGatewayTransportEthernet.cpp b/core/MyGatewayTransportEthernet.cpp index 5b0d9f7..ba85c27 100644 --- a/core/MyGatewayTransportEthernet.cpp +++ b/core/MyGatewayTransportEthernet.cpp @@ -138,28 +138,27 @@ bool gatewayTransportInit(void) #endif /* MY_GATEWAY_ESP8266 */ #if defined(MY_GATEWAY_CLIENT_MODE) - #if defined(MY_CONTROLLER_URL_ADDRESS) - if (client.connect(MY_CONTROLLER_URL_ADDRESS, MY_PORT)) { +#if defined(MY_CONTROLLER_URL_ADDRESS) + if (client.connect(MY_CONTROLLER_URL_ADDRESS, MY_PORT)) { #else - if (client.connect(_ethernetControllerIP, MY_PORT)) { + if (client.connect(_ethernetControllerIP, MY_PORT)) { #endif - debug(PSTR("Eth: connect\n")); - _w5100_spi_en(false); - gatewayTransportSend(buildGw(_msgTmp, I_GATEWAY_READY).set(MSG_GW_STARTUP_COMPLETE)); - _w5100_spi_en(true); - presentNode(); - } - else { - client.stop(); - debug(PSTR("Eth: Failed to connect\n")); - } + debug(PSTR("Eth: connect\n")); + _w5100_spi_en(false); + gatewayTransportSend(buildGw(_msgTmp, I_GATEWAY_READY).set(MSG_GW_STARTUP_COMPLETE)); + _w5100_spi_en(true); + presentNode(); + } else { + client.stop(); + debug(PSTR("Eth: Failed to connect\n")); + } #elif defined(MY_USE_UDP) _ethernetServer.begin(_ethernetGatewayPort); #else #if defined(MY_GATEWAY_LINUX) && defined(MY_IP_ADDRESS) _ethernetServer.begin(_ethernetGatewayIP); #else -// we have to use pointers due to the constructor of EthernetServer + // we have to use pointers due to the constructor of EthernetServer _ethernetServer.begin(); #endif #endif /* USE_UDP */ diff --git a/core/MyGatewayTransportMQTTClient.cpp b/core/MyGatewayTransportMQTTClient.cpp index d83a864..0795e47 100644 --- a/core/MyGatewayTransportMQTTClient.cpp +++ b/core/MyGatewayTransportMQTTClient.cpp @@ -6,7 +6,7 @@ * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad -* Copyright (C) 2013-2016 Sensnology AB +* Copyright (C) 2013-2017 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org diff --git a/core/MyGatewayTransportSerial.cpp b/core/MyGatewayTransportSerial.cpp index b54fa92..a092cfd 100644 --- a/core/MyGatewayTransportSerial.cpp +++ b/core/MyGatewayTransportSerial.cpp @@ -6,7 +6,7 @@ * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad - * Copyright (C) 2013-2016 Sensnology AB + * Copyright (C) 2013-2017 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org diff --git a/core/MyHw.h b/core/MyHw.h index 9e5f080..d3fe4a8 100644 --- a/core/MyHw.h +++ b/core/MyHw.h @@ -6,7 +6,7 @@ * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad - * Copyright (C) 2013-2015 Sensnology AB + * Copyright (C) 2013-2017 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org diff --git a/core/MyHwAVR.cpp b/core/MyHwAVR.cpp index 42d3fbd..4897a74 100644 --- a/core/MyHwAVR.cpp +++ b/core/MyHwAVR.cpp @@ -6,7 +6,7 @@ * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad - * Copyright (C) 2013-2015 Sensnology AB + * Copyright (C) 2013-2017 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org @@ -17,10 +17,17 @@ * version 2 as published by the Free Software Foundation. */ -#ifdef ARDUINO_ARCH_AVR - #include "MyHwAVR.h" +bool hwInit(void) +{ +#if !defined(MY_DISABLED_SERIAL) + MY_SERIALDEVICE.begin(MY_BAUD_RATE); +#endif + return true; +} + + #define INVALID_INTERRUPT_NUM (0xFFu) volatile uint8_t _wokeUpByInterrupt = @@ -197,14 +204,13 @@ int8_t hwSleep(uint8_t interrupt1, uint8_t mode1, uint8_t interrupt2, uint8_t mo return ret; } - bool hwUniqueID(unique_id_t* uniqueID) { // not implemented yet (void)uniqueID; return false; } -#if defined(MY_DEBUG) || defined(MY_SPECIAL_DEBUG) + uint16_t hwCPUVoltage() { // Measure Vcc against 1.1V Vref @@ -261,18 +267,17 @@ uint16_t hwFreeMem() int v; return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval); } -#endif -#ifdef MY_DEBUG void hwDebugPrint(const char *fmt, ... ) { char fmtBuffer[MY_SERIAL_OUTPUT_SIZE]; #ifdef MY_GATEWAY_FEATURE // prepend debug message to be handled correctly by controller (C_INTERNAL, I_LOG_MESSAGE) - snprintf_P(fmtBuffer, sizeof(fmtBuffer), PSTR("0;255;%d;0;%d;"), C_INTERNAL, I_LOG_MESSAGE); + snprintf_P(fmtBuffer, sizeof(fmtBuffer), PSTR("0;255;%d;0;%d;%lu "), C_INTERNAL, I_LOG_MESSAGE, + hwMillis()); MY_SERIALDEVICE.print(fmtBuffer); #else - // prepend timestamp (AVR nodes) + // prepend timestamp MY_SERIALDEVICE.print(hwMillis()); MY_SERIALDEVICE.print(" "); #endif @@ -289,9 +294,4 @@ void hwDebugPrint(const char *fmt, ... ) va_end (args); MY_SERIALDEVICE.print(fmtBuffer); MY_SERIALDEVICE.flush(); - - //MY_SERIALDEVICE.write(freeRam()); } -#endif - -#endif // #ifdef ARDUINO_ARCH_AVR diff --git a/core/MyHwAVR.h b/core/MyHwAVR.h index 6b15717..62190a0 100644 --- a/core/MyHwAVR.h +++ b/core/MyHwAVR.h @@ -6,7 +6,7 @@ * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad - * Copyright (C) 2013-2015 Sensnology AB + * Copyright (C) 2013-2017 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org @@ -38,35 +38,12 @@ #define MY_SERIALDEVICE Serial #endif -#if defined __AVR_ATmega328P__ -#ifndef sleep_bod_disable -#define sleep_bod_disable() \ - do { \ - unsigned char tempreg; \ - __asm__ __volatile__("in %[tempreg], %[mcucr]" "\n\t" \ - "ori %[tempreg], %[bods_bodse]" "\n\t" \ - "out %[mcucr], %[tempreg]" "\n\t" \ - "andi %[tempreg], %[not_bodse]" "\n\t" \ - "out %[mcucr], %[tempreg]" \ - : [tempreg] "=&d" (tempreg) \ - : [mcucr] "I" _SFR_IO_ADDR(MCUCR), \ - [bods_bodse] "i" (_BV(BODS) | _BV(BODSE)), \ - [not_bodse] "i" (~_BV(BODSE))); \ - } while (0) -#endif -#endif - - // Define these as macros to save valuable space #define hwDigitalWrite(__pin, __value) digitalWriteFast(__pin, __value) #define hwDigitalRead(__pin) digitalReadFast(__pin) #define hwPinMode(__pin, __value) pinModeFast(__pin, __value) -#if defined(MY_DISABLED_SERIAL) -#define hwInit() -#else -#define hwInit() MY_SERIALDEVICE.begin(MY_BAUD_RATE) -#endif +bool hwInit(void); #define hwWatchdogReset() wdt_reset() #define hwReboot() wdt_enable(WDTO_15MS); while (1) @@ -77,8 +54,6 @@ #define hwReadConfigBlock(__buf, __pos, __length) eeprom_read_block((void*)(__buf), (void*)(__pos), (__length)) #define hwWriteConfigBlock(__buf, __pos, __length) eeprom_update_block((void*)(__buf), (void*)(__pos), (__length)) - - enum period_t { SLEEP_15MS, SLEEP_30MS, diff --git a/core/MyHwESP8266.cpp b/core/MyHwESP8266.cpp index 7eb8fed..6913344 100644 --- a/core/MyHwESP8266.cpp +++ b/core/MyHwESP8266.cpp @@ -6,7 +6,7 @@ * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad - * Copyright (C) 2013-2015 Sensnology AB + * Copyright (C) 2013-2017 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org @@ -20,13 +20,14 @@ #include "MyHwESP8266.h" #include -void hwInit(void) +bool hwInit(void) { #if !defined(MY_DISABLED_SERIAL) MY_SERIALDEVICE.begin(MY_BAUD_RATE, SERIAL_8N1, MY_ESP8266_SERIAL_MODE, 1); MY_SERIALDEVICE.setDebugOutput(true); #endif EEPROM.begin(EEPROM_size); + return true; } void hwReadConfigBlock(void* buf, void* addr, size_t length) @@ -109,8 +110,6 @@ ADC_MODE(ADC_VCC); ADC_MODE(ADC_TOUT); #endif -#if defined(MY_DEBUG) || defined(MY_SPECIAL_DEBUG) - uint16_t hwCPUVoltage() { #if defined(MY_SPECIAL_DEBUG) @@ -118,7 +117,7 @@ uint16_t hwCPUVoltage() return ESP.getVcc(); #else // not possible - return 0; + return FUNCTION_NOT_SUPPORTED; #endif } @@ -132,16 +131,19 @@ uint16_t hwFreeMem() { return ESP.getFreeHeap(); } -#endif -#ifdef MY_DEBUG void hwDebugPrint(const char *fmt, ... ) { char fmtBuffer[MY_SERIAL_OUTPUT_SIZE]; #ifdef MY_GATEWAY_FEATURE // prepend debug message to be handled correctly by controller (C_INTERNAL, I_LOG_MESSAGE) - snprintf_P(fmtBuffer, sizeof(fmtBuffer), PSTR("0;255;%d;0;%d;"), C_INTERNAL, I_LOG_MESSAGE); + snprintf_P(fmtBuffer, sizeof(fmtBuffer), PSTR("0;255;%d;0;%d;%lu "), C_INTERNAL, I_LOG_MESSAGE, + hwMillis()); MY_SERIALDEVICE.print(fmtBuffer); +#else + // prepend timestamp + MY_SERIALDEVICE.print(hwMillis()); + MY_SERIALDEVICE.print(" "); #endif va_list args; va_start (args, fmt ); @@ -156,7 +158,4 @@ void hwDebugPrint(const char *fmt, ... ) va_end (args); MY_SERIALDEVICE.print(fmtBuffer); MY_SERIALDEVICE.flush(); - - //MY_SERIALDEVICE.write(freeRam()); } -#endif diff --git a/core/MyHwESP8266.h b/core/MyHwESP8266.h index bfb7e7c..f83dcc6 100644 --- a/core/MyHwESP8266.h +++ b/core/MyHwESP8266.h @@ -6,7 +6,7 @@ * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad - * Copyright (C) 2013-2015 Sensnology AB + * Copyright (C) 2013-2017 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org @@ -43,7 +43,7 @@ #define hwMillis() millis() #define hwRandomNumberInit() randomSeed(RANDOM_REG32) -void hwInit(void); +bool hwInit(void); void hwReadConfigBlock(void* buf, void* adr, size_t length); void hwWriteConfigBlock(void* buf, void* adr, size_t length); void hwWriteConfig(const int addr, uint8_t value); diff --git a/core/MyHwLinuxGeneric.cpp b/core/MyHwLinuxGeneric.cpp index 7e9e0d4..09c1dbe 100644 --- a/core/MyHwLinuxGeneric.cpp +++ b/core/MyHwLinuxGeneric.cpp @@ -6,7 +6,7 @@ * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad - * Copyright (C) 2013-2016 Sensnology AB + * Copyright (C) 2013-2017 Sensnology AB * Full contributor list: https://github.com/mysensors/MySensors/graphs/contributors * * Documentation: http://www.mysensors.org @@ -26,7 +26,7 @@ static SoftEeprom eeprom = SoftEeprom(MY_LINUX_CONFIG_FILE, 1024); // ATMega328 has 1024 bytes -void hwInit() +bool hwInit(void) { MY_SERIALDEVICE.begin(MY_BAUD_RATE); #ifdef MY_GATEWAY_SERIAL @@ -37,6 +37,7 @@ void hwInit() } #endif #endif + return true; } void hwReadConfigBlock(void* buf, void* addr, size_t length) @@ -107,25 +108,23 @@ int8_t hwSleep(uint8_t interrupt1, uint8_t mode1, uint8_t interrupt2, uint8_t mo return MY_SLEEP_NOT_POSSIBLE; } -#if defined(MY_DEBUG) || defined(MY_SPECIAL_DEBUG) uint16_t hwCPUVoltage() { // TODO: Not supported! - return 0; + return FUNCTION_NOT_SUPPORTED; } uint16_t hwCPUFrequency() { // TODO: Not supported! - return 0; + return FUNCTION_NOT_SUPPORTED; } uint16_t hwFreeMem() { // TODO: Not supported! - return 0; + return FUNCTION_NOT_SUPPORTED; } -#endif void hwDigitalWrite(uint8_t pin, uint8_t value) { @@ -142,13 +141,10 @@ void hwPinMode(uint8_t pin, uint8_t mode) pinMode(pin, mode); } -#ifdef MY_DEBUG void hwDebugPrint(const char *fmt, ...) { va_list args; - va_start(args, fmt); vlogDebug(fmt, args); va_end(args); } -#endif diff --git a/core/MyHwLinuxGeneric.h b/core/MyHwLinuxGeneric.h index acb2168..d7f914c 100644 --- a/core/MyHwLinuxGeneric.h +++ b/core/MyHwLinuxGeneric.h @@ -6,7 +6,7 @@ * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad - * Copyright (C) 2013-2016 Sensnology AB + * Copyright (C) 2013-2017 Sensnology AB * Full contributor list: https://github.com/mysensors/MySensors/graphs/contributors * * Documentation: http://www.mysensors.org @@ -48,7 +48,7 @@ inline void hwDigitalWrite(uint8_t, uint8_t); inline int hwDigitalRead(uint8_t); inline void hwPinMode(uint8_t, uint8_t); -void hwInit(); +bool hwInit(void); inline void hwReadConfigBlock(void* buf, void* addr, size_t length); inline void hwWriteConfigBlock(void* buf, void* addr, size_t length); inline uint8_t hwReadConfig(int addr); diff --git a/core/MyHwSAMD.cpp b/core/MyHwSAMD.cpp index 63d569f..04a3b51 100644 --- a/core/MyHwSAMD.cpp +++ b/core/MyHwSAMD.cpp @@ -6,7 +6,7 @@ * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad - * Copyright (C) 2013-2015 Sensnology AB + * Copyright (C) 2013-2017 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org @@ -67,22 +67,29 @@ void hwWriteConfig(int adr, uint8_t value) (void)eep.update(adr, value); } -void hwInit() +bool hwInit(void) { MY_SERIALDEVICE.begin(MY_BAUD_RATE); #if defined(MY_GATEWAY_SERIAL) while (!MY_SERIALDEVICE) {} #endif - // ext. EEPROM on sensebender GW - eep.begin(MY_EXT_EEPROM_TWI_CLOCK); + + const uint8_t eepInit = eep.begin(MY_EXT_EEPROM_TWI_CLOCK); +#if defined(SENSEBENDER_GW_SAMD_V1) + // check connection to external EEPROM - only sensebender GW + return eepInit==0; +#else + (void)eepInit; + return true; +#endif } -void hwWatchdogReset() +void hwWatchdogReset(void) { // TODO: Not supported! } -void hwReboot() +void hwReboot(void) { NVIC_SystemReset(); while (true); @@ -123,7 +130,6 @@ bool hwUniqueID(unique_id_t *uniqueID) return true; } -#if defined(MY_DEBUG) || defined(MY_SPECIAL_DEBUG) uint16_t hwCPUVoltage() { @@ -170,19 +176,22 @@ uint16_t hwCPUFrequency() uint16_t hwFreeMem() { // TODO: Not supported! - return 0; + return FUNCTION_NOT_SUPPORTED; } -#endif -#ifdef MY_DEBUG void hwDebugPrint(const char *fmt, ... ) { if (MY_SERIALDEVICE) { char fmtBuffer[MY_SERIAL_OUTPUT_SIZE]; #ifdef MY_GATEWAY_FEATURE // prepend debug message to be handled correctly by controller (C_INTERNAL, I_LOG_MESSAGE) - snprintf(fmtBuffer, sizeof(fmtBuffer), PSTR("0;255;%d;0;%d;"), C_INTERNAL, I_LOG_MESSAGE); + snprintf(fmtBuffer, sizeof(fmtBuffer), PSTR("0;255;%d;0;%d;%lu "), C_INTERNAL, I_LOG_MESSAGE, + hwMillis()); MY_SERIALDEVICE.print(fmtBuffer); +#else + // prepend timestamp + MY_SERIALDEVICE.print(hwMillis()); + MY_SERIALDEVICE.print(" "); #endif va_list args; va_start (args, fmt ); @@ -197,8 +206,5 @@ void hwDebugPrint(const char *fmt, ... ) va_end (args); MY_SERIALDEVICE.print(fmtBuffer); // MY_SERIALDEVICE.flush(); - - //MY_SERIALDEVICE.write(freeRam()); } } -#endif diff --git a/core/MyHwSAMD.h b/core/MyHwSAMD.h index 408e5c6..0e67e64 100644 --- a/core/MyHwSAMD.h +++ b/core/MyHwSAMD.h @@ -6,7 +6,7 @@ * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad - * Copyright (C) 2013-2015 Sensnology AB + * Copyright (C) 2013-2017 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org @@ -28,10 +28,10 @@ #include // defines for sensebender gw variant.h -#define MY_EXT_EEPROM_I2C_ADDRESS (0x50) +#define MY_EXT_EEPROM_I2C_ADDRESS (0x50u) #define MY_EXT_EEPROM_SIZE (kbits_512) #define MY_EXT_EEPROM_PAGE_SIZE (32u) -#define MY_EXT_EEPROM_TWI_CLOCK (twiClock400kHz) +#define MY_EXT_EEPROM_TWI_CLOCK (twiClock100kHz) // can be set to 400kHz with precaution if other i2c devices on bus extEEPROM eep(MY_EXT_EEPROM_SIZE, 1, MY_EXT_EEPROM_PAGE_SIZE, MY_EXT_EEPROM_I2C_ADDRESS); //device size, number of devices, page size @@ -48,9 +48,9 @@ extEEPROM eep(MY_EXT_EEPROM_SIZE, 1, MY_EXT_EEPROM_PAGE_SIZE, #define hwMillis() millis() #define hwRandomNumberInit() randomSeed(analogRead(MY_SIGNING_SOFT_RANDOMSEED_PIN)) -void hwInit(); -void hwWatchdogReset(); -void hwReboot(); +bool hwInit(void); +void hwWatchdogReset(void); +void hwReboot(void); void hwReadConfigBlock(void* buf, void* adr, size_t length); void hwWriteConfigBlock(void* buf, void* adr, size_t length); void hwWriteConfig(int adr, uint8_t value); diff --git a/core/MyInclusionMode.cpp b/core/MyInclusionMode.cpp index a3a2319..9aa0145 100644 --- a/core/MyInclusionMode.cpp +++ b/core/MyInclusionMode.cpp @@ -6,7 +6,7 @@ * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad - * Copyright (C) 2013-2015 Sensnology AB + * Copyright (C) 2013-2017 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org diff --git a/core/MyInclusionMode.h b/core/MyInclusionMode.h index 9c58c82..d1296d3 100644 --- a/core/MyInclusionMode.h +++ b/core/MyInclusionMode.h @@ -6,7 +6,7 @@ * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad - * Copyright (C) 2013-2015 Sensnology AB + * Copyright (C) 2013-2017 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org diff --git a/core/MyIndication.cpp b/core/MyIndication.cpp index 2a2f69f..473da5e 100644 --- a/core/MyIndication.cpp +++ b/core/MyIndication.cpp @@ -6,7 +6,7 @@ * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad - * Copyright (C) 2013-2016 Sensnology AB + * Copyright (C) 2013-2017 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org diff --git a/core/MyIndication.h b/core/MyIndication.h index 014c35f..9d613d3 100644 --- a/core/MyIndication.h +++ b/core/MyIndication.h @@ -6,7 +6,7 @@ * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad - * Copyright (C) 2013-2016 Sensnology AB + * Copyright (C) 2013-2017 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org @@ -47,6 +47,7 @@ typedef enum { INDICATION_FW_UPDATE_RX_ERR, //!< Received wrong piece of firmware data. INDICATION_ERR_START = 100, + INDICATION_ERR_HW_INIT, //!< HW initialization error INDICATION_ERR_TX, //!< Failed to transmit message. INDICATION_ERR_TRANSPORT_FAILURE, //!< Transport failure. INDICATION_ERR_INIT_TRANSPORT, //!< MySensors transport hardware (radio) init failure. diff --git a/core/MyLeds.cpp b/core/MyLeds.cpp index f27f718..4c00f29 100644 --- a/core/MyLeds.cpp +++ b/core/MyLeds.cpp @@ -6,7 +6,7 @@ * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad - * Copyright (C) 2013-2015 Sensnology AB + * Copyright (C) 2013-2017 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org diff --git a/core/MyLeds.h b/core/MyLeds.h index ab78ab2..b7ea852 100644 --- a/core/MyLeds.h +++ b/core/MyLeds.h @@ -6,7 +6,7 @@ * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad - * Copyright (C) 2013-2015 Sensnology AB + * Copyright (C) 2013-2017 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org diff --git a/core/MyMainDefault.cpp b/core/MyMainDefault.cpp index 0e006fd..d15df62 100644 --- a/core/MyMainDefault.cpp +++ b/core/MyMainDefault.cpp @@ -6,7 +6,7 @@ * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad - * Copyright (C) 2013-2015 Sensnology AB + * Copyright (C) 2013-2017 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org diff --git a/core/MyMainESP8266.cpp b/core/MyMainESP8266.cpp index 608a60f..5a871fa 100644 --- a/core/MyMainESP8266.cpp +++ b/core/MyMainESP8266.cpp @@ -6,7 +6,7 @@ * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad - * Copyright (C) 2013-2015 Sensnology AB + * Copyright (C) 2013-2017 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org diff --git a/core/MyMainLinux.cpp b/core/MyMainLinux.cpp index c2a4d39..764bdd6 100644 --- a/core/MyMainLinux.cpp +++ b/core/MyMainLinux.cpp @@ -6,7 +6,7 @@ * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad - * Copyright (C) 2013-2015 Sensnology AB + * Copyright (C) 2013-2017 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org diff --git a/core/MyMessage.cpp b/core/MyMessage.cpp index c5baf51..090fac5 100644 --- a/core/MyMessage.cpp +++ b/core/MyMessage.cpp @@ -6,7 +6,7 @@ * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad - * Copyright (C) 2013-2015 Sensnology AB + * Copyright (C) 2013-2017 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org diff --git a/core/MyMessage.h b/core/MyMessage.h index 822dc19..c57195c 100644 --- a/core/MyMessage.h +++ b/core/MyMessage.h @@ -6,7 +6,7 @@ * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad - * Copyright (C) 2013-2015 Sensnology AB + * Copyright (C) 2013-2017 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org diff --git a/core/MyOTAFirmwareUpdate.cpp b/core/MyOTAFirmwareUpdate.cpp index 2ac5f21..2d41af6 100644 --- a/core/MyOTAFirmwareUpdate.cpp +++ b/core/MyOTAFirmwareUpdate.cpp @@ -6,7 +6,7 @@ * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad - * Copyright (C) 2013-2016 Sensnology AB + * Copyright (C) 2013-2017 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org diff --git a/core/MyOTAFirmwareUpdate.h b/core/MyOTAFirmwareUpdate.h index cb17757..fc63e9f 100644 --- a/core/MyOTAFirmwareUpdate.h +++ b/core/MyOTAFirmwareUpdate.h @@ -6,7 +6,7 @@ * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad - * Copyright (C) 2013-2016 Sensnology AB + * Copyright (C) 2013-2017 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org diff --git a/core/MyPrivateConfig.h.sample b/core/MyPrivateConfig.h.sample index 5dace60..8311d39 100644 --- a/core/MyPrivateConfig.h.sample +++ b/core/MyPrivateConfig.h.sample @@ -6,7 +6,7 @@ * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad - * Copyright (C) 2013-2015 Sensnology AB + * Copyright (C) 2013-2017 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org diff --git a/core/MyProtocol.h b/core/MyProtocol.h index d22f71d..389628d 100644 --- a/core/MyProtocol.h +++ b/core/MyProtocol.h @@ -6,7 +6,7 @@ * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad - * Copyright (C) 2013-2015 Sensnology AB + * Copyright (C) 2013-2017 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org diff --git a/core/MyProtocolMySensors.cpp b/core/MyProtocolMySensors.cpp index 0c73085..4b79a82 100755 --- a/core/MyProtocolMySensors.cpp +++ b/core/MyProtocolMySensors.cpp @@ -6,7 +6,7 @@ * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad - * Copyright (C) 2013-2015 Sensnology AB + * Copyright (C) 2013-2017 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org diff --git a/core/MySensorsCore.cpp b/core/MySensorsCore.cpp index d41bd1a..bc6d232 100644 --- a/core/MySensorsCore.cpp +++ b/core/MySensorsCore.cpp @@ -6,7 +6,7 @@ * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad - * Copyright (C) 2013-2016 Sensnology AB + * Copyright (C) 2013-2017 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org @@ -88,7 +88,11 @@ void _begin(void) preHwInit(); } - hwInit(); + if (!hwInit()) { + CORE_DEBUG(PSTR("!MCO:BGN:HW ERR\n")); + setIndication(INDICATION_ERR_HW_INIT); + _infiniteLoop(); + } CORE_DEBUG(PSTR("MCO:BGN:INIT " MY_NODE_TYPE ",CP=" MY_CAPABILITIES ",VER=" MYSENSORS_LIBRARY_VERSION "\n")); @@ -687,3 +691,6 @@ void _checkNodeLock(void) } #endif } +#if DOXYGEN + +#endif \ No newline at end of file diff --git a/core/MySensorsCore.h b/core/MySensorsCore.h index f89d02d..6c6a911 100644 --- a/core/MySensorsCore.h +++ b/core/MySensorsCore.h @@ -39,6 +39,7 @@ * * |E| SYS | SUB | Message | Comment * |-|-------|-------|-----------------------------------------------|---------------------------------------------------------------------------- +* |!| MCO | BGN | HW ERR | Error HW initialization (e.g. ext. EEPROM) * | | MCO | BGN | INIT %%s,CP=%%s,LIB=%%s | Core initialization, capabilities (CP), library version (VER) * | | MCO | BGN | BFR | Callback before() * | | MCO | BGN | STP | Callback setup() @@ -83,6 +84,7 @@ #define INTERRUPT_NOT_DEFINED ((uint8_t)255) //!< _sleep() param: no interrupt defined #define MODE_NOT_DEFINED ((uint8_t)255) //!< _sleep() param: no mode defined #define VALUE_NOT_DEFINED ((uint8_t)255) //!< Value not defined +#define FUNCTION_NOT_SUPPORTED ((uint16_t)0) //!< Function not supported #ifdef MY_DEBUG diff --git a/core/MySigning.cpp b/core/MySigning.cpp index 326e825..04be187 100644 --- a/core/MySigning.cpp +++ b/core/MySigning.cpp @@ -6,7 +6,7 @@ * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad - * Copyright (C) 2013-2015 Sensnology AB + * Copyright (C) 2013-2017 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org diff --git a/core/MySigning.h b/core/MySigning.h index 386d603..792b18b 100644 --- a/core/MySigning.h +++ b/core/MySigning.h @@ -6,7 +6,7 @@ * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad - * Copyright (C) 2013-2015 Sensnology AB + * Copyright (C) 2013-2017 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org diff --git a/core/MySigningAtsha204.cpp b/core/MySigningAtsha204.cpp index 88078a9..24fb29d 100644 --- a/core/MySigningAtsha204.cpp +++ b/core/MySigningAtsha204.cpp @@ -6,7 +6,7 @@ * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad - * Copyright (C) 2013-2015 Sensnology AB + * Copyright (C) 2013-2017 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org diff --git a/core/MySigningAtsha204Soft.cpp b/core/MySigningAtsha204Soft.cpp index 62490f0..b564317 100644 --- a/core/MySigningAtsha204Soft.cpp +++ b/core/MySigningAtsha204Soft.cpp @@ -6,7 +6,7 @@ * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad - * Copyright (C) 2013-2015 Sensnology AB + * Copyright (C) 2013-2017 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org diff --git a/core/MyTransport.cpp b/core/MyTransport.cpp index cd04121..740f063 100644 --- a/core/MyTransport.cpp +++ b/core/MyTransport.cpp @@ -6,7 +6,7 @@ * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad - * Copyright (C) 2013-2016 Sensnology AB + * Copyright (C) 2013-2017 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org diff --git a/core/MyTransport.h b/core/MyTransport.h index 02a3f0e..2b8b423 100644 --- a/core/MyTransport.h +++ b/core/MyTransport.h @@ -6,7 +6,7 @@ * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad - * Copyright (C) 2013-2016 Sensnology AB + * Copyright (C) 2013-2017 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org diff --git a/core/MyTransportNRF24.cpp b/core/MyTransportNRF24.cpp index 14e8d25..a6bf0db 100644 --- a/core/MyTransportNRF24.cpp +++ b/core/MyTransportNRF24.cpp @@ -6,7 +6,7 @@ * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad - * Copyright (C) 2013-2015 Sensnology AB + * Copyright (C) 2013-2017 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org diff --git a/core/MyTransportRFM69.cpp b/core/MyTransportRFM69.cpp index d6753b6..2ee9296 100644 --- a/core/MyTransportRFM69.cpp +++ b/core/MyTransportRFM69.cpp @@ -6,7 +6,7 @@ * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad - * Copyright (C) 2013-2015 Sensnology AB + * Copyright (C) 2013-2017 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org diff --git a/core/MyTransportRFM95.cpp b/core/MyTransportRFM95.cpp index 3b88994..8437d71 100644 --- a/core/MyTransportRFM95.cpp +++ b/core/MyTransportRFM95.cpp @@ -6,7 +6,7 @@ * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad - * Copyright (C) 2013-2016 Sensnology AB + * Copyright (C) 2013-2017 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org diff --git a/core/MyTransportRS485.cpp b/core/MyTransportRS485.cpp index 976bc86..31cebab 100644 --- a/core/MyTransportRS485.cpp +++ b/core/MyTransportRS485.cpp @@ -6,7 +6,7 @@ * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad - * Copyright (C) 2013-2015 Sensnology AB + * Copyright (C) 2013-2017 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org diff --git a/drivers/extEEPROM/extEEPROM.h b/drivers/extEEPROM/extEEPROM.h index 7111d09..6ef0f7a 100644 --- a/drivers/extEEPROM/extEEPROM.h +++ b/drivers/extEEPROM/extEEPROM.h @@ -85,6 +85,13 @@ const uint8_t EEPROM_ADDR_ERR = 9; class extEEPROM { public: + /** + * @brief Constructor + * @param deviceCapacity + * @param nDevice + * @param pageSize + * @param eepromAddr + */ extEEPROM(eeprom_size_t deviceCapacity, byte nDevice, unsigned int pageSize, byte eepromAddr = 0x50); byte begin(twiClockFreq_t twiFreq = twiClock100kHz); //!< begin()