2

I'm using core bluetooth with a programmable BLE device (CC2541). I'm trying to scan for peripherals using a specific service like this:

CBUUID* serviceID = [CBUUID UUIDWithString:  @"adabfb00-6e7d-4601-bda2-bffaa68956ba"];
[self.manager scanForPeripheralsWithServices:@[serviceID] options:nil];

I'm coming up empty but if I set 'scanForPeripheralsWithServices:' to nil then I get all my BLE devices to come up. So I know the BLE is sending out ads.

Here is what I get when I log advertisementData from centralManager:didDiscoverPeripheral:advertisementData:RSSI:

AdvData: {
    kCBAdvDataChannel = 38;
    kCBAdvDataIsConnectable = 1;
    kCBAdvDataLocalName = "JhBC_ZDHTMDRNg";
    kCBAdvDataTxPowerLevel = 0;
}

I'm expecting kCBAdvDataServiceUUIDs to come up like my other BLE devices but the CC2541 doesn't seem to advertise this value.

kCBAdvDataServiceUUIDs =     (
    "Unknown (<adabfb00 6e7d4601 bda2bffa a68956ba>)"
);

How do I get CC2541 to advertise the custom UUID?

Jay Q.
  • 4,979
  • 3
  • 33
  • 36
  • Have you tried modifying the SimpleBLEPeripheral example? – allprog Dec 31 '13 at 19:16
  • @allprog I don't have SimpleBLEPeripheral nor any other hardware. I was just handed the device. Is there a way I can enable UUID to be included in the advertisement by writing to a characteristic? – Jay Q. Jan 01 '14 at 01:22
  • CC2541 is just a chip. Can you tell what the device is? If it can be programmed, then you can probably upload the SimpleBLEPeripheral application on it. FYI: http://processors.wiki.ti.com/index.php/LPRF_BLE_Simple_Application – allprog Jan 01 '14 at 09:26
  • Here's the device: http://ankhmaway.en.alibaba.com/product/1447639232-218447309/IOS7_CC2541_iBeacon_UUID_programmable.html I'm able to change uuid, minor, major values – Jay Q. Jan 01 '14 at 10:53

1 Answers1

3

The device you are using is an iBeacon. As such, it is handled specially by iOS. It doesn't have advertised services or anything it just broadcasts a specific advertisement. For more info on the details checkout this page and this SO answer.

The device manufacturer does not seem to have provided the functionality to update the firmware so you can only use the SDK they provide. If you want to, you can try to flash the firmware but there is no guarantee that the device will accept it or if it will be operating at all. (This is similar to changing the firmware in your dish washer; you can try but most probably it will be broken by the end.) The SDK seems to support the change or every parameter an iBeacon advertises so it's pretty good.

Also, note that iBeacons should be used with CoreLocation for location services, but the setup functions are possible only on CoreBluetooth usually. The parameters are exposed as services and characteristics that you can discover after connection and make the necessary changes by modifying the values.

Community
  • 1
  • 1
allprog
  • 16,540
  • 9
  • 56
  • 97
  • You're right about the iBeacon profile lacking services (why you can't filter based on a service in the above code), but you I wouldn't necessarily say that you can't use it with Core Bluetooth. I've seen people do this by looking into the advertisement data (that you link to in that SO answer) and filtering based on what devices are advertising what. – Brad Larson Jan 01 '14 at 18:46
  • @BradLarson This is why I said `should be used` :) The usage with Core Bluetooth is quite limited and can only be done in the foreground. Though, I guess ranging with CoreBluetooth is a lot more precise than with CoreLocation as the latter hides the RSSI and invokes callbacks according to some sophisticated heuristics which is sometimes not appropriate. – allprog Jan 01 '14 at 20:29
  • @allprog The "SDK" they provided is essentially just a source to a CoreBluetooth app that scans for services and write to characteristics. It even allows you ring the device. So I'm guessing this isn't exactly your standard iBeacon that has no services. Thanks for all the info! – Jay Q. Jan 02 '14 at 04:48
  • Thank you. I amended the description to better reflect the real situation. This is exactly how an iBeacon should operate, I guess. – allprog Jan 02 '14 at 10:34