<commit_before>## What is VoodooSpark?

VoodooSpark is a customized firmware build for the [Particle devices](https://www.particle.io) (Core and Photon) to allow a remote interface definition of the firmware API over a local TCP connection. The intent is to allow client-side programs to directly control the Particle devices in real-time regardless of their programming language. The interface exposed is directly mapped to the one provided by Particle available in their [docs section](https://docs.particle.io/).

The VoodooSpark uses the [Particle Cloud](https://www.particle.io/prototype) and its REST API to provide IP address and port information to the local Particle device. It will then initiate a direct connection to the host machine, on which will need to be a TCP server. Once the connection has been made, the host machine can drive the Particle device using the binary protocol defined below to effectively execute firmware API level commands dynamically.

## Loading the Firmware

With your Particle device connected to a Wifi network and has already gone through the [connection process](https://docs.particle.io/guide/getting-started/connect/photon/#connecting-your-device):

1.  Open the [Particle.io Editor](https://www.particle.io/build) with the credentials used when going through the connection process.
2.  Copy and paste the entire contents of [firmware/voodoospark.cpp](https://raw.githubusercontent.com/voodootikigod/voodoospark/master/firmware/voodoospark.cpp) into the editor window.
3.  Click "Verify"
4.  Click "Flash"
5.  Once the flashing process is complete, close the Particle.io Editor.


Alternately, the firmware may be loaded using the Particle CLI ([particle-cli](https://github.com/particle/particle-cli)) instead of the Particle.io Editor:

``` bash
npm install -g particle-cli
particle cloud login
particle cloud flash PARTICLE_DEVICE_ID firmware/voodoospark.cpp
```


Now your Particle device is running VoodooSpark, lets connect to it!

## Connecting the Particle device to You!

The way VoodooSpark works is to use the Particle Cloud as a channel to identify where to initiate the TCP connection to the Particle Device from your host machine.

In order to connect the Particle device to your computer, you will first need to issue an HTTP GET request to the Particle Cloud. This can be done via any programming language, but for this example we are using a simple CURL command. You will need some information outlined with curly braces below, please note the {DEVICE-ID} and {ACCESS-TOKEN} are available from the [Particle.io Editor](https://www.particle.io/build)

    curl https://api.particle.io/v1/devices/{DEVICE-ID}/endpoint?access_token={ACCESS-TOKEN}

This should return a JSON document that looks similar to this:

    {
      "cmd": "VarReturn",
      "name": "endpoint",
      "result": "192.168.1.10:48879",
      "coreInfo": {
        "last_app": "",
        "last_heard": "2014-05-08T02:51:48.826Z",<commit_msg>Fixing a bad link<commit_after>## What is VoodooSpark?

VoodooSpark is a customized firmware build for the [Particle devices](https://www.particle.io) (Core and Photon) to allow a remote interface definition of the firmware API over a local TCP connection. The intent is to allow client-side programs to directly control the Particle devices in real-time regardless of their programming language. The interface exposed is directly mapped to the one provided by Particle available in their [docs section](https://docs.particle.io/).

The VoodooSpark uses the [Particle Cloud](https://www.particle.io/prototype) and its REST API to provide IP address and port information to the local Particle device. It will then initiate a direct connection to the host machine, on which will need to be a TCP server. Once the connection has been made, the host machine can drive the Particle device using the binary protocol defined below to effectively execute firmware API level commands dynamically.

## Loading the Firmware

With your Particle device connected to a Wifi network and has already gone through the [connection process](https://docs.particle.io/guide/getting-started/connect/photon/#connecting-your-device):

1.  Open the [Particle.io Editor](https://www.particle.io/build) with the credentials used when going through the connection process.
2.  Copy and paste the entire contents of [firmware/voodoospark.cpp](https://raw.githubusercontent.com/voodootikigod/voodoospark/master/firmware/voodoospark.cpp) into the editor window.
3.  Click "Verify"
4.  Click "Flash"
5.  Once the flashing process is complete, close the Particle.io Editor.


Alternately, the firmware may be loaded using the Particle CLI ([particle-cli](https://github.com/spark/particle-cli)) instead of the Particle.io Editor:

``` bash
npm install -g particle-cli
particle cloud login
particle cloud flash PARTICLE_DEVICE_ID firmware/voodoospark.cpp
```


Now your Particle device is running VoodooSpark, lets connect to it!

## Connecting the Particle device to You!

The way VoodooSpark works is to use the Particle Cloud as a channel to identify where to initiate the TCP connection to the Particle Device from your host machine.

In order to connect the Particle device to your computer, you will first need to issue an HTTP GET request to the Particle Cloud. This can be done via any programming language, but for this example we are using a simple CURL command. You will need some information outlined with curly braces below, please note the {DEVICE-ID} and {ACCESS-TOKEN} are available from the [Particle.io Editor](https://www.particle.io/build)

    curl https://api.particle.io/v1/devices/{DEVICE-ID}/endpoint?access_token={ACCESS-TOKEN}

This should return a JSON document that looks similar to this:

    {
      "cmd": "VarReturn",
      "name": "endpoint",
      "result": "192.168.1.10:48879",
      "coreInfo": {
        "last_app": "",
        "last_heard": "2014-05-08T02:51:48.826Z",
{'fraction_non_alphanumeric': 0.07634101227509668, 'fraction_numerical': 0.012443248696821927, 'mean_word_length': 4.466911764705882, 'pattern_counts': {'":': 12, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 18, 'lorem ipsum': 0, 'www.': 8, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '848957', 'n_tokens_mistral': 1675, 'n_tokens_neox': 1554, 'n_words': 736}