Bluez Blotoothctl Scan VS Hcitool Scan

Why are two different BLE adapters show different devices when scanning?

I will try to help you with this one.

It seems that there is something wrong with your PixiePro device, however information you’ve provided is not enough to diagnose the issue.

It could be a problem with either the device itself, or Bluez stack, or, simply because the devices are out of the detectable range of the PixiePro device.

In order to debug your issue you may try to do the following:

  • First of all check mac-addresses, uuid, major and minor values of
    your devices. Usually you may find this information on the web-portal
    of your iBeacon vendor;

  • Ensure that all of the devices are turned on and working. The simplest way
    is to check whether they are detected by a mobile phone. You may
    install free iOS or Android application. You should be able to detect all of your devices. Also check the RSSI values of every iBeacon device. Please note that values will vary even though they can be at the same distance from the phone to the iBeacon. However, the behavior, while you are moving them further or closer to the receiving device, should be clearly recognized by the mobile application;

  • Once you are 100% sure that all of the iBeacon devices are
    working properly, you should be able to detect the mac-addresses on
    your board devices.
    To do this, I’d recommend to run the hcitool in
    the first terminal window and the hcidump tool in the second
    without any additional parameters. Unlike the hcitool command it
    will also output the RSSI values of captured packets like this:

    HCI Event: LE Meta Event (0x3e) plen 42 
    LE Advertising Report
    ADV_NONCONN_IND - Non connectable undirected advertising (3)
    bdaddr 02:AB:26:D4:9A:EE (Public)
    Flags: 0x1a
    Unknown type 0xff with 25 bytes data
    RSSI: -72

These values will help you to compare the behavior of scanning on different devices. DON’T expect them to be equal everywhere, these are simply relative values. Now try to move each of your devices close to your receiving board(s) and you should be able to see its mac-address in the output of the hcidump tool. 

  • In this case if you still don’t see your iBeacon devices then for
    sure there is an issue somewhere in your boards. It could be either
    hardware or software. This is where I’d recommend:

    1. Install the
      latest firmware, which may fix bugs in the BLE stack
      implementation.
    2. If this approach doesn’t help - then it means that the
      issue lies somewhere in the hardware and, therefore, the only thing you
      can do is to replace your board device.

Good luck!

If any questions, feel free to ask!

Capture bluetooth beacons from a specific device

When a new device is discovered BlueZ indicates this with [NEW]. When a property of an already discovered device CHanGes then it uses [CHG].

BlueZ allows discovery report to be filtered with SetDiscoveryFilter. More information at: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/adapter-api.txt

In bluetoothctl this is accessed from commands under menu scan.

If you want to do this with code I would generally recommend using the API's provided by BlueZ and documented at:
https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc

I have posted a Python example before at:
bluetootctl scan on parsing

The BlueZ D-Bus APIs can be accessed from any programming language that has D-Bus bindings.

hcitool lescan does not work on Bluetooth version 5

gatttool and hcitool were both deprecated back in 2017.

D-Bus API is documented at: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc

And there are examples at: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/test.

For exploration on the command line then either btmgmt or bluetoothctl should cover most situations.



Related Topics



Leave a reply



Submit