2

基本的に、アプリがバックグラウンドであっても、iOS アプリから近くの BLE デバイスを検索したいと考えています。

iOS は次の方法を提供します。

//_cbcManager は CBCentralManager のオブジェクトです

[_cbcManager scanForPeripheralsWithServices:nil options:[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO] forKey:CBCentralManagerScanOptionAllowDuplicatesKey]]

このメソッドはすべてのサービスをスキャンします (パラメーターに nil が指定されているため)。しかし、これはバックグラウンドでは機能しません。アプリがバックグラウンドにある場合、iOS には特定のサービス名が必要です。

基本的に、このページを読んで、オーディオ デバイスをスキャンしたいと思います: https://developer.bluetooth.org/gatt/services/Pages/ServicesHome.aspxオーディオ デバイスがブロードキャストする一般的なサービスのほとんどを提供しました。したがって、メソッドは次のようになります。

[_cbcManager scanForPeripheralsWithServices:@[[CBUUID UUIDWithString:@"180A"], [CBUUID UUIDWithString:@"1815"], [CBUUID UUIDWithString:@"1800"], [CBUUID UUIDWithString:@"1801"], [CBUUID UUIDWithString:@"1807"], [CBUUID UUIDWithString:@"180E"], [CBUUID UUIDWithString:@"1813"], [CBUUID UUIDWithString:@"181C"]] options:[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO] forKey:CBCentralManagerScanOptionAllowDuplicatesKey]]

すべての BLE デバイスがブロードキャストする特定/汎用のサービス名はありますか?

4

1 に答える 1