@@ -31,7 +31,7 @@ use objc2_core_bluetooth::{
31
31
CBCharacteristicProperties , CBCharacteristicWriteType , CBDescriptor , CBManager ,
32
32
CBManagerAuthorization , CBManagerState , CBPeripheral , CBPeripheralState , CBService , CBUUID ,
33
33
} ;
34
- use objc2_foundation:: { NSArray , NSData , NSMutableDictionary , NSNumber } ;
34
+ use objc2_foundation:: { NSArray , NSData , NSMutableDictionary , NSNumber , NSProcessInfo } ;
35
35
use std:: {
36
36
collections:: { BTreeSet , HashMap , VecDeque } ,
37
37
ffi:: CString ,
@@ -369,6 +369,7 @@ impl PeripheralInternal {
369
369
struct CoreBluetoothInternal {
370
370
manager : Retained < CBCentralManager > ,
371
371
delegate : Retained < CentralDelegate > ,
372
+ can_send_without_response_supported : bool ,
372
373
// Map of identifiers to object pointers
373
374
peripherals : HashMap < Uuid , PeripheralInternal > ,
374
375
delegate_receiver : Fuse < Receiver < CentralDelegateEvent > > ,
@@ -492,8 +493,16 @@ impl CoreBluetoothInternal {
492
493
msg_send_id ! [ CBCentralManager :: alloc( ) , initWithDelegate: & * delegate, queue: queue]
493
494
} ;
494
495
496
+ let process_info = unsafe { NSProcessInfo :: processInfo ( ) } ;
497
+ let version = unsafe { process_info. operatingSystemVersion ( ) } ;
498
+ let mut can_send_without_response_supported = false ;
499
+ if ( version. majorVersion , version. minorVersion ) >= ( 11 , 2 ) {
500
+ can_send_without_response_supported = true ;
501
+ }
502
+
495
503
Self {
496
504
manager,
505
+ can_send_without_response_supported,
497
506
peripherals : HashMap :: new ( ) ,
498
507
delegate_receiver : receiver. fuse ( ) ,
499
508
event_sender,
@@ -888,7 +897,9 @@ impl CoreBluetoothInternal {
888
897
{
889
898
trace ! ( "Writing value! With kind {:?}" , kind) ;
890
899
unsafe {
891
- if kind == WriteType :: WithoutResponse {
900
+ if kind == WriteType :: WithoutResponse
901
+ && self . can_send_without_response_supported
902
+ {
892
903
// probably better idea would be to wait for the result of peripheral.peripheralIsReadyToSendWriteWithoutResponse
893
904
let mut attempts = 0 ;
894
905
while !peripheral. peripheral . canSendWriteWithoutResponse ( )
0 commit comments