import SwiftUI import CoreBluetooth final class BluetoothManager: NSObject, ObservableObject { private var periphManager: CBPeripheralManager! @Published var status = "Starting..." override init() { super.init() periphManager = CBPeripheralManager(delegate: self, queue: nil) } } extension BluetoothManager: CBPeripheralManagerDelegate { func peripheralManagerDidUpdateState(_ central: CBPeripheralManager) { switch central.state { case .poweredOn: status = "Broadcasting" let uuid = CBUUID(string: "12345678-1234-1234-1234-123456789ABC") periphManager.startAdvertising( [ CBAdvertisementDataServiceUUIDsKey: [uuid], CBAdvertisementDataLocalNameKey: "scbt-Test" ]) case .poweredOff: status = "Bluetooth off" default: status = "Bluetooth unavailable" } } }