public class CloudConnectorManager
extends java.lang.Object
Unless noted, all Cloud Connector API methods require the
com.digi.android.permission.CLOUD_CONNECTOR
permission. If your
application does not have this permission it will not have access to any
Cloud Connector method.
Modifier and Type | Field and Description |
---|---|
static int |
MAX_SIZE_OF_BINARY_DATA_POINTS_KB
Maximum size of binary data point allowed:
64 KB.
|
static int |
MAXIMUM_DATA_POINTS
Maximum number of data points that can be sent in just one package:
250.
|
Constructor and Description |
---|
CloudConnectorManager(android.content.Context context)
Class constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
connect()
Opens the Cloud Connector connection.
|
void |
disconnect()
Closes the Cloud Connector connection.
|
void |
enableSystemMonitor(boolean enable)
Enables/disables the system monitor feature.
|
java.lang.String |
getDeviceID()
Returns the Cloud Connector Device ID.
|
CloudConnectorPreferencesManager |
getPreferencesManager()
Returns the Cloud Connector preferences manager.
|
java.lang.String |
getVendorID()
Returns the device vendor ID.
|
boolean |
isConnected()
Returns the Cloud Connector connection status.
|
boolean |
isSystemMonitorEnabled()
Returns the current state of the system monitor.
|
void |
registerDeviceRequestListener(java.lang.String target,
IDeviceRequestListener listener)
Registers the given listener to receive Device Requests from the
Cloud Connector for the given target.
|
void |
registerEventListener(ICloudConnectorEventListener listener)
Registers the given listener to receive Cloud Connector events.
|
void |
sendBinaryDataPoint(BinaryDataPoint dataPoint)
Sends the given
BinaryDataPoint to Device Cloud. |
void |
sendDataPoint(DataPoint dataPoint)
Sends the given
DataPoint to Device Cloud. |
void |
sendDataPoints(java.util.List<DataPoint> dataPoints)
Sends the given list of
DataPoint to Device Cloud. |
void |
setVendorID(java.lang.String vendorID)
Sets the Cloud Connector Vendor ID setting.
|
void |
unregisterDeviceRequestListener(IDeviceRequestListener listener)
Removes the given listener from the Device Request listeners list.
|
void |
unregisterEventListener(ICloudConnectorEventListener listener)
Removes the given listener from the event listeners list.
|
public static final int MAXIMUM_DATA_POINTS
public static final int MAX_SIZE_OF_BINARY_DATA_POINTS_KB
public CloudConnectorManager(android.content.Context context)
CloudConnectorManager
using the given application context.
The CloudConnectorManager
allows you to interact with the
Cloud Connector service.
context
- Android application context.java.lang.NullPointerException
- If the context is null
.public void connect()
disconnect()
,
isConnected()
public void disconnect()
connect()
,
isConnected()
public boolean isConnected()
true
if Cloud Connector is connected, false
otherwise.connect()
,
disconnect()
public void registerEventListener(ICloudConnectorEventListener listener)
listener
- A ICloudConnectorEventListener
that will receive
Cloud Connector events.java.lang.NullPointerException
- If listener == null
.unregisterEventListener(ICloudConnectorEventListener)
,
ICloudConnectorEventListener
public void unregisterEventListener(ICloudConnectorEventListener listener)
Following this call, the listener will stop receiving Cloud Connector events.
listener
- Listener object that no longer needs Cloud Connector
events.java.lang.NullPointerException
- If listener == null
.registerEventListener(ICloudConnectorEventListener)
,
ICloudConnectorEventListener
public void registerDeviceRequestListener(java.lang.String target, IDeviceRequestListener listener)
target
- The Device Request target that the listener will be waiting
for.listener
- A IDeviceRequestListener
that will receive the
Device Requests.java.lang.NullPointerException
- If target == null
or
if listener == null
.unregisterDeviceRequestListener(IDeviceRequestListener)
,
IDeviceRequestListener
public void unregisterDeviceRequestListener(IDeviceRequestListener listener)
Following this call, the listener will stop receiving Device Requests from the Cloud Connector service.
listener
- Listener object that no longer needs Device Request
events.java.lang.NullPointerException
- If listener == null
.registerDeviceRequestListener(String, IDeviceRequestListener)
,
IDeviceRequestListener
public CloudConnectorPreferencesManager getPreferencesManager()
The Cloud Connector preferences manager is used to read and set the Cloud Connector configuration parameters.
public java.lang.String getDeviceID()
public java.lang.String getVendorID()
Vendor ID follows this format: '0x01234567'
null
if not configured.setVendorID(String)
public void setVendorID(java.lang.String vendorID)
Vendor ID follows this format: '0x01234567'
vendorID
- The Cloud Connector VendorID setting.java.lang.IllegalArgumentException
- If vendorID
is invalid.java.lang.NullPointerException
- If vendorID
is null
.getVendorID()
public void sendDataPoint(DataPoint dataPoint)
DataPoint
to Device Cloud.
Cloud Connector must be connected in order to send the data points, otherwise an exception is thrown.
In order to be notified about the operation result, application must
be subscribed to the Cloud Connector service using a
ICloudConnectorEventListener
dataPoint
- The data point to send.java.lang.NullPointerException
- If dataPoint == null
.java.lang.UnsupportedOperationException
- If Cloud Connector is disconnected.registerEventListener(ICloudConnectorEventListener)
,
sendBinaryDataPoint(BinaryDataPoint)
,
sendDataPoints(List)
,
unregisterEventListener(ICloudConnectorEventListener)
,
DataPoint
,
ICloudConnectorEventListener
public void sendDataPoints(java.util.List<DataPoint> dataPoints)
DataPoint
to Device Cloud.
Cloud Connector must be connected in order to send the data points, otherwise an exception is thrown.
In order to be notified about the operation result, application must
be subscribed to the Cloud Connector service using a
ICloudConnectorEventListener
The size of the data points list must be between MINIMUM_DATA_POINTS
and MAXIMUM_DATA_POINTS
, otherwise an exception is thrown.
dataPoints
- The data points list to send.java.lang.IllegalArgumentException
- If dataPoints.size() < MINIMUM_DATA_POINTS
or
if dataPoints.size() > MAXIMUM_DATA_POINTS
.java.lang.NullPointerException
- If dataPoints == null
.java.lang.UnsupportedOperationException
- If Cloud Connector is disconnected.MAXIMUM_DATA_POINTS
,
MINIMUM_DATA_POINTS
,
registerEventListener(ICloudConnectorEventListener)
,
sendBinaryDataPoint(BinaryDataPoint)
,
sendDataPoint(DataPoint)
,
unregisterEventListener(ICloudConnectorEventListener)
,
DataPoint
,
ICloudConnectorEventListener
public void sendBinaryDataPoint(BinaryDataPoint dataPoint)
BinaryDataPoint
to Device Cloud.
Cloud Connector must be connected in order to send the data points, otherwise an exception is thrown.
In order to be notified about the operation result, application must
be subscribed to the Cloud Connector service using a
ICloudConnectorEventListener
The size of the byte array to be sent should be less than
MAX_SIZE_OF_BINARY_DATA_POINTS_KB
KB.
dataPoint
- The binary data point to send.java.lang.NullPointerException
- If dataPoint == null
.java.lang.IllegalArgumentException
- If the binary value to be sent is
> MAX_SIZE_OF_BINARY_DATA_POINTS_KB
.java.lang.UnsupportedOperationException
- If Cloud Connector is disconnected.MAX_SIZE_OF_BINARY_DATA_POINTS_KB
,
registerEventListener(ICloudConnectorEventListener)
,
sendDataPoint(DataPoint)
,
sendDataPoints(List)
,
unregisterEventListener(ICloudConnectorEventListener)
,
BinaryDataPoint
,
ICloudConnectorEventListener
public void enableSystemMonitor(boolean enable)
In order to configure the system monitor settings, you have to use
the CloudConnectorPreferencesManager
object. Use
getPreferencesManager()
method to access it.
enable
- true
to enable the system monitor, false
to disable it.getPreferencesManager()
,
isSystemMonitorEnabled()
public boolean isSystemMonitorEnabled()
In order to configure the system monitor settings, you have to use
the CloudConnectorPreferencesManager
object. Use
getPreferencesManager()
method to access it.
true
if the system monitor is enabled, false
otherwise.enableSystemMonitor(boolean)
,
getPreferencesManager()