Android Question BLE Manager Scan with UUID parameter

Discussion in 'Android Questions' started by John-E, Jan 28, 2015.

  1. John-E

    John-E Member Licensed User

    Hello All,

    I'm trying (hoping) to scan for particular devices using a service UUID. General scanning works fine, as cribbed from the BLE-extended example:
    Manager.Scan(3000, Null)
    finds devices without a problem. I can check the returned name and connect to it if I like.

    But I can't make Manager.Scan(Period, UUID-array) work. I create an array of strings with a couple of UUIDs in it valid for the target device, but passing this instead of Null just results in the scan passing without the device being found. The UUIDs are of the form "3a245ce8-0e73-451d-a01a-bb802deb9c62", and are definitely correct. It is also the only device present. I have captured the UUIDs from the functioning Null scan result just to make sure. What is the wrinkle I must be missing here?

    merlin2049er likes this.
  2. Erel

    Erel Administrator Staff Member Licensed User

    You are passing the service uuid, right? (not device Mac or characteristic).

    I'm checking the relevant code and it looks correct.
  3. John-E

    John-E Member Licensed User

    Hello Erel,

    Yes, I am passing a 128 bit service UUID:

    From the device GATT:
    <service uuid="3a245ce8-0e73-451d-a01a-bb802deb9c62">
    <characteristic uuid="dd603001-e978-4894-b822-25108e75af70" id="never_mind">
    <properties indicate="true"/>
    <value variable_length="true" length="4" />

    Dim uuid_ra(2) As String
    uuid_ra(0) = "3a245ce8-0e73-451d-a01a-bb802deb9c62"
    uuid_ra(1) = "00431c4a-a7a4-428b-a96d-d92d43c8c7cf"
    Manager.Scan(3000, uuid_ra)

    The very first service in the device GATT is the name service, UUID="1800", but it chokes on that one as soon as it calls Manager.Scan, so I've skipped that one. There is no significance in the order of the services in the GATT, so there is no requirement that any particular service would be the first entry. I presume it would need the short-form UUIDs such as Name or Battery (180F) to be expanded to the full 128 bit UUID, which is a nuisance, but BLE is an extraordinarily complex way of sending very short data packets anyway.

    In my case, the device with my particular service will always have a known name, so there is no actual benefit here, just curiosity; please don't spend much time on it.


    I tried with the expanded name service UUID "00001800-0000-1000-8000-00805f9b34fb", which is the very first service, no difference.
    Last edited: Jan 29, 2015
  4. Erel

    Erel Administrator Staff Member Licensed User

  5. John-E

    John-E Member Licensed User


    Well, thanks for finding that. It also explains why I couldn't get it to work device-to-device using BlueGiga BLE112 modules either. Simply just checking the name will do for me in this case.

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice