diff --git a/libraries/MySensors/MyConfig.h b/libraries/MySensors/MyConfig.h index c8323be..818eae5 100644 --- a/libraries/MySensors/MyConfig.h +++ b/libraries/MySensors/MyConfig.h @@ -22,6 +22,11 @@ #define MyConfig_h #include + +/********************************** +* Serial and debug options +***********************************/ + // Enables this 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 @@ -34,11 +39,21 @@ #undef MY_DEBUG #endif -// Serial output baud rate (for debug prints and serial gateway) +// Serial output baud rate (debug prints and serial gateway speed) #ifndef MY_BAUD_RATE #define MY_BAUD_RATE 115200 #endif +/********************************** +* Radio selection and modes +***********************************/ + +// Selecting radio transport is optional (for a gateway node). + +//#define MY_RADIO_NRF24 +//#define MY_RADIO_RFM69 + + // Node id defaults to AUTO (tries to fetch id from controller) #ifndef MY_NODE_ID #define MY_NODE_ID AUTO @@ -57,7 +72,7 @@ ***********************************/ // Enable MY_OTA_FIRMWARE_FEATURE in sketch to allow safe over-the-air firmware updates. -// This feature requires external flash and the DualOptiBoot bootloader. +// This feature requires external flash and the DualOptiBoot boot-loader. // Note: You can still have OTA FW updates without external flash but it // requires the MYSBootloader and disabled MY_OTA_FIRMWARE_FEATURE //#define MY_OTA_FIRMWARE_FEATURE @@ -174,22 +189,22 @@ * NRF24L01 Driver Defaults ***********************************/ #ifndef MY_RF24_CE_PIN -#define MY_RF24_CE_PIN 9 +#define MY_RF24_CE_PIN 9 #endif #ifndef MY_RF24_CS_PIN -#define MY_RF24_CS_PIN 10 +#define MY_RF24_CS_PIN 10 #endif #ifndef MY_RF24_PA_LEVEL -#define MY_RF24_PA_LEVEL RF24_PA_MAX +#define MY_RF24_PA_LEVEL RF24_PA_MAX #endif // RF channel for the sensor net, 0-127 #ifndef MY_RF24_CHANNEL -#define MY_RF24_CHANNEL 76 +#define MY_RF24_CHANNEL 76 #endif //RF24_250KBPS for 250kbs, RF24_1MBPS for 1Mbps, or RF24_2MBPS for 2Mbps #ifndef MY_RF24_DATARATE -#define MY_RF24_DATARATE RF24_250KBPS +#define MY_RF24_DATARATE RF24_250KBPS #endif // This is also act as base value for sensor nodeId addresses. Change this (or channel) if you have more than one sensor network. #ifndef MY_RF24_BASE_RADIO_ID @@ -246,11 +261,26 @@ #endif /************************************** -* Gateway Transport Ethernet Defaults +* Ethernet Gateway Transport Defaults ***************************************/ -// Enable to use DHCP for getting IP address. If not defined, static IP is expected -//#define MY_IP_ADDRESS_VIA_DHCP +// The gateway options available +//#define MY_GATEWAY_W5100 +//#define MY_GATEWAY_ENC28J60 +//#define MY_GATEWAY_ESP8266 + +// The port to open on controller or gateway +#ifndef MY_PORT +#define MY_PORT 5003 +#endif + +// Static ip address of gateway (if this is disabled, DHCP will be used) +//#define MY_IP_ADDRESS 192,168,178,66 + +// Enables UDP mode for Ethernet gateway (W5100) +//#define MY_USE_UDP + +// DHCP, default renewal setting #ifndef MY_IP_RENEWAL_INTERVAL #define MY_IP_RENEWAL_INTERVAL 60000 #endif @@ -258,7 +288,9 @@ #ifndef MY_MAC_ADDRESS #define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED #endif -// Enable to use UDP instead of plain Ethernet -//#define MY_USE_UDP + +// Controller ip-address, if this is defined, gateway will act as a client trying to contact controller on MY_PORT. +// If MY_CONTROLLER_IP_ADDRESS is left un-defined, gateway acts as server allowing incoming connections. +//#define MY_CONTROLLER_IP_ADDRESS 192, 168, 178, 254 #endif diff --git a/libraries/MySensors/MySensor.h b/libraries/MySensors/MySensor.h index 4b54a51..7f80bda 100644 --- a/libraries/MySensors/MySensor.h +++ b/libraries/MySensors/MySensor.h @@ -35,8 +35,6 @@ #define MY_NODE_TYPE "sensor" #endif -// CORE - // HARDWARE #if defined(ARDUINO_ARCH_ESP8266) @@ -184,14 +182,17 @@ extern void setup(); extern void loop(); -// Initialize library and call sketch functions +#include +// Initialize library and handle sketch functions like we want to int main() { - begin(); - setup(); + init(); // Init Arduino + begin(); // Startup MySensors library + setup(); // Call sketch setup while(1) { - // We handle incoming message processing here - process(); - loop(); + process(); // Process incoming data + loop(); // Call sketch loop + if (serialEventRun) serialEventRun(); } + return 0; } #endif diff --git a/libraries/MySensors/examples/EthernetGateway/EthernetGateway.ino b/libraries/MySensors/examples/EthernetGateway/EthernetGateway.ino index 79c1e08..29f6870 100644 --- a/libraries/MySensors/examples/EthernetGateway/EthernetGateway.ino +++ b/libraries/MySensors/examples/EthernetGateway/EthernetGateway.ino @@ -64,8 +64,8 @@ // Enable gateway type -//#define MY_GATEWAY_W5100 -#define MY_GATEWAY_ENC28J60 + + // Set default gateway protocol (http://www.mysensors.org/download/serial_api_15) #define MY_GATEWAY_PROTOCOL_DEFAULT diff --git a/libraries/MySensors/examples/MotionSensor/MotionSensor.ino b/libraries/MySensors/examples/MotionSensor/MotionSensor.ino index 7687d7b..35483f6 100644 --- a/libraries/MySensors/examples/MotionSensor/MotionSensor.ino +++ b/libraries/MySensors/examples/MotionSensor/MotionSensor.ino @@ -28,14 +28,17 @@ */ //#define MY_DEBUG + +#define MY_RADIO_NRF24 // MY_RADIO_RFM69 + //#define MY_SOFTSPI //#define MY_OTA_FIRMWARE_FEATURE -#define MY_SIGNING_SOFT +//#define MY_SIGNING_SOFT +//#define MY_REPEATER_FEATURE // #define MY_GATEWAY_SERIAL // REMOVE-ME // #define MY_GATEWAY_PROTOCOL_DEFAULT // REMOVE-ME -#define MY_RADIO_NRF24 // MY_RADIO_RFM69 #include