1. Home
  2. Knowledge Base
  3. Device SDK
  4. IoT-Ignite Device API

IoT-Ignite Manager

This class is the entrance point for using IoTIgnite SDK. Two parameters are required to get IoTIgniteManager instance:

  • context Android application context
  • connectionCallBack The listener points IoT-Ignite Agent connection notification.
try {
  IotIgniteManagermIotIgniteManager = new IotIgniteManager.Builder()
    .setContext(getApplicationContext()).setConnectionListener(new ConnectionCallback() {
    @Override
    public void onConnected() {
      Log.i("IgniteSample", "IoT-Ignite Connected!");
    }
    @Override
    public void onDisconnected() {
      Log.i("IgniteSample", "IoT-Ignite Disconnected!");
    }
  }).build();
} catch (UnsupportedVersionException e) {
  if (UnsupportedVersionExceptionType.UNSUPPORTED_IOTIGNITE_AGENT_VERSION.toString().equals(e.getMessage())) {
    Log.e(TAG, "UNSUPPORTED_IOTIGNITE_AGENT_VERSION");
  } else {
    Log.e(TAG, "UNSUPPORTED_IOTIGNITE_SDK_VERSION");
  }
}

Without connecting IgniteManager, no operation can be done on IoT-Ignite. After IoT-Ignite’s onConnected() callback is triggered, node can be created by using NodeFactory. Other functions belonging Ignite Manager are mentioned in Javadoc.

Node is used to manage related things (sensors or actuators). These things may be attached to a single physical device like micro controller unit (MCU) or to a software defined node. For example, an ArduinoYun connected to a mobile device can be registered as a node and sensors and actuators connected to it as things. It is possible to configure each node or thing separately

Sample Node is formed and registered as below:

Node myNode = IotIgniteManager.NodeFactory.createNode("Security Node", "Home Security Node"
    , NodeType.GENERIC, "HSN1", new NodeListener() {
    @Override
    public void onNodeUnregistered(String s) {
      Log.i(TAG, "Security Node unregistered!");
    }
  });
);
myNode.register(); // If the node is registered succesfully , “true” returns.

nodeID should be unique for each device. There are reserved nodeIDs like Built-in Sensors and Built-in Processors. These reserved ids are used by IoT-Ignite Agent App, hence other applications cannot use them.

If node is unregistered, onNodeUnregistered callback function is triggered.
All node operations are handled within that node instance. Major operations are registering, unregistering, querying nodes, altering node connection status, adding new things to that node.

The myNode.setConnected(true) function sets connection status of that node to online on the IoT Ignite Cloud. Unless a node is online, no operations can be applied to things registered under that node.

Thing

“Things” are the edge devices of IoT-Ignite. Thing may be a sensor or an actuator. A thing is a sensor it generates data. It is an an actuator if it emits messages or commands and respond them. It is possible to have a thing which is both.
Things may be physical devices attached to a physical node or they may be virtual (software defined). For example it is possible to define a virtual sensor by an application. Each “thing” should be connected to a node. Creating a thing object requires a connected IoTIgnite and a registered node.

Things can be saved via a registered node instance.

  • If the registered thing object is an Android sensor:
Thing myAndroidThing = myNode.createThing(myAndroidSensor, new ThingListener() {
  @Override
  public void onConfigurationReceived(Thing thing) {
  }
  @Override
  public void onActionReceived(String nodeId, String thingID, ThingActionData thingActionData) {
  }
  @Override
  public void onThingUnregistered(String nodeId, String thingID) {
  }
});
myAndroidThing.register();
  • If thing is other than an Android sensor:
ThingType type = new ThingType("myType","vendor", ThingDataType.STRING);
Thing myOtherThing = myNode.createThing("myUniqueThingID", type
  , ThingCategory.EXTERNAL, false, new ThingListener() {
  @Override
  public void onConfigurationReceived(Thing thing) {
  }
  @Override
  public void onActionReceived(String nodeID, String thingID, ThingActionData thingActionData) {
  }
  @Override
  public void onThingUnregistered(String nodeId, String thingID) {
  }
});

All thing operations are handled in the related thing instance. The connection status of thing object is determined by myThing.setconnected(true) function.

ThingListener, ThingConfiguration, Actuator

Each registered thing object has a listener. With the help of this listener, the thing can be controlled by IoTIgnite cloud. Cloud may deliver configuration parameters such as data sending period , data caching duration at local storage etc.

If the thing is defined as an actuator, the action is informed via onActionReceived(String nodeID, String thingID, ThingActionData thingActionData) callback. Thing configuration and action messages are defined at the IoT Ignite cloud side.

If thing is unregistered, onThingUnregistered(String nodeId, String thingID) callback function is triggered.

ThingType, ThingDataType, ThingCategory, ThingActionData

Two parameters are used while creating a thing object: ThingType and ThingCategory. ThingType states the type of the sensor. It stores information about sensor type and vendor/producer.
There are two category types: Hardware sensors in the device are in BULTIN category. External sensors, virtual things are in EXTERNAL category.

ThingDataType refers how sensor data is going to be interpreted on device or cloud. Currently, FLOAT, INT, STRING and GEOFENCE is supported for ThingDataType.

ThingActionData can be described as a messaging structure enables to realize actions that are formed after some events. This structure on IoT Ignite Cloud is between the rule creator and software developer and does not require any standard step.

For example, assume that a LED is registered as an actuator thing. A rule targetting this thing can be defined with an specific action message. Action message should be in JSON format. It may have an attribute named ‘ledState’ which can be set to a “1” or “0” that states turning on or off that LED respectively. When device application receives such a message, it should handle this message. It should initiate the corresponding internal command to actually turn on or foff the physical LED actuator.

Was this article helpful?

Related Articles