Merge branch 'tosa' of https://github.com/ToSa27/Arduino into
ToSa27-tosa Conflicts: libraries/MySensors/examples/EthernetGateway/EthernetGateway.ino
This commit is contained in:
@@ -4,6 +4,10 @@
|
||||
#include <DallasTemperature.h>
|
||||
#include <OneWire.h>
|
||||
|
||||
#ifndef MYSENSORS_SENSOR
|
||||
#error Please switch to MYSENSORS_SENSOR in MyConfig.h
|
||||
#endif
|
||||
|
||||
#define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected
|
||||
#define MAX_ATTACHED_DS18B20 16
|
||||
unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
|
||||
|
||||
@@ -57,18 +57,21 @@
|
||||
#include <PinChangeInt.h>
|
||||
#include "GatewayUtil.h"
|
||||
|
||||
#ifndef MYSENSORS_ETHERNET_MQTT_GATEWAY
|
||||
#error Please switch to MYSENSORS_ETHERNET_MQTT_GATEWAY in MyConfig.h
|
||||
#endif
|
||||
|
||||
// Use this if you have attached a Ethernet ENC28J60 shields
|
||||
//#include <UIPEthernet.h>
|
||||
#include <UIPEthernet.h>
|
||||
|
||||
// Use this fo WizNET module and Arduino Ethernet Shield
|
||||
#include <Ethernet.h>
|
||||
//#include <Ethernet.h>
|
||||
|
||||
|
||||
#define INCLUSION_MODE_TIME 1 // Number of minutes inclusion mode is enabled
|
||||
#define INCLUSION_MODE_PIN 3 // Digital pin used for inclusion mode button
|
||||
|
||||
#define W5100_SPI_EN 4 // Ethernet SPI enable
|
||||
#define W5100_SPI_EN 4 // Ethernet SPI enable (where available)
|
||||
#define RADIO_CE_PIN 5 // radio chip enable
|
||||
#define RADIO_SPI_SS_PIN 6 // radio SPI serial select
|
||||
|
||||
@@ -77,7 +80,7 @@
|
||||
#define RADIO_TX_LED_PIN 9 // the PCB, on board LED
|
||||
|
||||
|
||||
MySensor gw(RADIO_CE_PIN, RADIO_SPI_SS_PIN);
|
||||
MySensor gw;
|
||||
|
||||
|
||||
#define IP_PORT 5003 // The port you want to open
|
||||
@@ -128,13 +131,9 @@ void setup()
|
||||
{
|
||||
w5100_spi_en(false);
|
||||
// Initialize gateway at maximum PA level, channel 70 and callback for write operations
|
||||
gw.begin(incomingMessage, 0, true, 0, RF24_PA_LEVEL_GW, RF24_CHANNEL, RF24_DATARATE);
|
||||
// Setup pipes for radio library
|
||||
gw.openReadingPipe(WRITE_PIPE, BASE_RADIO_ID);
|
||||
gw.openReadingPipe(CURRENT_NODE_PIPE, BASE_RADIO_ID);
|
||||
gw.startListening();
|
||||
|
||||
gw.begin(incomingMessage, 0, true, 0);
|
||||
w5100_spi_en(true);
|
||||
|
||||
Ethernet.begin(mac, myIp);
|
||||
setupGateway(RADIO_RX_LED_PIN, RADIO_TX_LED_PIN, RADIO_ERROR_LED_PIN, INCLUSION_MODE_PIN, INCLUSION_MODE_TIME, output);
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef __GATEWAYUTIL_H__
|
||||
#define __GATEWAYUTIL_H__
|
||||
|
||||
#include <MyDriver.h>
|
||||
|
||||
|
||||
#ifdef ARDUINO
|
||||
|
||||
|
||||
@@ -62,6 +62,9 @@ http://forum.mysensors.org/topic/303/mqtt-broker-gateway
|
||||
#include <Ethernet.h>
|
||||
#include "MyMQTT.h"
|
||||
|
||||
#ifndef MYSENSORS_ETHERNET_MQTT_GATEWAY
|
||||
#error Please switch to MYSENSORS_ETHERNET_MQTT_GATEWAY in MyConfig.h
|
||||
#endif
|
||||
|
||||
#define INCLUSION_MODE_TIME 1 // Number of minutes inclusion mode is enabled
|
||||
#define INCLUSION_MODE_PIN 3 // Digital pin used for inclusion mode button
|
||||
@@ -89,7 +92,7 @@ uint8_t TCP_MAC[] = { 0x02, 0xDE, 0xAD, 0x00, 0x00, 0x42 }; // Mac-address - You
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
MySensor gw(RADIO_CE_PIN, RADIO_SPI_SS_PIN);
|
||||
MySensor gw;
|
||||
EthernetServer server = EthernetServer(TCP_PORT);
|
||||
MyMessage msg;
|
||||
char convBuf[MAX_PAYLOAD*2+1];
|
||||
@@ -143,12 +146,7 @@ void incomingMessage(const MyMessage &message) {
|
||||
void setup()
|
||||
{
|
||||
// Initialize gateway at maximum PA level, channel 70 and callback for write operations
|
||||
gw.begin(incomingMessage, 0, true, 0, RF24_PA_LEVEL_GW, RF24_CHANNEL, RF24_DATARATE);
|
||||
// Setup pipes for radio library
|
||||
gw.openReadingPipe(WRITE_PIPE, BASE_RADIO_ID);
|
||||
gw.openReadingPipe(CURRENT_NODE_PIPE, BASE_RADIO_ID);
|
||||
gw.startListening();
|
||||
|
||||
gw.begin(incomingMessage, 0, true, 0);
|
||||
Ethernet.begin(TCP_MAC, TCP_IP);
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#ifndef __GATEWAYUTIL_H__
|
||||
#define __GATEWAYUTIL_H__
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <MyDriver.h>
|
||||
|
||||
|
||||
#ifdef ARDUINO
|
||||
|
||||
@@ -48,6 +49,7 @@ void setupGateway(uint8_t _rx, uint8_t _tx, uint8_t _er, uint8_t _inc, uint8_t _
|
||||
countTx = 0;
|
||||
countErr = 0;
|
||||
|
||||
|
||||
// Setup led pins
|
||||
pinMode(pinRx, OUTPUT);
|
||||
pinMode(pinTx, OUTPUT);
|
||||
@@ -240,7 +242,6 @@ void ledTimersInterrupt() {
|
||||
digitalWrite(pinEr, HIGH);
|
||||
}
|
||||
if(countErr != 255) { countErr--; }
|
||||
|
||||
}
|
||||
|
||||
void rxBlink(uint8_t cnt) {
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
* - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly
|
||||
* - ERR (red) - fast blink on error during transmission error or recieve crc error
|
||||
*/
|
||||
|
||||
|
||||
#define NO_PORTB_PINCHANGES
|
||||
|
||||
#include <SPI.h>
|
||||
@@ -30,6 +30,9 @@
|
||||
#include <PinChangeInt.h>
|
||||
#include "GatewayUtil.h"
|
||||
|
||||
#ifndef MYSENSORS_SERIAL_GATEWAY
|
||||
#error Please switch to MYSENSORS_SERIAL_GATEWAY in MyConfig.h
|
||||
#endif
|
||||
|
||||
#define INCLUSION_MODE_TIME 1 // Number of minutes inclusion mode is enabled
|
||||
#define INCLUSION_MODE_PIN 3 // Digital pin used for inclusion mode button
|
||||
@@ -38,7 +41,7 @@
|
||||
#define RADIO_TX_LED_PIN 5 // the PCB, on board LED
|
||||
|
||||
|
||||
MySensor gw(DEFAULT_CE_PIN, DEFAULT_CS_PIN);
|
||||
MySensor gw;
|
||||
|
||||
char inputString[MAX_RECEIVE_LENGTH] = ""; // A string to hold incoming commands from serial/ethernet interface
|
||||
int inputPos = 0;
|
||||
@@ -57,11 +60,7 @@ void output(const char *fmt, ... ) {
|
||||
|
||||
void setup()
|
||||
{
|
||||
gw.begin(incomingMessage, 0, true, 0, RF24_PA_LEVEL_GW, RF24_CHANNEL, RF24_DATARATE);
|
||||
// Stetup pipes for radio library
|
||||
gw.openReadingPipe(WRITE_PIPE, BASE_RADIO_ID);
|
||||
gw.openReadingPipe(CURRENT_NODE_PIPE, BASE_RADIO_ID);
|
||||
gw.startListening();
|
||||
gw.begin(incomingMessage, 0, true, 0);
|
||||
|
||||
setupGateway(RADIO_RX_LED_PIN, RADIO_TX_LED_PIN, RADIO_ERROR_LED_PIN, INCLUSION_MODE_PIN, INCLUSION_MODE_TIME, output);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user