Difference between revisions of "How to install & execute"
From AMTech WikiDocs
(→Remote debugging =) |
|||
(54 intermediate revisions by 3 users not shown) | |||
Line 6: | Line 6: | ||
: <code>sudo apt-get update</code> | : <code>sudo apt-get update</code> | ||
: <code>sudo apt-get dist-upgrade</code> | : <code>sudo apt-get dist-upgrade</code> | ||
− | * Install java | + | * Install java (if LLRPReader is needed) |
: <code>sudo add-apt-repository ppa:webupd8team/java</code> | : <code>sudo add-apt-repository ppa:webupd8team/java</code> | ||
: <code>sudo apt-get update</code> | : <code>sudo apt-get update</code> | ||
− | : <code>sudo apt-get install oracle- | + | : <code>sudo apt-get install oracle-java8-installer oracle-java8-set-default</code> |
− | * Install nodejs | + | * Install nodejs |
− | : <code> | + | : <code>sudo apt-get install nodejs -y</code> |
− | + | : <code>sudo apt-get install npm</code> | |
− | : <code>sudo apt-get install | + | : <code>sudo npm install -g n</code> |
− | * Installs and configures Bluetooth core libraries | + | : <code>n 7.4.0 </code> |
+ | : <code>sudo apt-get remove nodejs -y</code> | ||
+ | |||
+ | * Install other requirement needed for building some libraries: | ||
+ | : <code>sudo apt-get install git autoconf libtool</code> | ||
+ | * Installs and configures Bluetooth core libraries (needed by bluetooth related plugins) | ||
: <code>sudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev</code> | : <code>sudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev</code> | ||
− | + | * Allow nodejs to read from bluetooth devices (required by bluetooth related plugins): | |
− | + | : <code>sudo setcap cap_net_raw+eip $(eval readlink -f `which node`)</code> | |
− | * Allow nodejs to read from bluetooth devices ( | + | * Allow non-privileged users (belonging to gpio group) to run GPIO commands (required by GPIO plugin): |
− | : <code>sudo setcap | + | |
− | * Allow non-privileged users (belonging to gpio group) to run GPIO commands: | + | |
: <code>git clone git://github.com/quick2wire/quick2wire-gpio-admin.git</code> | : <code>git clone git://github.com/quick2wire/quick2wire-gpio-admin.git</code> | ||
: <code>cd quick2wire-gpio-admin</code> | : <code>cd quick2wire-gpio-admin</code> | ||
: <code>make</code> | : <code>make</code> | ||
: <code>sudo make install</code> | : <code>sudo make install</code> | ||
+ | * Add user that runs the bridge to communicate through serial ports (required by ArduinoSerial plugin): | ||
+ | : <code>adduser <username> dialout</code> | ||
+ | * Install dependencies for XBee radios | ||
+ | :* Install librxtx from ubuntu/debian repository as: | ||
+ | : <code> sudo apt-get install librxtx-java </code> (check that the version is 2.2) | ||
+ | :* Create symbolic links in /usr/lib and run ldconfig to update library dependencies: | ||
+ | : <code> cd /usr/lib </code> | ||
+ | : <code>sudo ln jni/librxtxSerial-2.2pre1.so librxtxSerial.so</code> | ||
+ | |||
+ | * Install snmp if you are planning to configure a SNMPDevice instance to monitor the Raspberry Pi | ||
+ | [https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-an-snmp-daemon-and-client-on-ubuntu-14-04 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 === | === M2MBridge installation === | ||
− | * | + | |
− | + | * Use your credentials to identify yourself in the UI at https://platform.amtech.mx | |
− | * | + | * By using the menu go to <code>Main menu > Sensors > M2MBridge application </code> |
− | : <code> | + | * Save <code>M2MBridge.tar.gz</code> to the directory of your choice |
− | * Delete unneeded plugins from | + | * Untar the content: |
− | * Install packages for m2mBridge core and plug-ins (https://docs.npmjs.com/cli/install | + | : <code>tar xzvf M2MBridge.tar.gz</code> |
+ | * Delete unneeded plugins from M2MBridge/plugins/xxx (optional) | ||
+ | * Install packages for m2mBridge core and plug-ins (https://docs.npmjs.com/cli/install) | ||
+ | * Install a couple of requirements: | ||
+ | ** <code>sudo apt-get install libzmq3-dev libavahi-compat-libdnssd-dev libkrb5-dev</code> | ||
* Execute <code>npm install --save</code> at: | * Execute <code>npm install --save</code> at: | ||
** M2MBridge directory | ** M2MBridge directory | ||
** Each plugin directory | ** Each plugin directory | ||
*: LLRPReader plugin depends on java module and you should use the following options in the the <code>npm install</code> call: | *: LLRPReader plugin depends on java module and you should use the following options in the the <code>npm install</code> call: | ||
− | *: <code>GYP_DEFINES="armv7l=0 javalibdir=/usr/lib/jvm/java- | + | *: <code>GYP_DEFINES="armv7l=0 javalibdir=/usr/lib/jvm/java-8-oracle/jre/lib/arm/server/" CCFLAGS='-march=armv7' CXXFLAGS='-march=armv7' npm install</code> |
*If you get this error; var cwd = process.cwd(); Error: No such file or directory #200 | *If you get this error; var cwd = process.cwd(); Error: No such file or directory #200 | ||
: <code>https://github.com/foreverjs/forever/issues/200</code> | : <code>https://github.com/foreverjs/forever/issues/200</code> | ||
=== M2MBridge execution === | === M2MBridge execution === | ||
− | * Customize the bridge configuration [[Edge_Configuration|bridgeConfig | + | * Customize the bridge configuration [[Edge_Configuration|bridgeConfig.json]], defining the templateId with the bridge instance from DAP to clone [[Cloud Configuration]] |
− | * Execute | + | * Set environment variable NOBLE_REPORT_ALL_HCI_EVENTS=1 ([https://github.com/sandeepmistry/noble/blob/master/README.md#reporting-all-hci-events reporting all HCI events]) |
+ | * Execute M2MBridge.js startup script (located in the M2MBridge directory) | ||
+ | : <code>sudo NOBLE_REPORT_ALL_HCI_EVENTS=1 node M2MBridge.js | ||
=== Tools for configuration === | === Tools for configuration === | ||
Line 54: | Line 113: | ||
== The ansible way == | == The ansible way == | ||
− | == Remote debugging | + | This guide assumes you already have ansible installed (detailed instructions in [[Install ansible and requirements|this guide]]) |
+ | |||
+ | * In the directory of your choice, get a clone of the deployment project: | ||
+ | *: <code>git clone https://github.com/AMTechMX/m2mbridge_deployment.git</code> | ||
+ | * Change directory to m2mbridge_deployment | ||
+ | * Update your inventory by editing <code>static_inventory</code> file. Example: | ||
+ | *: <syntaxhighlight lang="ini"> | ||
+ | [rpis] | ||
+ | 10.0.0.10 | ||
+ | 10.0.0.11 | ||
+ | 10.0.0.12 | ||
+ | </syntaxhighlight> | ||
+ | *: {{Note|You need to configure private/public keys to access this hosts through SSH without password.}} | ||
+ | * 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: | ||
+ | *: <syntaxhighlight lang="linuxconfig"> | ||
+ | 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 | ||
+ | </syntaxhighlight> | ||
+ | * cd into rpis directory | ||
+ | * Run ansible playbook: | ||
+ | *: <code>ansible-playbook -i static_inventory main.yml</code> | ||
+ | |||
+ | == Remote debugging == | ||
*Install VSCode in your machine https://code.visualstudio.com/ | *Install VSCode in your machine https://code.visualstudio.com/ | ||
*If you need to modify the node code at the Raspberry Pi while debugging setup a share directory using samba | *If you need to modify the node code at the Raspberry Pi while debugging setup a share directory using samba | ||
Line 67: | Line 156: | ||
**Configure launch.json https://code.visualstudio.com/Docs/editor/debugging | **Configure launch.json https://code.visualstudio.com/Docs/editor/debugging | ||
*** set "address": "raspberry-pi ip address" and "remoteRoot": "shared-directory name" | *** set "address": "raspberry-pi ip address" and "remoteRoot": "shared-directory name" | ||
− | + | <syntaxhighlight lang="jsonld"> | |
− | < | + | { |
"version": "0.2.0", | "version": "0.2.0", | ||
"configurations": [ | "configurations": [ | ||
Line 96: | Line 185: | ||
"request": "attach", | "request": "attach", | ||
"port": 5858, | "port": 5858, | ||
− | "address": " | + | "address": "raspberry-pi ip address", |
"restart": false, | "restart": false, | ||
"sourceMaps": false, | "sourceMaps": false, | ||
"outDir": null, | "outDir": null, | ||
"localRoot": "${workspaceRoot}", | "localRoot": "${workspaceRoot}", | ||
− | "remoteRoot": " | + | "remoteRoot": "shared-directory name" |
} | } | ||
] | ] | ||
− | }</code> | + | } |
+ | </syntaxhighlight> | ||
+ | |||
+ | ==Debugging Node.js with Chrome DevTools== | ||
+ | *execute node as | ||
+ | **<code> node --inspect --inspect-brk M2MBridge.js</code> | ||
+ | *Instructions [https://medium.com/@paul_irish/debugging-node-js-nightlies-with-chrome-devtools-7c4a1b95ae27 Debugging nodejs with Chrome DevTools] |
Latest revision as of 11:42, 23 March 2018
Contents
Os and core components
Manual installation of initial components and prerequesites
- Installs Ubuntu OS on a Raspberry PI
- Boot PI and update packages:
-
sudo apt-get update
-
sudo apt-get dist-upgrade
- Install java (if LLRPReader is needed)
-
sudo add-apt-repository ppa:webupd8team/java
-
sudo apt-get update
-
sudo apt-get install oracle-java8-installer oracle-java8-set-default
- Install nodejs
-
sudo apt-get install nodejs -y
-
sudo apt-get install npm
-
sudo npm install -g n
-
n 7.4.0
-
sudo apt-get remove nodejs -y
- Install other requirement needed for building some libraries:
-
sudo apt-get install git autoconf libtool
- Installs and configures Bluetooth core libraries (needed by bluetooth related plugins)
-
sudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev
- Allow nodejs to read from bluetooth devices (required by bluetooth related plugins):
-
sudo setcap cap_net_raw+eip $(eval readlink -f `which node`)
- Allow non-privileged users (belonging to gpio group) to run GPIO commands (required by GPIO plugin):
-
git clone git://github.com/quick2wire/quick2wire-gpio-admin.git
-
cd quick2wire-gpio-admin
-
make
-
sudo make install
- Add user that runs the bridge to communicate through serial ports (required by ArduinoSerial plugin):
-
adduser <username> dialout
- Install dependencies for XBee radios
- Install librxtx from ubuntu/debian repository as:
-
sudo apt-get install librxtx-java
(check that the version is 2.2)- Create symbolic links in /usr/lib and run ldconfig to update library dependencies:
-
cd /usr/lib
-
sudo ln jni/librxtxSerial-2.2pre1.so librxtxSerial.so
- 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
- Use your credentials to identify yourself in the UI at https://platform.amtech.mx
- By using the menu go to
Main menu > Sensors > M2MBridge application
- Save
M2MBridge.tar.gz
to the directory of your choice - Untar the content:
-
tar xzvf M2MBridge.tar.gz
- Delete unneeded plugins from M2MBridge/plugins/xxx (optional)
- Install packages for m2mBridge core and plug-ins (https://docs.npmjs.com/cli/install)
- Install a couple of requirements:
-
sudo apt-get install libzmq3-dev libavahi-compat-libdnssd-dev libkrb5-dev
-
- 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-8-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
M2MBridge execution
- Customize the bridge configuration bridgeConfig.json, defining the templateId with the bridge instance from DAP to clone Cloud Configuration
- Set environment variable NOBLE_REPORT_ALL_HCI_EVENTS=1 (reporting all HCI events)
- Execute M2MBridge.js startup script (located in the M2MBridge directory)
-
sudo NOBLE_REPORT_ALL_HCI_EVENTS=1 node M2MBridge.js
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:
- <code>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:
- 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
- Note: You need to configure private/public keys to access this hosts through SSH without password.
-
- 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 -i static_inventory main.yml
-
Remote debugging
- Install VSCode in your machine https://code.visualstudio.com/
- If you need to modify the node code at the Raspberry Pi while debugging setup a share directory using samba
- Install Samba
sudo apt-get install samba samba-common-bin -y
- Configure share directory
- At M2MBridge directory run
node --debug-brk M2MBridge.js
- At your laptop
- Open shared or local folder from vscode
- Configure launch.json https://code.visualstudio.com/Docs/editor/debugging
- set "address": "raspberry-pi ip address" and "remoteRoot": "shared-directory name"
{
"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"
}
]
}
Debugging Node.js with Chrome DevTools
- execute node as
node --inspect --inspect-brk M2MBridge.js
- Instructions Debugging nodejs with Chrome DevTools