Skip to content

4 Creating RAP plugin agent

Vasilis Glykantzis edited this page May 8, 2018 · 1 revision

Communications between SSP RAP and agents are made with REST calls, therefore platform/SDEV RAP plugin agent shall create a REST server listening for incoming requests from SSP RAP. SSP RAP sends a POST request to the platform/SDEV agent with different JSON messages depending on the type of the request.

The REST endpoint where sending POST requests is specified by the agent in each resource during resource registration.

4.1 Accessing resources

Access features supported are (NB: the following examples refer to OData queries (e.g. /rap/Sensors('abcdefgh')/Observations), where paths were split in JSON arrays):

  • Read current value from resource, e.g.:
{
  "resourceInfo" : [ {
    "symbioteId" : "abcdefgh",
    "internalId" : "123456",
    "type" : "Light"
  }, {
    "type" : "Observation"
  } ],
  "type" : "GET"
}
  • Read history values from resource e.g.:
{
  "resourceInfo" : [ {
    "symbioteId" : "abcdefgh",
    "internalId" : "123456",
    "type" : "EnvSensor"
  }, {
    "type" : "Observation"
  } ],
  "filter" : {
    "type" : "expr",
    "param" : "temperature",
    "cmp" : "EQ",
    "val" : "20"
  },
  "type" : "HISTORY"
}

The read history values can be received with or without filters, depending on whether the plugin is supporting filters or not.

  • Actuating resource or invoking service When such request is requested, the body of the message will also include parameters needed for the actuation/invoking service, in a format that depends on the resource accessed:
{
  "resourceInfo" : [ {
    "symbioteId" : "{symbioteId}",
    "internalId" : "{internalId}",
    "type" : "{Model}"
  } ],
  "body" : {
    "{capability}": [
      { "{restriction}": "{value}" }
    ] 
  },
  "type" : "SET"
}

e.g.:

{
  "resourceInfo" : {
    "symbioteId" : "abcdefgh",
    "internalId" : "123456",
    "type" : "RGBLight"
  },
  "body" : {
    "RGBCapability": [
      { "R": "0" },
      { "G": "255" },
      { "B": "0" }
    ]     
  },
  "type" : "SET"
}