How to install & execute

From AMTech WikiDocs
Revision as of 15:47, 20 June 2016 by Amarrero (Talk | contribs) (The ansible way)

Jump to: navigation, search

Os and core components

Manual installation of initial components and prerequesites

  • Installs Ubuntu OS on a Raspberry PI
https://ubuntu-mate.org/raspberry-pi/
  • Boot PI and update packages:
sudo apt-get update
sudo apt-get dist-upgrade
  • Install java 7 (if LLRPReader is needed)
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
and then:
sudo apt-get install -y nodejs
  • Installs and configures Bluetooth core libraries
sudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev
  • Allow nodejs to read from bluetooth devices (require by bluetooth related plugins):
sudo setcap 'cap_net_raw+eip' /usr/bin/nodejs
  • Allow non-privileged users (belonging to gpio group) to run GPIO commands:
git clone git://github.com/quick2wire/quick2wire-gpio-admin.git
cd quick2wire-gpio-admin
make
sudo make install
  • Install snmp if you are planning to configure a SNMPDevice instance to monitor the Raspberry Pi
   how-to-install-and-configure-an-snmp-daemon-and-client-on-ubuntu-14-04
   sudo apt-get update
   sudo apt-get install snmp snmp-mibs-downloader
   sudo apt-get update
   sudo apt-get install snmpd
   sudo download-mibs
   ======================================================================
   Edit /etc/snmp.conf
   remove comment from #mibs : to mibs : 
   =======================================================================
   Edit /etc/snmp/snmpd.conf
   1)At ACCESS CONTROL give Full access from the local $
   *remove comment the line rocommunity public  localhost 
   *add the line rwcommunity private
   *comment #rocommunity public  default    -V systemonly
   *comment # rocommunity6 public  default   -V systemonly
       ###############################################################################
       #
       #  ACCESS CONTROL
       #
                                                        #  Full access from the local $
        rocommunity public  localhost
        rwcommunity private
                                                        #  Default access to basic sys$
       # rocommunity public  default    -V systemonly
       #  rocommunity6 is for IPv6
       # rocommunity6 public  default   -V systemonly
   2)At SYSTEM INFORMATION to make write/read sysLocation and sysContact
   *comment line #sysLocation    xxxxxx
   *comment line  #sysContact     xxxxxx
       ###############################################################################
       #
       #  SYSTEM INFORMATION
       #
       #  Note that setting these values here, results in the corresponding MIB object$
       #  See snmpd.conf(5) for more details
       #sysLocation    xxxxxx
       #sysContact     xxxxxx       
   ========================================================================================
   sudo service snmpd restart

M2MBridge installation

  • Install git:
sudo apt-get install git
git clone https://github.com/AMTechMX/M2MBridge.git
  • Delete unneeded plugins from /.../M2MBridge/plugins/xxx (optional)
  • Install packages for m2mBridge core and plug-ins (https://docs.npmjs.com/cli/install:)
  • Execute npm install --save at:
    • M2MBridge directory
    • Each plugin directory
    LLRPReader plugin depends on java module and you should use the following options in the the npm install call:
    GYP_DEFINES="armv7l=0 javalibdir=/usr/lib/jvm/java-7-oracle/jre/lib/arm/server/" CCFLAGS='-march=armv7' CXXFLAGS='-march=armv7' npm install
  • If you get this error; var cwd = process.cwd(); Error: No such file or directory #200
https://github.com/foreverjs/forever/issues/200

M2MBridge execution

  • Customize the bridge configuration bridgeConfig,json, defining the templateId with the bridge instance from DAP to clone Cloud Configuration
  • Execute node m2mbridge.js (located in the M2MBridge directory)

Tools for configuration

  • If you want to connect a device (like the LLRP Reader) to your PI by sharing you network you may want to run:
nm-connection-editor
Find there the connection that represents your ethernet card and configure in IPv4 Settings the method Shared to other computers
  • If you want to guess the IP that is assigned through DHCP to a device connected by using the previously mentioned option, you can inspect the syslog with:
grep DHCPREQUEST /var/log/syslog

The ansible way

This guide assumes you already have ansible installed (detailed instructions in this guide)

  • In the directory of your choice, get a clone of the deployment project:
    git clone git@github.com:AMTechMX/m2mbridge_deployment.git
  • Change directory to m2mbridge_deployment
  • Update your inventory by editing static_inventory file. Example:
     [rpis]
     10.0.0.10
     10.0.0.11
     10.0.0.12
    
  • Configure common options in rpis/group_vars/all
  • Create a file for each host configured in rpi/host_vars whose name matches the IP address. For instance:
     plugins_enabled: [ SNMPDevice, LLRPReader ]
     bridge_description: Amtech M2M Bridge
     template_id: m2mCreator:m2mBridge
     bridge_id_prefix: tienda1
     location: {"wkt":"POINT(-99.17125583 19.40501031)","sContext":"geo"}
     address_country: usa
     address_city: Las Vegas
     address_road: Las Vegas Boulevard South
     address_number: 3960
  • cd into rpis directory
  • Run ansible playbook:
    ansible-playbook main.yml

Remote debugging

 
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch",
            "type": "node",
            "request": "launch",
            "program": "${workspaceRoot}/M2MBridge.js",
            "stopOnEntry": false,
            "args": [],
            "cwd": "${workspaceRoot}",
            "preLaunchTask": null,
            "runtimeExecutable": null,
            "runtimeArgs": [
                "--nolazy"
            ],
            "env": {
                "NODE_ENV": "development"
            },
            "externalConsole": false,
            "sourceMaps": false,
            "outDir": null
        },
        {
            "name": "Attach",
            "type": "node",
            "request": "attach",
            "port": 5858,
            "address": "raspberry-pi ip address",
            "restart": false,
            "sourceMaps": false,
            "outDir": null,
            "localRoot": "${workspaceRoot}",
            "remoteRoot": "shared-directory name"
        }
    ]
}