cloud.smarthq.service.barcode¶
Description¶
Service to model barcode scanner
Example Device Response (Digital Twin API)¶
Service representing the barcode scanner for refrigerator devices.
{
"adapterId": "0000000000000000000000000000000000000000",
"alertTypes": [],
"createdDateTime": "2022-03-04T12:12:12.123Z",
"deviceId": "0000000000000000000000000000000000000000000000000000000000000000",
"deviceType": "cloud.smarthq.device.refrigerator",
"gatewayId": "0000000000000000000000000000000000000000000000000000000000000000",
"kind": "device#item",
"lastPresenceTime": "2022-03-04T12:12:12.123Z",
"lastSyncTime": "2022-03-04T12:12:12.123Z",
"presence": "OFFLINE",
"removable": true,
"services": [
{
"serviceType": "cloud.smarthq.service.barcode",
"lastSyncTime": "2022-03-04T12:12:12.123Z",
"domainType": "cloud.smarthq.domain.scanner",
"supportedCommands": [],
"state": {
"resultBarcodeType": "cloud.smarthq.type.barcode.codabar",
"requestBarcodeType": "cloud.smarthq.type.barcode.qr",
"resultBarcodeResult": "cloud.smarthq.result.barcode.added",
"requestMaxVisibleCharacters": 20.0,
"resultTitle": "Orange Juice 2L",
"requestBarcode": "A1B2C3D4",
"resultSequenceNumber": 110.0,
"requestSequenceNumber": 111.0,
"resultMaxVisibleCharacters": 15.0
},
"serviceId": "0000000000000000000000000000000000000000000000000000000000000000",
"serviceDeviceType": "cloud.smarthq.device.refrigerator",
"config": {},
"lastStateTime": "2022-03-04T12:12:12.123Z"
}
],
"userId": "000000000000000"
}
State¶
The following are properties for the device state report as part of the "state" object for each individual service.
| Field Name | Property Type | Required | Minimum | Maximum |
|---|---|---|---|---|
| disabled | BOOLEAN | No | ||
| requestBarcode | STRING | No | ||
| requestBarcodeType | BARCODE | No | ||
| requestMaxVisibleCharacters | INTEGER | No | -2147483648 | 2147483647 |
| requestSequenceNumber | INTEGER | No | -2147483648 | 2147483647 |
| resultBarcode | STRING | No | ||
| resultBarcodeResult | BARCODE_RESULT | No | ||
| resultBarcodeType | BARCODE | No | ||
| resultMaxVisibleCharacters | INTEGER | No | -2147483648 | 2147483647 |
| resultSequenceNumber | INTEGER | No | -2147483648 | 2147483647 |
| resultTitle | STRING | No |
Commands¶
The following are properties for both the Digital Twin API to send a command to the device as well as the properties passed as part of a command to the gateway to be processed by the device itself.
cloud.smarthq.command.barcode.set¶
Command to set a new value for the barcode service.
| Field Name | Property Type | Required | Minimum | Maximum |
|---|---|---|---|---|
| barcode | STRING | Yes | ||
| barcodeResult | BARCODE_RESULT | Yes | ||
| barcodeType | BARCODE | Yes | ||
| maxVisibleCharacters | INTEGER | Yes | -2147483648 | 2147483647 |
| sequenceNumber | INTEGER | Yes | -2147483648 | 2147483647 |
| title | STRING | Yes |
Example Commands¶
Command to set the barcode.
{
"command": {
"maxVisibleCharacters": 15.0,
"sequenceNumber": 110.0,
"commandType": "cloud.smarthq.command.barcode.set",
"barcodeType": "cloud.smarthq.type.barcode.codabar",
"title": "Orange Juice 2L",
"barcode": "A1B2C3D4",
"barcodeResult": "cloud.smarthq.result.barcode.added"
},
"deviceId": "00000000000000000000000000000000000000000000000000000000000000",
"domainType": "cloud.smarthq.domain.scanner",
"kind": "service#command",
"serviceDeviceType": "cloud.smarthq.device.refrigerator",
"serviceType": "cloud.smarthq.service.barcode"
}
Supported Outcomes¶
Each service has an allow listed set of outcomes that the device may return when asked to execute a command.
| Outcome | Documentation |
|---|---|
| cloud.smarthq.outcome.developererror | Only used when there is a server side bug |
| cloud.smarthq.outcome.deviceoffline | The device is offline. |
| cloud.smarthq.outcome.forbidden | The request is forbidden due to permissions. |
| cloud.smarthq.outcome.internalerror | The server had an issue processing the request |
| cloud.smarthq.outcome.missingconfig | The service config is missing |
| cloud.smarthq.outcome.missingstate | The service state is missing |
| cloud.smarthq.outcome.notallowed | The command is not allowed. |
| cloud.smarthq.outcome.notfound | The request is forbidden due to permissions. |
| cloud.smarthq.outcome.notsupported | The command is not supported. |
| cloud.smarthq.outcome.servicedisabled | Feature is currently disabled |
| cloud.smarthq.outcome.success | Successful request |
| cloud.smarthq.outcome.timeout | The server experienced timeout waiting for a response from the gateway |
Data Types¶
BOOLEAN¶
Value must be either true or false.
INTEGER¶
Value must be an integer. Field specific restrictions such as a minimum and maximum may apply depending on the field.
STRING¶
Value must be a sequence of characters, inserted between " and " (double quotes). Field specific restrictions such as a regular expression may apply depending on the field.
BARCODE¶
| BARCODE | Documentation |
|---|---|
| cloud.smarthq.type.barcode.aztec | AztecCode |
| cloud.smarthq.type.barcode.codabar | Codabar |
| cloud.smarthq.type.barcode.code11 | Code11 |
| cloud.smarthq.type.barcode.code128 | Code128 |
| cloud.smarthq.type.barcode.code39 | Code39 |
| cloud.smarthq.type.barcode.code93 | Code93 |
| cloud.smarthq.type.barcode.datamatrix | DataMatrix |
| cloud.smarthq.type.barcode.ean13 | Ean13 |
| cloud.smarthq.type.barcode.ean8 | Ean8 |
| cloud.smarthq.type.barcode.industrial2of5 | Industrial2of5 |
| cloud.smarthq.type.barcode.interleaved2of5 | Interleaved2of5 |
| cloud.smarthq.type.barcode.issb | Issb |
| cloud.smarthq.type.barcode.issn | Issn |
| cloud.smarthq.type.barcode.itf14 | Itf14 |
| cloud.smarthq.type.barcode.itf6 | Itf6 |
| cloud.smarthq.type.barcode.matrix2of5 | Matrix2of5 |
| cloud.smarthq.type.barcode.maxi | Maxicode |
| cloud.smarthq.type.barcode.msiplessey | Msi_Plessey |
| cloud.smarthq.type.barcode.pdf417 | Pdf417 |
| cloud.smarthq.type.barcode.pdf417.micro | MicroPdf417 |
| cloud.smarthq.type.barcode.qr | QRCode |
| cloud.smarthq.type.barcode.qr.micro | MicroQR |
| cloud.smarthq.type.barcode.rss14 | Rss14 |
| cloud.smarthq.type.barcode.rss14.expanded | Rss14Expanded |
| cloud.smarthq.type.barcode.rss14.limited | Rss14Limited |
| cloud.smarthq.type.barcode.rss14.stacked | Rss14Stacked |
| cloud.smarthq.type.barcode.upca | Upca |
| cloud.smarthq.type.barcode.upce | Upce |
BARCODE_RESULT¶
| BARCODE_RESULT | Documentation |
|---|---|
| cloud.smarthq.result.barcode.added | Added to shopping list |
| cloud.smarthq.result.barcode.error.connection | Connection Error |
| cloud.smarthq.result.barcode.error.timeout | Timeout Error |
| cloud.smarthq.result.barcode.rejected | Rejected |
| cloud.smarthq.result.barcode.unknown | Unknown |
| cloud.smarthq.result.barcode.valid | Valid |