2016-10-24 2 views

답변

1

CBCentralManager을 사용하여 연결된 블루투스 장치를 장치로 검색 할 수 있습니다. 당신의 블루투스 장치 (CBCentralManager 상태 == CBCentralManagerStatePoweredOn)에있는 경우,이 함수를 호출 :

func retrieveConnectedPeripherals(withServices serviceUUIDs: [CBUUID]) -> [CBPeripheral] 

그것은 당신의 아이폰에 연결된 모든 서비스의 UUID 당신의 목록을 제공합니다.

참조 : https://developer.apple.com/reference/corebluetooth/cbcentralmanager/1518924-retrieveconnectedperipherals

+0

확인이 프레임 워크, 나는 그것을 시도 할 것이다. 감사 –

0

콜이 메소드는 블루투스 헤드셋이 연결되지 않았거나 찾을 수 있습니다.

먼저 수입 #import <AVFoundation/AVFoundation.h>

- (BOOL) isBluetoothHeadsetConnected 
    { 
     AVAudioSession *session = [AVAudioSession sharedInstance]; 
     AVAudioSessionRouteDescription *routeDescription = [session currentRoute]; 

     NSLog(@"Current Routes : %@", routeDescription); 

     if (routeDescription) 
     { 
      NSArray *outputs = [routeDescription outputs]; 

      if (outputs && [outputs count] > 0) 
      { 
       AVAudioSessionPortDescription *portDescription = [outputs objectAtIndex:0]; 
       NSString *portType = [portDescription portType]; 

       NSLog(@"dataSourceName : %@", portType); 

       if (portType && [portType isEqualToString:@"BluetoothA2DPOutput"]) 
       { 
        return YES; 
       } 
      } 
     } 

     return NO; 
    } 
관련 문제