4.5. Device Types¶
Device Types are a technique for identifying a particular type of Device/Sensor. A Device Type is used to explicitly identify the type of device seen within a BLE Advertisement events.
4.5.1. Defining Device Types¶
Device Types are defined in the Edge Connect Configuration document. Any number of Device Types can be defined. Any key present within an advertisement may be used to identify advertisements as a type of device.
Each type of device is defined within the devices:{ types:[]}
section of the Edge Connect configuration. A device type
requires an id
and a matcher
. The matcher
definition informs Edge Connect of how to identify a BLE advertisement
as that type of device. Device types may also include accessible properties which behave similarly to
metadata but are simpler to access within filters
and actions
.
Example device type:
1 2 3 4 5 6 7 8 9 10 11 12 | {
"devices":{
"types": [
{
"id": "rs40",
"match": {
"serviceData.fd95": ""
}
}
]
}
}
|
The above example defines a device type for an rs40
which is a Rigado device. An advertisement will be identified as this
type of device if it contains a serviceData
section with a UUID of fd95
.
The general guideline is to provide an all lowercase single word device ID or multiple lowercase words separated by .
.
The data used to identify any device needs to be as specific as possible to avoid misidentification.
4.5.2. Device Type behaviors¶
When Edge Connect starts, all device types are registered within an internal registry. When any advertisement event
contains data which matches the matcher
defined for the device type, a deviceDetected
event is generated. This event
can be captured by a pipeline which can then perform additional actions, if necessary, when a new device of an appropriate
type is detected.
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | {
"pipelines": {
"rs40Detected": {
"eventType":"deviceDetected",
"filters":[
{
"matcher": {
"match": {
"deviceType":"rs40"
}
}
}
]
}
}
}
|
Further advertisements containing a device with a known type can access the device information using the template function Device
(i.e {{ Device.Type }}
).
See Template Functions for details on the available fields of Device
.
4.5.3. Targeting Device Types in Pipelines¶
To detect a type of device within a pipeline, a templated matcher is added either to the matchers
portion of the top level pipeline
configuration or with a matcher
filter within the pipeline. The templated matcher should use the Device
function to get the
type as follows:
"{{ eq Device.Type \"rs40\" }}"
Alternatively, upon receiving a device detected event, the device could be added to a device group. Then, pipelines which operate based on the device’s advertisement data can specify this device group. This ensures that only the appropriate types of device advertisements are delivered to the pipeline.
In addition to deviceDetected
events, the following events will occur as follows:
deviceAssigned
when any device is added to or removed from a device group.
deviceHealth
when health information about the device changes. Currently, this event is only triggered by the change in state of a device’s presence.
4.5.4. Device Type Events¶
As discussed, when a new advertisement matching any defined device type is observed,
a device detected event will occur. All of the following events contain, among other things,
the special key deviceType
. Validating that this key matches the type of device a behavior (pipeline, filter, etc)
is interested in should always be considered.
These events have the following format:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | {
"mac":"32427aad00fc",
"presence":"Unknown",
"lastRssi":-33,
"lastSeen":"2021-06-08T15:53:21.065286708Z",
"advIvl":0,
"health":"Unknown",
"deviceId":"32427aad00fc",
"smoothRssi":-33,
"firstSeen":"2021-06-08T15:53:21.065286708Z",
"lastAdv":{
"services":["4f8="],
"serviceData":{
"ffe1":["oQFfABYAGQ=="]
},
"mac":"32427aad00fc",
"addressType":1,
"eventType":3,
"connectable":false,
"rssi":-33,
"flags":"Ag=="
},
"assigned":false,
"deviceType":"minew-s1"
}
|
Device health events have the following format:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | {
"assigned":true,
"deviceType":"minew-s1",
"smoothRssi":-32,
"lastSeen":"2021-06-08T15:52:54.605252418Z",
"advIvl":15698,
"lastRssi":-38,
"firstSeen":"2021-06-08T15:51:20.415835922Z",
"lastAdv": {
"flags":"Ag==",
"mac":"32427aad0074",
"addressType":1,
"eventType":3,
"connectable":false,
"rssi":-38,
"services":["4f8="],
"serviceData": {
"ffe1":["oQFfABYAGQ=="]
}
},
"health":"OK",
"deviceId":"32427aad0074",
"mac":"32427aad0074",
"presence":"OK",
"groups":["validatedDevices"]
}
|
Device assignment events have the following format:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | {
"mac":"32427aad011b",
"deviceType":"rs40",
"lastRssi":-40,
"firstSeen":"2021-06-08T15:51:12.216959664Z",
"lastAdv": {
"serviceData": {
"fd95":["oUIAYlUKewECAwQFBgcICQo="]
},
"mac":"32427aad011b",
"addressType":1,
"eventType":3,
"connectable":false,
"rssi":-40,
"flags":"Ag==",
"services":["lf0="]
},
"assigned":true,
"deviceId":"32427aad011b",
"groups":["validatedDevices"],
"smoothRssi":-35,
"lastSeen":"2021-06-08T15:51:47.539083677Z",
"advIvl":17661,
"health":"OK",
"presence":"OK"
}
|