clausbroch / node-red-gfconnect

A Node-RED Project for connecting with Grainfather Connect G30 brewing system
https://www.norgesvej12a.dk/husbryg/category/equipment-and-integrations/grainfather-integration/
MIT License
19 stars 6 forks source link

V0.9.2 unable to connect to Bluetooth #8

Open jukkaTheFinn opened 4 years ago

jukkaTheFinn commented 4 years ago

Keep getting the following message in node-red-log after upgrade to v0.9.2:

14 Jun 17:49:01 - [error] [BLE scanner:Scan for GF] Error scanning for devices: Error: Could not start scanning, state is unknown (not poweredOn)

Versions are as follows:

Starting as a systemd service. 14 Jun 19:02:33 - [info] Welcome to Node-RED

14 Jun 19:02:33 - [info] Node-RED version: v1.0.6 14 Jun 19:02:33 - [info] Node.js version: v12.18.0 14 Jun 19:02:33 - [info] Linux 4.19.118-v7+ arm LE 14 Jun 19:02:37 - [info] Loading palette nodes 14 Jun 19:02:45 - [info] Dashboard version 2.22.1 started at /ui 14 Jun 19:02:47 - [info] Settings file : /home/pi/.node-red/settings.js 14 Jun 19:02:47 - [info] Context store : 'default' [module=memory] 14 Jun 19:02:47 - [info] User directory : /home/pi/.node-red 14 Jun 19:02:47 - [warn] Projects disabled : editorTheme.projects.enabled=false 14 Jun 19:02:47 - [info] Flows file : /home/pi/.node-red/flows_raspberrypi.json

Any help is much appreciated

-jukka

clausbroch commented 4 years ago

Do you have the Generic BLE module installed? If that'st the case then you need to ensure it's updated to v4.0.1 (or later). Otherwise it will interfere with the bluetooth module used by GF Connect.

jukkaTheFinn commented 4 years ago

I only have the node-red-contrib-noble-bluetooth installed.

In fact out of frustration, I reinstalled the whole OS/node.js/node-red setup, thinking that the problem might had to somehow do with the user not having rights to access the actual bluetooth device.

I've attached the list of installed nodes.

BR,

-jukka node-red_istalledNodes.txt

clausbroch commented 4 years ago

Could you try running the following command from the ~/.node-red directory and attach the result: npm list

jukkaTheFinn commented 4 years ago

Attached NpmList_Out.txt

phellarv commented 4 years ago

Same error: Jun 15 20:47:11 raspbian-dev Node-RED[6044]: Welcome to Node-RED Jun 15 20:47:11 raspbian-dev Node-RED[6044]: =================== Jun 15 20:47:11 raspbian-dev Node-RED[6044]: 15 Jun 20:47:11 - [info] Node-RED version: v1.0.6 Jun 15 20:47:11 raspbian-dev Node-RED[6044]: 15 Jun 20:47:11 - [info] Node.js version: v12.18.0 Jun 15 20:47:11 raspbian-dev Node-RED[6044]: 15 Jun 20:47:11 - [info] Linux 5.4.42-v7+ arm LE Jun 15 20:47:12 raspbian-dev Node-RED[6044]: 15 Jun 20:47:12 - [info] Loading palette nodes Jun 15 20:47:17 raspbian-dev Node-RED[6044]: 15 Jun 20:47:17 - [info] Dashboard version 2.21.0 started at /ui Jun 15 20:47:18 raspbian-dev Node-RED[6044]: 15 Jun 20:47:18 - [info] Settings file : /root/.node-red/settings.js Jun 15 20:47:18 raspbian-dev Node-RED[6044]: 15 Jun 20:47:18 - [info] Context store : 'default' [module=memory] Jun 15 20:47:18 raspbian-dev Node-RED[6044]: 15 Jun 20:47:18 - [info] User directory : /root/.node-red Jun 15 20:47:18 raspbian-dev Node-RED[6044]: 15 Jun 20:47:18 - [info] Server now running at http://127.0.0.1:1880/ Jun 15 20:47:18 raspbian-dev Node-RED[6044]: 15 Jun 20:47:18 - [info] Active project : node-red-gfconnect Jun 15 20:47:18 raspbian-dev Node-RED[6044]: 15 Jun 20:47:18 - [info] Flows file : /root/.node-red/projects/node-red-gfconnect/flow.json Jun 15 20:47:18 raspbian-dev Node-RED[6044]: 15 Jun 20:47:18 - [info] [GenericBLE] Start BLE scanning Jun 15 20:47:18 raspbian-dev Node-RED[6044]: 15 Jun 20:47:18 - [info] Starting flows Jun 15 20:47:18 raspbian-dev Node-RED[6044]: 15 Jun 20:47:18 - [info] [GenericBLE] Start BLE scanning Jun 15 20:47:18 raspbian-dev Node-RED[6044]: 15 Jun 20:47:18 - [info] Started flows Jun 15 20:47:18 raspbian-dev Node-RED[6044]: 15 Jun 20:47:18 - [error] [BLE scanner:Scan for GF] Error scanning for devices: Error: Could not start scanning, state is unknown (not poweredOn) Jun 15 20:47:18 raspbian-dev Node-RED[6044]: 15 Jun 20:47:18 - [info] [BLE scanner:Scan for GF] BLE state: poweredOn

And I have checked that I have the generic BLE installed. Updating it at the moment to see if that solves the problem.

clausbroch commented 4 years ago

