Skip to content
guillaume edited this page Jul 29, 2017 · 9 revisions

How to use

You first need to ensure that PDG is reading the OM2M stream:

> rosservice call /pdg/manage_stream "{om2mObject: true}"

You may also launch a script to read the OM2M stream and create some area (made for Adream flat of LAAS):

> cd ~/catkin_ws/src/toaster/tools/toaster_scripts/shell/MaRDi/
> ./area_init2_iot.sh

Now, PDG is listening for every message published in the /iot2pdg_updates topic. This topic is filled by the action and updates nodes, part of the iot_bridge package.

If you wish to add an IOT object or to modify the facts generation of an existing object, to determine which fact to deduce depending on the value received by OM2M, you need to define some rules in the iot_objects.xml configuration file.

Here is an example of an iot_objects.xml configuration file with comments to explain each part of it:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<objects>
    <!-- Path to the AE of the object in OM2M -->
    <object id="/BBB_ADREAM_1/ETH_GW/PHG_FAN_11">
        <!-- Name of a fact you want to bind to this object -->
        <fact name="FanON">
            <!-- What triggers this fact: "object_value_name" is the content of the oBIX field containing the value you test, "operation" is what PDG has to do to handle the previously defined value
            So here, it is going to copy the "data" oBIX field of the XML received and publish it as the string value of the fact -->
            <value object_value_name="data" operation="copy" />
        </fact>
    </object>
    <object id="/BBB_ADREAM_1/ETH_GW/PHL_LMP_01">
        <!-- You can define multiple facts to one object -->
        <fact name="LampON">
            <value object_value_name="data" operation="copy" />
        </fact>
        <fact name="LightColor">
            <!-- The "equals" operation is going to test the value found in the oBIX, and if it is the same as one from object_value, it is going to publish the content of fact_value as the content of the fact -->
            <value object_value_name="color" operation="equals" object_value="YELLOW" fact_value="Yellow" />
            <value object_value_name="color" operation="equals" object_value="RED" fact_value="Red" />
            <value object_value_name="color" operation="equals" object_value="25500" fact_value="Green" />
            <value object_value_name="color" operation="equals" object_value="BLUE" fact_value="Blue" />
            <value object_value_name="color" operation="equals" object_value="PURPLE" fact_value="Purple" />
        </fact>
    </object>
</objects>

So, now, you can see the OM2M objects appearing in the /pdg/objectList topic and the deduced facts in the /pdg/factList topic.

> rostopic echo /pdg/objectList

In the objects list, you can see the current value of each object in the "value" field of the message.

> rostopic echo /pdg/factList

The values of the facts coming from OM2M devices are by convention represented as strings, but they may contain digits.


If you need more information about how to use the iot_bridge package visit this page.

Clone this wiki locally