Well i finally managed to get it working via Windows curl. (No luck with Tasker yet).
I had to make 2 changes to the example. Not sure if its because of something I’m doing wrong, or because there were errors in the example. Mentioning them here in case its the latter, so that the documentation can be corrected:
Curl didn’t like the SSL certificate. I had to use the -k flag, else it would give this error:
curl: (60) SSL certificate problem: self signed certificate in certificate chain
More details here: http://curl.haxx.se/docs/sslcerts.html
curl performs SSL certificate verification by default, using a "bundle"
of Certificate Authority (CA) public keys (CA certs). If the default
bundle file isn’t adequate, you can specify an alternate file
using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
the bundle, the certificate verification probably failed due to a
problem with the certificate (it might be expired, or the name might
not match the domain name in the URL).
If you’d like to turn off curl’s verification of the certificate, use
the -k (or --insecure) option.
For the second issue, here’s a snippet of Spark’s example code i used :
int ledControl(String command)
int state = 0;
//find out the pin number and convert the ascii to integer
int pinNumber = (command.charAt(1) - ‘0’) - 1;
//Sanity check to see if the pin numbers are within limits
if (pinNumber < 0 || pinNumber > 1) return -1;
// find out the state of the led
if(command.substring(3,7) == "HIGH") state = 1;
else if(command.substring(3,6) == "LOW") state = 0;
else return -1;
// write to the appropriate pin
See the 2nd last line.
Wont pinNumber be just “0” or any single digit instead of the required “D0” or “A0” ? Is this a bug in the program?
I hard coded it to D7 and then the curl commands worked
[EDIT: I guess a single digit works too, but for some reason the example program has a sanity check to only allow a 0 or 1 - which i guess is relevant to its initial choice of pins]
Anyway - now back to Tasker!