[SOLVED]Core variables not exposed

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?

I was able to fix my own problem (what good a little time away from the computer can do for the mind).
After 5 hours of looking for an answer I figured out it has to do with the length of the variable name. If it goes above 12 characters I can not see it published.

I did not know there was a limitation on the number of characters used, but I am glad I figured it out.

2 Likes

For future reference:

2 Likes