My first steps into snappifying, I have publish a RestApi for PiGlow (glowapi 0.1.2). I though it might be a good first step and mildly useful for people wanting to set up build notifications, twitter mentions, whatever you fancy!
You can find it in the webdm store…
Code is here: https://code.launchpad.net/~vtuson/+junk/glowapi
And here is how it works:
PiGlow Api exposes PiGlow in your board port 8000, so you can easy accessing by POST in port 8000.
remeber to do the hardware assign, something like: sudo snappy hw-assign glowapi.vtuson /dev/i2c-1
API calls , method POST:
v1/flare
turns all the leds on to max brightness
v1/on
turns all the leds on to med brigthness
v1/clear
turns off all leds
v1/legs/:id
turns all the leds in a leg (:id) to a given brightness
(if not specify it uses a default setting)
parms: intensity , range 0 to 1
eg: http://localhost:8000/v1/legs/1?intensity=0.3
v1/legs/:id/colors/:colid
turns on one led (colid) in a leg (:id) to a given brightness
(if not specify it uses a default setting)
parms: intensity , range 0 to 1
eg: http://localhost:8000/v1/legs/1/colors/green?intensity=0.3
v1/colors/:colid
turn on all leds for a color across all legs
if not specify it uses a default setting)
parms: intensity , range 0 to 1
eg: http://localhost:8000/v1/colors/green?intensity=0.3
ID ranges
legs range : 0 – 2
colors:
green
white
blue
yellow
orange
red
Hi, I installed this snap app on my Raspberry Pi2 with latest snappy image but I always got “404 page not found” error. I replaced localhost in POST command with real IP. And I can see glowapi is running with ‘ps’ output. I’m sure other app like piglowtop can access I2C interface and other app like system-status works as running a web server to monitor port. Did I miss something? Thanks.
well, localhost is only going to work for calls within the Pi itself… what reply you get when you use the ip address? Also, can you please post the curl command thay you are using?
sorry I misunderstood the api need POST method to triage.
Chipaca on IRC already helped me to have a piece of python code to post to API url to program PiGlow LED. I also wrote a simple html page to do similar thing. 🙂
you can also use curl from the terminal:
curl -i -X POST “your_uri”
Cool. It works good.