Difference between revisions of "M2M Bridge"

From AMTech WikiDocs
Jump to: navigation, search
(Implementation notes)
(Implementation notes)
Line 73: Line 73:
  
 
== Implementation notes ==
 
== Implementation notes ==
*M2MBridge is an open source stack developed by the AMTEch team; it discovers and loads nodes modules implementing "M2MBridge plugin interface"(See [[Activities#Thing types|Thing types]]) tacking into account existing thing instances observation production configuration (See [[Activities#Observation production configuration|Observation production configuration]]) and M2MBridge credentials (See [[Access control#Actors|Actors]] and [[M2M Bridge#Edge Configuration|Edge Configuration]]).
+
*M2MBridge is an open source stack developed by the AMTEch team; it discovers and loads nodes modules implementing "M2MBridge plugin interface"(See [[Activities#Thing types|Thing types]]) tacking into account thing instances, activity(s) observation production configuration (See [[Activities#Observation production configuration|Observation production configuration]]) and M2MBridge credentials (See [[Access control#Actors|Actors]] and [[M2M Bridge#Edge Configuration|Edge Configuration]]).
 
**It leverages AMTech IoT DAP (See [[Integration Guideline|Integration Guideline]])
 
**It leverages AMTech IoT DAP (See [[Integration Guideline|Integration Guideline]])
 
***Gets observation production configuration (See [[Integration Guideline#DAP Restful API#Get observation production configuration|Observation production configuration API]])
 
***Gets observation production configuration (See [[Integration Guideline#DAP Restful API#Get observation production configuration|Observation production configuration API]])

Revision as of 13:24, 19 April 2016

Functionality

  • Configurable edge intelligence
  • Bridges standard and proprietary protocols to AMTech IoT DAP.
    • MQTT, LLRP, CoAP, STOMP, SmartM2M, LWM2M, PLC, Zigbee and others
  • Device-to-device or device-to-cloud communications.
  • Allow remote and centralized administration of IoT devices and gateways.
    • SNMP/MIB/TRAP and other
  • Configurable auto-discover
  • Implements common functionality and orchestrates the execution of the protocols
  • Network failure detection and recovery
  • Get centralized configuration information at startup and real time modifications
  • Access control policies to manage observation production and consumption
  • The following diagram illustrates a M2MBrdige configuration:
    • Using LLRP protocol to get the data from EPC tags and send commands to the reader
    • Using SNMP to monitor the health o the readers
    • Implementing smoothing, decoding, grouping, access control and other edge intelligence

Example.jpg

Edge Configuration

  • bridgeConfig.json located at M2MBridge.js directory
   {
   //text to be assigned to M2MBridges description property
   "description": "AMTech M2M Bridge", 
   //if the description property will be assigned to M2MBridge's linked things
   "description:children" : true,
       "dap":{
           //amtech IoT DAP ur
           "dapUrl": "https://dap.amtech.mx",     
           //userid for the m2mBridge instance bridgeId 
           "userId": "xxxxxxx@amtech.mx",
           // tenant where bridge been configured       
           "tenant" : "xxxxxxx",  
           //m2mBridge userId password  
           "password" :"xxxxxxxx"
       },
        //M2MBridge instance id to be cloned
       "templateId":"m2mCreator:m2mBridge",
       //Prefix to add to the unique M2MBridge identifier, the mac address of the device is use as unique id
       //In absence of the prefix just the mac address is used as identifier
       "bridgeIdPrefix":"tienda1",       
        //wkt location to set m2mBridge location overrides address
       "location": "{\"wkt\":\"POINT(-99.17125583 19.40501031)\",\"sContext\":\"geo\"}",  
       //if the location property will be assigned to M2MBridge's linked things
       "location:children" : true,
       //Address to be used to get m2mBridge's location
       "address" :{				 
           "country" : "usa",
           "city": "Las Vegas",
           "road": "Las Vegas Boulevard South",
           "number":"3960"
       },
   }

Cloud Configuration

  • Create an amtechM2mBridge instance (See "/amtech/linkeddata/types/composite/entity/amtechM2mBridge")
  • Create an actor actorX with the polices required by the activity(s) (See Actors)
    • Add the things type polices the bridge needs to the actor actorX
  • Register a follower (See Roles)
    • Assign to follower actor actorX access
  • Activity observation configuration (See Observation production configuration)
  • Things instance creation
    • Configuring autoDiscover (See Edge Configuration)
      • The bridge will request the DAP to clone templateId instance with the name convention bridgeIdPrefix:(device mac address) from bridgeConfig.json
      • the things instances linked to the templateId property bridgeInstances will be cloned with the name convention bridgeIdPrefix:(device mac address):thing._name from bridgeConfig.json
      • cloned instance will be giving the access control owner to the follower user id of the bridge that requested it.
  • Monitoring M2MBridge status
    • Create an SNMPDevice instance and give access to your M2MBridge actor (See "/amtech/linkeddata/types/composite/entity/SNMPDevice")
      • Send observations to /m2mBridge/snmp/read a core activity /amtech/activities/monitorM2MBridgeStatus will analyze the data and notify to the user and guestusers of the M2MBridge instance.
        • This get done by setting at the observation production configuration /observationproductionconfig/SNMPDevice/observationsproducedconfig/snmpRead topic to value /m2mBridge/snmp/ (See Observation production configuration)

Implementation notes

  • M2MBridge is an open source stack developed by the AMTEch team; it discovers and loads nodes modules implementing "M2MBridge plugin interface"(See Thing types) tacking into account thing instances, activity(s) observation production configuration (See Observation production configuration) and M2MBridge credentials (See Actors and Edge Configuration).
    • It leverages AMTech IoT DAP (See Integration Guideline)
      • Gets observation production configuration (See Observation production configuration API)
      • Gets thing types instances (See Observation instances API)
      • Creates a web socket to receive asynchronous commands and thing instances changes (crud operations) (See CRUD and Commands API)
        • Dispatch command observations to plugin instance leveraging thing type instance @id (See Thing types)
        • Restart instance when supported properties change by calling stop and star plugin interface
      • Creates configuration information for Thing type leveraging configuration information and client side M2MBridge placeholders (See Observation production configuration and Placeholders)
      • Load plugin nodes modules required by configuration
      • Creates an instance of plugin for each type from observation production configuration leveraging thing type instance @id (See Thing types)
        • JavaScript object is extended with the properties values from the thing instance (See plugin example )
        • Properties and methods are injected like common logg for m2mBridge plugins, methods to send observations with and without transformation, methods for restarting, observation production configuration and others (See for details)
        • If instance does not exist at the server side execute auto discover process from bridgeConfig.json can be configured (See Edge Configuration)
      • Creates a centralized observation dispatcher with persistence to ensure:
        • Observations delivery in the order that observations occurred .

How to implement a new plugin

  • 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 XXXDevice (See Thing types)
  • Create the observations type the thing XXXDevice produces or consumes, example XXXDeviceObserv1 (See Observations and observation types)
  • Associate the observation XXXDeviceObserv1 type to the XXXDevice
  • 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;

How to install it

Existing plugins

LLRPReader

BLEPeripheralsScanner

BLEbeaconsScanner

SNMPDevice

MQTTBroker

COAP