2014-03-03 3 views
0

iPhone 응용 프로그램을 사용하고 있으며, 포도당 측정을 위해 블루투스 장치로 연결하려고합니다. 기기는 here에서 찾을 수 있습니다.코어에서 주변 장치를 찾을 수 없음 Bluetooth

코어 블루투스에 관한 Apple의 문서를 읽은 후, 나는이 tutorial을 읽기 시작했습니다. 또한이 링크에서 블루투스 장치 용 서비스 ID를 얻습니다. here

그래서 기초를 이해 한 후 튜토리얼 에서처럼 코드를 작성하기 시작했습니다.

그리고이 내 코드 : 나는 CBCentralManagerDelegate 및 CBPeripheralDelegate

의 대표를 구현했습니다

#define POLARH7_HRM_DEVICE_INFO_SERVICE_UUID @"180A" // for Device Information service. 
#define POLARH7_HRM_HEART_RATE_SERVICE_UUID @"1808" // For Glucose service. 

NSArray *services = @[[CBUUID UUIDWithString:POLARH7_HRM_HEART_RATE_SERVICE_UUID], [CBUUID UUIDWithString:POLARH7_HRM_DEVICE_INFO_SERVICE_UUID]]; 
CBCentralManager *centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil]; 
[centralManager scanForPeripheralsWithServices:services options:nil]; 
self.centralManager = centralManager; 

그리고

나는 centralManagerDidUpdateState

- (void)centralManagerDidUpdateState:(CBCentralManager *)central 
{ 
    // Determine the state of the peripheral 
    if ([central state] == CBCentralManagerStatePoweredOff) { 
     NSLog(@"CoreBluetooth BLE hardware is powered off"); 
    } 
    else if ([central state] == CBCentralManagerStatePoweredOn) { 
     NSLog(@"CoreBluetooth BLE hardware is powered on and ready"); 
    } 
    else if ([central state] == CBCentralManagerStateUnauthorized) { 
     NSLog(@"CoreBluetooth BLE state is unauthorized"); 
    } 
    else if ([central state] == CBCentralManagerStateUnknown) { 
     NSLog(@"CoreBluetooth BLE state is unknown"); 
    } 
    else if ([central state] == CBCentralManagerStateUnsupported) { 
     NSLog(@"CoreBluetooth BLE hardware is unsupported on this platform"); 
    } 
} 

내 NSLog 로그에 대한 알림을받을 : CoreBluetooth BLE hardware is powered on and ready.

그러나 central didDiscoverPeripheral에 대한 알림을받지 못했습니다.

- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI 
{ 
    NSString *localName = [advertisementData objectForKey:CBAdvertisementDataLocalNameKey]; 
    if ([localName length] > 0) { 
     NSLog(@"Found the heart rate monitor: %@", localName); 
     [self.centralManager stopScan]; 
     self.polarH7HRMPeripheral = peripheral; 
     peripheral.delegate = self; 
     [self.centralManager connectPeripheral:peripheral options:nil]; 
    } 
} 

이 메소드는 호출되지 않습니다.

중앙 (내 iPhone)이 내 포도당 장치 인 주변 장치를 찾지 못했습니다.

설정 -> 블루투스에서 장치를 검색 할 때 장치를 찾을 수 없습니다.

+0

시도해보십시오.'[centralManager scanForPeripheralsWithServices : nil options : nil];'그러면 알 수 있습니다. 귀하의 장치가 정말로 BLE인지, 링크가 없는지 나는 알지 못했고,'centralManagerDidUpdateState'를'CBCentralManagerStatePoweredOn'으로했을 때 검사를 했습니까? – Larme

+0

[중앙 관리자 scanForPeripheralsWithServices : nil 옵션 : nil]; 하지만 didDiscoverPeripheral 대리자에서 알림을받지 못했습니다. – Abo3atef

답변

0

centralManager:didDiscoverPeripheral:advertisementData:RSSI:이 호출되지 않으면 제공된 CBUUID 중 하나가있는 주변 장치가 없음을 의미합니다. 서비스 배열 대신 nil을 제공하고 사용 가능한 주변 장치가 있는지 확인할 수 있습니다 (프로덕션 모드에서는 수행하지 마십시오).

+0

이들을 만들려고 했음 [centralManager scanForPeripheralsWithServices : nil options : nil]; didDiscoverPeripheral 대리자에서 알림을받지 못했습니다. – Abo3atef

+0

어제 문제가 어제 장치에 연결되어 centralManager에서 알림을 수신했습니다. didDiscoverPeripheral : advertiserData : RSSI 그리고 장치의 이름을 기록 할 수 있습니다. 즉 장치가 저에너지 장치라는 것을 의미합니다 !!! 하지만 지금은 연결할 수 없습니다 !! 심지어 코드를 프로젝트의 다른 위치에 두려고했는데 응답이 없습니다! – Abo3atef

0

좋아, 나는이 장치가 아이폰 블루투스 통합을 지원하지 않는다고 나에게 말했다고 타이 다이크 (TaiDoc) 회사에 이메일을 보낸 후에 문제를 발견했다고 생각한다.

Tom-Tom GPS watch으로 연결을 시도했지만 성공적으로 연결되었습니다. 그래서 문제의 문제점은 하드웨어 문제라고 생각합니다.

관련 문제