A general test to build a connection to a low power bluetooth device
This write up assumes you have node with NPM installed. If not please install node and NPM on your system.
The js files listed below are example files from the noble git repository
- Clone this project
$ git clone https://github.com/carynewfeldt/btconnector.git
- Change in the the btconnector folder
$ cd btconnector
- Issue a npm install command
$ npm install
-
You will see a number of node modules being installed to your system
-
To test the bluetooth connection to a number of devices
-
Call the node advertisement-discovery.js file to connect to all bluetooth devices in your vicinity
$ node advertisement-discovery.js hello my local name is: Apple TV can I interest you in any of the following advertised services: [] here is my manufacturer data: "0000000000000000000000" You will see other devices here as well.
- To test the bluetooth connection to a specific device
- In the peripheral-explorer.js add the device UUID to the peripheralUuid variable.
var peripheralUuid = "1c234567cc24acc4c2c2e0e03cfc123";
- Ensure your device is in discover mode
- Call the node peripheral-explorer.js file to connect to the specified bluetooth device
$ node peripheral-explorer.js
- You will see the following if connection is successful
peripheral with UUID 1c234567cc24acc4c2c2e0e03cfc123 found Local Name = DEVICE_NAME TX Power Level = 3 Manufacturer Data = ffff12345f Service Data = [object Object] Service UUIDs = { localName: 'DEVICE_NAME', txPowerLevel: 3, manufacturerData: , serviceData: [ { uuid: '180a', data: } ], serviceUuids: [] } services and characteristics: 180a (Device Information) 2a29 (Manufacturer Name String) (Manufacturer) properties read value 000000000000000000000000000000000000 | '' 2a24 (Model Number String) properties read value 000000000000000000000000000000000000 | 'E\' 2a25 (Serial Number String) properties read value 0000000000000000000000 | '' 2a27 (Hardware Revision String) properties read value 0000000000000000000000 | '' 2a26 (Firmware Revision String) properties read value 0000000000000000000000 | '' 3ea0 3ea1 (PPG) properties notify 3ea8 (EDA) properties notify 3ea3 (ACC) properties notify 3ea6 (ST) properties notify 3e70 3e71 (DEVICE command) properties write 3eb0 3eb2 (DEVICE Control) properties notify 3eb3 (Battery) properties notify