Post not yet marked as solved
Hi. I'm strictly following the documentation about requesting value for a characteristic containing large data, as it states:
Note: Use notifications to send a single packet of data to subscribed centrals. That is, when you update a subscribed central, you should send the entire updated value in a single notification, by calling the updateValue:forCharacteristic:onSubscribedCentrals: method only once.
Depending on the size of your characteristic’s value, not all of the data may be transmitted by the notification. If this happens, the situation should be handled on the central side through a call to the readValueForCharacteristic: method of the CBPeripheral class, which can retrieve the entire value.
Source:
(https://developer.apple.com/library/archive/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/PerformingCommonPeripheralRoleTasks/PerformingCommonPeripheralRoleTasks.html#//apple_ref/doc/uid/TP40013257-CH4-SW1)
I'm doing just that. I request the characteristic value with a single request:
- (void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error
{
if (error)
{
[self disconnectWithError:error];
return;
}
[service.characteristics enumerateObjectsUsingBlock:^(CBCharacteristic * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop)
{
NSString * chUUID = obj.UUID.UUIDString;
if ([chUUID isEqualToString:Test_Char])
{
self.testCh = obj;
[peripheral readValueForCharacteristic:obj];
}
}];
}
Then on PeripheralManager side I'm implementing the delegate method as suggested:
- (void)peripheralManager:(CBPeripheralManager *)peripheral didReceiveReadRequest:(CBATTRequest *)request
{
if ([request.characteristic.UUID isEqual:self.testCh.UUID])
{ // test
if (request.offset > self.testCh.value.length)
{
[self.peripheralManager respondToRequest:request
withResult:CBATTErrorInvalidOffset];
return;
}
NSInteger length = self.testCh.value.length - request.offset;
request.value = [self.testCh.value subdataWithRange:NSMakeRange(request.offset,
length)];
[self.peripheralManager respondToRequest:request
withResult:CBATTErrorSuccess];
return;
}
[self.peripheralManager respondToRequest:request
withResult:CBATTErrorInvalidHandle];
}
code-block
The delegate method get called multiple times, but always with offset 0. Also, peripheral side, I'm receiving without error a truncated value with unexpected length. (552)
Any clues? Is the documentation not being updated with a newest implementation?
Thx
Post not yet marked as solved
I have an iOS App as peripheral which advertises packets.
NSDictionary *advertise = @{CBAdvertisementDataLocalNameKey : shortName, CBAdvertisementDataServiceUUIDsKey: @[[CBUUID UUIDWithString:uuidA]]};
[self.manager startAdvertising:advertise];
Then, my other centratl app will scan and filter by the same serviceUUID.
[self.manager scanForPeripheralsWithServices:@[[CBUUID UUIDWithString:uuidA] options:@{CBCentralManagerScanOptionAllowDuplicatesKey: @(true)}];
Now, we want to change the ServiceUUID (uuidA -> uuidB), but we hope that the old version of the central app can still scan for the new peripheral app, so I need do multi-advertisement of BLE.
// 1
NSDictionary *advertise = @{CBAdvertisementDataLocalNameKey : shortName, CBAdvertisementDataServiceUUIDsKey: @[[CBUUID UUIDWithString:uuidA], [CBUUID UUIDWithString:uuidB]]};
[self.manager startAdvertising:advertise];
// 2
NSDictionary *advertise = @{CBAdvertisementDataLocalNameKey : shortName, CBAdvertisementDataServiceUUIDsKey: @[[CBUUID UUIDWithString:uuidA]]};
[self.manager startAdvertising:advertise];
NSDictionary *advertise = @{CBAdvertisementDataLocalNameKey : shortName, CBAdvertisementDataServiceUUIDsKey: @[[CBUUID UUIDWithString:uuidB]]};
[self.manager2 startAdvertising:advertise];
However, these two implementations, on the central side, it can always scan only one broadcast packet.
Can somebody suggest any method to do this task? From the central (scanner) app, I should get two different advertisements.
Post not yet marked as solved
Hello,
I would like to work on a feature to turn off earbud button/touch controls for Bluetooth devices. I was wondering where I could start with this.
Post not yet marked as solved
Hi,
I have a certified and qualified BLE device that is a Central role.
When I try to connect it to an iOS device as a peripheral (using 3rd party application such as nRF Connect) I am able to create pairing and bonding, but for some reason the iOS device disconnect immediately after the encryption and authentication process success.
I have heard one explanation for this issue, but I haven't found it in any documentation:
iOS device as a peripheral will disconnect if he sees that there are no requests from the Central side.
is it true?
I would be happy to be inferred to the relevant documentation about this issue.
Thank you
Post not yet marked as solved
I have an App that connects to an IOT device via Bluetooth. I gave it the proper permissions in the info.plist file, and it works fine when I run it from XCode, is able to connect to and communicate with the IOT device via bluetooth. However, when I installed the App on another device via TestFlight, it does not work despite having all the same permissions and the exact same code. I do not know how to debug it since in Dev it works fine. Does anyone have any idea how I can track down what is happening?
Post not yet marked as solved
Hello
What is the best framework for indoor geofencing (with iBeacons devices)? Would the SensorKit framework be any good?
I'm trying to build an indoor geofencing app that uses UWB or BLE devices.
I am thinking of the SensorKit framework because it is used for research and studies and I am looking for the best way to realize indoor geofencing (preferably using UWB devices). The app should also work while it's in the background.
Thank you!
Post not yet marked as solved
Calling the Bluetooth GetMessage function for a message that was sent via Bluetooth, the returned BMessage contains an incorrect folder path to the message. The Event Report returns the correct folder path when the message is successfully sent.
Scenario:
Connect to Bluetooth MAP services (MNS and MAS).
Call Bluetooth "PushMessage" function.
Get 'Name Header' for the Message Handle.
MAP-Event-Report received with Type of SendingSuccess and Folder equal to "telecom/msg/sent".
Use "SetFolder" to navigate to Sent folder.
Call "GetMessage" with the Message Handle (the handle is the same for both the event report and PushMessage function).
The BMessage response has a folder of "telecom/msg/inbox"
BMessage:
BEGIN:BMSG
VERSION:1.0
STATUS:UNREAD
TYPE:SMS_GSM
FOLDER:telecom/msg/inbox
NOTIFICATION:1
BEGIN:VCARD
VERSION:2.1
FN;CHARSET=UTF-8:[Contact]
N;CHARSET=UTF-8:[Contact]
TEL:3:
END:VCARD
BEGIN:BENV
BEGIN:VCARD
VERSION:2.1
FN;CHARSET=UTF-8:[Contact]
N;CHARSET=UTF-8:[Contact]
TEL:[Phone Number]
END:VCARD
BEGIN:BBODY
CHARSET:UTF-8
LANGUAGE:UNKNOWN
LENGTH:[Some Length]
BEGIN:MSG
iOS is the worst.
END:MSG
END:BBODY
END:BENV
END:BMSG
Set Folder to telecom:
85-00-20-02-00-01-00-13-00-74-00-65-00-6C-00-65-00-63-00-6F-00-6D-00-00-4C-00-03-CB-08-60-59-D0
Set Folder to msg:
85-00-18-02-00-01-00-0B-00-6D-00-73-00-67-00-00-4C-00-03-CB-08-60-59-D0
Setting Folder to sent:
85-00-1A-02-00-01-00-0D-00-73-00-65-00-6E-00-74-00-00-4C-00-03-CB-08-60-59-D0
Calling GetMessage function:
83-00-44-01-00-23-00-44-00-33-00-42-00-43-00-34-00-45-00-39-00-31-00-30-00-35-00-41-00-41-00-34-00-43-00-32-00-00-42-00-10-78-2D-62-74-2F-6D-65-73-73-61-67-65-00-4C-00-09-14-01-01-0A-01-00-CB-08-60-59-D0
Section 3.1.4 of the Bluetooth Specification states:
"telecom/msg/sent: This folder shall contain messages that were successfully sent to the network by the MSE, at least during the period of the current MAP session. In particular these messages have been queued in the 'Outbox' folder before sending and are shifted by the MSE to this folder after transmission."
Apple is also nice enough to not include any additional contacts when the text message is part of a group text. This has been made unnecessarily difficult for developers to use and what's worse, it seems intentional.
Post not yet marked as solved
From what I understand, iOS supports receiving a BLE advertisement packet while the app is running in the background if:
The app defines "bluetooth-central" in the UIBackgroundModes section of info.plist
The service UUID is given when calling the centralManager.scanForPeripherals function
The service UUID is transmitted in the actual advertisement packet, and not the scan response
My question is this: if the peripheral uses BLE 5.0 extended advertisements, and the service UUID that the iOS device is scanning for is in the extended packet, will the app get a didDiscover peripheral callback while in background mode?
https://developer.apple.com/videos/play/wwdc2019/901/
Post not yet marked as solved
I use CoreBluetooth to develop bluetooth application, but now I use scanPeripheralWithService, gave the UDID and then the method was never invoked
`State : Powered On
State: Powered on ) is writing to /var/mobile/Containers/Data/Application/7A8F6CF8-E1E8-49E4-AEC1-450A30DC9071/Documents/29-06-2022.log
Discovered %s at %d nil -70
Bluetooth Manager --> didDiscoverPeripheral, RSSI:-70 data:["kCBAdvDataRxPrimaryPHY": 1, "kCBAdvDataRxSecondaryPHY": 0, "kCBAdvDataTimestamp": 678161943.056277, "kCBAdvDataIsConnectable": 0]-- peripheral:<CBPeripheral: 0x280b91360, identifier = F87EDA74-A896-1320-AEE4-4DCA51F2FD51, name = (null), mtu = 0, state = disconnected>
advertisementData is ["kCBAdvDataRxPrimaryPHY": 1, "kCBAdvDataRxSecondaryPHY": 0, "kCBAdvDataTimestamp": 678161943.056277, "kCBAdvDataIsConnectable": 0]
Bluetooth Manager --> didDiscoverPeripheral, RSSI:-70 data:["kCBAdvDataRxPrimaryPHY": 1, "kCBAdvDataRxSecondaryPHY": 0, "kCBAdvDataTimestamp": 678161943.056277, "kCBAdvDataIsConnectable": 0]-- peripheral:<CBPeripheral: 0x280b91360, identifier = F87EDA74-A896-1320-AEE4-4DCA51F2FD51, name = (null), mtu = 0, state = disconnected>) is writing to /var/mobile/Containers/Data/Application/7A8F6CF8-E1E8-49E4-AEC1-450A30DC9071/Documents/29-06-2022.log
Discovered %s at %d nil -50
Bluetooth Manager --> didDiscoverPeripheral, RSSI:-50 data:["kCBAdvDataTimestamp": 678161943.088981, "kCBAdvDataRxSecondaryPHY": 0, "kCBAdvDataIsConnectable": 0, "kCBAdvDataRxPrimaryPHY": 1]-- peripheral:<CBPeripheral: 0x280b914a0, identifier = 36954FD9-A8B4-B112-EBA2-844EAC80B32C, name = (null), mtu = 0, state = disconnected>
advertisementData is ["kCBAdvDataTimestamp": 678161943.088981, "kCBAdvDataRxSecondaryPHY": 0, "kCBAdvDataIsConnectable": 0, "kCBAdvDataRxPrimaryPHY": 1]
Post not yet marked as solved
We used Bluetooth Connection in our project, but in iOS 16 beta version, we found that the first Connection pairing can be connected normally, but the Connection will fail again after disconnection. The system HCI log shows "Encryption Change completion-Connection Timeout".
I would like to ask what changes iOS 16 system version has made to bluetooth connection pairing that cause such trouble for our use.
Post not yet marked as solved
I was wondering if it is possible to use the bluetooth API on iPadOS to let an app become an emulated "bluetooth speaker/car". I want to make an app where an iPhone or Android phone can connect to it via bluetooth so the app can play the audio from the phone, and receive and handle calls just like a car can play audio and handle calls and display call information via bluetooth. I would also like to know if the app could also get contact information from the phone over bluetooth.
If it is possible to do so, how? I would love a friendly nudge in the right direction :)
Post not yet marked as solved
I am making a chat app and have researched how to send data from one phone to another phone for the messages but it has the Central and peripherals which is one way only.
From what I can find, there is no way for both of them to be able to send data to each other.
If anyone knows how to fix this please help!
Post not yet marked as solved
Dear Everyone!
I am using RxBluetooth Kit library to connect bluetooth to peripheral devices.
But now, when I read data from 1 characteristics, in call back I did not read another characteristics.
My code is as follows:
viewDidAppearSubject
.take (1)
.flatMap {self.bluetoothProvider.getValueUpdates (for: charator2102)}
.subscribe (
onNext: {
if $ 0 == "2103" {
self.read2103 ()
}
print ($ 0)
},
onError: {_ in self.showError ()}
)
.disposed (by: disposeBag)
When I receive data of charator2102, I cannot read more data of charactor2103 anymore.
Hope everyone help me!
Thanks very much!
Post not yet marked as solved
Any developer has experience in CTKD?
I saw it was mentioned in WWDC 2019 (https://developer.apple.com/videos/play/wwdc2019/901), and it stated that there would be a sample project from documentation (https://developer.apple.com/documentation/corebluetooth/using_core_bluetooth_classic). But I could not find further information on it.
Post not yet marked as solved
I am very new to the Bluetooth/BLE world and have been using multiple different online resources to help learn my way through it.
I want to be able to list the discovered devices in a list, and upon clicking on the device in the list I want to connect to that device. All the guides show connecting to the device after scanning. What is the best approach to store the peripherals so that I can connect to the device of choice from the list?
I can post my current code if it helps!
Thanks!
Post not yet marked as solved
I am developing an ios Bluetooth app with Swift and UIKIT, The app scans for a specific Bluetooth service and connects to it.
Once the connection is established, I discover the services and characteristics of the connected peripheral. The peripheral has two characteristics. One for writing to the peripheral and the other for notifying and reading data from the device.
Writing to the peripheral works fine but reading from the device gives the error shown below. Error Domain=CBATTErrorDomain Code=2 "Reading is not permitted." UserInfo={NSLocalizedDescription=Reading is not permitted.}
But I have the same app developed in swift and SwiftUI and both writing and reading work fine with the same peripheral connected.
Can anyone please explain to me why this is happening?
Thank you
Post not yet marked as solved
I'm hitting an issue with a connected peripheral that was discovered with BLE when that peripheral also happens to be classic BT paired. If that peripheral is not classic BT paired, there is no issue.
When calling discoverServices([serviceCBUUID]) the peripheral delegate peripheral:didDiscoverServices: is called without error, but peripheral.services is empty whenever the peripheral happens to also be classic BT paired.
How can it be possible to get a callback that services where discovered, yet the peripheral has no services when queried in that callback?
Is this a known issue with a workaround? Thanks.
Post not yet marked as solved
In my app the shortcut intent handler is scanning for Bluetooth devices and based of a given selection it connects to them devices and perform some actions.
Now as soon the option 'Show When Run' is set to disabled, the Bluetooth centralManager does no longer connect to any peripheral, device scanning is still working though and running the shortcut by Siri is working as well.
As a result, automation doesn't work and apparently I cannot use the shortcut as widget on lockscreen.
What else does the 'Show When Run' option apart from raising a user notification after the shortcut completed?
Could this be a missing permission issue? I already added required keys on the info.plist for Bluetooth access and added Bluetooth background option on both app and shortcut targets.
Post not yet marked as solved
Hi,
We have connected with hardware device successfully without add password.
We would like to use the device with password authorization. When device is connect successfully then password is required and without password device should not work.
We have tired all authentication and authorization methods in core bluetooth documentation but not work.
We have also search on stack overflow we got this link
https://stackoverflow.com/questions/26483669/ios-core-bluetooth-pin-code
Please guide us how can achieve with password ?
https://developer.apple.com/documentation/corebluetooth/cbcharacteristicproperties/1518980-authenticatedsignedwrites
Thanks
Post not yet marked as solved
Hello,
We are a company working on Ultra Wideband solutions and, hence, using Apple's NearbyInteraction framework to establish UWB Ranging sessions with our UWB-enabled third-party accessory.
This week we were excited about the new background UWB Ranging session possibility, which opens new use cases. The wwdc2022 10008 video that provides the technical details for this feature indicates that the third-party accessory is responsible to expose the Nearby Interaction GATT Server. We don't manage to get full details about what needs to be implemented to by compliant with Apple's framework.
The URL below indicates that full BLE details should be explained in the "Nearby Interaction Accessory Protocol Specification" but we don't see any info there.
https://developer.apple.com/documentation/nearbyinteraction/ninearbyaccessoryconfiguration
https://developer.apple.com/nearby-interaction/specification/
Can someone indicate us where the find full details for this background Nearby Interaction feature?
Thanks in advance.
Regards.