3

I am trying to send some data from an iOS device to the HM-10 Bluetooth LE Module connected to an arduino. Problem is after connecting to the module discoverServices doesn't return a characteristic for the service.

    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)")
    }
}

This outputs:

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

I am a beginner with this arduino stuff as well as iOS. So any suggestions would be welcome. Maybe there is a way to write to the bluetooth module without knowing the characteristic... I have no idea.

Sam Protsenko
  • 14,045
  • 4
  • 59
  • 75

1 Answers1

1

I finally managed to get the answer. Because of my rudimentary understanding of the CoreBluetooth Framework I forgot to call discoverCharacteristics in didDiscoverServices. Well, I am really learning by doing. (I somehow thought discoverServices would call discoverCharacteristics itself.)