Difference between revisions of "How to implement a new plugin"

From AMTech WikiDocs
Jump to: navigation, search
(Created page with "*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 SNMPDe...")
 
Line 1: Line 1:
 
*Clone git repository (https://github.com/AMTechMX/M2MBridge.git)
 
*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 [[Activities#Thing types|Thing types]])
 
**at /.../M2MBridge/plugins create a directory that matched with the Thing type name to bridge example SNMPDevice (See [[Activities#Thing types|Thing types]])
*Create a thing type XXXDevice (See [[Activities#Thing types|Thing types]])
+
*Create a thing type XXXThing (See [[Activities#Thing types|Thing types]])
*Create the observations type the thing XXXDevice produces or consumes, example XXXDeviceObserv1 (See [[Sensor's network#Observations and observation types|Observations and observation types]])  
+
*Create the observations type the thing XXXThing produces or consumes, example XXXThingObserv1 (See [[Sensor's network#Observations and observation types|Observations and observation types]])  
*Associate the observation XXXDeviceObserv1 type to the XXXDevice
+
*Associate the observation XXXThingObserv1 type to the XXXThing
 
*Implement a nodejs module with the following interface
 
*Implement a nodejs module with the following interface
  

Revision as of 18:30, 27 April 2016

  • 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;