TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

Bluetooth Low Energy (BLE)

Forums > iOS

Hi

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.

Regards

4      

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.

3      

One key reason for the incredible success of Bluetooth® technology is the tremendous flexibility it provides developers. Offering two radio options, Bluetooth technology provides developers with a versatile set of full-stack, fit-for-purpose solutions to meet the ever-expanding needs for wireless connectivity🥰.

Whether a product streams high-quality audio between a smartphone and speaker, transfers data between a tablet and medical device, or sends messages between thousands of nodes in a building automation solution, the Bluetooth Low Energy (LE) and Bluetooth Classic radios are designed to meet the unique needs of developers worldwide.

3      

Hacking with Swift is sponsored by Blaze.

SPONSORED Still waiting on your CI build? Speed it up ~3x with Blaze - change one line, pay less, keep your existing GitHub workflows. First 25 HWS readers to use code HACKING at checkout get 50% off the first year. Try it now for free!

Reserve your spot now

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

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

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.