How to implement a new plugin

From AMTech WikiDocs
Revision as of 18:30, 27 April 2016 by Carlos (Talk | contribs)

Jump to: navigation, search
  • Clone git repository (https://github.com/AMTechMX/M2MBridge.git)
    • at /.../M2MBridge/plugins create a directory that matched with the Thing type name to bridge example SNMPDevice (See Thing types)
  • Create a thing type XXXThing (See Thing types)
  • Create the observations type the thing XXXThing produces or consumes, example XXXThingObserv1 (See Observations and observation types)
  • Associate the observation XXXThingObserv1 type to the XXXThing
  • Implement a nodejs module with the following interface
    function XXXThing() {
    }

    XXXThing.prototype.start = function ( complete) {
        try {
            complete(null);
        } catch (e) {
            complete(e);
        }
    };

    XXXThing.prototype.stop = function (complete) {
        try {
            complete(null);
        } catch (e) {
            complete(e);
        }
    };

    XXXThing.prototype.command = function (observation, complete) {
        try {
            complete(null);
        } catch (e) {
            complete(e);
        }
    };

    module.exports.XXXThing = XXXThing;