All Projects → CANDY-LINE → Node Red Contrib Generic Ble

CANDY-LINE / Node Red Contrib Generic Ble

Licence: apache-2.0
A Node-RED node set for providing access to generic BLE peripheral GATT characteristics.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Node Red Contrib Generic Ble

bluetooth-iot-service-python
This application connects two devices over Bluetooth and allows one to send messages to the other using json. Raspberry Pi Bluetooth interfacing with Linux via RFCOMM BT network
Stars: ✭ 23 (+15%)
Mutual labels:  ble, raspberry-pi-3
Thingsboard Gateway
Open-source IoT Gateway - integrates devices connected to legacy and third-party systems with ThingsBoard IoT Platform using Modbus, CAN bus, BACnet, BLE, OPC-UA, MQTT, ODBC and REST protocols
Stars: ✭ 796 (+3880%)
Mutual labels:  ble
Android Scanner Compat Library
A compat library for Bluetooth Low Energy scanning on Android.
Stars: ✭ 462 (+2210%)
Mutual labels:  ble
Enclosure Picroft
Mycroft interface for Raspberry Pi environment
Stars: ✭ 649 (+3145%)
Mutual labels:  raspberry-pi-3
Android Dfu Library
A library with DFU feature for Android 4.3+.
Stars: ✭ 532 (+2560%)
Mutual labels:  ble
Pi64
A 64-bit OS for the Raspberry Pi 3
Stars: ✭ 720 (+3500%)
Mutual labels:  raspberry-pi-3
Esp32 mouse keyboard
ESP32 implementation for HID over GATT Keyboard and Mouse (Bluetooth Low Energy). Including serial API for external modules (similar to Adafruit EZKey HID)
Stars: ✭ 420 (+2000%)
Mutual labels:  ble
Fotobox
Python based photo-booth script for Raspberry Pi and RPi Camera
Stars: ✭ 22 (+10%)
Mutual labels:  raspberry-pi-3
Shiny
A Xamarin Framework for Backgrounding & Device Hardware Services (iOS, Android, UWP, Tizen, tvOS, watchOS, & more coming soon)
Stars: ✭ 763 (+3715%)
Mutual labels:  ble
Xiaomigateway3
Control Zigbee, BLE and Mesh devices from Home Assistant with Xiaomi Gateway 3 (ZNDMWG03LM) on original firmware
Stars: ✭ 617 (+2985%)
Mutual labels:  ble
Raspberryio
The Raspberry Pi's IO Functionality in an easy-to-use API for Mono/.NET/C#
Stars: ✭ 593 (+2865%)
Mutual labels:  raspberry-pi-3
Homebridge Raspbian Image
Official Homebridge Raspberry Pi Image based on Raspbian Lite.
Stars: ✭ 534 (+2570%)
Mutual labels:  raspberry-pi-3
Blinker Py
Blinker python library for hardware. Works with Raspberry Pi, Banan Pi, Linux devices
Stars: ✭ 680 (+3300%)
Mutual labels:  ble
Homepwn
HomePwn - Swiss Army Knife for Pentesting of IoT Devices
Stars: ✭ 526 (+2530%)
Mutual labels:  ble
Open Home Automation
Open Home Automation with Home Assistant, ESP8266/ESP32 and MQTT
Stars: ✭ 820 (+4000%)
Mutual labels:  ble
Fastble
Android Bluetooth Low Energy (BLE) Fast Development Framework. It uses simple ways to filter, scan, connect, read ,write, notify, readRssi, setMTU, and multiConnection.
Stars: ✭ 4,409 (+21945%)
Mutual labels:  ble
Esp32 ble arduino
The library source for the ESP32 BLE support for Arduino.
Stars: ✭ 552 (+2660%)
Mutual labels:  ble
Ubuntu64 Rpi
适用于树莓派3b/3b+的64位系统.
Stars: ✭ 652 (+3160%)
Mutual labels:  raspberry-pi-3
Woa Installer Rpi
This repository was deprecated, use:
Stars: ✭ 865 (+4225%)
Mutual labels:  raspberry-pi-3
Esp32 ble wedo
A library to control LEGO wedo 2.0 with the ESP32 through Bluetooth low energy
Stars: ✭ 16 (-20%)
Mutual labels:  ble

