User Tools

Site Tools


projects:aa4rdemonstrator:internalprotocol

AA4R-Sensor-Controller Protocol

Sensors and controller communicate via CoAP.

  1. The sensor sends a Resource Discovery Request to the multicast address
    coap://FF02::1/.well-known/core
  2. The answer of a potential controller contains the a resource of the type
    rt="sensorCommunicationPoint"
  3. The sensor sends a GET Request to the resource of the potential controller
  4. The controller answers with a Response containing the 16 bit Entity ID (which is unique for each patient) and the current timestamp (32 bit) of the controller
  5. If the Entity ID is the same as the on of the sensor, the timestamp is used to adjust the time of the sensor and the connection to the controller is established
  6. The sensor will now use POST Requests to push its data to the controller

The format of the messages used to push the data is as follows:

16 bit Entity ID, 16 bit Sensor ID, 8 bit Type ID, 16 bit Value, 32 bit Timestamp. It is possible that more values with timestamps may follow, but those will be compressed. Only the value and timestamp differences will be encoded by the following code (see the Method readSensorData in the file cometos_v6/src/medic/CoAPMedicSensor.cc):

uint16_t timeDiff = timeStamp - lastValueTime;
int16_t valueDiff = value - lastValue;
uint16_t vD;
 
if (valueDiff < 0) {
    datastream[pos] = 0x40;
    vD = -(valueDiff + 1);
} else {
    datastream[pos] = 0;
    vD = valueDiff;
}
 
if (vD > 63) {
    vD -= 64;
    datastream[pos] |= 0x80 | ((vD >> 8) & 0x3F);
    datastream[pos+1] = vD;
    pos += 2;
} else {
    datastream[pos] |= (vD & 0x3F);
    pos++;
}
 
if (timeDiff > 127) {
    timeDiff -= 128;
    datastream[pos] = 0x80 | ((timeDiff >> 8) & 0x7F);
    datastream[pos+1] = timeDiff;
    pos += 2;
} else {
    datastream[pos] = timeDiff & 0x7F;
    pos++;
}
projects/aa4rdemonstrator/internalprotocol.txt · Last modified: 2015/07/10 11:39 by ti5mr