Get the MAC address of your Bluetooth device using the Apples "External Accessory Infrastructure"

I have an Apple compatible Bluetooth device.

Now I am trying to get the MAC address of this device in the application. Can I get the MAC address of a Bluetooth device using the “External Accessory Cell”?

I heard that it is impossible to get the MAC address in the usual way, but I don’t understand the “external accessory infrastructure” well enough to decide if this is possible with this structure or not.

+4
source share
3 answers

No, you cannot get the address of EAAccessory mac. I mean, you can use the following command:

 NSString *macAddress = [accessory valueForKey:@"macAddress"]; 

But it is not documented, as you can see in EAAccessory docs . Apple may reject your application, or this feature may stop working with the next iOS update, etc.

If you are just trying to create a custom action on a specific device model, in most cases you can use one of the available information:

 <EAAccessory: 0x17445c180> { connected:YES connectionID:29354791 name: 23HG YKL CXN manufacturer: MANUFACTURER NAME modelNumber: 878253-222 serialNumber: //not always available firmwareRevision: 1.0.0 hardwareRevision: 1.0.0 protocols: ( "com.some.protocol", "com.some.other.protocol" ) } 

Or a combination of its type (modelNumber + firmwareRevision), etc.

PS: I know that with the information above, you do not know the difference between two identical devices, but depending on what application you are developing, it does not matter.

Hope this helps.

+4
source

Try the following:

 NSString *macAddress = [accessory valueForKey: @"macAddress"]; 

but I noticed that this is only working with the latest devices. (iPad 1 accessory does not match key value for "macAddress" code)

Take a look at the entire helper dictionary for more keys:

 NSLog(@"%@", accessory); 
+1
source

The short answer is no, you cannot do this.

The reason is that all that the infrastructure of an external accessory does is configure the input and output data streams with the device. If you want to get the MAC address from the hardware, the hardware must provide this information through any communication mechanism that they have created for their devices and the associated iOS software.

0
source

Source: https://habr.com/ru/post/1398117/


All Articles