草庐IT

ble-state-preservation

全部标签

ios - 从 BLE 获取字符串

你好,我是swift的初学者,我正在尝试制作一个应用程序,将一个BLE与极地心率进行通信,我无法从characteristic.value生成的数据结构中获取正确的信息,我真的有一个将它从uint8转换为更简单的东西(如int或字符串)的问题。她是我的代码:funcperipheral(_peripheral:CBPeripheral,didUpdateValueForCharacteristiccharacteristic:CBCharacteristic,error:NSError?){ifcharacteristic.uuid==POLARH7_HRM_MEASUREMENT_C

iOS Swift 3 BLE CBCharacteristic/Size 8 Bytes (4 Words)/如何分隔单词

我想从蓝牙模块读取数据。有一个特征有4个值,存储在8个字节/4个字中。这是存储在characteristic.value中的数据:0x010x010x000x010x040x050x000x01我使用Swift3。这是代码funcperipheral(_peripheral:CBPeripheral,didUpdateValueForcharacteristic:CBCharacteristic,error:Error?){letdata=characteristic.valueletdataString=String(data:data!,encoding:String.Encodi

ios - 如何在后台定期将数据发送到 IOS (swift) 应用程序上的 BLE 外围设备?

我是iOS编程的新手,我正在使用Swift3中的CoreBluetooth连接和交换数据到特定的(定制的)ble外围设备。如果用户在应用程序中选择特定模式,我需要定期(每分钟)或在特定时间向设备发送数据(写入特性),即使用户打开另一个应用程序或关闭屏幕也是如此.如果应用程序处于事件状态,我可以使用scheduledTimer实现此目的,但一旦应用程序变为非事件状态,它就会停止。如果应用程序进入前台,有什么方法可以继续向外设发送数据?这可能吗?编辑这是我的背景模式(如DeepakTagadiya所述):BackgroundModes下面是来self的Controller的一些代码:cla

ios - {"msg":"Fence: onClientEventRegionState, invalid state", "regionState":"0"} 在 ios 中

我想在用户到达特定楼层时使用估算信标通知用户。为了完成我的任务,我开发了如下代码:funcapplication(_application:UIApplication,didFinishLaunchingWithOptionslaunchOptions:[UIApplicationLaunchOptionsKey:Any]?)->Bool{//Overridepointforcustomizationafterapplicationlaunch.self.beaconManager.delegate=selfself.beaconManager.requestAlwaysAuthori

ios - BLE 设备应该在不扫描的情况下连接

BLE(低功耗蓝牙)设备无需扫描到我的iPhone(应用程序)即可连接。我有通过扫描QRCode获得的BLE地址。所以从那里我想要连接特定设备(我传递地址的设备)而不调用(manager.scanForPeripherals(withServices:nil))因为它将调出所有设备。现在我可以扫描我的BLE设备的QRCode并扫描所有可用的设备,然后当我找到我的特定设备时。我正在停止扫描并使用中的广告数据连接到它funccentralManager(_central:CBCentralManager,didDiscoverperipheral:CBPeripheral,advertis

ios - swift AVAudioEngine 崩溃 : player started when in a disconnected state

所以我下面的代码应该以更高的音调一遍又一遍地重播chimes.wav文件,但由于底部的错误而崩溃。谁能找到导致此错误的原因?importUIKitimportAVFoundationclassaboutViewController:UIViewController{varaudioEngine:AVAudioEngine=AVAudioEngine()varaudioFilePlayer:AVAudioPlayerNode=AVAudioPlayerNode()overridefuncviewDidLoad(){super.viewDidLoad()//Doanyadditionals

swift - setTitle(_ title : String? , for state : UIControlState) where is . 正常状态?

这个问题在这里已经有了答案:UIControlState.NormalisUnavailable(4个答案)关闭6年前。我正在使用Xcode8上的iOS10将我的应用程序更新到Swift3我得到一个错误:Btn.setTitle('str',forState:.Normal).Normal不再是UIControlState的枚举类型。我应该为此状态使用哪种类型的UIControlState?Apple枚举现在定义为publicstructUIControlState:OptionSet{publicinit(rawValue:UInt)publicstaticvarhighlighte

ios - BLE 只获取 Battery Level 特征值 IOS

我正在尝试使用CoreBluetooth框架从设备读取所有可用服务及其特征值。-(void)centralManager:(CBCentralManager*)centraldidDiscoverPeripheral:(CBPeripheral*)peripheraladvertisementData:(NSDictionary*)advertisementDataRSSI:(NSNumber*)RSSI{NSLog(@"Receivedperipheral:\n%@",peripheral);NSLog(@"Advdata:%@",advertisementData);self.ac

ios - BLE iOS9 的 Swift 后台模式

我想改进MPCRisited项目,它是使用多对等方法的聊天应用程序。我正在使用BLE将一台设备连接到另一台设备(iPad和iPod)并发送和接收数据。但是,当我在一台设备上按下主页按钮进入后台模式时,5秒后,我无法发送或接收数据。图片描述在这里我已经在后台模式下检查了所有的东西,但它仍然根本不起作用。importUIKitimportMultipeerConnectivityclassParkBenchTimer{letstartTime:CFAbsoluteTimevarendTime:CFAbsoluteTime?init(){startTime=CFAbsoluteTimeGet

swift - 在序列中使用闭包作为 'state'(状态 :next:): function mis-use or Swift limitation?

背景我们可以使用闭包作为inout参数:funcmutate(_closure:inout()->Int){letnum=closure()closure={return2*num}}varclosure:()->Int={return21}print(closure())//21mutate(&closure)print(closure())//42问题但是,当我尝试使用闭包作为全局sequence(state:next:)function中的(初始)state参数时,系统提示我出现了一些奇怪的错误(与通常的“公共(public)错误”不同)和堆栈跟踪。//dummyexamplen