IOS Bluetooth Get MAC Address

Source: Internet
Author: User

Cited by: http://www.jianshu.com/p/1d6a8fc8134f

iOS to get Bluetooth device MAC address There are two: first, the hardware engineer to open the service characteristics of the MAC information, we get from the channel, and the second is the hardware engineer in the scan device information placed in the MAC information, we get from the Rssi function

1. As you can see on other sites on the service of a board module, such as: "A180", which has acquired the characteristics of the Mac. Here we skip, because other places are very clear, the invocation of the Office also has. Requires hardware provisioning and adding service features.

2. Is obtained in the function with Rssi.

First let the hardware engineer write the MAC information on the Board module.

-(void) Centralmanager: (Cbcentralmanager *) Central diddiscoverperipheral: (cbperipheral *) Peripheral Advertisementdata: (nsdictionary *) advertisementdata Rssi: (NSNumber *) Rssi
- (void) Centralmanager: (Cbcentralmanager *) Central diddiscoverperipheral: (cbperipheral *) Peripheral Advertisementdata: ( Nsdictionary<nsstring *, id> *) advertisementdata RSSI: (NSNumber *) rssi{//Get MacNSLog (@"%@ ", peripheral); NSLog (@"%@ ", Peripheral.name); NSLog (@"%@ ", peripheral.identifier.UUIDString); NSData*data = [Advertisementdata objectforkey:@"Kcbadvdatamanufacturerdata"]; NSString*astr=[[NSString alloc] Initwithdata:data encoding:nsutf8stringencoding];//nsstring *mac = [Nsstringtool converttonsstringwithnsdata:data];ASTR = [AStr stringbyreplacingoccurrencesofstring:@" "Withstring:@""]; NSLog (@"astr:%@", ASTR); NSLog (@"advertisementdata:%@", Advertisementdata); //a perimeter may be found many times    if(![_peripheralarr containsobject:peripheral])        {[_peripheralarr addobject:peripheral]; if([Self.Delegaterespondstoselector: @selector (blemanagerupdatedevicelist)]) {[Self.DelegateBlemanagerupdatedevicelist]; }    }}

You can see there is a advertisementdata, this dictionary type is the broadcast packet, there will be some device properties, such as the name of the device, service Ah, etc., but are limited by Apple, so it is not your hardware engineers want to broadcast anything can.
This dictionary has a: only this key can be put into the information, so the hardware engineer to write the MAC address in this field, so you can find the device in the process of getting MAC address!

Key:kcbadvdatamanufacturerdata

IOS Bluetooth Get MAC Address

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.