Device Signals
A device signal can be defined by sending its definition to config_io resource
Signal parsing
Signal parsing means we will parse and save the signal data into our time series database for future analytics.
Enable signal parsing
For new solutions signal parsing is enabled by default. For existing solution it can be enabled by clicking "Services" -> "Device2" -> "Enable Signal Parser"
Creating a signal
Signals are automatically created for each channel for a published config_io resource message. Signals are never deleted. please refer Device defined resource for more details.
Each time a new config_io is published with different channels, they are created as new signals in addition to the old ones.
To see all signals within a solution, click the "Signals" tab on the left.
Publishing data
Signal data is published by sending data to the data_in resource. See APIs references & SDKs
Publish As another device (need permission)
It is possible for a device to publish on behalf of another device id.
This can be done using the new
$as/<device-id>/<resource-name>
(publish only) topic
Note
Client provided timestamp (via the batch API) is limited to at most 1 day in the future or 10 years in the past. Data with timestamp outside this range will be rejected.
Subscribing to data
By default, signal data is not accessible to other devices than the publishing one. Access can be enabled per-device. Cross solution access is not supported.
Signals are organized into one or more hierarchies.
The default hierarchy is <device_id>/<signal_name>
.
A device can subscribe to one or more signals by subscribing to a hierarchy.
Prefix "s/" specifies the default hierarchy and can be used like this:
s/deviceA/* # Subscribe to all signals published by deviceA
s/*/* # Subscribe to all signals in the solution
s/deviceA/signalA # subscribe to a single signalA from deviceA
Shared subscription
If multiple devices connects & subscribes to a topic with the same device id, signals within that topic will be spread evenly between the connected devices.
QoS0
When subscribing with MQTT QoS0 a device will only receive realtime as its published to the subscribed signals. Also known as at most once subscription.
QoS1
When subscribing with MQTT QoS1 devices are guaranteed to receive all messages at least once. If a device disconnects, and reconnects later and subscribe to same topic it will continue receiving data from the last successfully acknowledged message.
For shared subscriptions, last acknowledged message might be from another device using the same device id.
Allow multiple connection with same token
Existing Authentication Types now allow multiples connection with same token (need to use password or token).
When (client_id, username, password) is - (Empty, Empty, token) -> ok - (Empty, DeviceID, token) -> ok - (DeviceID, Empty, token) -> ok - (DeviceID, DeviceID, token) -> ok - (random, DeviceID, token) -> ok - (ramdom, random, token) -> fail
There is one thing to notice, if you connect with DeviceID as client_id, it will disconnect the previous connection no matter which client_id the previous connection uses. For example:
Suppose we have a device mydevice
with a token mytoken
,
1. Connect with client_id = mydevice, username = mydevice, token = mytoken
, OKAY
2. Connect with client_id = random1, username = mydevice, token = mytoken
, OKAY
3. Connect with client_id = random2, username = mydevice, token = mytoken
, OKAY
4. Connect with client_id = mydevice, username = mydevice, token = mytoken
, OKAY (but it will disconnect random2
, the other two are still connected)
Access control
Subscription
By default a device can only subscribe to signals created by itself, topic s/<current_device>/*
. If a device needs access to more data,
go to device sttings and add the required subscription filters to the allow list.
Publish as
A source
device can send data pretending to be the target
device.
By default no device can pretend to be another device. Go to the target
device settings to enable a source
device send data on its behalf.
Alternatively go to "Services" -> "Device2" -> "permission" and configure a "gateway" device. This device can send data as any other device in the connector.