node-red-contrib-generic-ble

GitHub release master Build Status

A Node-RED node set for providing access to generic BLE peripheral GATT characteristics.

As of v4.0.0, this node is optmized for Linux with BlueZ 5 D-Bus API (HCI socket is no longer used on Linux). The node should still work on macOS and Windows as nothing is modified for these platforms.

Supported operations are as follows:

  • Start BLE Scanning
  • Stop BLE Scanning
  • Restart BLE Scanning (Stop then start BLE Scanning again)
  • Connect to a peripheral device
  • Disonnect from a peripheral device
  • Read
  • Write
  • Write without Response
  • Notify (Subscribing the Notify events)

The node status modes are as follows:

  • missing the configured BLE peripheral device is missing. When the device is discovered, the state transitions to disconnected. The disconnected device may transiton to missing again when RSSI is invalidated (Linux only)
  • disconnected when the configured BLE peripheral device is found but not conncted
  • connecting when the configured BLE peripheral device is being connected
  • connected when the configured BLE peripheral device is connected
  • disconnecting when the configured BLE peripheral device is being disconnected
  • error when unexpected error occurs

Known issues for Linux BlueZ D-Bus API:

  • Unlike the older version, you must set the process owner's permission properly and manually. Non-root user's Node-RED process will fail to get this node working. Read Installation Note (Linux) below.
  • It seems the local name in advertisement packet isn't transferred to LocalName property in org.bluez.Device1 BlueZ D-Bus API. With the HCI socket implementaion, the local name was resolved. So the local name can be resolved on macOS and Windows.
  • Bluetooth: hci0: hardware error 0x03 error sometimes occurs (and logged in syslog). When it's observed, all devices are disconnected and cahches are gone. The node tries to power on the BLE adapter again.

How to use

How to configure a new BLE peripheral device

At first, drag either a Generic BLE in node or a Generic BLE out node to the workspace from the node palette and double-click the node. And you can find the following dialog. Here, click the pencil icon (1) to add a new BLE peripheral or edit the existing one.

ble out node

Then the new config node dialog appears as shown below.

The BLE Scanning shows whether or not BLE scanning is going on. In order to start BLE scanning, check it (2).

ble config node

As soon as you check it, Scan Result select box and Apply button appear. The scan results are automatically fufilled in the select box. The content will be refreshed every 10 seconds.

ble config node

Chosoe one of the listed devices and then click Apply to populate Local Name, MAC and UUID input text boxes. Clicking Apply button also triggers GATT characteristics discovery as well.

The following picure shows the Apply button clicking results. GATT Characteristics has a characteristic list of the selected device. When you see (not available) message in the box, check if the device is NOT sleeping (a sleeping device fails to respond to a connect request) and click Apply again.

GATT Characteristics must be populated as the node uses the list to verify if a given characteristic UUID is valid on performing Read, Write and Subscribe requests.

Click Add (3) to save the information when everything is OK.

ble config node

Now back to Generic BLE out node. Click Done (4) to finish the Generic BLE out node settings.

ble config node

You can also import an example flow from the menu icon() > Import > Examples > node-red-contrib-generic-ble > 01-read-write for learning more about this node.

How to translate gatttool command into flow

In this example, we show how to describe gatttool commands for characteristic value write and read with Generic BLE nodes.

NOTICE: As of BlueZ 5, gatttool is deprecated. gatttool will be removed in the future relesase.

Characteristics Value Write

The following simple command line just issues a characteristic write request to the handle 0x0027, which the BLE peripheral associates with the characteristic uuid f000aa02-0451-4000-b000-000000000000(uuids and handles can be listed by gatttool -b 88:99:00:00:FF:FF --characteristics command).

$ gatttool -b 88:99:00:00:FF:FF --char-write-req --handle=0x0027 --value=ca
Characteristic value was written successfully