@phellarv the last line in your log shows that the state changes to "poweredOn" which is OK. @jukkaTheFinn are you also seeing this change to poweredOn, or does it stay in state unknown?

clausbroch commented 4 years ago

@phellarv It appears from your log that you had a version of Generic BLE older than v4.0.1 installed, as it starts scanning for nodes even though it isn't part of any flow. Even worse, it also connects to the found nodes and thus prevents the BLE module used in GF Connect 0.9.2 from connecting

phellarv commented 4 years ago

@clausbroch Yep - Upgraded now, and it starts scanning, but no connect so far.

clausbroch commented 4 years ago

@phellarv did you restart the Raspberry Pi? I have sometimes seen the bluetooth getting into an undefined state where it appears to be working, but it doesn't connect to any devices. You can also make a quick check with the Grainfather App to verify that it is able to connect. Just make sure to disconnect it again before connecting with GF Connect

jukkaTheFinn commented 4 years ago

Stays in state "unknown"

phellarv commented 4 years ago

@clausbroch After a couple of restarts I found out that I have an extremely short range on the bluetooth on this RPi. It might be that the metal case which I use with X820 SSD HAT limits the range severely. Wifi range is limited too.

clausbroch commented 4 years ago

@phellarv metal cases and wireless are seldom a good combination. This could be the reason it starts scanning, but doesn't detect any devices. I also noticed you are running Linux 5.4.42. As far as I know the latest Raspberry Pi OS is 4.19.xxx. I'm not sure if there might be any issues here with compatibility of the used modules. Did you install it from the official image?

phellarv commented 4 years ago

@clausbroch Upgraded to 5.4.42 with rpi-upgrade. When I place the RPi close to the Grainfather, it works. About 1 meter is ok.

phellarv commented 4 years ago

@clausbroch I will probably go and buy myself another RPi later this week, and put it into a plastic casing.

clausbroch commented 4 years ago

@phellarv good to hear that it can connect now.

clausbroch commented 4 years ago

@jukkaTheFinn just out of curiosity, did you install node-red-contrib-noble-bluetooth from the Node-RED palette manager, or from the command line?

jukkaTheFinn commented 4 years ago

@clausbroch I installed node-red-contrib-noble-bluetooth from the palette manager

clausbroch commented 4 years ago

@jukkaTheFinn Ok. I’m not sure it will solve your problem, but could you try installing it from the command line as described in https://www.norgesvej12a.dk/husbryg/gf-connect-v0-9-2-released/

Hopefully it will provide some indication to the underlying problem

jukkaTheFinn commented 4 years ago

@clausbroch Tried commendline install and not sure if I should be concerned with all the errors, and the ultimate terminated compilation.

Output is attached. npmInstall_Out.txt

jukkaTheFinn commented 4 years ago

Corrected the problem with the missing libudev.h by installing the libudev-dev Linux package and npm install compilation looked to complete successfully.

Still no success with Bluetooth though

clausbroch commented 4 years ago

@jukkaTheFinn Even though there are a lot of intermediate errors the last few lines appears to indicate successful installation of several packages.

What is the verdict after restarting Node-Red?

jukkaTheFinn commented 4 years ago

Still no success with Bluetooth

clausbroch commented 4 years ago

Found this on https://github.com/abandonware/noble: Try to install the prerequisites for the noble library: sudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev

jukkaTheFinn commented 4 years ago

Still no joy :(

Installed all the packages, re-started node-red, still wasn't working.

Then un-installed node-red-contrib-noble-bluetooth and re-installed it again to force re-compile, and it's still not going.

clausbroch commented 4 years ago

Do you have anything else installed on the Raspberry that use Bluetooth?

clausbroch commented 4 years ago

There also seems to be some reports regarding missing access from non-root users on Linux platforms

Could you try running this command and see if that might be the case: sudo setcap cap_net_raw+eip $(eval readlink -f which node)

jukkaTheFinn commented 4 years ago

Ran the command and if I just copy and paste it there are some syntax errors. I have a feeling there were some back quotes that got interpreted as formatting characters in your message. Putting in the back quotes (`) around which node, this command comes back with nothing.

jukkaTheFinn commented 4 years ago

I did restart node-red after issuing the command, but it's still not going :(

I think I'll reinstall the OS to get a clean slate, and try everything again.

clausbroch commented 4 years ago

@jukkaTheFinn did you manage to reinstall the OS - and did this solve the connection problems?

inspectaclueso commented 4 years ago

I too am unable to connect to the Grainfather. New Pi 4 (4Gb), new install of Rasbian and new install of node-red. The node-red flow shows it as connecting and sometimes the Bluetooth logo appears on the Grainfather however it doesn't actually connect.

jukkaTheFinn commented 3 years ago

Hi Claus,

Hope you are well, and Happy New Year!

Got bit busy but was finally able to take some time to look into this.

Yes, reinstall worked with some extra steps.

Steps were basically:

  1. Re-install Raspbian followed by full update/upgrade
  2. Install necessary packages: sudo apt install git build-essential libudev-dev libsystemd-dev
  3. install node-red using the recommended script: bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)
  4. Use npm to install necessary node-red modules npm install node-red-dashboard npm install node-red-contrib-ui-level npm install node-red-contrib-noble-bluetooth
  5. Install the gfconnect json to new flow in node-red
  6. At this point not sure why but the modules installed in step 4 didn't show in node-red, so had to re-install from GUI
  7. After deploying for one last time it all started to work

Thanks for your time on developing this and helping me to get this going.

BR,

-jukka