juliansteenbakker / flutter_ble_peripheral

A Flutter package for advertising BLE data in peripheral mode
BSD 3-Clause "New" or "Revised" License
72 stars 50 forks source link

The advertised service doesn't show up in any scans #113

Open MrCsabaToth opened 1 year ago

MrCsabaToth commented 1 year ago

I experimented with the example app. Unfortunately I couldn't get it to work: the advertised service doesn't show up in any scans. I'm using a OnePlus Nord Android phone with Android 12 which supposedly supports peripheral mechanisms. The example code doesn't give me any error messages, Bluetooth is enabled and the app has permissions. I tried both the Advertise method and the AdvertiseSet. I'm trying to scan the BLE peripheral with other Android phones using nRF Connect, an iPad with nRF Connect and my laptop (Linux with BlueZ).

  final AdvertiseData advertiseData = AdvertiseData(
    // FTMS
    serviceUuid: '00001826-0000-1000-8000-00805f9b34fb',
    // Indoor Bike
    serviceDataUuid: '00002ad2-0000-1000-8000-00805f9b34fb', // kinda mute without being able to send data
    // according to zwifit/src/ble/enable.js buildAdvertisingData
    serviceData: Uint8List.fromList([2, 0x01, 0x05, 3, 0x03, 0x18, 0x26]),
    // Precor
    manufacturerId: 1819,
    // By the FTMS specification chapter 3
    manufacturerData: Uint8List.fromList([0, 0x18, 0x26, 1, 32, 0]),
  );

  final AdvertiseSettings advertiseSettings = AdvertiseSettings(
    connectable: true,  // I was just trying this if it may help
    advertiseMode: AdvertiseMode.advertiseModeBalanced,
    txPowerLevel: AdvertiseTxPower.advertiseTxPowerMedium,
    timeout: 3600,
  );

  final AdvertiseSetParameters advertiseSetParameters = AdvertiseSetParameters(
    // connectable: true,  // I was just trying this if it may help
    scannable: true,  // I was just trying this if it may help
    txPowerLevel: txPowerMedium,
    duration: 3600,
  );

It's another issue that if I'd see that service I don't seem to find a way to actually communicate data, which kinda makes the whole experiment mute: it has no value if I cannot communicate (#85). But even the mute service does not seem to show.

microgeniusz80 commented 1 year ago

I/BluetoothLeAdvertiser(15672): startAdvertisingSet, calling package name = dev.steenbakker.flutter_ble_peripheral_example I/BluetoothAdapter(15672): isLeEnabled(): ON I/FlutterBlePeripheral(15672): onStartSuccess() mode: 2, txPOWER 1 I/BLE Peripheral state (15672): advertising I/BluetoothLeAdvertiser(15672): stopAdvertising is called I/BluetoothLeAdvertiser(15672): stopAdvertisingSet, calling package name = dev.steenbakker.flutter_ble_peripheral_example

it seems that as soon as I/BLE Peripheral state (15672): advertising happened, within a second: I/BluetoothLeAdvertiser(15672): stopAdvertising is called

causing, it not to show any advertisement