1. 程式人生 > >iOS 關於已配對裝置重新檢測連線問題

iOS 關於已配對裝置重新檢測連線問題

//zwl

//已經被系統或者其他APP連線上的裝置陣列

NSArray *arr = [self.CBcentralmagagerretrieveConnectedPeripheralsWithServices:@[[CBUUIDUUIDWithString:ServiceUUID]]];

    if(arr.count>0)

    {

     for (CBPeripheral* peripheral in arr)

     {

             if (peripheral != nil)

             {

                 peripheral.delegate

= self;

                 [self.CBcentralmagager connectPeripheral:peripheral options:nil];

                 self.connectedPeripheral=peripheral;

                 [AppDelegatesharedAppDelegate].peripheral = self.connectedPeripheral;//zwl

                 [AppDelegatesharedAppDelegate].Globeuuidstr = [[

AppDelegatesharedAppDelegate].peripheral.identifierUUIDString];

                 [[NSNotificationCenterdefaultCenter] postNotificationName:VDBlueToothSearchSuccessNotificationobject:nil];

             }

     }

    }

    else

    {

        [self.CBcentralmagagerscanForPeripheralsWithServices:

niloptions:nil];

        [NSTimerscheduledTimerWithTimeInterval:10.0ftarget:selfselector:@selector(scanTimeout:) userInfo:nilrepeats:NO];

        _blackPeriperalInfos=blackPeriperalInfos;

        [PeriperalInfosremoveAllObjects];

    }