hkayann / node-red-contrib-ble-sense

Node-RED module for Bluetooth Low Energy (BLE) devices.
MIT License
6 stars 4 forks source link

Not working on raspian buster #5

Closed nospam2k closed 2 years ago

nospam2k commented 2 years ago

I am able to get the scanner node to work but the connection isn't.

Inject: topic - "<mac>"
Subscribed: {"services":["180d"],"characteristics":["2a37"]}

Either does nothing or returns a message about peripheral not issued.

If I start a scan and then connect I get a status of connected but no data. I then have to restart node to do anything as both nodes stop responding to anything.

Raspberry pi Buster and nodejs 12.

hkayann commented 2 years ago

You need to inject the MAC address of the peripheral. Can you share your Node-RED flow please?

nospam2k commented 2 years ago

Sorry, I didn't realise that in my post it ate the gt and lt signs. I did inject the mac. [ { "id": "9ad4f1cec0b3a3f7", "type": "tab", "label": "Flow 1", "disabled": false, "info": "", "env": [] }, { "id": "6396396ae77b1094", "type": "BLE Scanner", "z": "9ad4f1cec0b3a3f7", "name": "BLE Scanner", "searchFor": "Fitcent_CL806_0013025", "searchForType": "Name", "output": "Peripheral", "outputType": "Output", "x": 560, "y": 220, "wires": [ [ "a6171fd546b6092b" ] ] }, { "id": "24a1cb0bf246be16", "type": "inject", "z": "9ad4f1cec0b3a3f7", "name": "", "props": [ { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "start", "x": 410, "y": 200, "wires": [ [ "6396396ae77b1094" ] ] }, { "id": "b4e9d5eae8478216", "type": "inject", "z": "9ad4f1cec0b3a3f7", "name": "", "props": [ { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "stop", "x": 410, "y": 240, "wires": [ [ "6396396ae77b1094" ] ] }, { "id": "2e7b1ad559bd89b8", "type": "debug", "z": "9ad4f1cec0b3a3f7", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "statusVal": "", "statusType": "auto", "x": 890, "y": 220, "wires": [] }, { "id": "806de51994404cf8", "type": "BLE Connect", "z": "9ad4f1cec0b3a3f7", "name": "Fitcent_CL806_0013025", "subscribe": "{\"services\":[\"180d\"],\"characteristics\":[\"2a37\"]}", "x": 670, "y": 320, "wires": [ [ "1b4b0d0490ca217c" ] ] }, { "id": "19c64c73282a0fee", "type": "inject", "z": "9ad4f1cec0b3a3f7", "name": "", "props": [ { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "c8:26:85:ae:09:94", "x": 440, "y": 300, "wires": [ [ "806de51994404cf8" ] ] }, { "id": "e688069f6875b587", "type": "inject", "z": "9ad4f1cec0b3a3f7", "name": "", "props": [ { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "disconnect", "x": 460, "y": 341, "wires": [ [ "806de51994404cf8" ] ] }, { "id": "1b4b0d0490ca217c", "type": "debug", "z": "9ad4f1cec0b3a3f7", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "statusVal": "", "statusType": "auto", "x": 870, "y": 320, "wires": [] }, { "id": "a6171fd546b6092b", "type": "function", "z": "9ad4f1cec0b3a3f7", "name": "", "func": "node.warn(msg.payload.advertisement.localName + \":\" +\n msg.payload.advertisement.serviceUuids[0] + \":\" +\n msg.payload.rssi);", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 740, "y": 220, "wires": [ [ "2e7b1ad559bd89b8" ] ] }, { "id": "fb3e4db00994ee2f", "type": "catch", "z": "9ad4f1cec0b3a3f7", "name": "", "scope": null, "uncaught": false, "x": 140, "y": 120, "wires": [ [ "2957128778ccc31b" ] ] }, { "id": "2957128778ccc31b", "type": "debug", "z": "9ad4f1cec0b3a3f7", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "statusVal": "", "statusType": "auto", "x": 300, "y": 120, "wires": [] } ]

nospam2k commented 2 years ago

Just following up

hkayann commented 2 years ago

I am away currently and will be back 2nd week of Jan. Then, I can have a look at this in detail. By the mean time, please share the Node-RED log. My guess is your peripheral does not let you subscribe, hence the issue is related to peripheral.

boomvalt commented 2 years ago

Not working for me in Debian Bullseye. nothing happens with start injection, just reports connected. MAC address injection for BLE Connect returns "Error: Peripheral object is null."

hkayann commented 2 years ago

I am back. @boomvalt are you running it on Raspberry Pi or laptop?

Can you share the output of sudo btmon? Also please make sure you peripheral is advertising. You can try nRF Connect app.

boomvalt commented 2 years ago

Hi, I'm running the latest Homebridge Raspian image. with node-red. btmon receives no signal of any kind. Output below:

