@@ -31,7 +31,7 @@ use objc2_core_bluetooth::{
3131 CBCharacteristicProperties , CBCharacteristicWriteType , CBDescriptor , CBManager ,
3232 CBManagerAuthorization , CBManagerState , CBPeripheral , CBPeripheralState , CBService , CBUUID ,
3333} ;
34- use objc2_foundation:: { NSArray , NSData , NSMutableDictionary , NSNumber } ;
34+ use objc2_foundation:: { NSArray , NSData , NSMutableDictionary , NSNumber , NSProcessInfo } ;
3535use std:: {
3636 collections:: { BTreeSet , HashMap , VecDeque } ,
3737 ffi:: CString ,
@@ -369,6 +369,7 @@ impl PeripheralInternal {
369369struct CoreBluetoothInternal {
370370 manager : Retained < CBCentralManager > ,
371371 delegate : Retained < CentralDelegate > ,
372+ can_send_without_response_supported : bool ,
372373 // Map of identifiers to object pointers
373374 peripherals : HashMap < Uuid , PeripheralInternal > ,
374375 delegate_receiver : Fuse < Receiver < CentralDelegateEvent > > ,
@@ -492,8 +493,16 @@ impl CoreBluetoothInternal {
492493 msg_send_id ! [ CBCentralManager :: alloc( ) , initWithDelegate: & * delegate, queue: queue]
493494 } ;
494495
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+
495503 Self {
496504 manager,
505+ can_send_without_response_supported,
497506 peripherals : HashMap :: new ( ) ,
498507 delegate_receiver : receiver. fuse ( ) ,
499508 event_sender,
@@ -888,7 +897,9 @@ impl CoreBluetoothInternal {
888897 {
889898 trace ! ( "Writing value! With kind {:?}" , kind) ;
890899 unsafe {
891- if kind == WriteType :: WithoutResponse {
900+ if kind == WriteType :: WithoutResponse
901+ && self . can_send_without_response_supported
902+ {
892903 // probably better idea would be to wait for the result of peripheral.peripheralIsReadyToSendWriteWithoutResponse
893904 let mut attempts = 0 ;
894905 while !peripheral. peripheral . canSendWriteWithoutResponse ( )
0 commit comments