0

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?

pacification
  • 5,838
  • 4
  • 29
  • 51
Gerald
  • 109
  • 9
  • You will need to scan for the peripheral using `scanForPeripherals` on `CBCentralManager` – Paulw11 Sep 14 '17 at 03:30
  • use this https://stackoverflow.com/questions/41899838/not-able-to-scan-through-cbcentral-manager-with-service-id-for-ibecon-signal/41955750#41955750 – IOS Singh Sep 14 '17 at 04:43
  • @Paulw11 I already called it and the CBCentralManagerDelegate function `didDiscover` already fired. I need help after that point which is why I left that part off of my post. – Gerald Sep 14 '17 at 05:23
  • Well, you need to show more code, but you simply save a reference to the peripheral object in a property and then discover its services and characteristics. – Paulw11 Sep 14 '17 at 05:24

0 Answers0