3

I'm working with CoreBluetooth for the first time and trying to figure out how to filter down the list of devices to just RFID scanners. I've learned that there are pre-defined Service UUIDs for various types of devices, but I can't find any of those services that explicitly mention, or even seem to match up with, RFID Scanners.

However, in the Minor Device Class table that bits 5-2 for handheld RFID scanners should be 1000. I'm confused as to where that goes though. The Class of Device section describes what bits 23-0 are used for when defining various types of devices so I know those 5-2 bits go into that overall 23-0 bits collection... but I'm not sure how that overlaps/interacts with the service UUIDs or whether they interact at all.

For example, the common example I've found is that the Heart Rate service is defined with a shortened UUID of 0x180D, but that would be 32 bits, not 24 like the Device Class above.

Is there a Bluetooth Service UUID for RFID scanners? How can I filter the list of discovered devices so that I can only present the RFID scanners?

func startBluetoothScan() {
    print("starting bt scan...")
    self.centralManager.scanForPeripherals(withServices: nil,
        options: [CBCentralManagerScanOptionAllowDuplicatesKey: false]
    )
    print("started bt scan")
}

func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String: Any], rssi: NSNumber) {
    if self.discoveredPeripherals[peripheral.identifier] == nil {
        print("did discover bt peripheral (strength: \(rssi)): \(peripheral.name ?? "-") | \(advertisementData[CBAdvertisementDataLocalNameKey] ?? "-")")
        self.discoveredPeripherals[peripheral.identifier] = CBPeripheralInfo(peripheral: peripheral, data: advertisementData, rssi: rssi)
    }
}
Kenny Wyland
  • 20,844
  • 26
  • 117
  • 229
  • Does [this](https://github.com/MintPlayer/DagucarIRacerXamarin/blob/master/Activities/DiscoverActivity.cs) help you? It's c# but in Java it should be the same – Pieterjan Jul 25 '23 at 23:32
  • @Pieterjan No, that code is just generic BLE connection code in C#/Android. I'm trying to figure out how to filter down the list of devices that are being discovered so that I only get a certain type (i.e. RFID readers). – Kenny Wyland Jul 25 '23 at 23:59
  • Is there a Bluetooth Service UUID for RFID scanners? How can I filter the list of discovered devices so that I can only present the RFID scanners? -> You can pass the some part of unique service uuid in advertisement data and then scan using the service uuid – Arpit B Parekh Jul 26 '23 at 05:18

1 Answers1

4

There are certain services that are defined by the Bluetooth SIG - You give an example of one such; The heart rate service. These services are contained in the assigned numbers document.

These assigned services use a 16 bit value that is substituted into the base UUID of 0000xxxx-0000-1000-8000-00805F9B34FB - The actual service code for the heart rate service is 0000180d-0000-1000-8000-00805F9B34FB

Core Bluetooth recognises these 16 bit service identifiers and does the substitution for you.

The assigned GATT service ids are listed in section 3.4.1.

The 1 0 0 0 bits you refer to are in the peripheral device class section, not the GATT service section.

There does not appear to be a defined service for RFID scanners. I suspect that it would be likely for such a device to use the HID Bluetooth profile and appear as a keyboard, in which case it would not be visible to an iOS app via Core Bluetooth.

Manufacturers may also choose to expose their device via their own GATT services; You would need to refer to the documentation for the specific device.

Paulw11
  • 108,386
  • 14
  • 159
  • 186