File tree 1 file changed +9
-2
lines changed
1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -596,21 +596,28 @@ def read_value(self, offset=0):
596
596
error = _error_from_dbus_error (e )
597
597
self .service .device .characteristic_read_value_failed (self , error = error )
598
598
599
- def write_value (self , value , offset = 0 ):
599
+ def write_value (self , value , offset = 0 , with_response = True ):
600
600
"""
601
601
Attempts to write a value to the characteristic.
602
602
603
603
Success or failure will be notified by calls to `write_value_succeeded` or `write_value_failed` respectively.
604
604
605
605
:param value: array of bytes to be written
606
606
:param offset: offset from where to start writing the bytes (defaults to 0)
607
+ :param with_response: whether a response should be requested for the write (defaults to True)
607
608
"""
608
609
bytes = [dbus .Byte (b ) for b in value ]
609
610
611
+ if with_response == True :
612
+ write_type = "request"
613
+ else :
614
+ write_type = "command"
615
+
610
616
try :
611
617
self ._object .WriteValue (
612
618
bytes ,
613
- {'offset' : dbus .UInt16 (offset , variant_level = 1 )},
619
+ {'offset' : dbus .UInt16 (offset , variant_level = 1 ),
620
+ 'type' : write_type },
614
621
reply_handler = self ._write_value_succeeded ,
615
622
error_handler = self ._write_value_failed ,
616
623
dbus_interface = 'org.bluez.GattCharacteristic1' )
You can’t perform that action at this time.
0 commit comments