Hi guys,
I’m having trouble when I try to call my function through the browser like that:
http://‘IP from my local cloud’:8080/v1/devices/‘CORE_ID’/blink?access_token=‘MY TOKEN’
I’m running this code:
int led=D7;
void setup() {
pinMode(led, OUTPUT); // set the D7 LED as output
Spark.function("blink",blinkfunc); // a POST request for "blink" will reference blinkfunc, defined below
}
// call the below function when the POST request matches it
int blinkfunc(String command) {
digitalWrite(led, HIGH); // turn it on
delay(1000); // wait 1 second
digitalWrite(led, LOW); // turn it off
delay(1000); // wait another second
return 1; // return 1 to show that this worked.
}
void loop() {
//not doing anything here
}
I got the message in the browser:
{
"ok": false,
"error": "Variable not found"
}
But if I try to run via terminal like that:
curl ‘IP from my local cloud’:8080/v1/devices/‘CORE_ID’/blink -d access_token=‘MY TOKEN’
It works perfectly.
Also if I try to get the spark list, I receive that:
spark list
Checking with the cloud...
Retrieving cores... (this might take a few seconds)
name ('CORE ID') is online
Functions:
int blink(String args)
And if i run:
http://‘IP from my local cloud’:8080/v1/devices/‘CORE ID’/?access_token=‘MY TOKEN’
without send the function called blink it returns me the right information like that:
{
"id": "'CORE ID'",
"name": "name",
"connected": true,
"variables": {},
"functions": [
"blink"
]
}
Any ideas what could be the error of Variable not found?
Best Regards.