38
votes

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!

7

7 Answers

22
votes

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/

13
votes

The best solution I've found so far is this one from Tim Duckett: https://github.com/timd/MactsAsBeacon

Just grab the project, set up a UUID, major, and minor value and click Broadcast. Really simple. The solution is based upon this blog post: http://www.blendedcocoa.com/blog/2013/11/02/mavericks-as-an-ibeacon/

4
votes

If you want to save the 9.99€ take a look at the latest Version of the open source client by mttrb. I added some more GUI so you can adjust all the fields. https://github.com/deadfalkon/BeaconOSX/releases even has a binary download.

4
votes

This is possible with OSX Mavericks, but not in Mountain Lion and earlier versions of the OS. My company, Radius Networks, has a MacBeacon app that does this on Mavericks.

In OSX Mountain Lion, unlike iOS 6+, there is no built-in support for the Bluetooth peripheral mode you need to advertise like an iBeacon. This means rolling your own low-level Bluetooth code, which is not easy to say the least.

But there is a solution for older operating systems. I paired an external Bluetooth dongle on my Mac with a VirtualBox VM running Linux and achieved what you are looking for. My company made this VM available for a free download here: http://developer.radiusnetworks.com/ibeacon/

3
votes

I tried all these solutions, but couldn't get AirLocate to pick up a signal until I complied this: https://github.com/lgaches/BeaconEmitter and started transmitting with this UUID: E2C56DB5-DFFB-48D2-B060-D0F5A71096E0 and with an identifier of: hello

I found this post about AirLocate useful as well: Does AirLocate only look for particular UUIDs?

1
votes

Yep its possible. Check out this github project https://github.com/nolim1t/iBeaconAdvertisement

0
votes

The only utility to turn a Mac into an iBeacon that worked for me under El Capitan (OS X 10.11) was iBeaconSwiftOSX. Also reported to work under Yosemite (OS X 10.10). The (free) iOS scanning utility used was iBeacon Loc from Eurelis.

FYI: on iOS, a scanner MUST search for a SPECIFIC combination of UUID and major/minor advertised by an iBeacon. Make sure scanner setup and iBeacon setup match.