File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ use std::{
38
38
fmt:: { self , Debug , Formatter } ,
39
39
ops:: Deref ,
40
40
thread,
41
+ time:: Duration ,
41
42
} ;
42
43
use tokio:: runtime;
43
44
use uuid:: Uuid ;
@@ -887,6 +888,19 @@ impl CoreBluetoothInternal {
887
888
{
888
889
trace ! ( "Writing value! With kind {:?}" , kind) ;
889
890
unsafe {
891
+ if kind == WriteType :: WithoutResponse {
892
+ // probably better idea would be to wait for the result of peripheral.peripheralIsReadyToSendWriteWithoutResponse
893
+ let mut attempts = 0 ;
894
+ while !peripheral. peripheral . canSendWriteWithoutResponse ( )
895
+ && attempts < 100
896
+ {
897
+ attempts += 1 ;
898
+ // min. connection interval time is 15ms. see the document:
899
+ // https://developer.apple.com/library/archive/qa/qa1931/_index.html
900
+ thread:: sleep ( Duration :: from_millis ( 15 ) ) ;
901
+ }
902
+ }
903
+
890
904
peripheral. peripheral . writeValue_forCharacteristic_type (
891
905
& NSData :: from_vec ( data) ,
892
906
& characteristic. characteristic ,
You can’t perform that action at this time.
0 commit comments