||
Skip to end of metadata
Go to start of metadata

WSO2 IoT Server's analytics feature allows you to publish operations to devices via the external or internal events that come through analytics. Once published, an operation entry is created in the WSO2 IoT Server's core profile. These operations are delivered to the device via Firebase Cloud Messaging (FCM) or local polling for android devices and via Apple Push Notification Service (APNS) for iOS.

To expose basic functions in the WSO2 IoT Server's device management core to the Siddhi runtime, you need the following WSO2 IoT Server Siddhi extensions. You can use them according to your scenario:

Confirming enrolled devices

Description

This extension returns true if a device matches the given device ID of a device that is already enrolled with WSO2 IoT Server and device type, such as Android, iOS, and Windows. Else, it returns false.

Extensiondevice:isEnrolled(deviceId, deviceType)
Usage

It is assumed that the input stream has the deviceId and deviceType values defined. Else, you need to define values for them.

from inputStream[device:isEnrolled(deviceId, deviceType)]
select deviceId insert into outputStream;

Confirming if the device is in a device group

Description

This extension returns true if the given device that has the specified device ID and device type, such as Android, iOS, and Windows, is in the specified group.

Extensiondevice:isInGroup(groupId, deviceId, deviceType)
Usage

It is assumed that the input stream has the groupId, deviceId, and deviceType values defined. Else, you need to define values for them.

from inputStream[device:isInGroup(groupId, deviceId, deviceType)] 
select deviceId insert into outputStream;

Confirming if a user has a specific device type enrolled

Description

This extension checks if a user having the specified username has already enrolled a specific device type, such as Android, iOS, and Windows.

Optionally, you are able to specify the status of the device too, such as active, inactive, and removed.

Extensiondevice:hasDevicesOfUser(user, deviceType [, status])
Usage

It is assumed that the input stream has the user and deviceId values defined. Else, you need to define values for them.

from inputStream[device:hasDevicesOfUser(user, deviceType)] 
select user insert into outputStream;
from inputStream[device:hasDevicesOfUser(user, deviceType, status)] 
select user insert into outputStream;

Getting the list of devices enrolled by a user

Description

This extension returns a list of devices in the JSON format if it belongs to the specified device type and is owned by the specified user.

Optionally, you are able to specify the status of the device too, such as active, inactive, and removed.

Extensiondevice:getDevicesOfUser(user, deviceType [, status])
Usage

It is assumed that the input stream has the user, status, and deviceType values defined. Else, you need to define values for them.

from inputStream
select device:getDevicesOfUser(user, deviceType) as devices insert into outputStream;
from inputStream
select device:getDevicesOfUser(user, deviceType, status) as devices insert into outputStream;

Checking for devices that belong to a specified device status

Description

This extension checks if there are any enrolled devices that belong to the specified device status.

Optionally, you are able to specify the device type too, such as Android, iOS, and Windows.
Extension

device:hasDevicesOfStatus(status [, deviceType])

Usage

It is assumed that the input stream has the status and deviceId values defined. Else, you need to define values for them.

from inputStream[device:hasDevicesOfStatus(status)]
select status insert into outputStream;
from inputStream[device:hasDevicesOfStatus(status, deviceType)]
select status insert into outputStream;

Getting the list of devices based on the device status

Description

This extension returns a list of devices in the JSON format if it belongs to specified device status, such as active, inactive, and removed.

Optionally, you are able to specify the device type too, such as Android, iOS, and Windows.

Extensiondevice:getDevicesOfStatus(status [, deviceType])
Usage

It is assumed that the input stream has the status and deviceId values defined. Else, you need to define values for them.

from inputStream
select device:getDevicesOfStatus(status) as devices insert into outputStream;
from inputStream
select device:getDevicesOfStatus(status, deviceType) as devices insert into outputStream;

Getting the property from the JSON string

Description

Returns the value of the property from the given JSON string.

Extensionjson:getProperty(payload, 'property name')
Usage
from inputStream
select id, json:getProperty(payload, 'property_name') as property_name insert into outputStream;

Example:

from inputStream
select id, json:getProperty(payload, 'latitude') as latitude insert into outputStream;

Getting the JSON array

Description

Returns JSON array for objects in the argument, such as STRING, INT, DOUBLE, or FLOAT.

Extension

json:getArray(args ..)

Usage

It is assumed that the input stream has the arg1 and arg2 values defined. Else, you need to define values for them.

from inputStream 
select json:getArray(arg1, arg2) as array insert into outputStream;

Checking if the specified coordinates are within the geo location

DescriptionThis extension checks if the specified longitude and latitude are within the geo fence specified by the geoJson.
Extensiongeo:within(longitude,latitude,geoJson)
Usage
from inputStream [geo:within(longitude,latitude,"{geoJSOn}")]
select deviceId insert into outputStream;

Example

from inputStream [geo:within(longitude,latitude,"{'type':'Polygon','coordinates'
:[[[79.85213577747345, 6.909673257977737],[79.85266149044037,6.909673257977737],
[79.85266149044037,6.91003538888127],[79.85213577747345,6.91003538888127],
[79.85213577747345,6.909673257977737]]]}")]
select deviceId insert into outputStream;

What's next?

  • No labels