Fixed inclusion mode
This commit is contained in:
@@ -57,7 +57,10 @@
|
||||
* - Connect GPIO2 via 10K resistor to VCC
|
||||
* - Connect GPIO0 via 10K resistor to VCC, and via switch to GND ('bootload switch')
|
||||
*
|
||||
* Signing, RF69 radio, inclusion button and a separate SPI flash are not supported yet!
|
||||
* Inclusion mode button:
|
||||
* - Connect GPIO5 via switch to GND ('inclusion switch')
|
||||
*
|
||||
* * Signing, RF69 radio and a separate SPI flash are not supported yet!
|
||||
*
|
||||
* Make sure to fill in your ssid and WiFi password below for ssid & pass.
|
||||
*/
|
||||
@@ -78,8 +81,8 @@
|
||||
const char *ssid = "MySSID"; // cannot be longer than 32 characters!
|
||||
const char *pass = "MyVerySecretPassword"; //
|
||||
|
||||
#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 INCLUSION_MODE_TIME 1 // Number of minutes inclusion mode is enabled
|
||||
#define INCLUSION_MODE_PIN 5 // Digital pin used for inclusion mode button
|
||||
|
||||
#define RADIO_CE_PIN 4 // radio chip enable
|
||||
#define RADIO_SPI_SS_PIN 15 // radio SPI serial select
|
||||
@@ -127,9 +130,9 @@ void output(const char *fmt, ... ) {
|
||||
void setup()
|
||||
{
|
||||
// Setup console
|
||||
Serial.begin(115200);
|
||||
hw_init();
|
||||
|
||||
Serial.println();
|
||||
Serial.println(); Serial.println();
|
||||
Serial.println("ESP8266 MySensors Gateway");
|
||||
Serial.print("Connecting to "); Serial.println(ssid);
|
||||
|
||||
@@ -142,15 +145,8 @@ void setup()
|
||||
Serial.print("IP: "); Serial.println(WiFi.localIP());
|
||||
Serial.flush();
|
||||
|
||||
#ifndef INCLUSION_MODE_PIN
|
||||
setupGateway(255, INCLUSION_MODE_TIME, output);
|
||||
#else
|
||||
setupGateway(INCLUSION_MODE_PIN, INCLUSION_MODE_TIME, output);
|
||||
|
||||
// Add interrupt for inclusion button to pin
|
||||
PCintPort::attachInterrupt(pinInclusion, startInclusionInterrupt, RISING);
|
||||
#endif
|
||||
|
||||
// Initialize gateway at maximum PA level, channel 70 and callback for write operations
|
||||
gw.begin(incomingMessage, 0, true, 0);
|
||||
|
||||
@@ -162,10 +158,8 @@ void setup()
|
||||
void loop() {
|
||||
gw.process();
|
||||
|
||||
#ifdef INCLUSION_MODE_PIN
|
||||
checkButtonTriggeredInclusion();
|
||||
checkInclusionFinished();
|
||||
#endif
|
||||
|
||||
//check if there are any new clients
|
||||
if (server.hasClient())
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
#ifndef __GATEWAYUTIL_H__
|
||||
#define __GATEWAYUTIL_H__
|
||||
|
||||
#include <MyTransport.h>
|
||||
|
||||
|
||||
#ifdef ARDUINO
|
||||
|
||||
|
||||
uint8_t inclusionTime = 1; // Number of minutes inclusion mode is enabled
|
||||
uint8_t pinInclusion = 3; // Input pin that should trigger inclusion mode
|
||||
static uint8_t inclusionTime = 1; // Number of minutes inclusion mode is enabled
|
||||
static uint8_t pinInclusion = 3; // Input pin that should trigger inclusion mode
|
||||
|
||||
#define MAX_RECEIVE_LENGTH 100 // Max buffersize needed for messages coming from controller
|
||||
#define MAX_SEND_LENGTH 120 // Max buffersize needed for messages destined for controller
|
||||
|
||||
volatile boolean buttonTriggeredInclusion;
|
||||
boolean inclusionMode; // Keeps track on inclusion mode
|
||||
static volatile boolean buttonTriggeredInclusion;
|
||||
static boolean inclusionMode; // Keeps track on inclusion mode
|
||||
bool inclusionButtonSupported = false;
|
||||
void (*serial)(const char *fmt, ... );
|
||||
|
||||
@@ -26,6 +23,11 @@ char convBuf[MAX_PAYLOAD*2+1];
|
||||
char serialBuffer[MAX_SEND_LENGTH]; // Buffer for building string when sending data to vera
|
||||
unsigned long inclusionStartTime;
|
||||
|
||||
|
||||
void startInclusionInterrupt() {
|
||||
buttonTriggeredInclusion = true;
|
||||
}
|
||||
|
||||
void setupGateway(uint8_t _inc, uint8_t _incTime, void (* _serial)(const char *, ... )) {
|
||||
inclusionMode = 0;
|
||||
buttonTriggeredInclusion = false;
|
||||
@@ -36,19 +38,15 @@ void setupGateway(uint8_t _inc, uint8_t _incTime, void (* _serial)(const char *,
|
||||
if (inclusionButtonSupported)
|
||||
{
|
||||
pinInclusion = _inc;
|
||||
|
||||
|
||||
// Setup digital in that triggers inclusion mode
|
||||
pinMode(pinInclusion, INPUT);
|
||||
digitalWrite(pinInclusion, HIGH);
|
||||
pinMode(pinInclusion, INPUT_PULLUP);
|
||||
|
||||
// Add interrupt for inclusion button to pin
|
||||
attachInterrupt(pinInclusion, startInclusionInterrupt, FALLING);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void startInclusionInterrupt() {
|
||||
buttonTriggeredInclusion = true;
|
||||
}
|
||||
|
||||
void incomingMessage(const MyMessage &message) {
|
||||
// if (mGetCommand(message) == C_PRESENTATION && inclusionMode) {
|
||||
// gw.rxBlink(3);
|
||||
|
||||
Reference in New Issue
Block a user