2015-12-14 38 views
3

我想將一些數據從iOS設備發送到連接到arduino的HM-10藍牙LE模塊。問題是連接到模塊後discoverServices沒有爲該服務返回一個特性。如何獲取iOS中的HM-10藍牙LE的特性

func peripheral(peripheral: CBPeripheral, didDiscoverServices error: NSError?) { 
    if(error != nil) { 
     print(error?.description) 
    } 
    for service in peripheral.services! { 
     let thisService = service as CBService 
     print("Service: \(thisService.description)") 
     print("Characteristic: \(thisService.characteristics)") 
    } 
} 

此輸出:

Service: <CBService: 0x137e84ea0, isPrimary = YES, UUID = FFE0> 
Characteristic: nil 

我這個Arduino的東西,以及iOS的初學者。所以任何建議都會受到歡迎。也許有一種方法可以在不知道特性的情況下寫入藍牙模塊......我不知道。

回答

1

我終於設法得到答案。由於我對CoreBluetooth Framework的基本理解,我忘記了撥打discoverCharacteristicsdidDiscoverServices。那麼,我真的在學習。 (我不知何故認爲discoverServices本身會叫discoverCharacteristics)。