我正在研究BLE
(蓝牙LE)应用程序,该应用程序与硬件设备连接。 我能够发现并连接到设备,从设备读取数据,将数据写入设备。从BLE设备获取通知
我在苹果的BLE文档中找不到什么东西,当你靠近设备,应用程序靠近时,如何获得通知。
我知道如何注册到characteristic
通知,但只有当应用程序在后台时才会发生此通知。
我知道iBeacon
可以在应用程序关闭时检测到蓝牙,并发送通知,但是当设备发现某个的某个BLE时,我想要收到通知。
iBeacon,正在使用BLE UUID
和major and minor
字段,我不需要/不想要。我只想注册一个来自BLE的某个UUID
的通知。
我这样做,没有任何回应:
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
[self initRegion];
- (void)initRegion
{
NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:@"4AD3FADF-F179-4343-0000-000000000000"];
self.beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:uuid identifier:@"BLE-NAME"];
[self.locationManager startMonitoringForRegion:self.beaconRegion];
}
- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region {
[self.locationManager startRangingBeaconsInRegion:self.beaconRegion];
NSLog(@"ENTER");
}
-(void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region {
[self.locationManager stopRangingBeaconsInRegion:self.beaconRegion];
NSLog(@"EXIT");
}