A guide to deploy an OPC UA Server on an Android device using NodeJS.
To deploy an OPC-UA Server on Android with NodeJS runtime follow the section Sequence Of Instructions down below.
Tests has been done on Android 7.1 Nougat with a Sony Xperia Z5 Premium device.
Make sure to have at least 5 GB of disk space free, it will be necessary to install g++, needed to compile deasync
library that rely on C++. Also you will have to install the app Termux
.
Make sure to have Termux
installed. Then enter Termux and start typing these commands:
pkg install openssl-tool g++ make python2 nodejs
.alias python=python2
.npm install node-gyp
.- Modify the following file
.node-gyp/<<version>>/include/node/common.gypi
according to the following section. npm install node-opcua
or if you prefer, enter in the cloned repository and thennpm install
.
As stated into the following URL https://blog.akehir.com/2017/05/building-node-sass-libsass-python.html, is necessary to change the compiler flags from [ '-fPIE', -pie' ] to ['-fPIC'] as showed below. So start browsing your common.gypi
file: you will find two entries to change, one for the Release and one for Debug configuration.
` ['OS == "android"', {
'cflags': [ '-fPIC' ],
'ldflags': [ '-fPIC' ]
}], `
To start the Server just type into Termux node src/index.js