core-bluetooth

iOS CoreBluetooth can't receive notifications in background

我与影子孤独终老i 提交于 2019-12-25 09:14:19
问题 I am writing an app that should be able to connect to a Ble device and receive update for one of the characteristics. I am able to discover the device I want to connect to, connect to it, and register for notifications on the characteristic I am interested in. Every time the app receives an update for this characteristic it will send the value to a server via an http call. Everything is working fine in the foreground but as soon as I background my app, it stops receiving the updates. I added

Iterate over byte array to parse out individual lengths

霸气de小男生 提交于 2019-12-25 04:04:48
问题 I am reading data off of a hardware device through Core Bluetooth (BLE). One of the charecteristics I am reading is a struct compressed down to a single value. The struct as programmed to the board looks like this: typedef struct { uint8 id; uint32 dur; uint16 dis; } record; Most of the other characteristics I am parsing are of a single type, uint8 , uint32 , so on. How can I loop through the bytes and parse each individual characteristic either to native type or an NSString ? Is there a way

How to implement secure connection to CBPeripheral?

∥☆過路亽.° 提交于 2019-12-25 03:35:28
问题 I want only trusted devices to connect to my peripheral. And I don't want anyone to be able to discover services and characteristics of my peripheral. So before connecting to the peripheral I would like to show an alert with a pin code. Is it possible to do it and what is the easiest way? I couldn't find the answer to this question and tried to implement encrypted characteristic by adding CBAttributePermissionsWriteEncryptionRequired to the permissions: self.characteristic = [

How to implement secure connection to CBPeripheral?

不打扰是莪最后的温柔 提交于 2019-12-25 03:35:10
问题 I want only trusted devices to connect to my peripheral. And I don't want anyone to be able to discover services and characteristics of my peripheral. So before connecting to the peripheral I would like to show an alert with a pin code. Is it possible to do it and what is the easiest way? I couldn't find the answer to this question and tried to implement encrypted characteristic by adding CBAttributePermissionsWriteEncryptionRequired to the permissions: self.characteristic = [

Sending BLE device data to server in background

跟風遠走 提交于 2019-12-25 02:00:31
问题 I develop an application that reading data from BLE device and send this data to MQTT broker (server). But when application entering to the background, data sending stopped after 3 minutes (I use Background Tasks). How I can increase this time. Or maybe there is an official mechanism, that Apple promotes and will not reject on the confirmation step on App Store, for reading data from BLE and sending this data to the server in the background that not limited by time? My Background Task:

didDiscoverServices is not being called after a BLE connection

情到浓时终转凉″ 提交于 2019-12-25 01:46:07
问题 I'm working with a BLE device which I need to verify. The BLE code I'm using is below //Pragma Bluetooth Methods func centralManagerDidUpdateState(_ central: CBCentralManager) { if central.state == .poweredOn { central.scanForPeripherals(withServices: nil, options: nil) } else { print("Bluetooth not available.") } } func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber){ if let peripheralName =

iOS CoreBluetooth - Peripheral connect to Central within range

霸气de小男生 提交于 2019-12-25 01:34:02
问题 I have a basic BLE App that I am running with Objective-C. I am using PeripheralManager and running my iPhone8 as a peripheral with serivces, characteristics added. What I would like to do is connect to a central device that I know by Device ID or when it comes within range. I have written a BLE App for Android that does this now. All I have to do is trigger the device.connectGatt() when onConnectionStateChange() is connected. This is in the BluetoothGattServerCallback() eventHandler. What is

Switching from iBeacon to BLE in real time?

守給你的承諾、 提交于 2019-12-25 01:24:10
问题 Our beacon hardware was programmed to be iBeacon + writeable BLE . So i can discover it with iBeacon , and also connect to it via BLE. I would like to scan for iBeacon, and when i enter the region (app is in background) , and the delegate is being called, he will than switch to BLE and connect to the device with BLE : - (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region { // here connect as usual via bluetooth } So,as i said, i can separately write/discover

How to edit the advertisement data?

筅森魡賤 提交于 2019-12-24 21:47:55
问题 I need to edit the advertisement data of bluetooth peripheral from central manager. i tried a lot.. The following code provides the details : 1.After the Peripheral connection: - (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral { NSLog(@"Connection successfull to peripheral: %@",peripheral); peripheral.delegate = self; [peripheral discoverServices:nil]; //Do somenthing after successfull connection. } 2.Discovering Services: - (void)peripheral:

Objective C-Is it possible to connect to BLE devices from iWatch?

旧城冷巷雨未停 提交于 2019-12-24 17:24:32
问题 Is it possible to get the BLE devices and connect to it using Watch Kit extension.In iPhone CoreBluetooth framework is used,what is the framework for iWatch I am new to Watckit.Please help me with some solutions.. 回答1: Core Bluetooth is not currently available on watchOS 2. I'm not sure if this would work for your application, but you could "daisy chain" your connection. You would use core bluetooth to connect your device to your iPhone, and then you could interact with your iPhone using