ZDS for RFID – Web Subscriptions using JQ Transformation


Audience

Devices: FX9600 and FX7500
Firmware: 3.8.22 or higher

Event Subscriptions allows for changing the JSON format of the data coming from the cloud on its way to your data consuming endpoint. This can be quite useful if you need to setup a quick demonstration. But it can also be very useful for partners and customers such that they can add location and sub-location information to the data payload coming from an FX reader with ZDS for RFID.

The JQ Transformation setting is extremely powerful, and can allow for conditionally adding data to the JSON payload using JQ nomenclature.

With one FX9600 reader (or FX7500) and 4 antennas set to fairly low power, one can emulate a tag moving through a process or supply chain. Below are the mode settings and the subscription details. Using conveyor mode, the reader will report a tag event only once per antenna that detects it. Once the tag has been seen by all 4 antennas, it will never be reported again until the reader is restarted or rebooted.

Don't forget to stop and start your reader when performing the test or demo:
https://api.zebra.com/v2/devices/readers/{{deviceId}}/stop
https://api.zebra.com/v2/devices/readers/{{deviceId}}/start

Here is an example subscription that emulates a patient moving through a surgery process based on the same reader, but using the antenna ID for the location:
1. Registration
2. Pre-Op
3. OR – Surgery
4. Post-Op

Reader Configuration using POST https://api.zebra.com/v2/devices/readers/REPLACE WITH YOUR READER ID/mode API:
{
"filter": {
"match": "prefix",
"operation": "include",
"value": "30540BEEB1"
},
"tagMetaData": [
"ANTENNA",
"RSSI"
],
"transmitPower": 10,
"type": "CONVEYOR"
}

Reader Subscription using POST https://api.zebra.com/v2/devices/readers/event/subscription API:

{
"userTags": [],
"changeFields": [
"decodedTagData"
],
"deviceIdentifiers": [
"REPLACE WITH YOUR READER(S)"
],
"jqTransform": {
"decodedTagData": "if .event.data.antennaId == \"1\" then ({resource: {id: .event.id,typeId: .type,lastLocateTime: .event.timestamp,tags: [{id:.event.data.id}],zones: [{id: \"Registration\", name: \"Registration\", zoneGroupName: \"Processing\", siteId: \"Hospital001\", siteName: \"Acme Medical Center\"}]}}) elif .event.data.antennaId == \"2\" then ({resource: {id: .event.id,typeId: .type,lastLocateTime: .event.timestamp,tags: [{id:.event.data.id}], zones: [{id: \"Pre-Op\", name: \"Pre-Op\", zoneGroupName: \"Surgery\", siteId: \"Hospital001\", siteName: \"Acme Medical Center\"}]}}) elif .event.data.antennaId == \"3\" then ({resource: {id: .event.id,typeId: .type,lastLocateTime: .event.timestamp,tags: [{id:.event.data.id}],zones: [{id: \"OR1\", name: \"OR1\", zoneGroupName: \"Surgery\", siteId: \"Hospital001\", siteName: \"Acme Medical Center\"}]}}) elif .event.data.antennaId == \"4\" then ({resource: {id: .event.id,typeId: .type,lastLocateTime: .event.timestamp,tags: [{id:.event.data.id}],zones: [{id: \"Post-Op\",name: \"Post-Op\", zoneGroupName: \"Surgery\", siteId: \"Hospital001\", siteName: \"Acme Medical Center\"}]}}) else {} end"
},
"name": "Subscription JQ Example for Acme Medical Center",
"webhookUrl": "https://your data consuming API/webhook/acme",
"webhookVerb": "POST",
"headers": {
"x-api-key": "add your key or add other necessary headers that your service requires"
}
}