@hek
I've been trying to get some buttons in the vera plugin but I've had not much luck.
I addded some code to arduino.xml and arduino.json but nothing appears.
I uploaded the files to the repo. Could you take a look when you have the time?
S_Arduino.xml
D_Arduino1.json
L_Arduino.lua
Yesterday I also made a new system for the nodes to have also a queue.
Looks something like this:
#include <MySensor.h>
#include <SPI.h>
#include <MyBuffer.h>
.......
long previousMillis = 0; // will store last time buffer was processed
long interval = 1000; // interval at which to check buffer
MyBuffer buffer; // define a new buffer
MySensor gw;
..........
void setup() { .... sensor setup code.... }
void loop()
{
gw.process();
unsigned long currentMillis = millis();
if(currentMillis - previousMillis > interval) {
previousMillis = currentMillis;
processBuffer();
}
}
void incomingMessage(const MyMessage &message) {
buffer.push(message.sensor,message.type);
}
//gets message from buffer if exists
void processBuffer(){
if(!buffer.isEmpty()){
String msg=buffer.pop();
int mIndex = msg.indexOf(';');
int secondmIndex = msg.indexOf(';,', mIndex+1);
String firstValue = msg.substring(0, mIndex);
String secondValue = msg.substring(mIndex+1, secondmIndex);
int sensor = firstValue.toInt();
int type = secondValue.toInt();
processMsg(sensor, type);
}
}
//process message from queue
void processMsg(int sensor, int type){
//do some stuff
}
It's pretty basic but it works.
The library files are here:
MyBuffer.h
MyBuffer.cpp