get eaaccessory macaddress in swift

1.1k Views Asked by At

i have a bt 2.0 device with certified.

i can send/recv data with this bt device with eaaccessory input/output stream.

but i went to get the device's mac address

there is a ios9 eaaccessory header

https://github.com/JaviSoto/iOS9-Runtime-Headers/blob/master/Frameworks/ExternalAccessory.framework/EAAccessory.h

  • (id)macAddress;

how can i call this method ??

this app do not need submit to apple store.

2

There are 2 best solutions below

0
Alessandro Ornano On BEST ANSWER

Try to get value with:

let mac = myAccessory.valueForKey("macAddress")
print("mac address is: \(mac)")
0
didge On

Calling accessory.valueForKey("macAddress") may work, but you might also find that some manufacturers encode the MAC address in the accessory.serialNumber field.

For example, Epson Bluetooth printers' serial numbers are just their MAC addresses without the : separators.