Share

engineering

3min read

Make your own PIXIE. Coding Time

Make your own PIXIE. Coding Time

Firmware

After having installed our beautiful PIXIE, you want to have it up and running! First thing you have to do is to setup your Particle device. In order to do that you should follow the instructions available on Particle website. When the device is connected to the network you can install our firmware. Here is a list of steps that have to be done:

  1. Download the firmware from our github
  2. Put your device into listening mode
  3. Run particle setup command from command line and remember the name that you’ve given to your device
  4. Log in to Particle build site using credentials defined in previous step and copy the AccessToken
    Access token
  5. Make sure that the device is connected to WiFi (it should slowly blink cyan)
  6. Run following command from command line:
$ particle flash DEVICE_NAME /PATH_TO_FIRMWARE/firmware.bin
  1. Wait until the device is connected to WiFi again (slowly blinking cyan)

Now the device is running our firmware and it’s connected to your WiFi network. In order to show build status you have to set the endpoints that will return your build statuses for each USB ports. Our firmware has 4 remote functions that allows you to do that: setPort1Url setPort2Url setPort3Url and setPort4Url You can call these functions by making an http request. Here is an example using curl\:

$ curl https://api.particle.io/v1/devices/DEVICE_NAME/setPortXUrl \
    -d access_token=ACCESS_TOKEN  \
    -d "args=http://YOUR_URL"

Where:

  • DEVICENAME_ is the name of your device that you’ve specified during setup
  • setPortXUrl is one of 4 remote functions available in our firmware
  • ACCESSTOKEN_ is the token taken from Particle build site
  • YOURURL_ is the url to your endpoint that returns build status for a specific project

Note: YOURURL_ can not be longer than 63 characters!

Connecting to your CI

Our example on github is written for Travis CI. For other CI systems you will need to write some code (but it shouldn’t be too hard).

Make sure you have Node.js 5.x and run the command:

$ npm install
$ npm start

Your app should now be running on localhost:5000. You can test it by making GET request to http://localhost:5000/https://travis-ci.org/Polidea/ios-class-guard. This will get status for Polidea/ios-class-guardproject.

Deploying to Heroku

Deploy

or

Install Heroku Toolbelt, clone our example and

$ heroku create
$ git push heroku master

Documentation

PIXIE requires to receive data in format

{
  "status": "running",
  "time": 41,
  "previous_status": "failed",
  "previous_time": 364
}

status and previous_status can be either:

  • running
  • failed
  • success
  • canceled

time and previous_time is duration of build in seconds.

Making a request to PIXIE CI service with /<original url to CI>, for example /travis-ci.org/Polidea/ios-class-guard returns status for this project in the format above.

Here you go! you now have an up and running beautifully crafted CI status light. Let us know what do you think about our tutorials and send us pictures of your working PIXIE.

Share

Piotr

Senior Software Engineer

Michał

Senior Software Engineer

Did you enjoy the read?

If you have any questions, don’t hesitate to ask!

Did you enjoy the read?

If you have any questions, don’t hesitate to ask!