Skip to content

Latest commit

 

History

History
154 lines (146 loc) · 2.06 KB

File metadata and controls

154 lines (146 loc) · 2.06 KB

Commands

These are representative examples of all available commands with responses.

setState

{
  "command": "setState",
  "params": {
    "pinName": "GPIO21",
    "state": true
  }
}
{
  "messageType": "ack",
  "data":{
    "command": "setState",
    "pinName": "GPIO21"
  }
}

toggleState

{
  "command": "toggleState",
  "params": {
    "pinName": "GPIO21"
  }
}
{
  "messageType": "ack",
  "data": {
    "command": "toggleState",
    "pinName": "GPIO21",
    "state":false
  }
}

readState

{
  "command": "readState",
  "params": {
    "pinName": "GPIO21"
  }
}
{
  "messageType": "state",
  "data": {
    "pinName": "GPIO21",
    "state": true
  }
}

readDirection

{
  "command": "readDirection",
  "params": {
    "pinName": "GPIO21"
  }
}
{
  "messageType": "direction",
  "data": {
    "pinName": "GPIO21",
    "direction": "out"
  }
}

registerPin

{
  "command": "registerPin",
  "params": {
    "pinName": "GPIO22",
    "direction": "in",
    "edge": "falling"
  }
}
{
  "messageType": "ack",
  "data": {
    "command": "registerPin",
    "pinName":"GPIO22"
  }
}

getRegisteredPins

{
  "command": "getRegisteredPins"
}
{
  "messageType": "registeredPins",
  "data": [
    {
      "pinName": "GPIO17",
      "direction":"in",
      "edge":"both",
      "state":true
    },
    {
      "pinName": "GPIO21",
      "direction": "out",
      "state": true
    },
    {
      "pinName": "GPIO22",
      "direction": "in",
      "edge": "rising",
      "state": true
    }
  ]
}

Errors

If a command is unrecognised or malformed the server will respond with:

{
  "messageType": "error",
  "data": {
    "errorString": "request message was malformed"
  }
}

If a command attempts to access a pin that has not been registered the server will respond with:

{
  "messageType": "error",
  "data": {
    "errorString": "pin XXX is not registered"
  }
}

where XXX is the name of the pin requested.