iBeacon是iOS7的新增的功能,通过BLE实现室内定位,精确到厘米级别。

测试使用两台iPhone(支持BLE),一台作为iBeacon基站广播信号,代码使用官方源码AirLocate,另外一台作为接收端,直接使用的是App Store下载的AirLocate)。

1、广播端主要代码

NSDictionary *peripheralData = nil;
region = [[CLBeaconRegion alloc] initWithProximityUUID:self.uuid major:[self.major shortValue]
                minor:[self.minor shortValue] identifier:BeaconIdentifier];
peripheralData = [region peripheralDataWithMeasuredPower:power]; // The region's peripheral data contains the CoreBluetooth-specific data we need to advertise.
if(peripheralData)
{
        //开始广播
        [peripheralManager startAdvertising:peripheralData];
     }

2、接收端主要代码

  self.locationManager = [[CLLocationManager alloc] init];
  self.locationManager.delegate = self;    //接收端的uuid数组需要包含广播端的uuid
  for (NSUUID *uuid in [APLDefaults sharedDefaults].supportedProximityUUIDs)
{
CLBeaconRegion *region = [[CLBeaconRegion alloc] initWithProximityUUID:uuid identifier:[uuid UUIDString]];
self.rangedRegions[region] = [NSArray array];
} for (CLBeaconRegion *region in self.rangedRegions)
{
[self.locationManager startRangingBeaconsInRegion:region];
}

官方源码AirLocate:https://developer.apple.com/library/ios/samplecode/AirLocate/Introduction/Intro.html

App Store地址:https://itunes.apple.com/cn/app/airlocate/id716260068?mt=8

最新文章

  1. dotnet webapi 中添加Swagger文档
  2. 面试准备 - HashTable 的C#实现 开放地址法
  3. tomee.xml
  4. C# 如何使用 svcutil.exe 创建 WCF 客户端代码
  5. hiho_1050_树中的最长路
  6. New Distinct Substrings
  7. 这几天阅读的shadowgun的几个shader
  8. struts2框架的核心内容
  9. android 学习之RecyclerView
  10. 一天带你入门到放弃vue.js(二)
  11. Nginx调试入门
  12. 自动生成Excel 报表工具类
  13. visual studio 2017 installer 安装包的安装必备组件设置
  14. 扩展欧几里得,解线性同余方程 逆元 poj1845
  15. python面试题~反射,元类,单例
  16. java 冒泡排序 二分查找 选择排序 插入排序
  17. 【RF库XML测试】测试的XML文件说明
  18. mysql查询操作1
  19. Devexpress 百分号显示格式
  20. 对sssp项目搭建的补充,总错误处理。

热门文章

  1. python 读写三菱PLC数据,使用以太网读写Q系列,L系列,Fx系列的PLC数据
  2. Linux上jdk安装及环境变量设置
  3. Tiny4412 u-boot分析(3)u-boot 引导内核流程
  4. mysql/oracle ip地址比较
  5. java中的DAO设计模式
  6. Centos命令行窗口显示一大串前缀,777;notify;Command completed;的解决方法
  7. hdu-4432-Sum of divisors
  8. MVVMLight介绍以及在项目中的使用
  9. iOS开发系列-ARC浅解
  10. python一些不错的东西