Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Turn Macbook into iBeacon

I know that I can turn iOS devices into iBeacons (Can an iOS7 device act as an iBeacon?). Unfortunately, I only have one device and my beacons have not arrived yet. So I was wondering how I could turn my MacBook Air (Mid-2011, does support Bluetooth 4.0) into an iBeacon for testing purposes. Are there any ready-made applications available like the airlocate for iOS? Thanks in advance!

like image 460
user2887527 Avatar asked Oct 16 '13 17:10

user2887527


People also ask

Can an iPhone act as a iBeacon?

Overview. Any iOS device that supports sharing data using Bluetooth low energy can be turned into an iBeacon.

What is Apple's iBeacon?

Apple introduced the iBeacon protocol at the Apple Worldwide Developers Conference in 2013. iBeacon opened doors to a host of opportunities for location-data and proximity marketing. This protocol enables seamless interactivity between iOS and Android devices, and an iBeacon hardware, such as BLE beacons.

Is iBeacon a Bluetooth?

iBeacon is a small-scale network device that uses Bluetooth Low Energy (BLE) and acts as a transmitter to detect and track smartphones.


1 Answers

Note: This only works in Mavericks, it does NOT work in Yosemite.

Mavericks doesn't have the iBeacon support in Core Location that was added to iOS 7. However, Mavericks does now have the ability to act as an BLE peripheral device. Given that an iBeacon is basically a peripheral it should be (and indeed is) possible to use Mavericks as an iBeacon.

In order to create an iBeacon on iOS you first create a CLBeaconRegion object and then use the peripheralDataWithMeasuredPower: method to get an NSDictionary containing the necessary advertisement data to broadcast. If you take the contents of this NSDictionary from an iOS device and use it on Mavericks then you get an iBeacon.

I have created a class to make this easier and allow you to generate the advertisement data dictionary directly on Mavericks. The source code is available at https://github.com/mttrb/BeaconOSX

The BLCBeaconAdvertisementData class take the proximityUUID, major, minor and calibrated power values and creates an NSDictionary that can be passed to the startAdvertising: method of CBPeripheralManager on Mavericks.

The BLCBeaconAdvertisementData class is quite simple. The main work is done by the following method:

- (NSDictionary *)beaconAdvertisement {     NSString *beaconKey = @"kCBAdvDataAppleBeaconKey";      unsigned char advertisementBytes[21] = {0};      [self.proximityUUID getUUIDBytes:(unsigned char *)&advertisementBytes];      advertisementBytes[16] = (unsigned char)(self.major >> 8);     advertisementBytes[17] = (unsigned char)(self.major & 255);      advertisementBytes[18] = (unsigned char)(self.minor >> 8);     advertisementBytes[19] = (unsigned char)(self.minor & 255);      advertisementBytes[20] = self.measuredPower;      NSMutableData *advertisement = [NSMutableData dataWithBytes:advertisementBytes length:21];      return [NSDictionary dictionaryWithObject:advertisement forKey:beaconKey]; } 

I have a more detailed blog post about this at http://www.blendedcocoa.com/blog/2013/11/02/mavericks-as-an-ibeacon/

like image 67
mttrb Avatar answered Oct 13 '22 11:10

mttrb