eschava / node-red-contrib-xiaomi-ble

Xiaomi Bluetooth4 (BLE) sensors
MIT License
19 stars 15 forks source link

Problem installing on Raspberry Pi Zero (arm6) #10

Closed hunnimonstr closed 4 years ago

hunnimonstr commented 5 years ago

First Thanks for a great node/project.

I am having a lot of problems installing this node, I started with a brand new install of raspbian-lite on a 16gb sd card and after config and update/upgrade I installed and configured mosquitto and the installed node red with the advised script as found on the nodered.org pi page (build-essentials were upto date btw) all well and good untill i tried to install the node-red-xiaomi-ble node through the pallet manager it failed, npm audits point to a known issue of version2.x.x of noble.debug, https://www.npmjs.com/advisories/534 npm list indicates ├─┬ node-red-contrib-xiaomi-ble@1.2.3 │ └─┬ noble@1.9.1 │ ├─┬ UNMET OPTIONAL DEPENDENCY bluetooth-hci-socket@0.5.1 │ │ ├─┬ UNMET OPTIONAL DEPENDENCY debug@2.6.9 │ │ │ └── UNMET OPTIONAL DEPENDENCY ms@2.0.0 │ │ ├── nan@2.12.1 deduped │ │ └── usb@1.5.0 deduped │ ├── bplist-parser@0.0.6 │ ├─┬ debug@2.2.0 │ │ └── ms@0.7.1 │ └─┬ UNMET OPTIONAL DEPENDENCY xpc-connection@0.1.4 │ └── nan@2.12.1 dedupe

that the suggested version failed to get installed and the buggy version was the fallback. and that the 404 failure to find the web resources node-pre-gyp WARN Using needle for node-pre-gyp https download node-pre-gyp WARN Tried to download(404): https://github.com/tessel/node-usb/releases/download/1.5.0/usb_bindings-v1.5.0-node-v64-linux-arm.tar.gz node-pre-gyp WARN Pre-built binaries not found for usb@1.5.0 and node@10.15.1 (node-v64 ABI, glibc) (falling back to source compile with node-gyp)

Is the real culprit?

browsing for similar problems with solutions ive tried 3 versions of node red and attempted to install V1.2.1 of this node, all fail after attempting to rebuild without any available resources?

my last attempt involved using Pete Scargills "The Script" which took over an hour to run and installed an earlier release of node and node red. and 1st the pallet manager failed to install V1.2.3 then cli npm install failed with a cascading roll back on the failure to find the resources listed above . As did an attempt to clone and install V1.2.1.

while i appreciate this is probably not a problem with your node, but i am suffering it attempting to install your node, and have done all i can think of by tracking down any and all required resources and installed them in advance of need when identified.

thanks in advance,,

eschava commented 5 years ago

Hi! Thanks for your kind words and detailed description of the issue Have you checked similar issue https://github.com/eschava/node-red-contrib-xiaomi-ble/issues/4 ?

hunnimonstr commented 5 years ago

Yes, I have tried that and a sled full of similar fixes all it seems on raspberry pi 3B or 3B+ sbcs. I am using a Pi-Zero-W, and that solution like all others fails and tries to access the same missing arm6 resource for node-pre-gyp

pi@ZeroPi1:~ $ cd node-bluetooth-hci-socket
pi@ZeroPi1:~/node-bluetooth-hci-socket $ sudo npm install
npm WARN deprecated cryptiles@2.0.5: This version is no longer maintained. Please upgra       de to the latest version.
npm WARN deprecated boom@2.10.1: This version is no longer maintained. Please upgrade t       o the latest version.
npm WARN deprecated hoek@2.16.3: This version is no longer maintained. Please upgrade t       o the latest version.
npm WARN lifecycle bluetooth-hci-socket@0.5.2~preinstall: cannot run in wd %s %s (wd=%s       ) bluetooth-hci-socket@0.5.2 npm install node-pre-gyp /home/pi/node-bluetooth-hci-socke       t
[                ..] / extract:usb: verb gentlyRm don't care about contents; nuking /home/pi/

That is currently running as i had not used that particular fix using Pete Scargills 'solution' again focused and tested on a 3B arm7 Pi. But its going the same way....