@.***:/var/lib/homebridge $ sudo btmon Bluetooth monitor ver 5.55 = Note: Linux version 5.10.. 0.584371 = Note: Bluetooth subsyste.. 0.584385 ..New Index (Primary,UART,hci0) [hci0] 0.584391 = Open Index: B8:27.. [hci0] 0.584395 = Index Info (Cypress Semiconductor) [hci0] 0.584399 RAW Open version 2.22 {0x0002} [hci0] 0.584403 .[1;32m@ MGMT Open (privileged) version 1.18 {0x0001} 0.584409

Sent with ProtonMail Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On Tuesday, January 25th, 2022 at 6:00 PM, hkayann @.***> wrote:

I am back. @.***(https://github.com/boomvalt) are you running it on Raspberry Pi or laptop?

Can you share the output of sudo btmon? Also please make sure you peripheral is advertising. You can try nRF Connect app.

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you were mentioned.Message ID: @.***>

boomvalt commented 2 years ago

Some further information - the node-red and the homebridge instances are on a raspberry pi 3B+. I administer them remotely.

Sent with ProtonMail Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On Tuesday, January 25th, 2022 at 11:03 PM, Boomvalt @.***> wrote:

Hi, I'm running the latest Homebridge Raspian image. with node-red. btmon receives no signal of any kind. Output below:

@.***:/var/lib/homebridge $ sudo btmon Bluetooth monitor ver 5.55 = Note: Linux version 5.10.. 0.584371 = Note: Bluetooth subsyste.. 0.584385 ..New Index (Primary,UART,hci0) [hci0] 0.584391 = Open Index: B8:27.. [hci0] 0.584395 = Index Info (Cypress Semiconductor) [hci0] 0.584399 RAW Open version 2.22 {0x0002} [hci0] 0.584403 .[1;32m@ MGMT Open (privileged) version 1.18 {0x0001} 0.584409

Sent with ProtonMail Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On Tuesday, January 25th, 2022 at 6:00 PM, hkayann @.***> wrote:

I am back. @.***(https://github.com/boomvalt) are you running it on Raspberry Pi or laptop?

Can you share the output of sudo btmon? Also please make sure you peripheral is advertising. You can try nRF Connect app.

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you were mentioned.Message ID: @.***>

hkayann commented 2 years ago

@boomvalt please use code tags. I have never seen sudo btmon returning nothing. We cannot debug further without proper info. Run sudo btmon before running Node-RED. Then replay the issue and post the output of btmon.

boomvalt commented 2 years ago

***@***.***:/var/lib/homebridge $ sudo btmon Bluetooth monitor ver 5.55 = Note: Linux version 5.10.. 0.584371 = Note: Bluetooth subsyste.. 0.584385 ..New Index (Primary,UART,hci0) [hci0] 0.584391 = Open Index: B8:27.. [hci0] 0.584395 = Index Info (Cypress Semiconductor) [hci0] 0.584399 RAW Open version 2.22 {0x0002} [hci0] 0.584403 .[1;32m@ MGMT Open (privileged) version 1.18 {0x0001} 0.584409

hkayann commented 2 years ago

I can not see any scanning here, do you scan first?

boomvalt commented 2 years ago

Yes, that's what I'm telling you - nothing happens. Maybe it's a permission thing? My node-red is running on a remote raspberry pi 3B+

Sent with ProtonMail Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On Monday, January 31st, 2022 at 10:34 AM, hkayann @.***> wrote:

I can not see any scanning here, do you scan first?

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you were mentioned.Message ID: @.***>

hkayann commented 2 years ago

Run the following command: sudo setcap cap_net_raw+eip $(eval readlink -f `which node`) Then run Node-RED and see if you can scan.

boomvalt commented 2 years ago

Not allowed, probably because it's a potential security risk. Output bellow: $ sudo setcap cap_net_raw+eip $(eval readlink -f which node) unable to set CAP_SETFCAP effective capability: Operation not permitted

Sent with ProtonMail Secure Email.

------- Original Message ------- On Tuesday, February 1st, 2022 at 10:58 AM, hkayann @.***> wrote:

Run the following command: sudo setcap cap_net_raw+eip $(eval readlink -f which node) Then run Node-RED and see if you can scan.

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you were mentioned.Message ID: @.***>

boomvalt commented 2 years ago

The standard CLI command for performing a BLE scan on Raspbian is:

sudo hcitool lescan

This works well.

Sent with ProtonMail Secure Email.

------- Original Message ------- On Tuesday, February 1st, 2022 at 10:58 AM, hkayann @.***> wrote:

Run the following command: sudo setcap cap_net_raw+eip $(eval readlink -f which node) Then run Node-RED and see if you can scan.

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you were mentioned.Message ID: @.***>

hkayann commented 2 years ago

In this case, you might not able to use my package as it depends on abandonware/noble. hcitool is deprecated, use either bluetoothctl or gatttool if you would like to do it via terminal.

Check this stackoverflow discussion for further info: https://unix.stackexchange.com/questions/106336/unable-to-set-capability-cap-setfcap-by-user.

hkayann commented 2 years ago

I am closing this issue, as issue seems to be related to permissions. I will add permission command to Read.ME as well.

boomvalt commented 2 years ago

Ok, thanks.

Sent with ProtonMail Secure Email.

------- Original Message ------- On Tuesday, February 8th, 2022 at 4:43 PM, hkayann @.***> wrote:

I am closing this issue, as issue seems to be related to permissions. I will add permission command to Read.ME as well.

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you were mentioned.Message ID: @.***>