WWDC22 SALE: Save 50% on all my Swift books and bundles! >>

Bluetooth Low Energy (BLE)

Forums > iOS


I am experimenting with connecting to BLE devices and hope there maybe some experts out there who can help. I have been pretty successful at connecting to various devices but something is bugging me.

I have a Polar H7 Heart Rate Monitor - about as inductry standard as you can get.

I define

let BLE_Heart_Rate_Service_CBUUID = CBUUID(string: "0x180D")

and use

self.centralManager.scanForPeripherals(withServices: [BLE_Heart_Rate_Service_CBUUID])

as predicted the central manager calls didDiscover and I can move on to connecting, discovering characteristices etc.

I also have a development board from Cypress which is programmed with Immediate Alert service (0x1802)

I define

let BLE_Find_Me_Service_CBUUID = CBUUID(string: "0x1802")

and call

self.centralManager.scanForPeripherals(withServices: [BLE_Find_Me_Service_CBUUID])

For this device it cannot find the device. didDiscover is not called

If I try

self.centralManager.scanForPeripherals(withServices: nil)

I can debug print a list of every device found and the one I'm looking for is there.

I can filter in this call back on the name and move on but was wondering of anyone knew why scanForPeripherals works or doesnt work as I described.

Sorry if that was a bit rambling.



Hello. I'm sorry I can't help you, I'm following the 100 days course with Swift so my level is apprentice. But I would ask for your help to know where to get an example of a BLE application with Swift 5.5 where I can read and write an characteristics in a peripheral Thank you very much.


Save 50% in my Black Friday sale.

SAVE 50% To celebrate WWDC22, all our books and bundles are half price, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.

Save 50% on all our books and bundles!

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.