I can provide a full list of all the 'prerequisite installs used i have them in a working file ..

Im fairly sure the missing arm6 node-pre-gyp sources are the root of this, but i am aware i dont know anywhere near enough to say it with any confidence.

eschava commented 5 years ago

Have you tried instructions from https://github.com/noble/node-bluetooth-hci-socket/issues/95 ?

hunnimonstr commented 5 years ago

yes i manually installed node.js 8 and then node red on top and still had the same issue,

and the version now running is node.js 6 .1.0

ive installed 3 x versions of node.js and the recommended version of node-red on top according to the results of my searches..

i will attach both the error log (tty output) from the 'fix' run refered to above node-bluetooth-hci-socket-install-error.txt

my working file of installs and pre-fixes is not on this puter when i get home i can post that too but it involves at least another git clone patch for modules/usb ..

eschava commented 5 years ago

One more similar issue https://github.com/tessel/node-usb/issues/175

hunnimonstr commented 5 years ago

Im not attempting to install as root tho i have enabled root ssh and set a pw.

But yes thats one i found and tried too, npm install --unsafe-perm

hunnimonstr commented 5 years ago

I took a couple of days off ;)

Right I have now managed to install the node, But it isnt working as expected, it just hangs 'searching'. In order to install I had to downgrade Node-red node.js... to

 'node-red-project': '0.0.1',
  npm: '3.10.10',
  ares: '1.10.1-DEV',
  http_parser: '2.7.0',
  icu: '58.2',
  modules: '48',
  node: '6.10.0',
  openssl: '1.0.2k',
  uv: '1.9.1',
  v8: '5.1.281.93',
  zlib: '1.2.8' }

installed using Pete Scargills 2019 version of 'The Script' in advance of installing the script i also installed the following resources.

sudo apt install -y mosquitto mosquitto-clients
sudo systemctl enable mosquitto.service
sudo apt install python-dev build-essential curl git mc -y
sudo apt install bluetooth bluez libbluetooth-dev libudev-dev -y

I used Pete Scargills script to install 'prerequisites', node.js, node-red, and rpi-clone only.

and in order to install with only warnings i needed to execute in the .node-red dir sudo npm install --no-perf pkg-config restart and then install node-red-contrib-xiaomi-ble

Checking syslog | grep Node-RED i discovered nobel warnings regarding running as root or using sudo with a link to instructions to

` sudo setcap cap_net_raw,cap_net_admin+eip $(eval readlink -f /home/pi/.node-red/node_modules/node-red-contrib-xiaomi-ble/xiaomi-ble.js)

which had no effect, or i errd in typing it?..


Feb 17 04:19:21 ZeroPi1 Node-RED[220]: 17 Feb 04:19:21 - [info] Starting flows
Feb 17 04:19:21 ZeroPi1 Node-RED[220]: 17 Feb 04:19:21 - [info] Started flows
Feb 17 04:19:21 ZeroPi1 Node-RED[220]: 17 Feb 04:19:21 - [info] Server now running at http://127.0.0.1:1880/
Feb 17 04:20:36 ZeroPi1 Node-RED[220]: 17 Feb 04:20:36 - [info] Stopping flows
Feb 17 04:20:36 ZeroPi1 Node-RED[220]: 17 Feb 04:20:36 - [info] Stopped flows
Feb 17 04:20:36 ZeroPi1 Node-RED[220]: 17 Feb 04:20:36 - [info] Starting flows
Feb 17 04:20:36 ZeroPi1 Node-RED[220]: 17 Feb 04:20:36 - [info] Started flows
Feb 17 04:20:41 ZeroPi1 Node-RED[220]: noble warning: adapter state unauthorized, please run as root or with sudo
Feb 17 04:20:41 ZeroPi1 Node-RED[220]:                or see README for information on running without root/sudo:

Any pointers as to how to investigate deeper would be appreciated. As a very casual and new user to node-red i am WAY out of my depth... Thanks in advance

eschava commented 5 years ago

Hi Wow, you have come a long way :)

About root permissions: you need to do setcap for node.js binary (whereis node), not js script

eschava commented 4 years ago

Should be fixed with 1.2.4