1

I have discovered that Core Bluetooth Peripheral Discovery seems to return different results for Mac, and iOS.

iOS seems to give me a lot more info, in the discovery callback, while the Mac seems extremely sparse.

I'm wondering if anyone could shed light on why, exactly, this is.

The test project I created is about as simple as you can get (NOTE: The link I just gave was for an initial "super-simple" version of the project. The current head is a bit more robust).

I have a pretty much default "Hello World" SwiftUI project, with targets for MacOS and iOS, using a shared ContentView that also instantiates a VERY simple CBCentralManagerDelegate object, and prints discovery info to the console.

I will simply paste the contents of the README, below. It should explain the issue. The two console dumps were made from my Mac and my iPhone, about six inches apart, and about thirty seconds apart.

BTW: You need to run the iOS target on a device. The simulator won't work.

——-

STRANGE CORE BLUETOOTH ISSUE

This project contains about the simplest comparison I can make for testing this.

This is the GitHub repo for this project

THE ISSUE

When a MacOS app gets the centralManager(_ central: CBCentralManager, didDiscover: CBPeripheral, advertisementData: [String : Any], rssi: NSNumber) callback, it delivers different data on the Mac, than on iOS.

The code is EXACTLY the same between them. I use a simple shared SwiftUI view to instantiate a dirt-simple CentralManager, and display discovered devices.

On iOS, I get the names of the devices.

On the Mac, I fail to get most of the names.

iOS console log:

Discovered "Soulcatcher"
Discovered "Croaker"
Discovered "One-Eye"
Discovered "[TV]Living Room TV"
Discovered "Soulcatcher"
Discovered "NO NAME!"
Discovered "Desk"
Discovered "NO NAME!"
Discovered "Lady"
Discovered "Eve Light Switch 60"
Discovered "NO NAME!"
Discovered "Tom-Tom"
Discovered "The Limper"
Discovered "TV"
Discovered "NO NAME!"
Discovered "NO NAME!"

Mac console log:

Discovered "NO NAME!"
Discovered "NO NAME!"
Discovered "NO NAME!"
Discovered "NO NAME!"
Discovered "NO NAME!"
Discovered "NO NAME!"
Discovered "NO NAME!"
Discovered "NO NAME!"
Discovered "NO NAME!"
Discovered "NO NAME!"
Discovered "NO NAME!"
Discovered "NO NAME!"
Discovered "NO NAME!"
Discovered "NO NAME!"
Discovered "Eve"
Discovered "Eve Light Switch 60CC"
Discovered "NO NAME!"
Discovered "NO NAME!"
Discovered "NO NAME!"
Discovered "NO NAME!"
Discovered "NO NAME!"
Discovered "NO NAME!"
Discovered "NO NAME!"
Discovered "Eve"
Discovered "Eve Light Switch 60CC"
Discovered "NO NAME!"
Discovered "NO NAME!"
Discovered "NO NAME!"
Discovered "NO NAME!"
Discovered "NO NAME!"
Discovered "NO NAME!"
Discovered "NO NAME!"
Discovered "NO NAME!"
Discovered "NO NAME!"
Discovered "NO NAME!"
Discovered "NO NAME!"
Discovered "NO NAME!"
Discovered "NO NAME!"
Discovered "NO NAME!"
Discovered "NO NAME!"
Discovered "NO NAME!"
Discovered "NO NAME!"
Discovered "NO NAME!"
Discovered "NO NAME!"
Discovered "NO NAME!"
Discovered "NO NAME!"
Discovered "NO NAME!"
Discovered "NO NAME!"
Chris Marshall
  • 4,910
  • 8
  • 47
  • 72
  • Boy, the tumbleweeds are blowing around this question, eh? I'm pretty sure it's a bug (not a serious one, but a bug, nonetheless). I'll be doing a bit more poking around, then I may report it. – Chris Marshall Jul 21 '20 at 09:14
  • I will leave this unanswered, but it really appears to be buggy behavior. I reported it as such, but I have scant hope that Apple will actually do anything about it. I suspect they want Mac people to use IOBluetooth, and Core Bluetooth is really meant for iOS. It also behaves a bit differently for TVOS, so I guess that TV is out, too. – Chris Marshall Jul 29 '20 at 17:42

0 Answers0