Post not yet marked as solved
Hi Team,
I am developing a sample authPluggin which should connect to a mobile app via bluetooth connection,
So here are the scenario
Authplugin with Bluetooth connection shoould work on lockscreen+login
I have created mechanism- prepared:privillaged, main, clean:Privilaged
Calling corebluetoothmanager initiation at the time of prepared:privilaged mechanism
I have to add my auth plugin’s mechanism before loginwindow:success mechanism
But I always gets unauthorized = 3, from power state of bluetooth
Note: With App, bluetooth connection is working fine, Its giving error with authPlugin
How to achieve my ultimate goal, is this the right way?
Post not yet marked as solved
Hi,
I'm working on an SPM library that uses CoreBluetooth. Since I need to work with Bluetooth in background, I've set CBCentralManagerOptionRestoreIdentifierKey option to my instance of CBCentralManager. When I run the unit tests I encounter the following exception:
Thread 1: "State restoration of CBCentralManager is only allowed for applications that have specified the "bluetooth-central" background mode"
Of course, my demo application that I use to test the library has the bluetooth-central background mode checked.
I think the issue is related to the fact that when the test target is executed, there is no associated application. Can background modes be applied to the package? How can this be resolved?
I have tried below code to open [Settings(App) -> Bluetooth Settings] but it is navigating to App permission screen instead of Bluetooth Settings. I have tried to search but didn't get any latest documentation regarding it. Is there any way to do this?
guard let url = URL(string: UIApplication.openSettingsURLString) else {
return
}
if UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
Post not yet marked as solved
I'm trying a Data value (1438 bytes) to write to a characteristic which exceeds the MTU size.
When I issue the write request I receive .prepareQueueFull
According to the documentation: "The prepare queue is full, as a result of there being too many write requests in the queue."
The unfortunate thing is that on the I only call the write request once.
peripheral.writeValue(data, for: characteristic, type: .withResponse)
Any input and possible solution is welcome.
Thank you in advance.
Post not yet marked as solved
We are implementing indoor positioning and proximity sensing in our iOS app using iBeacons. We have placed multiple beacons to detect the proximity of one point of interest(POI). We are using the startRangingBeacons method in the CLLocationManager class and implementing corresponding delegates to receive the ranging information. With all required foreground and background permissions granted, when a user walks from one POI to another, beacon ranging is working as expected and we are continuously receiving the sightings in the app.
We have observed that, if user stops walking for a few minutes at a POI and then device automatically pauses the scan. Hence, we will not receive any beacon signals. When there is a movement, it performs beacon ranging again for a minute or so, then stops again for longer time even when user is walking. The interval between the pausing and resuming the service is not a constant. We have also observed that sometimes it takes more than 15 minutes to resume the service once the system pauses the ranging automatically. Is it an expected behavior? How long does it usually take for beacon ranging services to resume after the user starts moving? Is there any way we can reduce this delay between the pause and resume of ranging beacons?
Appreciate your support
Post not yet marked as solved
Hello everyone,
I am new to Swift, it is my first project and I am a PhD Electrical Engineer student.
I am designing an iOS app for a device that we are designing that is capable of reading electrical brain data and sending them via BLE with a sampling frequency of 2400 Hz.
I created a Bluetooth service for the Swift app that every time it receives new data, processes it to split the different channels and add the new data to the Charts data arrays. Here is the code I've designed:
func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) {
if characteristic.uuid == Nordic_UART_TX_CHAR_UUID {
guard error == nil, let data = characteristic.value else {
print("[Bluetooth] Error receiving data or no data: \(error?.localizedDescription ?? "Unknown Error")")
return
}
DispatchQueue.global(qos: .background).async {
self.processReceivedData(data)
}
}
}
func processReceivedData(_ data: Data) {
var batch = [(Int, Int)]()
for i in stride(from: 0, to: data.count - 4, by: 4) {
let channel = Int(data[i] & 0xFF)
let value = Int((Int(data[i + 3] & 0xFF) << 16) | (Int(data[i + 2] & 0xFF) << 8) | (Int(data[i + 1] & 0xFF))) - 8388608
batch.append((channel, value))
}
DispatchQueue.main.async {
for (channel, value) in batch {
let nowTime = (Date().timeIntervalSince1970 - self.dataGraphService.startTime)
let newDataPoint = DataGraphService.VoltagePerTime(time: nowTime, voltage: Double(value)/8388608, channel: "Channel \(channel - 15)")
if channel == 16 {
self.dataGraphService.lastX1 = nowTime
self.dataGraphService.dataCh1.append(newDataPoint)
} else if channel == 17 {
self.dataGraphService.lastX2 = nowTime
self.dataGraphService.dataCh2.append(newDataPoint)
} else if channel == 18 {
self.dataGraphService.lastX3 = nowTime
self.dataGraphService.dataCh3.append(newDataPoint)
} else if channel == 19 {
self.dataGraphService.lastX4 = nowTime
self.dataGraphService.dataCh4.append(newDataPoint)
}
}
}
}
// DataGraphService.swift
struct VoltagePerTime {
var time: Double
var voltage: Double
var channel: String
}
@Published var dataCh1: [VoltagePerTime] = []
@Published var dataCh2: [VoltagePerTime] = []
@Published var dataCh3: [VoltagePerTime] = []
@Published var dataCh4: [VoltagePerTime] = []
@Published var windowSize: Double = 2.0
@Published var lastX1: Double = 0
@Published var lastX2: Double = 0
@Published var lastX3: Double = 0
@Published var lastX4: Double = 0
I also created a View that shows the real-time data from the different channels.
ChartView(
data: dataGraphService.dataCh1.filter {
dataGraphService.getXAxisRange(for: dataGraphService.dataCh1, windowSize: dataGraphService.windowSize).contains($0.time)
},
xAxisRange: dataGraphService.getXAxisRange(for: dataGraphService.dataCh1, windowSize: dataGraphService.windowSize),
channel: "Channel 1",
windowSize: dataGraphService.windowSize
)
// ChartView.swift
import SwiftUI
import Charts
struct ChartView: View {
var data: [DataGraphService.VoltagePerTime]
var xAxisRange: ClosedRange<Double>
var channel: String
var windowSize: Double
var body: some View {
RoundedRectangle(cornerRadius: 10)
.fill(Color.gray.opacity(0.1))
.overlay(
VStack{
Text("\(channel)")
.foregroundColor(Color.gray)
.font(.system(size: 16, weight: .semibold))
Chart(data, id: \.time) { item in
LineMark(
x: .value("Time [s]", item.time),
y: .value("Voltage [V]", item.voltage)
)
}
.chartYAxisLabel(position: .leading) {
Text("Voltage [V]")
}
.chartYScale(domain: [-1.6, 1.6])
.chartYAxis {
AxisMarks(position: .leading, values: [-1.6, -0.8, 0, 0.8, 1.6])
AxisMarks(values: [-1.6, -1.2, -0.8, -0.4, 0, 0.4, 0.8, 1.2, 1.6]) {
AxisGridLine()
}
}
.chartXAxisLabel(position: .bottom, alignment: .center) {
Text("Time [s]")
}
.chartXScale(domain: xAxisRange)
.chartXAxis {
AxisMarks(values: .automatic(desiredCount: Int(windowSize)*2))
AxisMarks(values: .automatic(desiredCount: 4*Int(windowSize)-2)) {
AxisGridLine()
}
}
.padding(5)
}
)
.padding(2.5)
.padding([.leading, .trailing], 5)
}
}
With these code I can receive and plot the data in real-time but after some time the CPU of the iPhone gets saturated and the app stop working. I have the guess that the code is designed in a way that the functions are called one inside the other one in a very fast speed that the CPU cannot handle.
My doubt is if there is any other way to code this real-time plotting actions without make the iPhone's CPU power hungry.
Thank you very much for your help!
Post not yet marked as solved
My watch APP needs to keep Bluetooth connected with peripherals whether it is in the foreground or background, but the results of my test show that the connection in the background is very unstable, sometimes you can keep the Bluetooth on for a day, but sometimes it will be disconnected 50 times a day, and every time it is disconnected, I will immediately initiate a reconnection, it is certain that there is no problem with the peripheral Bluetooth, because I have another iOS device that has been stably connected to the peripheral, I want to know what causes this instability, and if there is any solution, if someone can provide relevant advice, I will be very grateful
Post not yet marked as solved
Hi,
I am inquiring in regard to how to handle data from a bluetooth device. The device would send data in JSON format to a Mac via bluetooth, and I would need to constantly refresh or fetch data from the device in real time.
How would I go about this? Any help would be greatly appreciated.
Thank you.
Post not yet marked as solved
Hey, I've been trying to find information but haven't had any luck so far. I own two third party bluetooth trackers (not AirTags), which I've linked to Find My.
Recently, I misplaced an item that had one of these trackers attached. Surprisingly, even though I was quite far away, I was still receiving updates on its location a couple hours after I lost it.
I'm curious to know, does connecting a third party bluetooth tracker to Find My function in the same way as AirTags? Are there any specific documents or resources where I can learn more about this? I'm really interested in understanding how it works.
TL;DR my singleton BLEManager managing Bluetooth communication keeps getting re-initialised (see console log). How should I prevent this?
Using Swift 5.9 for iOS in Xcode 15.1
My code finds multiple BT devices, and lists them for selection, also building an array of devices for reference.
Most code examples connect each device immediately. I am trying to connect later, when a specific device is selected and its View opens.
I pass the array index of the device to the individual Model to serve as a reference, hoping to pass that back to BLEManager to connect and do further communication.
After scanning has completed, the log message shows there is 1 device in it, so its not empty.
As soon as I try and pass a reference back to BLEManager, the app crashes saying the array reference is out of bounds. The log shows that BLEManager is being re-initialised, presumably clearing and emptying the array.
How should I be declaring the relationship to achieve this?
Console log showing single device found:
ContentView init
BLEManager init
didDiscover id: 39D43C90-F585-792A-5BD6-8749BA0B5385
In didDiscover devices count is 1
stopScanning
After stopScanning devices count is 1
<-- selection made here
DeviceModel init to device id: 0
BLEManager init
BLEManager connectToDevice id: 0
devices is empty
Swift/ContiguousArrayBuffer.swift:600: Fatal error: Index out of range
2023-12-28 11:45:55.149419+0000 BlueTest1[20773:1824795] Swift/ContiguousArrayBuffer.swift:600: Fatal error: Index out of range
BlueTest1App.swift
import SwiftUI
@main
struct BlueTest1App: App {
var body: some Scene {
WindowGroup {
ContentView(bleManager: BLEManager())
}
}
}
ContentView.swift
import SwiftUI
struct TextLine: View {
@State var dev: Device
var body: some View {
HStack {
Text(dev.name).padding()
Spacer()
Text(String(dev.rssi)).padding()
}
}
}
struct PeripheralLineView: View {
@State var devi: Device
var body: some View {
NavigationLink(destination: DeviceView(device: DeviceModel(listIndex: devi.id))) {
TextLine(dev: devi)
}
}
}
struct ContentView: View {
@StateObject var bleManager = BLEManager.shared
init(bleManager: @autoclosure @escaping () -> BLEManager) {
_bleManager = StateObject(wrappedValue: bleManager())
print("ContentView init")
}
var body: some View {
VStack (spacing: 10) {
if !bleManager.isSwitchedOn {
Text("Bluetooth is OFF").foregroundColor(.red)
Text("Please enable").foregroundColor(.red)
}
else {
HStack {
Spacer()
if !bleManager.isScanning {Button(action: self.bleManager.startScanning){ Text("Scan ")
}
} else { Text("Scanning")
}
}
NavigationView {
List(bleManager.devices) { peripheral in
PeripheralLineView(devi: peripheral)
}.frame(height: 300)
}
}
}
}
}
//@available(iOS 15.0, *)
struct DeviceView: View {
var device: DeviceModel
var body: some View {
ZStack {
VStack {
Text("Data Window")
Text("Parameters")
}
}.onAppear(perform: {
device.setUpModel()
})
}
}
BLEManager.swift
import Foundation
import CoreBluetooth
struct Device: Identifiable {
let id: Int
let name: String
let rssi: Int
let peri: CBPeripheral
}
class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeripheralDelegate {
static let shared: BLEManager = {
let instance = BLEManager()
return instance
}()
var BleManager = BLEManager.self
var centralBE: CBCentralManager!
@Published var isSwitchedOn = false
@Published var isScanning = false
var devices = [Device]()
var deviceIds = [UUID]()
private var activePeripheral: CBPeripheral!
override init() {
super.init()
print(" BLEManager init")
centralBE = CBCentralManager(delegate: self, queue: nil)
}
func centralManagerDidUpdateState(_ central: CBCentralManager) {
if central.state == .poweredOn {
isSwitchedOn = true
}
else { isSwitchedOn = false }
}
func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) {
if let name = advertisementData[CBAdvertisementDataLocalNameKey] as? String {
if !deviceIds.contains(peripheral.identifier) {
print("didDiscover id: \(peripheral.identifier)")
deviceIds.append(peripheral.identifier)
let newPeripheral = Device(id: devices.count, name: name, rssi: RSSI.intValue, peri: peripheral)
devices.append(newPeripheral)
print("didDiscover devices count now \(devices.count)")
}
}
}
/// save as activePeripheral and connect
func connectToDevice(to index: Int) {
print("BLEManager connectToDevice id: \(index)")
if devices.isEmpty {print ("devices is empty")}
activePeripheral = devices[index].peri
activePeripheral.delegate = self
centralBE.connect(activePeripheral, options: nil)
}
func startScanning() {
centralBE.scanForPeripherals(withServices: nil, options: nil)
isScanning = true
// Stop scan after 5.0 seconds
let _: Timer = Timer.scheduledTimer(timeInterval: 5.0, target: self, selector: #selector(stopScanning), userInfo: nil, repeats: false)
}
@objc func stopScanning() { // need @objc for above Timer selector
print("stopScanning")
centralBE.stopScan()
isScanning = false
print("After stopScanning devices count is \(devices.count)")
}
func peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: CBService, error: Error?) { }
func disconnect(peripheral: Int) { }
func discoverServices(peripheral: CBPeripheral) { }
func discoverCharacteristics(peripheral: CBPeripheral) { }
func peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Error?) { }
func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) { }
}
DeviceModel.swift
import Foundation
import CoreBluetooth
class DeviceModel: BLEManager {
var index: Int //CBPeripheral position in found array
init(listIndex: Int) {
index = listIndex
print("DeviceModel init to device id: \(index)")
}
func setUpModel() {
connectToDevice(to: index)
}
}
Post not yet marked as solved
Hello everyone,
Like so many others, I am a very newbie App developer. To my own detriment, I acknowledge I am trying to shortcut things a bit by using and modifying other pieces of code. Always easier to modify something that is already working, rather than staring at a blank screen not knowing how to begin.
So this leads me to this problem I am having. This is a Bluetooth application. And the Bluetooth runs just fine in both of my views. However, when the Bluetooth is linked and active, and I am receiving data, a Timer will not run. As soon as I stop the Bluetooth source (using an Arduino nano), the time begins to count again. There are no errors flagged in Xcode, just does not work properly. I was hoping someone could take a look and find the issue, and let me know how to fix it. Hopefully it is something easy, but without any errors being thrown, hard to know what to look for. Thanks...
So this is my Bluetooth Code:
import Foundation
import CoreBluetooth
enum ConnectionStatus: String {
case connected
case disconnected
case scanning
case connecting
case error
}
let BarrelBaristaService: CBUUID = CBUUID(string: "4FAFC201-1FB5-459E-8FCC-C5C9C331914B")
//Temperature F
let TemperatureCharacteristic: CBUUID = CBUUID(string: "5D54D470-8B08-4368-9E8F-03191A0314A5")
//Humidity %
let HumidityCharacteristic: CBUUID = CBUUID(string: "B2F5E988-C50F-4200-A1D9-5884F9417DEF")
//Weight %
let WeightCharacteristic: CBUUID = CBUUID(string: "BEB5483E-36E1-4688-B7F5-EA07361B26A8")
class BluetoothService: NSObject, ObservableObject {
private var centralManager: CBCentralManager!
var BarrelBarristaPeripheral: CBPeripheral?
@Published var peripheralStatus: ConnectionStatus = .disconnected
@Published var TempValue: Float = 0
@Published var HumidValue: Float = 0
@Published var WeightValue: Float = 0
@Published var Connected: Bool = false
override init() {
super.init()
centralManager = CBCentralManager(delegate: self, queue: nil)
}
func scanForPeripherals() {
peripheralStatus = .scanning
centralManager.scanForPeripherals(withServices: nil)
}
}
extension BluetoothService: CBCentralManagerDelegate {
func centralManagerDidUpdateState(_ central: CBCentralManager) {
if central.state == .poweredOn {
print("CB Powered On")
scanForPeripherals()
}
}
func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) {
if peripheral.name == "Barrel Barista" {
print("Discovered \(peripheral.name ?? "no name")")
BarrelBarristaPeripheral = peripheral
centralManager.connect(BarrelBarristaPeripheral!)
peripheralStatus = .connecting
}
}
func centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral) {
peripheralStatus = .connected
Connected = true
peripheral.delegate = self
peripheral.discoverServices([BarrelBaristaService])
centralManager.stopScan()
}
func centralManager(_ central: CBCentralManager, didDisconnectPeripheral peripheral: CBPeripheral, error: Error?) {
peripheralStatus = .disconnected
Connected = false
}
func centralManager(_ central: CBCentralManager, didFailToConnect peripheral: CBPeripheral, error: Error?) {
peripheralStatus = .error
print(error?.localizedDescription ?? "no error")
}
}
extension BluetoothService: CBPeripheralDelegate {
func peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Error?) {
for service in peripheral.services ?? [] {
if service.uuid == BarrelBaristaService {
print("found service for \(BarrelBaristaService)")
peripheral.discoverCharacteristics([TemperatureCharacteristic], for: service)
peripheral.discoverCharacteristics([HumidityCharacteristic], for: service)
peripheral.discoverCharacteristics([WeightCharacteristic], for: service)
}
}
}
func peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: CBService, error: Error?) {
for characteristic in service.characteristics ?? [] {
peripheral.setNotifyValue(true, for: characteristic)
print("found characteristic, waiting on values.")
}
}
func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) {
if characteristic.uuid == TemperatureCharacteristic {
guard let data = characteristic.value else {
print("No data received for \(characteristic.uuid.uuidString)")
return
}
let TempData: Float = data.withUnsafeBytes { $0.pointee }
TempValue = TempData
}
if characteristic.uuid == HumidityCharacteristic {
guard let data = characteristic.value else {
print("No data received for \(characteristic.uuid.uuidString)")
return
}
let HumidData: Float = data.withUnsafeBytes { $0.pointee }
HumidValue = HumidData
}
if characteristic.uuid == WeightCharacteristic {
guard let data = characteristic.value else {
print("No data received for \(characteristic.uuid.uuidString)")
return
}
let WeightData: Float = data.withUnsafeBytes { $0.pointee }
WeightValue = WeightData
}
}
}
Post not yet marked as solved
Hello everyone,
I've developed an application using ElectronJS and NodeJS, utilizing the Web Bluetooth API for connecting to and streaming data from peripherals. Initially, this was built and tested on macOS Ventura, where everything worked as expected. However, I've encountered a couple of issues post the Sonoma update.
Issue 1: Slower Streaming Speed Post-Sonoma Update
After updating to Sonoma, the streaming speed from peripherals significantly decreased. This is perplexing because the app continues to perform well on Ventura. To troubleshoot, I even developed a version using Rust with the btleplug library, hoping for improved Bluetooth performance. However, this did not lead to any noticeable difference; both the Electron and Rust versions perform nearly the same. Has anyone experienced similar issues or knows what might be causing this slowdown?
Issue 2: GATT Operation Error Resolved, but Streaming Speed Affected
On Ventura, one specific command consistently failed with a GATT operation error. Interestingly, post-Sonoma update, this command works without error, but this seems to have affected the streaming speed. The improved GATT operation seems to come at the cost of decreased streaming performance. Is there a known connection between these two aspects, or has anyone observed a similar trade-off?
I'm looking for insights or suggestions to resolve these issues, particularly the streaming speed degradation post-Sonoma. The application needs to maintain consistent performance across different macOS versions, and these discrepancies are quite challenging.
Thank you in advance for your help and insights!
Best regards,
Post not yet marked as solved
Hello,
I had trouble with bluetooth on my MacBook Air running macOs Sonoma 14.2.1.
I could not find some bluetooth devices, like my iPad for instance, so I decided to delete the plist file to "reset" bluetooth settings. Unfortunately bluetooth still behaves the same and additionally PacketLogger stopped working. It stays empty and does not show any traffic. Anybody knows what to do here?
Post not yet marked as solved
I have used this example to create the following code:
import Foundation
import CoreLocation
let monitorName = "BeaconMonitor"
let testBeaconId = UUID(uuidString: "EDFA3FFA-D80A-4C23-9104-11B5B0B8E8F3")!
@MainActor
public class ObservableMonitorModel: ObservableObject {
private let manager: CLLocationManager
public var monitor: CLMonitor?
init() {
self.manager = CLLocationManager()
self.manager.requestWhenInUseAuthorization()
self.manager.requestAlwaysAuthorization()
}
func startMonitoringConditions() {
Task {
monitor = await CLMonitor(monitorName)
await monitor!.add(getBeaconIdentityCondition(), identifier: "Beacon")
for identifier in await monitor!.identifiers {
guard let lastEvent = await monitor!.record(for: identifier)?.lastEvent else { continue }
print(identifier, lastEvent.state)
}
for try await event in await monitor!.events {
print("Event", event.identifier, event)
}
}
}
}
func getBeaconIdentityCondition() -> CLMonitor.BeaconIdentityCondition {
CLMonitor.BeaconIdentityCondition(uuid: testBeaconId)
}
Unfortunately, running this on my iPhone only prints "Beacon CLMonitoringState". I don't see anything from the for try await block starting with "Event".
Any ideas where I've gone wrong?
Post not yet marked as solved
I would like to know how to check the Bluetooth version on macOS.
There have been similar questions in the past, and the answers suggested checking the LMP Version in the system profile to find this information.
However, in the latest macOS (Sonoma - 14.2.1), this method no longer seems to work. According to other posts on platforms like Reddit, it appears that this change has persisted at least until version 12.
I considered using terminal commands for more detailed information, but the results were similar.
❯ system_profiler -detailLevel full SPBluetoothDataType
Bluetooth:
Bluetooth Controller:
Address: 3C:06:30:0F:92:18
State: On
Chipset: BCM_4378
Discoverable: Off
Firmware Version: 21.1.527.3724
Product ID: 0x4A01
Supported services: 0x392039 < HFP AVRCP A2DP HID Braille LEA AACP GATT SerialPort >
Transport: PCIe
Vendor ID: 0x004C (Apple)
Wanted to check if anyone here has insights or alternative methods to determine the Bluetooth version on the latest macOS. If there's a command-line solution or any other approach that works with recent macOS versions, I would greatly appreciate the guidance.
Post not yet marked as solved
I scan my ble device with the code below.
centralManager.scanForPeripherals(withServices: [connectionServiceUUID], options: nil)
and the call back method is called when the device is scaned.
func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) { ... }
I have 2 questions with the value of advertisementData[CBAdvertisementDataLocalNameKey] from the callback method.
Suppose there is connections, and the localNameKey of the device is A. When it is scanned and connected at first, the advertisementData[CBAdvertisementDataLocalNameKey] I get is not A but something else. Here, if I do the same then I get A.
Now, I change the localNameKey of the device to B. And when it is scanned, the advertisementData[CBAdvertisementDataLocalNameKey] is still A, and I do the same, now it is B. Why?
When the screen is off, advertisementData[CBAdvertisementDataLocalNameKey] never changes, why?
Post not yet marked as solved
I have a BLE device and the centralManger scans with "centralManager.scanForPeripherals(withServices: [connectionServiceUUID], options: nil)"
Then
func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) { ... } is called.
Here, I could get the advertisementData[CBAdvertisementDataLocalNameKey].
I have set my BLE device to change its local name key for every connections.
The BLE communication is repeated in the background.(scan, connect, stop scan, disconnect, ... etc)
It works well, but when the screen is off, the value of advertisementData[CBAdvertisementDataLocalNameKey] in didDiscover does not change. Why?
Hello,
I'm looking for an end-to-end example project that shows a correct implementation for the new iBeacon CoreLocation APIs in iOS 17.0 (CLMonitor, etc.). Ideally the example would cover background waking as that is the area in which I am facing the largest challenges.
Perhaps there's an Open Source project or an official Apple example?
Thanks for pointing me in the right direction.
Jeremy
Post not yet marked as solved
objectC program: iOS all : iPhone ~
swift program. : iOS 13 ~ : iPhone 6s ~
swiftUI Program : iOS 13 ~ : iPhone 6s ~
bluetooth classic : ~ iPhone 4s
Bluetooth Low Engery : iPhone 5 ~
are All above content right?
i am making iOS app with swiftUI app, and Bluetooth Low Energy.
after making app, i found that my app can run on greater than iOS13 , iPhone 6s.
how many is ther number of above iPhone6s User ?
Post not yet marked as solved
Hello everyone:
I used corebluetooth, but currently I cannot connect Airpods headphones.
details as following:
Unable to scan to unconnected devices.
If the device is already linked, it can be searched, but the connection cannot be made successfully.
I searched Google for related posts but couldn't find a website that can solve the problem. I need to ask if there are any relevant restrictions on Airpods or if there are other real solutions that I can link to.
thank you all.