2012-08-09 4 views
1

다음 방법으로 블루투스 장치를 CBCentralManager의 도움으로 페어링하려고합니다.페어링 된 블루투스 장치로 다시 연결하십시오.

- (void)connectPeripheral:(CBPeripheral *)peripheral options:(NSDictionary *)options; 

나는 옵션 사전에서 CBConnectPeripheralOptionNotifyOnDisconnectionKey을 true로 설정합니다.

처음으로 작동하고 페어링에 대한 확인을 요청하고 기기가 연결되어 있는지 확인하는 팝업이 표시됩니다. 어떻게 지금까지 내가

- (void)cancelPeripheralConnection:(CBPeripheral *)peripheral; 

또는 장치를 사용하여이 장치를 분리 할 때 내가 그것을 연결되지 같은 "connectPeripheral: options:" 방법을 사용하여 동일한 장치에 연결하려고하면 다음 범위를 벗어 간다. 내가 여기서 뭘 잘못하고 있는지.

+0

아마도 일부 코드를 게시하면 도움이 될 것입니다. 잘못된 정보를 알려주는 데 도움이됩니다. – justinkoh

답변

0

대리인 기능 didDisconnectPeripheral을 확인하면 플래그를 설정 또는 재설정하지 못할 수 있습니다.

샘플 코드는 CoreBluetooth: Heart Rate Monitor입니다.

/* 
Invoked whenever an existing connection with the peripheral is torn down. 
Reset local variables 
*/ 
- (void)centralManager:(CBCentralManager *)central didDisconnectPeripheral:(CBPeripheral *)aPeripheral error:(NSError *)error 
{ 
    self.connected = @"Not connected"; 
    [connectButton setTitle:@"Connect"]; 
    self.manufacturer = @""; 

    if(peripheral) 
    { 
     [peripheral setDelegate:nil]; 
     [peripheral release]; 
     peripheral = nil; 
    } 
} 
관련 문제