In this tutorial, we translate the above command into Node-RED flow.

First of all, we use the following nodes.

  1. inject node to trigger a write request
  2. Generic BLE out node to perform the write request

gatttool

So the first step to create a flow is to place the above nodes on the workspace and connect them as shown above.

Next, open the inject dialog so that you can provide the write request parameters, the characteristic uuid and the value.

Important!) Unlike gatttool, Generic BLE nodes NEVER use handles. Always use uuids instead.

gatttool

In this dialog, choose JSON at Payload input item since Generic BLE out node accepts a JSON object as its input value. See Inputs in the node description shown in the info tab for detail.

gatttool

Click/tap ... to launch JSON value editor and populate the following JSON text.

{
    "f000aa0204514000b000000000000000": "ca"
}

The property f000aa0204514000b000000000000000 is a characteristic uuid. However, unlike gatttool, you must strip hyphens from the original uuid value. Generic BLE nodes doesn't accept gatttool style uuid format.

The value ca is a hex string to be written, which is identical to the above command line.

So you'll see the following image.

gatttool

Close the dialog by clicking Done button after entering the JSON text.

Configure Generic BLE out node for your BLE peripheral (This step is already introduced above so we don't describe here. See How to configure a new BLE peripheral).

Now you're ready to issue a characteristic write request to your BLE peripheral. Click Deploy and click inject node to issue a characteristic write request.

gatttool

Node-RED shows the notification message after your write request is performed successfully.

Here in this tutorial, we use inject node to create characteristic write request parameters. However, this isn't the only way to do so. You can use other nodes than inject node. All you need is to prepare a valid JSON object for Generic BLE out node and provide it to the node.

In order to retrieve the written value from your BLE peripheral, go to the next step.

Characteristics Value Read

The both commands perform characteristic value read commands and return the same result, the characteristic value of the uuid f000aa02-0451-4000-b000-000000000000.

$ gatttool -b 88:99:00:00:FF:FF --char-read -u f000aa02-0451-4000-b000-000000000000
handle: 0x0027 	 value: ca

$ gatttool -b 88:99:00:00:FF:FF --char-read --handle=0x0027
Characteristic value/descriptor: ca

In this tutorial, we translate the above commands into Node-RED flow.

We use the following nodes this time.

  1. inject node to trigger a read command
  2. Generic BLE in node to perform the read command
  3. debug node to show the read value

gatttool

Put the above nodes onto your workspace and add connectors like above.

Open inject node dialog and enter the characteristic uuid at Topic input box. Leave default values other than Topic since Generic BLE in sees only the topic value.

You can also leave Topic empty when you want to retrieve all characteristics values.

gatttool

Click Done after entering the uuid to close the dialog. You need to configure Generic BLE in node to use your BLE peripheral but we skip to mention here as the instruction is described above (See How to configure a new BLE peripheral for detail).

Click Deploy to function the flow.

gatttool

Let's read the characteristic value by clicking inject node pedal. The read result will be displayed on the debug tab.

BLE in and out nodes

See info tab for detail on the editor UI.

Example Flow

You can import the example flow on Node-RED UI.

Installation Note (Linux)

The Node-RED process owner must belong to bluetooth group in order to access BlueZ D-Bus API, otherwise this node doesn't work at all because of bluetoothd permission issue. For example, if you're going to run the process by pi user, run the following command.

sudo usermod -G bluetooth -a pi

Then reboot the OS so that the policy changes take effect.

sudo reboot

Node-RED users

Run the following commands:

cd ~/.node-red
npm install node-red-contrib-generic-ble

Then restart Node-RED process. Again, for Linux users, read the above chapter Installation Note (Linux) to get this node working.

CANDY RED users

Run the following commands:

cd $(npm -g root)/candy-red
sudo npm install --unsafe-perm node-red-contrib-generic-ble

Then restart candy-red service.

sudo systemctl restart candy-red

Appendix

How to build

# build
$ NODE_ENV=development npm run build
# package
$ NODE_ENV=development npm pack
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].