From 44406c28351ed8d33875efd650342e0cf0490506 Mon Sep 17 00:00:00 2001 From: Henrik Ekblad Date: Mon, 30 Mar 2015 22:44:10 +0200 Subject: [PATCH] Add driver-options to gateways. --- libraries/MySensors/MyConfig.h | 2 +- libraries/MySensors/MySensor.h | 4 ++-- .../EthernetGateway/EthernetGateway.ino | 24 +++++++++++++++---- .../examples/MQTTGateway/MQTTGateway.ino | 24 +++++++++++++++---- .../examples/SerialGateway/SerialGateway.ino | 19 +++++++++++---- 5 files changed, 55 insertions(+), 18 deletions(-) diff --git a/libraries/MySensors/MyConfig.h b/libraries/MySensors/MyConfig.h index 4b7b4f1..d4a0633 100644 --- a/libraries/MySensors/MyConfig.h +++ b/libraries/MySensors/MyConfig.h @@ -18,7 +18,7 @@ // which requires external flash and the DualOptiBoot bootloader. // 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 +//#define MY_OTA_FIRMWARE_FEATURE // Slave select pin for external flash #define MY_OTA_FLASH_SS 8 // Flash jdecid diff --git a/libraries/MySensors/MySensor.h b/libraries/MySensors/MySensor.h index 7873c22..40b44bb 100644 --- a/libraries/MySensors/MySensor.h +++ b/libraries/MySensors/MySensor.h @@ -31,10 +31,10 @@ // Set the hardware driver to use (initialized by MySensor-class) -#if defined __AVR_ATmega328P__ +//#if defined __AVR_ATmega328P__ #include "MyHwATMega328.h" typedef MyHwATMega328 MyHwDriver; -#endif +//#endif #ifdef DEBUG diff --git a/libraries/MySensors/examples/EthernetGateway/EthernetGateway.ino b/libraries/MySensors/examples/EthernetGateway/EthernetGateway.ino index bde2cf1..81f65f6 100644 --- a/libraries/MySensors/examples/EthernetGateway/EthernetGateway.ino +++ b/libraries/MySensors/examples/EthernetGateway/EthernetGateway.ino @@ -44,7 +44,12 @@ #include #include +#include #include +#include +#include +#include + #include #include #include @@ -72,11 +77,20 @@ // NRFRF24L01 radio driver (set low transmit power by default) -MyTransportNRF24 radio(RF24_CE_PIN, RF24_CS_PIN, RF24_PA_LEVEL_GW); -// Message signing driver (none default) -MySigningNone signer; -// Construct MySensors library -MySensor gw(radio, signer); +MyTransportNRF24 transport(RF24_CE_PIN, RF24_CS_PIN, RF24_PA_LEVEL_GW); +//MyTransportRF69 transport; + +// Message signing driver (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h) +//MySigningNone signer; +//MySigningAtsha204Soft signer; +//MySigningAtsha204 signer; + +// Hardware profile +MyHwATMega328 hw; + +// Construct MySensors library (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h) +MySensor gw(transport, hw /*, signer*/); + #define IP_PORT 5003 // The port you want to open IPAddress myIp (192, 168, 178, 66); // Configure your static ip-address here COMPILE ERROR HERE? Use Arduino IDE 1.5.7 or later! diff --git a/libraries/MySensors/examples/MQTTGateway/MQTTGateway.ino b/libraries/MySensors/examples/MQTTGateway/MQTTGateway.ino index 169ad89..4742331 100644 --- a/libraries/MySensors/examples/MQTTGateway/MQTTGateway.ino +++ b/libraries/MySensors/examples/MQTTGateway/MQTTGateway.ino @@ -60,7 +60,12 @@ http://forum.mysensors.org/topic/303/mqtt-broker-gateway #include #include +#include #include +#include +#include +#include + #include #include #include @@ -94,11 +99,20 @@ uint8_t TCP_MAC[] = { 0x02, 0xDE, 0xAD, 0x00, 0x00, 0x42 }; // Mac-address - You ////////////////////////////////////////////////////////////////// // NRFRF24L01 radio driver (set low transmit power by default) -MyTransportNRF24 radio(RF24_CE_PIN, RF24_CS_PIN, RF24_PA_LEVEL_GW); -// Message signing driver (none default) -MySigningNone signer; -// Construct MySensors library -MySensor gw(radio, signer); +MyTransportNRF24 transport(RF24_CE_PIN, RF24_CS_PIN, RF24_PA_LEVEL_GW); +//MyTransportRF69 transport; + +// Message signing driver (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h) +//MySigningNone signer; +//MySigningAtsha204Soft signer; +//MySigningAtsha204 signer; + +// Hardware profile +MyHwATMega328 hw; + +// Construct MySensors library (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h) +MySensor gw(transport, hw /*, signer*/); + EthernetServer server = EthernetServer(TCP_PORT); MyMessage msg; diff --git a/libraries/MySensors/examples/SerialGateway/SerialGateway.ino b/libraries/MySensors/examples/SerialGateway/SerialGateway.ino index d103407..a1b01e4 100644 --- a/libraries/MySensors/examples/SerialGateway/SerialGateway.ino +++ b/libraries/MySensors/examples/SerialGateway/SerialGateway.ino @@ -23,8 +23,12 @@ #define NO_PORTB_PINCHANGES +#include +#include #include #include +#include +#include #include #include @@ -40,15 +44,20 @@ #define RADIO_RX_LED_PIN 6 // Receive led pin #define RADIO_TX_LED_PIN 5 // the PCB, on board LED - // NRFRF24L01 radio driver (set low transmit power by default) -MyTransportNRF24 radio(RF24_CE_PIN, RF24_CS_PIN, RF24_PA_LEVEL_GW); -// Message signing driver (none default) +MyTransportNRF24 transport(RF24_CE_PIN, RF24_CS_PIN, RF24_PA_LEVEL_GW); +//MyTransportRF69 transport; + +// Message signing driver (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h) //MySigningNone signer; -// Construct MySensors library +//MySigningAtsha204Soft signer; +//MySigningAtsha204 signer; + +// Hardware profile MyHwATMega328 hw; -MySensor gw(radio, hw); +// Construct MySensors library (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h) +MySensor gw(transport, hw /*, signer*/); char inputString[MAX_RECEIVE_LENGTH] = ""; // A string to hold incoming commands from serial/ethernet interface int inputPos = 0;