gpt4 book ai didi

ios - 自定义 ios 应用程序找不到我的 nrf 信标

转载 作者:行者123 更新时间:2023-11-30 13:01:59 26 4
gpt4 key购买 nike

我有一些带有此 uuid 的信标:

0112233445566778899aabbccddeeff0和 Major = 1 但它们的 Minor 不同。

这是固件代码的一部分,显示这些数字:

#define APP_MAJOR_VALUE                 0x01, 0x02                        #define APP_MINOR_VALUE                 0x03, 0x04                        
#define APP_BEACON_UUID 0x01, 0x12, 0x23, 0x34, \
0x45, 0x56, 0x67, 0x78, \
0x89, 0x9a, 0xab, 0xbc, \
0xcd, 0xde, 0xef, 0xf0
static uint8_t m_beacon_info[APP_BEACON_INFO_LENGTH] =
{
APP_DEVICE_TYPE,
APP_ADV_DATA_LENGTH,
APP_BEACON_UUID,
APP_MAJOR_VALUE,
APP_MINOR_VALUE,
APP_MEASURED_RSSI
};

这是我的快速代码:

import UIKit
import CoreLocation
import CoreBluetooth

class HomeViewController: UIViewController, CLLocationManagerDelegate {

var locationManager: CLLocationManager!
var managerBLE: CBCentralManager?

override func viewDidLoad() {
super.viewDidLoad()

managerBLE = CBCentralManager(delegate: nil, queue: nil, options: [CBCentralManagerOptionShowPowerAlertKey: true])

locationManager = CLLocationManager()
locationManager.delegate = self
if CLLocationManager.authorizationStatus() == .authorizedWhenInUse {
locationManager.requestWhenInUseAuthorization()
}

startScanning()
}

func startScanning() {
let beaconRegion = CLBeaconRegion(proximityUUID: UUID(uuidString: "your UUID")!, major: 1, identifier: "MyBeacon")
locationManager.startRangingBeacons(in: beaconRegion)
}



func locationManager(_ manager: CLLocationManager, didRangeBeacons beacons: [CLBeacon], in region: CLBeaconRegion) {
if beacons.count > 0 {
for beacon in beacons {
updateDistance(beacon.proximity)
if beacon.proximity == .near {
// run your code
}else if beacon.proximity == .far {
// run your code
}
}
}
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}

但是当我在 iPhone 上安装我的应用程序时,基本上没有任何反应。我不知道我做错了什么?

最佳答案

您的代码需要调试。不幸的是,这对我们来说很难做到,因为我们没有信标。当您能够连接到信标时,尝试打印到日志。这是调试的良好起点。

确保您的信标有电池并且位于范围内。

关于ios - 自定义 ios 应用程序找不到我的 nrf 信标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39817416/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com