Skip to content
This repository has been archived by the owner on Jun 25, 2024. It is now read-only.

enableiot/iotanalytics-websocket-server

Repository files navigation

PROJECT NOT UNDER ACTIVE MANAGEMENT

This project will no longer be maintained by Intel.

Intel has ceased development and contributions including, but not limited to, maintenance, bug fixes, new releases, or updates, to this project.

Intel no longer accepts patches to this project.

If you have an ongoing need to use this project, are interested in independently developing it, or would like to maintain patches for the open source software community, please create your own fork of this project.

Contact: webadmin@linux.intel.com

IoT Websocket Server

This component is used to support actuations over websocket protocol. It is an alternative for mqtt protocol.

Server listens on determined port. It uses 'echo-protocol' for receiving and sending requests.

Websocket client also has to use 'echo-protocol'. After the establishment of connection client has to send initial json object message:

KeyDescription
typetype of message, always "device" for clients
deviceIdidentifier of your device in iotkit database
deviceTokentoken of device which is received after activation

Example json message:

{
    "type": "device",
    "deviceId": <deviceId>,
    "deviceToken": "eyJ0eXA....asdfwefadA"
}

Basic response codes:

CodeDescription
401"Invalid device token" or "Wrong message format"
500Internal server error
200Subscribed to ws server
1024Received actuation message

Example of actuations message:

{
    "code":1024,
    "content": {
        "type":"command",
        "transport":"ws",
        "content": {
            "accountId":"c4715841-bb1e-4c87-ad78-2376fe596a11",
            "deviceId":"example001",
            "gatewayId":"example001",
            "componentId":"1e447b10-9afd-4221-b4d8-7bc5c5bb6c3f",
            "command":"LED.v1.0","params":[{"name":"LED","value":"1"}]
        }
    }
}

More informations about websockets on website https://github.com/theturtle32/WebSocket-Node/blob/master/docs/index.md

Pre-requirements

Requirements to run

  1. Generate a pair RSA keys and put your public keys in ./keys/ directory as public.pem

On Trusted Analytics Platform (https://github.com/trustedanalytics)

Before installation, make sure that you are logged into Trusted Analytics Platform with command:

cf login
  1. Create instances with specified name for each of required services from marketplace:

    • PostgreSQL 9.3 or newer with name mypostgres
  2. Create following user-provided services with properties filled with real values:

     cf cups websocket-ups -p "{\"username\":\"${USER}\",\"password\":\"${PASSWORD}\"}"
    
  3. Executing ./cf-deploy.sh in main repository catalog builds package and pushes it to CF as an app with name {SPACE}-dashboard where space is currently selected space by cf t -s "SPACE"

  4. Check logs and wait for application start.