Giter Site home page Giter Site logo

nadley / spark-protocol Goto Github PK

View Code? Open in Web Editor NEW

This project forked from particle-iot/spark-protocol

0.0 2.0 0.0 492 KB

Node.JS module for hosting direct encrypted CoAP socket connections

License: GNU Lesser General Public License v3.0

JavaScript 100.00%

spark-protocol's Introduction

spark-protocol

Node.JS module for hosting direct encrypted CoAP socket connections! Checkout the local spark-server

                          __      __        __              __
   _________  ____ ______/ /__   / /___  __/ /_  ___  _____/ /
  / ___/ __ \/ __ `/ ___/ //_/  / __/ / / / __ \/ _ \/ ___/ / 
 (__  ) /_/ / /_/ / /  / , |   / /_/ /_/ / /_/ /  __(__  )_/  
/____/ .___/\__,_/_/  /_/|_|   \__/\__,_/_.___/\___/____(_)   
    /_/                                                       

What do I need to know?

This module knows how to talk encrypted CoAP. It's really good at talking with Spark Cores, and any other hardware that uses this protocol. You'll need a server key to use and load onto your devices. You'll also need to grab any public keys for your connected devices and store them somewhere this module can find them. The public server key stored on the device can also store an IP address or DNS name for your server, so make sure you load that onto your server key when copying it to your device. The server will also generate a default key if you don't have one when it starts up.

What code modules should I start with?

There's lots of fun stuff here, but in particular you should know about the "SparkCore" ( https://github.com/spark/spark-protocol/blob/master/js/clients/SparkCore.js ) , and "DeviceServer" ( https://github.com/spark/spark-protocol/blob/master/js/server/DeviceServer.js ) modules. The "DeviceServer" module runs a server that creates "SparkCore" objects, which represent your connected devices.

How do I start a server in code?

var DeviceServer = require("spark-protocol").DeviceServer;
var server = new DeviceServer({
    coreKeysDir: "/path/to/your/public_device_keys"
});
global.server = server;
server.start();

How do I get my key / ip address on my core?

1.) Figure out your IP address, for now lets say it's 192.168.1.10

2.) Make sure you have the Spark-CLI (https://github.com/spark/spark-cli) installed

3.) Connect your Spark Core to your computer in listening mode (http://docs.spark.io/connect/#appendix-dfu-mode-device-firmware-upgrade)

4.) Load the server key and include your IP address / dns address:

spark keys server server_public_key.der your_ip_address
spark keys server server_public_key.der 192.168.1.10

5.) That's it!

Where's the API / webserver stuff, this is just a TCP server?

Oh, you want the Spark-Server module here: https://github.com/spark/spark-server :)

spark-protocol's People

Contributors

dmiddlecamp avatar

Watchers

Nahir Mohamed avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.