简体   繁体   中英

How to connect to BLE device that isn't advertising service UUID in iOS app

I am trying to connect an ESP32 module to my iPhone via BLE and am using centralManager.scanForPeripherals(withServices: [carServiceCBUUID], options: nil) where let carServiceCBUUID = CBUUID(string: "c0de0001-feed-f00d-c0ff-eeb3d05ebeef") . I am following Ray Wenderlich's heart monitor tutorial but since the ESP32 bluetooth module is not advertising the main Service UUID, it won't find the device when I do scanForPeripherals . Attached is the screenshot of the LightBlue information on the BLE device. Is there a way I can change the advertising data so I can advertise the service? I am running this code on the ESP32 https://thejeshgn.com/2018/06/11/esp32-ble-building-an-echo-service-gatt-server/

screenshot of LightBlue connection

According to documentation of scanForPeripheralsWithServices:options: the serviceUUIDs parameter can be nil - in that case

all discovered peripherals are returned regardless of their supported services (not recommended)

So unless you are planning to use background modes to scan when app is in background, you can just pass nil as serviceUUIDs parameter

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM