0

i want to detect an altBeacon (transmitted by an Android Smartphone with the QuickBeacon App) with CoreBluetooth and Swift.

But when I search for a specific UUID the delegate method is not being called.

   func centralManagerDidUpdateState(central: CBCentralManager!){

    if (central.state == .PoweredOff) {
        println("CoreBluetooth BLE hardware is powered off")
    }
    else if (central.state == .PoweredOn) { 
        var UUIDObj:NSArray! = [CBUUID(string: "2f234454-cf6d-4a0f-adf2-f4911ba9ffa6")]
        self.centralManager.scanForPeripheralsWithServices(UUIDObj as [AnyObject], options: nil)
        NSLog("Scanning started"); }}

Normally this method should be called

func centralManager(central: CBCentralManager!, didDiscoverPeripheral peripheral: CBPeripheral!, advertisementData: [NSObject : AnyObject]!, RSSI: NSNumber!) {

When i change the Beacon Format to "iBeacon" it also don't work. Does anybody know how i can get the advertising values of the AltBeacon and iBeacon standard with coreBluetooth?

Update:

When i search for all peripheral devices i get this information from my AltBeacon:

in DidDiscoverPeripheral AdvertisementData: [kCBAdvDataIsConnectable: 0] RSSI: -47 Peripheral Name: nil , State: (Enum Value) , Services:nil, RSSI:nil,ID: <__NSConcreteUUID 0x17002edc0> A91CBF8C-DA69-B2FB-1A9A-CDDB60A48209 , Description:

But the UUID does not match with the given ID :(

user3143691
  • 1,533
  • 3
  • 11
  • 19
  • If you scan for peripheral without giving specific Service UUID, do you fid it? – Larme May 27 '15 at 09:58
  • It seems that AltBeacon doesn't advertise its services UUID. So, you can't scanForPeripheral filtering on a specific service UUID if it does broadcast one. – Larme May 27 '15 at 15:47
  • I broadcast the beacon signal with the QuickBeacon App of Radius Networks with my Nexus 6. Is it possible that the app or the Nexus 6 does not broadcast the right package? – user3143691 May 27 '15 at 15:57
  • It seems so. Since we can read in your logs: "Services:nil", it doesn't broadcast services. It may have the service, but doesn't broadcast it. – Larme May 27 '15 at 19:21
  • Do you think that a real AltBeacon (for example a RadBeacon) would broadcast the "right" advertisement data so that i could define the region by UUID? – user3143691 May 28 '15 at 09:22
  • A "real beacon" shouldn't be read with CoreBluetooth, but with CoreLocation. iOS separate both case. – Larme May 28 '15 at 09:24
  • But with CoreLocation I can scan only at 1 Hz. With CoreBluetooth it would be possible to scan with 10 Hz. This is the reason why I want to use CoreBluetooth. Do you have another solution? – user3143691 May 28 '15 at 09:28
  • No. A Beacon only advertise its UUID, Minor, Major, etc. The only way is to use CoreLocation. Even if it's BLE, Apple separates it, and since it analyze it, it won't allow you to find it with CoreBluetooth. – Larme May 28 '15 at 09:30
  • But in this post davidyound told something different: http://stackoverflow.com/questions/30373723/ibeacon-get-advertisement-package-faster – user3143691 May 28 '15 at 09:41
  • Seems that AltBeacon is not a real iBeacon, and is between both. So that may explains why you should be able to find it with CoreBluetooth. – Larme May 28 '15 at 09:43

1 Answers1

0

I can answer a part of your question: The CBCentralManager's delegate methods (e.g. func centralManagerDidUpdateState(central: CBCentralManager!)) are only called if you instantiate the manager with a queue, i.e. using init(delegate:queue:) or init(delegate:queue:options:) instead of just init()...

severin
  • 10,148
  • 1
  • 39
  • 40
  • The func 'centralManagerDidUpdateState' works with an normal init when I do not specify the service UUID. This is not the problem – user3143691 May 27 '15 at 11:39