- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
有没有办法找出 altBeacon 的主要值和次要值?我正在使用这个库 ( https://github.com/CharruaLab/AltBeacon ) 来检测附近的 BLE 设备(无论是否有信标)。检测到信标,我知道它们的 uuid。我可以使用 iOS CoreBluetooth 框架提取主要值和次要值吗?
更新:代码看起来不错。看起来找出主要或次要的唯一方法是请求信标的数据,因为它在下面接受的答案中完成。但是在这种情况下,信标本身不一定会响应您。
最佳答案
覆盖下面的 CLLocationManager
委托(delegate)方法,当您能够检测到信标时,将调用此方法。
-(void)locationManager:(CLLocationManager*)manager
didRangeBeacons:(NSArray*)beacons
inRegion:(CLBeaconRegion*)region {
// Beacon found!
CLBeacon *foundBeacon = [beacons firstObject];
// You can retrieve the beacon data from its properties
NSString *uuid = foundBeacon.proximityUUID.UUIDString;
NSString *major = [NSString stringWithFormat:@"%@", foundBeacon.major];
NSString *minor = [NSString stringWithFormat:@"%@", foundBeacon.minor];
}
要使用 Core 定位框架检测信标,您需要在 viewDidLoad
方法中添加以下代码。
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
// Initialize location manager and set ourselves as the delegate
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
// Create a NSUUID with the same UUID as the broadcasting beacon
NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:@"XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"];
// Setup a new region with that UUID and same identifier as the broadcasting beacon
self.myBeaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:uuid
identifier:@"com.app.identifier"];
// Tell location manager to start monitoring for the beacon region
[self.locationManager startMonitoringForRegion:self.myBeaconRegion];
// Check if beacon monitoring is available for this device
if (![CLLocationManager isMonitoringAvailableForClass:[CLBeaconRegion class]]) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Monitoring not available" message:nil delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles: nil];
[alert show];
}
}
使用两个委托(delegate) CBCentralManagerDelegate
和 CBPeripheralDelegate
扩展 View Controller
在 viewDidLoad
中创建 CBCentralManager
对象。
_centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
并覆盖以下方法(scan
方法除外):
- (void)centralManagerDidUpdateState:(CBCentralManager *)central {
if (central.state != CBCentralManagerStatePoweredOn) {
return;
}
// The state must be CBCentralManagerStatePoweredOn...
// ... so start scanning
[self scan];
}
- (void) scan {
// UUID for peripheral services
[self.centralManager scanForPeripheralsWithServices:[NSArray arrayWithObject:[CBUUID UUIDWithString:@"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX"]] options:nil];
NSLog(@"Scanning started");
}
- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI {
NSLog(@"Discovered %@ at %@", peripheral.name, RSSI);
if (self.discoveredPeripheral != peripheral) {
// Save a local copy of the peripheral, so CoreBluetooth doesn't get rid of it
self.discoveredPeripheral = peripheral;
// And connect
NSLog(@"Connecting to peripheral %@", peripheral.UUID);
[self.centralManager connectPeripheral:peripheral options:nil];
}
}
- (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral {
NSLog(@"Peripheral Connected");
// Stop scanning
[self.centralManager stopScan];
NSLog(@"Scanning stopped");
// Make sure we get the discovery callbacks
peripheral.delegate = self;
[peripheral discoverServices:nil];
}
关于ios - iOS 下 altBeacons 上的 Major 和 Minor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28582532/
我一直在尝试使用 altbeacon library 连接到 Jaalee 信标没有成功。服务 UUID 为 0x00001532-1212-EFDE-1523-785FEABCD123altbeac
我正在尝试使用 Altbeacon 解析 Estimote Nearable 数据包格式: 我有 IBeacon 的引用: // Apple iBeacon beaconManager.getBeac
我正在尝试使用自定义数据创建 AltBeacon。我看到了 AltBeacon 协议(protocol)格式( https://github.com/AltBeacon/spec ),但我不知道如何模
我正在尝试使用 AltBeacon/android-beacon-library。我从 reference app 开始.按照所有说明设置应用程序,但它仍然找不到周围的任何信标。我也试过定位应用程序,
我正在开发一个也使用后台扫描的应用程序。参见 Using AltBeacon: start and stop scanning from app settings 我观察到一个奇怪的行为。当我从设备设
我想扫描我周围的任何一种信标。基本上,如果我理解正确的话,您需要在扫描之前知道他们的 ID?你将如何扫描你周围的任何信标并提取他们的 UUID/Factory Id/等等? 这是我当前的代码: pub
我正在尝试使用 Radius Networks ( http://altbeacon.github.io/android-beacon-library/index.html ) 制作的适用于 Andr
我正在使用 iBeacons 撰写有关室内导航的学士论文。为此,我使用三边测量来找到我的位置。我一直在使用 android beacon 库(现在称为 AltBeacon 库)来检测信标并计算距离。我
这是我用来检测进入区域事件的示例代码: public class BeaconApplication extends android.app.Application implements Bootst
我的应用程序有一些问题。在我禁用 regionBootstrap 并通过 System.exit(0) 关闭应用程序后,我的应用程序会在几分钟后(通常是 3-4 分钟)自行重启。 这是我每次重新启动应
我正在使用 AltBeacon 库来监视信标区域并在它进入和离开该区域时收到通知。问题是我有时会收到错误的“ExitRegion”事件。有时我也没有收到“EnterRegion”事件。 例如,当信标插
我想知道信标代码代表什么。我的意思是,据我所知,它应该识别信标布局。这是否意味着我可以自定义任何类型的布局并为其分配任何类型的信标代码?我的意思是,我可以写这样的东西吗: setBeaconLayou
使用测距信标,从理论上讲,它工作正常。我有 3 个信标,一个简单的算法可以在最短距离内一次只检测一个信标,但由于 RSSI 值的连续波动,我最终会非常频繁地检测到其他信标。好吧,如果我可以在检测之间多
我正在使用此处的 AltBeacon 库开发一个简单的信标接近应用程序 https://altbeacon.github.io/android-beacon-library/samples.html
我的代码或信标返回“错误”值(用引号引起来,因为这很可能是我的代码中的错误)有问题。我一直在阅读信标,据我所知,我可以给我的信标 3 个标识符。我已将信标的标识符配置为 000000000000001
我尝试使用 altBeacon 库查找 iBeacon,但收到此错误: 01-31 11:34:08.628 31582-31582/es.deusto.beaconsapp2 I/art: Late
我正在使用 Altbeacon我的应用程序用于扫描信标的库。我已经成功地在有广告时扫描并推送通知。我的要求是我需要扫描一个 UUID 列表,但文档中给出的示例仅使用一个 UUID 进行扫描。 这是我到
我正在尝试发现我的设备与我在办公室为实习项目设置的信标之间的距离。我对 Android 工作室和 Java 还是很陌生。信标来自苹果(iBeacon)。但是我只设法找出其中一个信标,即使我打开了五个信
Ì 我正在尝试连接我的 Android 应用程序中的信标。但我似乎找不到我的信标。我正在使用 Ibeacons。我正在使用 AltBeacon 库。 onBeaconServiceConnect 开始
我正在尝试创建应用程序来定位信标并获取其距离,为此我正在使用 altbeacon 库。通过使用代码,我得到了附近信标的详细信息,但我没有得到距离。这是我的代码和堆栈跟踪。我的代码中有什么问题可以帮助我
我是一名优秀的程序员,十分优秀!