How do I connect to a HM-10 BLE module?

694 views Asked by At

I have been unsuccessful in connecting to an HM-10 BLE device from my iPhone for a couple of days. I am using Swift 3 on XCode 8.

I have tried using retrieveConnectedPeripherals but it seems that the HM10 is not connected. I looked at the CoreBluetooth documentation for retrievePeripheralsWithIdentifiers but I am still confused as to how to use it. This code that I tried gave me errors because I am still unsure of how to input the HM10 service UUID FFE0.

var serviceUUID = UUID(string: "FFE0")
let peripherals = centralManager.retrievePeripherals(withIdentifiers: [serviceUUID])

I inserted test lines into my code, so I know that I can scan and discover the device, but I don't know how to store it somewhere that I can connect to it. How do I get the CBCentralManager to retrieve a peripheral with a service UUID FFE0 and store it into peripherals?

0

There are 0 answers