chrvadala / node-ble

Bluetooth Low Energy (BLE) library written with pure Node.js (no bindings) - baked by Bluez via DBus
https://www.npmjs.com/package/node-ble
MIT License
315 stars 46 forks source link

Service in UUIDs list not accessible via GattServer getPrimaryService() #2

Closed robmckinnon closed 1 year ago

robmckinnon commented 4 years ago

I'm trying to write to a MIDI characteristic of a MIDI service. The MIDI UUIDs are:

const midiServiceUUID = '03b80e5a-ede8-4b33-a751-6ce34ec4c700';
const midiCharacteristicUUID = '7772e5db38684112a1a9f2669d106bf3';

I can see the MIDI service UUID in the UUIDs property list:

> gattServer.helper.props().then(x => console.log(x))

> { Address: 'C7:26:DE:18:ED:28',
  AddressType: 'random',
  Name: 'MD-BT01',
  Alias: 'MD-BT01',
  Paired: true,
  Trusted: false,
  Blocked: false,
  LegacyPairing: false,
  RSSI: -91,
  Connected: true,
  UUIDs:
   [ '00001800-0000-1000-8000-00805f9b34fb',
     '00001801-0000-1000-8000-00805f9b34fb',
     '0000180a-0000-1000-8000-00805f9b34fb',
     '03b80e5a-ede8-4b33-a751-6ce34ec4c700' ], // <- midiServiceUUID
  Adapter: '/org/bluez/hci0',
  ServicesResolved: true }

However I can only see two service children nodes:

> gattServer.helper.children().then(x => console.log(x))

> [ 'service0008', 'service000c' ]

Trying to get to the MIDI service UUID fails:

> gattServer.getPrimaryService(midiServiceUUID).then(s => {
    console.log(s);
  }, (e) => console.log(e));

> Error: Service not available
    at GattServer.getPrimaryService (/home/pi/apps/mpr121_touch_midi/node_modules/node-ble/src/GattServer.js:41:11)

I can get two of the other service UUIDs:

> gattServer.getPrimaryService('00001801-0000-1000-8000-00805f9b34fb').then(s => {
...   s.helper.props().then(x => console.log(x));
... }, (e) => console.log(e));

> { UUID: '00001801-0000-1000-8000-00805f9b34fb',
  Device: '/org/bluez/hci0/dev_C7_26_DE_18_ED_28',
  Primary: true,
  Includes: [] }

> gattServer.getPrimaryService('0000180a-0000-1000-8000-00805f9b34fb').then(s => {
...   s.helper.props().then(x => console.log(x));
... }, (e) => console.log(e));

> { UUID: '0000180a-0000-1000-8000-00805f9b34fb',
  Device: '/org/bluez/hci0/dev_C7_26_DE_18_ED_28',
  Primary: true,
  Includes: [] }

Any ideas on how to access the MIDI Service UUID 03b80e5a-ede8-4b33-a751-6ce34ec4c700?

chrvadala commented 4 years ago

Unfortunately I don't have a MIDI device to test. Do you have some BLE MIDI simulator?

Anyway, I suggest you to debug bluez connection, through d-feet. Basically you should be able to perform the same node-ble operations directly on the bluez driver. Then you can identify if it is a node-ble issue or a wrong bluez configuration.

chrvadala commented 1 year ago

This issue was closed because it has been stalled for a lot of days with no activity. Feel free to create a new issue or discussion