EAAccessory.Name is not matching the paired device name
Asked Answered
R

2

6

I have an iOS application. I can successfully connect to my paired EAAccessory (Bluetooth Classic). I am able to pull information off of the device that is exposed through the EAAccessory object. One thing I noticed is that the name of the device that is paired (in my Settings -> Bluetooth -> My Devices list) does not match the name of the device that my EAAccessory object exposes. I find this very odd.

Is there any way to get the actual name of the device (the one from the Settings page) through my iOS app?

Richly answered 13/6, 2018 at 3:48 Comment(2)
How about using UIDevice.current.name for getting the name of device and UIDevice.current.model for getting the model of device.Patmos
@KeyurTailor Isn't UIDevice my current device and not the bluetooth connected device?Richly
C
1

You didn't mention if this is Bluetooth Classic or BLE ?, My answer below is for bluetooth Classic, I recall I've seen something like that before, here's my findings so far:

Take a look at the Accessory Design Guidelines, sections 2.1.5 and 2.1.8 specifically.

2.1.5:

During the Bluetooth discovery process, the Apple product prefers to display the Friendly Name of discovered accessories. Before the 2.1 version of the Bluetooth specification the Apple product would have to set up a connection to the accessory and do a Remote Name Request, which takes power, antenna time, and user's time. The Extended Inquiry Response feature, introduced in Bluetooth 2.1, lets an accessory send its Local Name and other information as part of the Inquiry Response and thereby increase the speed and efficiency of the discovery process. The Local Name should match the accessory's markings and packaging and not contain ':' or ';'.

Also review the Class of device section

2.1.8:

Every accessory that is compatible with an Apple product must accurately set its Class of Device using the Bluetooth SIG defined Major Device Class and Minor Device Class. See Volume 3, Part C, Section 3.2.4 in the Bluetooth Core Specification , Version 5.0. For example, an audio/video accessory intended to operate in a vehicle should set Major Device Class to audio/video and Minor Device Class to car-audio .

Your case might be just the fact that the accessory has a friendly name, and iOS did not clear the cache for the name at that point for the settings, or it could be a faulty implementation on the firmware side.

If this doesn't answer your question, please let me know what names do you see on settings and within your app, and what type of accessory this is with FW version if applicable and I'll try to take a further look into it.

Cheap answered 21/6, 2018 at 13:13 Comment(4)
Sorry, I assumed my putting 'EAAccessory' would denote it was classic. Yes, it is indeed Bluetooth classic. It is for a custom MFi device that does not have much for documentation sadly. On Android, using RFComm, it is able to see the proper device name. I asked about this and all I got in return was this message -- "The name is part of the bluetooth advertisement.". I wasn't sure through the EAAccessory framework that I could get access to the 'advertisement' data.Richly
Also, I don't want the bounty points to go to waste. I will grant you them but any help you can continue to give would be greatly appreciated.Richly
Thanks a lot for the bounty :). Do you have access to a Bluetooth sniffer by any chance ? Also, what kind of accessory is it ? And what is the “friendly” name that is being displayed ?Cheap
I will message you outside of the post if that's ok.Richly
F
0

It is possible to get the list of paired/connected devices if you have their advertisement UUID.

var centralQueu = DispatchQueue(label: "A_NAME")
centralManager = CBCentralManager(delegate: self, queue: centralQueu, options: [CBCentralManagerOptionRestoreIdentifierKey: "RESTORE_KEY", CBCentralManagerOptionShowPowerAlertKey: true])
ServiceUUIDs = [CBUUID(string: "THE_UUID")]
//the array of CBUUIDs which you are looking for

You need to find the service UUID in which you are interested:

var options = [
    CBCentralManagerScanOptionAllowDuplicatesKey : (1)
]
centralManager.scanForPeripherals(withServices: [CBUUID(string: SERVICE_UUID)], options: options)

centralManager.retrieveConnectedPeripherals(withServices: ServiceUUIDs)

handle didDiscoverperipheral in this way:

func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) {
    discoveredPeripheral = peripheral
    if !mRemoteDevices.contains(discoveredPeripheral) {
        let peripherels = centralManager.retrievePeripherals(withIdentifiers: [discoveredPeripheral.identifier])
        mRemoteDevices.append(peripherels[0])
    }
}

this code is converted from objective-C to swift if you are familiar with objective C then the original code is here.

Fatally answered 21/6, 2018 at 7:31 Comment(1)
Sorry, I think I needed to specify if it was Bluetooth Classic or not. I think this would only work for BLE correct?Richly

© 2022 - 2024 — McMap. All rights reserved.