use*_*527 37 macos bluetooth-lowenergy ibeacon
我知道我可以将iOS设备变成iBeacons(iOS7设备能否充当iBeacon?).不幸的是,我只有一台设备而且我的信标尚未到达.所以我想知道如何将我的MacBook Air(2011年中期,支持蓝牙4.0)转换为iBeacon用于测试目的.是否有现成的应用程序,如iOS的airlocate?提前致谢!
mtt*_*trb 22
注意:这仅适用于Mavericks,它不适用于Yosemite.
小牛队在核心位置没有添加到iOS 7的iBeacon支持.但是,Mavericks现在可以充当BLE外围设备.鉴于iBeacon基本上是一个外设,它应该(实际上)可以使用Mavericks作为iBeacon.
要在iOS上创建iBeacon,首先要创建一个CLBeaconRegion对象,然后使用该peripheralDataWithMeasuredPower:方法获取NSDictionary包含要广播的必要广告数据.如果您NSDictionary从iOS设备获取此内容并在Mavericks上使用它,那么您将获得iBeacon.
我创建了一个类来使这更容易,并允许您直接在Mavericks上生成广告数据字典.源代码可从https://github.com/mttrb/BeaconOSX获得
的BLCBeaconAdvertisementData类取proximityUUID,major,minor和校正的功率值,并创建可被传递到一个NSDictionary startAdvertising:的方法CBPeripheralManager对小牛.
这BLCBeaconAdvertisementData堂课很简单.主要工作是通过以下方法完成的:
- (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];
}
Run Code Online (Sandbox Code Playgroud)
我在http://www.blendedcocoa.com/blog/2013/11/02/mavericks-as-an-ibeacon/上有更详细的博客文章.
Jam*_*ost 12
到目前为止我找到的最好的解决方案是来自Tim Duckett的这个:https://github.com/timd/MactsAsBeacon
只需抓取项目,设置UUID,主要和次要值,然后单击"广播".真的很简单.该解决方案基于以下博客文章:http://www.blendedcocoa.com/blog/2013/11/02/mavericks-as-an-ibeacon/
这在 OSX Mavericks 中是可能的,但在 Mountain Lion 和早期版本的操作系统中则不行。我的公司 Radius Networks 有一个MacBeacon应用程序可以在 Mavericks 上执行此操作。
在 OSX Mountain Lion 中,与 iOS 6+ 不同,没有内置支持您需要像 iBeacon 那样宣传的蓝牙外设模式。这意味着滚动您自己的低级蓝牙代码,这至少可以说并不容易。
但对于较旧的操作系统有一个解决方案。我将 Mac 上的外部蓝牙适配器与运行 Linux 的 VirtualBox VM 配对,并实现了您想要的效果。我的公司在此提供此 VM 供免费下载: http ://developer.radiusnetworks.com/ibeacon/
| 归档时间: |
|
| 查看次数: |
38227 次 |
| 最近记录: |