@hek
Still can't see in code why it get discarded.. Saw that there is discard for 1.0 versions in payload - changed to 2.0 in my sketch - no luck.
Here is my sketch, look plz maybe somewhere is an error, but took here on forum from some member who has it working on Vera:
// Enable debug prints to serial monitor
//#define MY_DEBUG
// Enable and select radio type attached
//Comento la siguiente linea para que no necesite radio
//#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
// Set LOW transmit power level as default, if you have an amplified NRF-module and
// power your radio separately with a good regulator you can turn up PA level.
//#define MY_RF24_PA_LEVEL RF24_PA_LOW
// Enable serial gateway
#define MY_GATEWAY_SERIAL
// Define a lower baud rate for Arduino's running on 8 MHz (Arduino Pro Mini 3.3V & SenseBender)
//#define MY_BAUD_RATE 9600
// Enable inclusion mode
#define MY_INCLUSION_MODE_FEATURE
// Enable Inclusion mode button on gateway
#define MY_INCLUSION_BUTTON_FEATURE
// Inverses behavior of inclusion button (if using external pullup)
//#define MY_INCLUSION_BUTTON_EXTERNAL_PULLUP
// Set inclusion mode duration (in seconds)
#define MY_INCLUSION_MODE_DURATION 60
// Digital pin used for inclusion mode button
#define MY_INCLUSION_MODE_BUTTON_PIN 3
// Uncomment to override default HW configurations
//#define MY_DEFAULT_ERR_LED_PIN 4 // Error led pin
//#define MY_DEFAULT_RX_LED_PIN 6 // Receive led pin
//#define MY_DEFAULT_TX_LED_PIN 5 // the PCB, on board LED
#include <SPI.h>
#include <MySensors.h>
//Para el sensor de temperatura
#ifdef TEMP
#include <DallasTemperature.h>
#include <OneWire.h>
#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
MyMessage msg(0,V_TEMP);
#endif
//Structura de reles
typedef struct {
int pin;
char desc[20];
bool ON;
bool OFF;
} sRELE;
sRELE Rele [] = { {13 , "LED", HIGH, LOW},
{31 , "RELE ASPERSOR PORCHE", LOW, HIGH},
{33 , "RELE TURBINAS", LOW, HIGH},
{35 , "RELE GOTEROS BAJOS", LOW, HIGH}
};
#define NUMBER_OF_RELAYS 4 // Total number of attached relays
void setup() {
// Setup locally attached sensors
#ifdef TEMP
//Para el sensor de temperatura
sensors.begin();
#endif
//Para los reles
// Serial.println("start call Setup");
for (int sensor=0 ; sensor<NUMBER_OF_RELAYS;sensor++) {
// Poner el rele en output mode
pinMode(Rele[sensor].pin, OUTPUT);
// Poner el rele en el ultimo estado conocido (usando eeprom storage)
digitalWrite(Rele[sensor].pin, loadState(sensor)?Rele[sensor].ON:Rele[sensor].OFF);
}
// Serial.println("End call Setup");
}
void presentation() {
// Presentar los sensores y actuadores locales
//Serial.println("start call presentation");
// Mandar la info del sketch
sendSketchInfo("myGateway", "2.0");
//Presentar los reles
for (int rele=0; rele<NUMBER_OF_RELAYS;rele++) {
// Registrar todos los reles al gw
present(rele, S_LIGHT,Rele[rele].desc);
}
//Serial.println("End call presentation");
#ifdef TEMP
//Presento el sensor de temperatura
present(9,S_TEMP,"SENSOR_TEMP");
#endif
}
bool STATUS;
void loop() {
// Send locally attached sensor data here
#ifdef TEMP
// Serial.print("Solicitando temperaturas...");
sensors.requestTemperatures(); // Send the command to get temperatures
float temperatura = sensors.getTempCByIndex(0);
send(msg.setSensor(9).set(temperatura,1));
// Serial.println("DONE");
sleep(2000);
#endif
}
void receive(const MyMessage &message) {
// Solo esperamos mensajes V_LIGTH de momento, pero lo chequeamos por si acaso.
if (message.type==V_LIGHT) {
// Cambiar estado del rele
digitalWrite(Rele[message.sensor].pin, message.getBool()?Rele[message.sensor].ON:Rele[message.sensor].OFF);
// Almacenar estado en la eeprom
saveState(message.sensor, message.getBool());
// Escribir informacion de debug
// Serial.print("Cambio entrante para sensor:");
// Serial.print(message.sensor);
// Serial.print(", Nuevo status: ");
//Serial.println(message.getBool());
}
}