Skip to content

jelyoussefi/oisp-websocket-server

 
 

Repository files navigation

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 82.0%
  • Shell 17.2%
  • Dockerfile 0.8%