Toggle pins using REST API on Local Cloud?(solved)

Hi,i am currently running the local spark server on my mac book and have the spark core connected to local spark server.

now i want to know is it possible to use the spark restful api to make pin on and off, just like using the spark mobile application to click the button and make one IO pin on the spark core on / off.

Yes, this is possible, but - as far as I know - not with the official Spark mobile app.

I’ve extended the Android Spark Tinker app to support local server, tho’

But as there was no call for my version and now with the Spark Mobile SDK, I’ve stopped pursuing this.
On the other hand, there are other ways to do what you asked in other threads on this forum.

Have a search :wink:

2 Likes

Thanks,ScruffR. All I need is just the rest API how to control the pin on and off not the Mobile App.

Are you using this API ?

https://api.spark.io/v1/devices/0123456789abcdef/led
-d access_token=123412341234
-d params=l1,HIGH

I wonder is -d a parameter or a query?

You can obviously no longer use the api.spark.io address once you’re using the Local :cloud:, and will have to replace that by the address of your server. There are some guides available on the forum which you should be able to find by using search (it works surprisingly well :slight_smile: )

2 Likes

@Moors7 i tested that you cannot have 2 device of the same name in an account :wink:

1 Like

Hi, @kennethlimcp, my local server is working,

curl http://192.168.43.70:8080/v1/devices/51ff70065082554910410887\?access_token=87e0e022e4688fd77f800d518197138a5443cf9e

here is the response of the server about my core condition:

{
  "id": "51ff70065082554910410887",
  "name": null,
  "connected": true,
  "variables": {},
  "functions": [
    "digitalread",
    "digitalwrite",
    "analogread",
    "analogwrite"
  ]
}

so I tried to give the PIN 7 a digitalwrite on HIGH, this is my http call:

curl http://192.168.43.70:8080/v1/devices/51ff70065082554910410887/digitalwrite?access_token=87e0e022e4688fd77f800d518197138a5443cf9e -d params=L7,HIGH

It returns me a response:

{
  "id": "51ff70065082554910410887",
  "name": null,
  "last_app": null,
  "connected": true,
  "return_value": -3
}

but the LED connected to PIN 7 is not on, is it something wrong with my rest call ?

It should be D7

@kennethlimcpken thanks, it works