This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
oak:tutorials:localserver [2016/10/22 22:02] digistump [1. Convert the server's public key to the DER format and then Base64 Encode it] |
oak:tutorials:localserver [2017/03/05 01:48] malaire programming is not possible |
||
|---|---|---|---|
| Line 2: | Line 2: | ||
| You may chose to use your Oak with a local version of the Particle server. This is a guide for how to install the local server and setup an Oak to use it. | You may chose to use your Oak with a local version of the Particle server. This is a guide for how to install the local server and setup an Oak to use it. | ||
| + | |||
| + | **:!: NOTE: Oak can't be programmed at all when used with Particle Local Server because of protocol mismatch. So in practice it is nearly useless to try using Oak with Particle Local Server. ([[http://digistump.com/board/index.php/topic,2525.msg12180.html#msg12180|forum post]]** | ||
| NOTE: You can also use many other cloud services for storing data, just look for any of them that have a ESP8266 Arduino library and they should work with the Oak - though you may need to remove the WiFi connection code in their examples because the Oak handles that automatically. | NOTE: You can also use many other cloud services for storing data, just look for any of them that have a ESP8266 Arduino library and they should work with the Oak - though you may need to remove the WiFi connection code in their examples because the Oak handles that automatically. | ||
| Line 9: | Line 11: | ||
| ===== Installing the Particle Local Server ===== | ===== Installing the Particle Local Server ===== | ||
| - | * Install Node.JS 4.x or older (anything from v0.10 to 4.x should work) for your platform: https://nodejs.org/en/download/ | + | * Install Node.JS 4.x or older (anything from v0.10 to 4.x should work) for your platform: https://nodejs.org/en/download/ (4.6.1 32bit recommended for windows - https://nodejs.org/download/release/v4.6.1/node-v4.6.1-x86.msi) |
| ==== OSX/Linux ==== | ==== OSX/Linux ==== | ||
| Line 21: | Line 23: | ||
| ==== Windows ==== | ==== Windows ==== | ||
| - | * Download pre-built windows zip file here: | + | * Download pre-built windows zip file here: http://digistump.com/spark-server.zip |
| * Unzip the download and open a command line window in that folder and then run the following command: | * Unzip the download and open a command line window in that folder and then run the following command: | ||
| <code>node main.js</code> | <code>node main.js</code> | ||
| - | * If this doesn't work try the OSX/Linux procedure above, installing git from here: https://git-scm.com/downloads or any where else - git version doesn't matter too much. You will also need to install C++ compiling tools - see windows instructions on this page for more: https://github.com/nodejs/node-gyp | + | * If this doesn't work try the OSX/Linux procedure above, installing git from here: https://git-scm.com/downloads or any where else - git version doesn't matter too much. You will also need to install C++ compiling tools - see windows instructions on this page for more: https://github.com/nodejs/node-gyp (for OpenSSL - in our experience - you'll want this version: http://code.x2go.org/releases/binary-win32/3rd-party/Win32OpenSSL/Win32OpenSSL-1_0_1j.exe) |
| The Particle local server should now be running! | The Particle local server should now be running! | ||
| Line 30: | Line 32: | ||
| ===== Installing the Particle CLI Tool ===== | ===== Installing the Particle CLI Tool ===== | ||
| - | * With node installed in the last step you can install the Particle CLI tool with this command: | + | * With node installed in the last step you can install the Particle CLI tool with this command: <code>npm install -g particle-cli</code> |
| - | <code>npm install -g particle-cli</code> | + | |
| + | * If you are on the Raspberry Pi, you will need to use the following command so that the serialport dependency is successfully compiled as there are no pre-compiled binaries for the Raspberry Pi/ARM platform: <code>sudo npm install -g particle-cli --unsafe-perm --build-from-source</code> | ||
| ===== Setting up an Oak to use the Local Server ===== | ===== Setting up an Oak to use the Local Server ===== | ||
| Line 49: | Line 53: | ||
| Run (from the same folder as the server): | Run (from the same folder as the server): | ||
| <code> | <code> | ||
| - | openssl rsa -in default_key.pem -pubin -pubout -outform DER -out default_key.der | + | openssl rsa -in default_key.pub.pem -pubin -pubout -outform DER -out default_key.pub.der |
| </code> | </code> | ||
| and then use a base64 encoder (locally for best safety) or here for convenience: http://bin-hex-converter.online-domain-tools.com/ | and then use a base64 encoder (locally for best safety) or here for convenience: http://bin-hex-converter.online-domain-tools.com/ | ||
| - | Upload the default_key.der and get the encoded output, save this somewhere, you will need it in the next step. | + | Upload the default_key.pub.der and get the hex encoded output, save this somewhere, you will need it in the next step. |
| ==== 2. Set the Server Address and Server Public Key for the Oak ==== | ==== 2. Set the Server Address and Server Public Key for the Oak ==== | ||
| Line 70: | Line 74: | ||
| - | ==== 3. Set the Particle CLI tool to allow it to talk to the local server ==== | + | ==== 3. Copy the device Public Key to the Server ==== |
| + | |||
| + | In the server folder create a core_keys folder if it does not exist. | ||
| + | |||
| + | While still connected to the Oak that is in config mode go to http://192.168.0.1/device-id - you should get a response like this: | ||
| + | |||
| + | <code> | ||
| + | { "id":"ABCDEFGHJK","c":"1" } | ||
| + | </code> | ||
| + | |||
| + | Where "ABCDEFGHJK" is the device ID for this device - copy this without the quotes, you will need it to complete the rest of this step. | ||
| + | |||
| + | Now go to http://192.168.0.1/public-key - you should get a response like this: | ||
| + | <code> | ||
| + | { "r": 0, "b":"AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXXYYZZ" } | ||
| + | </code> | ||
| + | |||
| + | Where "AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXXYYZZ" is a string of numbers and letters that make up the hex encoded public key for the device. Copy this string without the quotes into a text editor and save as DEVICE_ID.pub.der - where DEVICE_ID is the device id you got above. | ||
| + | |||
| + | Upload it here (or use another hex decoder): http://bin-hex-converter.online-domain-tools.com/ and hit decode, then click download as binary file. Rename that download to DEVICE_ID.pub.pem and place in the core_keys directory you created above. | ||
| + | |||
| + | |||
| + | ==== 4. Set the Particle CLI tool to allow it to talk to the local server ==== | ||
| Source: https://docs.particle.io/support/troubleshooting/cloud-solutions/photon/ | Source: https://docs.particle.io/support/troubleshooting/cloud-solutions/photon/ | ||
| Line 85: | Line 111: | ||
| This adds the local server ip to the cli tool, switches to using it, and creates an account on the local cloud. | This adds the local server ip to the cli tool, switches to using it, and creates an account on the local cloud. | ||
| - | ==== 4. Restart Oak so it connects ==== | + | ==== 5. Restart Oak so it connects ==== |
| + | |||
| + | Stop and restart the server. | ||
| Repeat steps #2 and #3 for other Oaks you want on the same cloud. | Repeat steps #2 and #3 for other Oaks you want on the same cloud. | ||
| Line 91: | Line 119: | ||
| Remove power from the Oak and then re-apply power. The Oak should now connect to the local server and you should see the connection in the local server command window. | Remove power from the Oak and then re-apply power. The Oak should now connect to the local server and you should see the connection in the local server command window. | ||
| - | See the Particle guides for more about what you can do with the local server, use the Particle-cli upload and compile options to push firmware. | + | See the Particle guides for more about what you can do with the local server. |