国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

iOS7的iBeacon初步使用

2019-11-14 20:39:18
字體:
來源:轉載
供稿:網友

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


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 克山县| 阿合奇县| 平江县| 潮州市| 沾益县| 金阳县| 军事| 云龙县| 扎赉特旗| 宜君县| 陇南市| 庄浪县| 冕宁县| 西林县| 衡东县| 长沙市| 洛阳市| 诸暨市| 安平县| 南雄市| 图们市| 甘谷县| 大埔县| 栾城县| 山阴县| 宜丰县| 汶川县| 伊宁县| 安图县| 五台县| 岫岩| 阿尔山市| 怀来县| 略阳县| 禹州市| 綦江县| 丘北县| 桃园县| 银川市| 正蓝旗| 周至县|