The following SerialGateway code works but inclusion is not possible as NO_PINCHANGE is set for all ports.
#define NO_PORTB_PINCHANGES
#define NO_PORTC_PINCHANGES
#define NO_PORTD_PINCHANGES
#include <SPI.h>
#include <MySensor.h>
#include <stdarg.h>
#include <MsTimer2.h>
#include <PinChangeInt.h>
#include "GatewayUtil.h"
#include <SoftwareSerial.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
#define RADIO_ERROR_LED_PIN A3 // Error led pin
#define RADIO_RX_LED_PIN A5 // Receive led pin
#define RADIO_TX_LED_PIN A4 // the PCB, on board LED
MySensor gw;
SoftwareSerial SIM900(7, 8);
char inputString[MAX_RECEIVE_LENGTH] = ""; // A string to hold incoming commands from serial/ethernet interface
int inputPos = 0;
boolean commandComplete = false; // whether the string is complete
void parseAndSend(char *commandBuffer);
void output(const char *fmt, ... ) {
va_list args;
va_start (args, fmt );
vsnprintf_P(serialBuffer, MAX_SEND_LENGTH, fmt, args);
va_end (args);
Serial.print(serialBuffer);
}
void setup()
{
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);
// Add led timer interrupt
MsTimer2::set(300, ledTimersInterrupt);
MsTimer2::start();
// Add interrupt for inclusion button to pin
PCintPort::attachInterrupt(pinInclusion, startInclusionInterrupt, RISING);
// Send startup log message on serial
serial(PSTR("0;0;%d;0;%d;Gateway startup complete.\n"), C_INTERNAL, I_GATEWAY_READY);
}
void loop()
{
gw.process();
checkButtonTriggeredInclusion();
checkInclusionFinished();
if (commandComplete) {
// A command wass issued from serial interface
// We will now try to send it to the actuator
parseAndSend(gw, inputString);
commandComplete = false;
inputPos = 0;
}
}
/*
SerialEvent occurs whenever a new data comes in the
hardware serial RX. This routine is run between each
time loop() runs, so using delay inside loop can delay
response. Multiple bytes of data may be available.
*/
void serialEvent() {
while (Serial.available()) {
// get the new byte:
char inChar = (char)Serial.read();
// if the incoming character is a newline, set a flag
// so the main loop can do something about it:
if (inputPos<MAX_RECEIVE_LENGTH-1 && !commandComplete) {
if (inChar == '\n') {
inputString[inputPos] = 0;
commandComplete = true;
} else {
// add it to the inputString:
inputString[inputPos] = inChar;
inputPos++;
}
} else {
// Incoming message too long. Throw away
inputPos = 0;
}
}
}
But as soon as i comment out any of the three #define NO_PORTx_PINCHANGES I get a compile error including the vector 3, 4 or 5 messages. If I am correct the #define NO_PORTD_PINCHANGES should be uncommented for the inclusion to work. Any ideas on how to fix this annoying problem?