don/ionic-ble-examples

scan filtered by services seems not to work?

Closed this issue · 1 comments

Hi there,

I am developing a simple app to connect to a BLE device. My first approach worked like a charm:

  • Scan all (without any "services" filter) BLE devices and list them.
  • Select one device and show the peripheral data.

The code except would be like this

this.ble.scan([], 5)
    .subscribe(
        device => { devices.push(device); console.log('New device discovered: ' + device); },
        error => { console.log('Error scanning: ' + error); });

Here the problem comes when I add a service filter in order to list only certain devices. This service UUID is "0003cdd0-0000-1000-8000-00805f9b0131" so, as API explains, I was supposed to do the following

var myService = '0003cdd0-0000-1000-8000-00805f9b0131';

this.ble.scan([myService], 5)
    .subscribe(
        device => { devices.push(device); console.log('New device discovered: ' + device); },
        error => { console.log('Error scanning: ' + error); });

It simply does not discover any device, even when I have 2 of them in my desktop.

What am I doing wrong? Any help would be very appreciated.

Notes: I have already checked the communication (read and write) with such service+characteristic in both devices.

Sorry, this issue does not belong to this project but to cordova-plugin-ble-central.

My bad 😞