简体   繁体   English

我们如何使用BLE将Garmin设备连接到iOS应用程序

[英]How can we connect garmin devices to iOS Application using BLE

I am developing an iOS application for Heart rate monitoring, and want to connect a garmin device to my application using Bluetooth. 我正在开发用于心率监测的iOS应用程序,并希望使用蓝牙将garmin设备连接到我的应用程序。

But I am not able to list down any Garmin device Using Core bluetooth in Swift using (180D Service UUID). 但是我无法列出使用(180D Service UUID)在Swift中使用Core蓝牙的任何Garmin设备。

  func startUpCentralManager() {
        print("Initializing central manager")
        centralManager = CBCentralManager(delegate: self, queue: nil)
    }

    func discoverDevices() {
        print("discovering devices")
        let services = [CBUUID(string: HRM_HEART_RATE_SERVICE_UUID),CBUUID(string:HRM_DEVICE_INFO_SERVICE_UUID),CBUUID(string:HRM_DEVICE_BATTERY_LEVEL_SERVICE_UUID),CBUUID(string:CALORIE_SERVICE)]
        centralManager.scanForPeripherals(withServices: services, options: nil)
    }

    //MARK: CBCentralManagerDelegate
    func centralManagerDidUpdateState(_ central: CBCentralManager) {
        print("checking state")
        switch (central.state) {
        case .poweredOff:
            print("CoreBluetooth BLE hardware is powered off")

        case .poweredOn:
           print("CoreBluetooth BLE hardware is powered on and ready")
           blueToothReady = true;

        case .resetting:
            print("CoreBluetooth BLE hardware is resetting")

        case .unauthorized:
            print("CoreBluetooth BLE state is unauthorized")

        case .unknown:
            print("CoreBluetooth BLE state is unknown");

        case .unsupported:
            print("CoreBluetooth BLE hardware is unsupported on this platform");

        }
        if blueToothReady {
            discoverDevices()
        }
    }

    func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) {

        let nameOfDeviceFound = (advertisementData as NSDictionary).object(forKey: CBAdvertisementDataLocalNameKey) as? NSString
        print("\(String(describing: nameOfDeviceFound))")
        print("Discovered Peripheral name : ", peripheral.name ?? String())

           if !Utilities.allPeripheralList.contains(peripheral)
           {
               Utilities.allPeripheralList.add(peripheral)
        }
        let deviceObj = DeviceModel()
        deviceObj.deviceName = peripheral.name ?? String()
        deviceObj.UDID = String(format: "%@",(peripheral.identifier).uuidString)
        self.addingPeripheralToGlobalSearchArray(obj: deviceObj)

    }

    func centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral) {
        peripheral.delegate = self
        peripheral.discoverServices(nil)
        self.connected = peripheral.state == CBPeripheralState.connected ? "YES" : "NO"
        print("Connection Status : %@", self.connected)
        if self.connected == "YES"{

    Utilities.sharedInstance.goToDashboardTabBarScreen(viewController: self)
        }
    }


func centralManager(_ central: CBCentralManager, didDisconnectPeripheral peripheral: CBPeripheral, error: Error?) {
    //        central.scanForPeripherals(withServices: nil, options: nil)
}

func addingPeripheralToGlobalSearchArray(obj:DeviceModel){
    var isFound:Bool = false
    for i in 0..<Utilities.allDeviceList.count{
        let deviceObj = Utilities.allDeviceList[i] as! DeviceModel
        if obj.UDID == deviceObj.UDID{
            isFound = true
        }
    }

    if !isFound{
        Utilities.allDeviceList.add(obj)
    }
}

Above is the code which I am using to list down BLE devices. 上面是我用来列出BLE设备的代码。 I am able to find Mio-Fuse devices using same peace of code but not Garmin devices. 我可以使用相同的代码和平度找到Mio-Fuse设备,但找不到Garmin设备。

You need to use the Garmin Standard SDK. 您需要使用Garmin Standard SDK。 Contact Garmin and register as a developer. 联系Garmin并注册为开发人员。 You cannot connect directly using BLE you have to connect via the Garmin SDK API. 您无法使用BLE直接连接,而必须通过Garmin SDK API连接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法连接到某些 iOS 设备中的 BLE 外设 - Can't connect to BLE Peripheral in some iOS devices 同时连接到多个BLE设备iOS - Connect to multiple BLE devices simultaneously iOS 如何使用BLE公布我的数据以便被iOS设备正确提取 - How can I advertise my data in order to be picked up correctly by iOS devices, using BLE 我们可以更改 iOS 中央和外围设备上的 BLE MTU 和特征大小吗 - Can we Change BLE MTU and characteristic sizes on iOS central and peripheral devices 适用于Garmin CIQ设备的iOS伴侣应用 - iOS companion app for Garmin CIQ devices iOS-如何处理BLE中的绑定设备 - iOS - How to deal with bonded devices in BLE 谁能帮我解决 iOS 13.5.1 设备中的此错误,以使用 CoreBluetooth 进行 ble 传输 - Can any one help me to solve this error in iOS 13.5.1 devices for using CoreBluetooth for ble transmission 我们使用Xcode 4.5.2在IOS 6上开发蓝牙低功耗。 下载到IOS5设备的应用程序可以连接到BLE设备 - We develop Bluetooth Low Energy on IOS 6 with Xcode 4.5.2. The apps downloaded to a IOS5 device can connect to BLE device 使用MAC ios连接到BLE设备 - Connect to a BLE device using MAC ios 是否所有支持BLE 4.0的设备都可以在支持BLE 4.0的iOS设备上连接? - Are all the devices which support BLE 4.0 can be connected in my iOS devices which support BLE 4.0?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM