28
28
* Author(s): Dan Halbert for Adafruit Industries
29
29
30
30
"""
31
- from bleio import Characteristic , CharacteristicBuffer , Peripheral , Service
31
+ from bleio import Attribute , Characteristic , CharacteristicBuffer , Peripheral , Service
32
32
from .advertising import ServerAdvertisement
33
33
from .uart import NUS_SERVICE_UUID , NUS_RX_CHAR_UUID , NUS_TX_CHAR_UUID
34
34
@@ -56,8 +56,14 @@ class UARTServer:
56
56
"""
57
57
58
58
def __init__ (self , * , timeout = 1.0 , buffer_size = 64 , name = None ):
59
- self ._read_char = Characteristic (NUS_RX_CHAR_UUID , write = True , write_no_response = True )
60
- self ._write_char = Characteristic (NUS_TX_CHAR_UUID , notify = True )
59
+ self ._read_char = Characteristic (
60
+ NUS_RX_CHAR_UUID ,
61
+ properties = Characteristic .WRITE | Characteristic .WRITE_NO_RESPONSE ,
62
+ read_perm = Attribute .NO_ACCESS , write_perm = Attribute .OPEN )
63
+ self ._write_char = Characteristic (
64
+ NUS_TX_CHAR_UUID ,
65
+ properties = Characteristic .NOTIFY ,
66
+ read_perm = Attribute .OPEN , write_perm = Attribute .NO_ACCESS )
61
67
self ._read_buffer = CharacteristicBuffer (self ._read_char ,
62
68
timeout = timeout , buffer_size = buffer_size )
63
69
@@ -82,6 +88,10 @@ def connected(self):
82
88
"""True if someone connected to the server."""
83
89
return self ._periph .connected
84
90
91
+ def disconnect (self ):
92
+ """Disconnect from peer."""
93
+ self ._periph .disconnect ()
94
+
85
95
def read (self , nbytes = None ):
86
96
"""
87
97
Read characters. If ``nbytes`` is specified then read at most that many bytes.
0 commit comments