I have a core that I want to use to expose a variable. The code I use is very basic :
int analogvalue = 0;
int brewCoffee(String command);
void setup() {
Spark.variable("iotTestWaarde", &analogvalue, INT);
Particle.function("brew", brewCoffee);
}
// Now for the loop.
void loop() {
analogvalue = analogvalue + 1;
}
int brewCoffee(String command)
{
// look for the matching argument "coffee" <-- max of 64 characters long
if(command == "coffee")
{
// some example functions you might have
//activateWaterHeater();
//activateWaterPump();
return 1;
}
else return -1;
}
My problem is that the function does get exposed, the variable does not.
I have also tried replacing
Spark.variable("iotTestWaarde", &analogvalue, INT);
with the newer
Particle.variable("iotTestWaarde", &analogvalue, INT);
When viewing the device using the api I get the following :
{
"id": "DEVICE_ID",
"name": "livingroom",
"connected": true,
"variables": {},
"functions": [
"brew"
],
"cc3000_patch_version": "1.29",
"product_id": 0,
"last_heard": "2015-11-04T19:57:43.118Z"
}
Can somebody please help me in finding out what I am doing wrong?