Skip to content

Commit 049921f

Browse files
authored
Merge branch 'main' into memmonitor
2 parents 1ec3580 + 02b71e0 commit 049921f

File tree

107 files changed

+698
-686
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+698
-686
lines changed

shared-bindings/_bleio/Adapter.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@
6565
//| connections and also initiate connections."""
6666
//|
6767

68-
//| def __init__(self, ):
68+
//| def __init__(self) -> None:
6969
//| """You cannot create an instance of `_bleio.Adapter`.
7070
//| Use `_bleio.adapter` to access the sole instance available."""
7171
//| ...
7272
//|
7373

74-
//| enabled: Any = ...
74+
//| enabled: bool = ...
7575
//| """State of the BLE adapter."""
7676
//|
7777
STATIC mp_obj_t bleio_adapter_get_enabled(mp_obj_t self) {
@@ -95,7 +95,7 @@ const mp_obj_property_t bleio_adapter_enabled_obj = {
9595
(mp_obj_t)&mp_const_none_obj },
9696
};
9797

98-
//| address: Any = ...
98+
//| address: Address = ...
9999
//| """MAC address of the BLE adapter. (read-only)"""
100100
//|
101101
STATIC mp_obj_t bleio_adapter_get_address(mp_obj_t self) {
@@ -111,7 +111,7 @@ const mp_obj_property_t bleio_adapter_address_obj = {
111111
(mp_obj_t)&mp_const_none_obj },
112112
};
113113

114-
//| name: Any = ...
114+
//| name: str = ...
115115
//| """name of the BLE adapter used once connected.
116116
//| The name is "CIRCUITPY" + the last four hex digits of ``adapter.address``,
117117
//| to make it easy to distinguish multiple CircuitPython boards."""
@@ -135,7 +135,7 @@ const mp_obj_property_t bleio_adapter_name_obj = {
135135
(mp_obj_t)&mp_const_none_obj },
136136
};
137137

138-
//| def start_advertising(self, data: buf, *, scan_response: buf = None, connectable: bool = True, anonymous: bool = False, timeout: int = 0, interval: float = 0.1) -> Any:
138+
//| def start_advertising(self, data: buf, *, scan_response: buf = None, connectable: bool = True, anonymous: bool = False, timeout: int = 0, interval: float = 0.1) -> None:
139139
//| """Starts advertising until `stop_advertising` is called or if connectable, another device
140140
//| connects to us.
141141
//|
@@ -202,7 +202,7 @@ STATIC mp_obj_t bleio_adapter_start_advertising(mp_uint_t n_args, const mp_obj_t
202202
}
203203
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_adapter_start_advertising_obj, 2, bleio_adapter_start_advertising);
204204

205-
//| def stop_advertising(self, ) -> Any:
205+
//| def stop_advertising(self) -> None:
206206
//| """Stop sending advertising packets."""
207207
//| ...
208208
//|
@@ -215,7 +215,7 @@ STATIC mp_obj_t bleio_adapter_stop_advertising(mp_obj_t self_in) {
215215
}
216216
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_adapter_stop_advertising_obj, bleio_adapter_stop_advertising);
217217

218-
//| def start_scan(self, prefixes: sequence = b"", *, buffer_size: int = 512, extended: bool = False, timeout: float = None, interval: float = 0.1, window: float = 0.1, minimum_rssi: int = -80, active: bool = True) -> Any:
218+
//| def start_scan(self, prefixes: sequence = b"", *, buffer_size: int = 512, extended: bool = False, timeout: float = None, interval: float = 0.1, window: float = 0.1, minimum_rssi: int = -80, active: bool = True) -> iterable:
219219
//| """Starts a BLE scan and returns an iterator of results. Advertisements and scan responses are
220220
//| filtered and returned separately.
221221
//|
@@ -288,7 +288,7 @@ STATIC mp_obj_t bleio_adapter_start_scan(size_t n_args, const mp_obj_t *pos_args
288288
}
289289
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_adapter_start_scan_obj, 1, bleio_adapter_start_scan);
290290

291-
//| def stop_scan(self, ) -> Any:
291+
//| def stop_scan(self) -> None:
292292
//| """Stop the current scan."""
293293
//| ...
294294
//|
@@ -301,7 +301,7 @@ STATIC mp_obj_t bleio_adapter_stop_scan(mp_obj_t self_in) {
301301
}
302302
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_adapter_stop_scan_obj, bleio_adapter_stop_scan);
303303

304-
//| advertising: Any = ...
304+
//| advertising: bool = ...
305305
//| """True when the adapter is currently advertising. (read-only)"""
306306
//|
307307
STATIC mp_obj_t bleio_adapter_get_advertising(mp_obj_t self) {
@@ -317,7 +317,7 @@ const mp_obj_property_t bleio_adapter_advertising_obj = {
317317
(mp_obj_t)&mp_const_none_obj },
318318
};
319319

320-
//| connected: Any = ...
320+
//| connected: bool = ...
321321
//| """True when the adapter is connected to another device regardless of who initiated the
322322
//| connection. (read-only)"""
323323
//|
@@ -334,7 +334,7 @@ const mp_obj_property_t bleio_adapter_connected_obj = {
334334
(mp_obj_t)&mp_const_none_obj },
335335
};
336336

337-
//| connections: Any = ...
337+
//| connections: tuple = ...
338338
//| """Tuple of active connections including those initiated through
339339
//| :py:meth:`_bleio.Adapter.connect`. (read-only)"""
340340
//|
@@ -350,7 +350,7 @@ const mp_obj_property_t bleio_adapter_connections_obj = {
350350
(mp_obj_t)&mp_const_none_obj },
351351
};
352352

353-
//| def connect(self, address: Address, *, timeout: float/int) -> Any:
353+
//| def connect(self, address: Address, *, timeout: float/int) -> Connection:
354354
//| """Attempts a connection to the device with the given address.
355355
//|
356356
//| :param Address address: The address of the peripheral to connect to
@@ -380,7 +380,7 @@ STATIC mp_obj_t bleio_adapter_connect(mp_uint_t n_args, const mp_obj_t *pos_args
380380
}
381381
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_adapter_connect_obj, 2, bleio_adapter_connect);
382382

383-
//| def erase_bonding(self, ) -> Any:
383+
//| def erase_bonding(self) -> None:
384384
//| """Erase all bonding information stored in flash memory."""
385385
//| ...
386386
//|

shared-bindings/_bleio/Address.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
//| """Encapsulates the address of a BLE device."""
3939
//|
4040

41-
//| def __init__(self, address: buf, address_type: Any):
41+
//| def __init__(self, address: ReadableBuffer, address_type: int) -> None:
4242
//| """Create a new Address object encapsulating the address value.
4343
//| The value itself can be one of:
4444
//|
@@ -77,8 +77,8 @@ STATIC mp_obj_t bleio_address_make_new(const mp_obj_type_t *type, size_t n_args,
7777
return MP_OBJ_FROM_PTR(self);
7878
}
7979

80-
//| address_bytes: Any = ...
81-
//| r"""The bytes that make up the device address (read-only).
80+
//| address_bytes: bytes = ...
81+
//| """The bytes that make up the device address (read-only).
8282
//|
8383
//| Note that the ``bytes`` object returned is in little-endian order:
8484
//| The least significant byte is ``address_bytes[0]``. So the address will
@@ -108,7 +108,7 @@ const mp_obj_property_t bleio_address_address_bytes_obj = {
108108
(mp_obj_t)&mp_const_none_obj},
109109
};
110110

111-
//| type: Any = ...
111+
//| type: int = ...
112112
//| """The address type (read-only).
113113
//|
114114
//| One of the integer values: `PUBLIC`, `RANDOM_STATIC`, `RANDOM_PRIVATE_RESOLVABLE`,
@@ -128,7 +128,7 @@ const mp_obj_property_t bleio_address_type_obj = {
128128
(mp_obj_t)&mp_const_none_obj},
129129
};
130130

131-
//| def __eq__(self, other: Any) -> Any:
131+
//| def __eq__(self, other: Any) -> bool:
132132
//| """Two Address objects are equal if their addresses and address types are equal."""
133133
//| ...
134134
//|
@@ -154,7 +154,7 @@ STATIC mp_obj_t bleio_address_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_o
154154
}
155155
}
156156

157-
//| def __hash__(self, ) -> Any:
157+
//| def __hash__(self) -> int:
158158
//| """Returns a hash for the Address data."""
159159
//| ...
160160
//|
@@ -187,17 +187,17 @@ STATIC void bleio_address_print(const mp_print_t *print, mp_obj_t self_in, mp_pr
187187
buf[5], buf[4], buf[3], buf[2], buf[1], buf[0]);
188188
}
189189

190-
//| PUBLIC: Any = ...
190+
//| PUBLIC: int = ...
191191
//| """A publicly known address, with a company ID (high 24 bits)and company-assigned part (low 24 bits)."""
192192
//|
193-
//| RANDOM_STATIC: Any = ...
193+
//| RANDOM_STATIC: int = ...
194194
//| """A randomly generated address that does not change often. It may never change or may change after
195195
//| a power cycle."""
196196
//|
197-
//| RANDOM_PRIVATE_RESOLVABLE: Any = ...
197+
//| RANDOM_PRIVATE_RESOLVABLE: int = ...
198198
//| """An address that is usable when the peer knows the other device's secret Identity Resolving Key (IRK)."""
199199
//|
200-
//| RANDOM_PRIVATE_NON_RESOLVABLE: Any = ...
200+
//| RANDOM_PRIVATE_NON_RESOLVABLE: int = ...
201201
//| """A randomly generated address that changes on every connection."""
202202
//|
203203
STATIC const mp_rom_map_elem_t bleio_address_locals_dict_table[] = {

shared-bindings/_bleio/Attribute.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,32 +36,32 @@
3636
//| :py:class:`~Characteristic` and :py:class:`~Descriptor`,
3737
//| but is not defined as a Python superclass of those classes."""
3838
//|
39-
//| def __init__(self, ):
39+
//| def __init__(self) -> None:
4040
//| """You cannot create an instance of :py:class:`~_bleio.Attribute`."""
4141
//| ...
4242
//|
4343

4444
STATIC const mp_rom_map_elem_t bleio_attribute_locals_dict_table[] = {
4545

46-
//| NO_ACCESS: Any = ...
46+
//| NO_ACCESS: int = ...
4747
//| """security mode: access not allowed"""
4848
//|
49-
//| OPEN: Any = ...
49+
//| OPEN: int = ...
5050
//| """security_mode: no security (link is not encrypted)"""
5151
//|
52-
//| ENCRYPT_NO_MITM: Any = ...
52+
//| ENCRYPT_NO_MITM: int = ...
5353
//| """security_mode: unauthenticated encryption, without man-in-the-middle protection"""
5454
//|
55-
//| ENCRYPT_WITH_MITM: Any = ...
55+
//| ENCRYPT_WITH_MITM: int = ...
5656
//| """security_mode: authenticated encryption, with man-in-the-middle protection"""
5757
//|
58-
//| LESC_ENCRYPT_WITH_MITM: Any = ...
58+
//| LESC_ENCRYPT_WITH_MITM: int = ...
5959
//| """security_mode: LESC encryption, with man-in-the-middle protection"""
6060
//|
61-
//| SIGNED_NO_MITM: Any = ...
61+
//| SIGNED_NO_MITM: int = ...
6262
//| """security_mode: unauthenticated data signing, without man-in-the-middle protection"""
6363
//|
64-
//| SIGNED_WITH_MITM: Any = ...
64+
//| SIGNED_WITH_MITM: int = ...
6565
//| """security_mode: authenticated data signing, without man-in-the-middle protection"""
6666
//|
6767
{ MP_ROM_QSTR(MP_QSTR_NO_ACCESS), MP_ROM_INT(SECURITY_MODE_NO_ACCESS) },

shared-bindings/_bleio/Characteristic.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@
3737
//| """Stores information about a BLE service characteristic and allows reading
3838
//| and writing of the characteristic's value."""
3939
//|
40-
//| def __init__(self, ):
40+
//| def __init__(self) -> None:
4141
//| """There is no regular constructor for a Characteristic. A new local Characteristic can be created
4242
//| and attached to a Service by calling `add_to_service()`.
4343
//| Remote Characteristic objects are created by `Connection.discover_remote_services()`
4444
//| as part of remote Services."""
4545
//| ...
4646
//|
4747

48-
//| def add_to_service(self, service: Service, uuid: UUID, *, properties: int = 0, read_perm: int = Attribute.OPEN, write_perm: int = Attribute.OPEN, max_length: int = 20, fixed_length: bool = False, initial_value: buf = None) -> Any:
48+
//| def add_to_service(self, service: Service, uuid: UUID, *, properties: int = 0, read_perm: int = Attribute.OPEN, write_perm: int = Attribute.OPEN, max_length: int = 20, fixed_length: bool = False, initial_value: buf = None) -> Characteristic:
4949
//| """Create a new Characteristic object, and add it to this Service.
5050
//|
5151
//| :param Service service: The service that will provide this characteristic
@@ -141,7 +141,7 @@ STATIC MP_DEFINE_CONST_CLASSMETHOD_OBJ(bleio_characteristic_add_to_service_obj,
141141

142142

143143

144-
//| properties: Any = ...
144+
//| properties: int = ...
145145
//| """An int bitmask representing which properties are set, specified as bitwise or'ing of
146146
//| of these possible values.
147147
//| `BROADCAST`, `INDICATE`, `NOTIFY`, `READ`, `WRITE`, `WRITE_NO_RESPONSE`."""
@@ -160,7 +160,7 @@ const mp_obj_property_t bleio_characteristic_properties_obj = {
160160
(mp_obj_t)&mp_const_none_obj },
161161
};
162162

163-
//| uuid: Any = ...
163+
//| uuid: Optional[UUID] = ...
164164
//| """The UUID of this characteristic. (read-only)
165165
//|
166166
//| Will be ``None`` if the 128-bit UUID for this characteristic is not known."""
@@ -180,7 +180,7 @@ const mp_obj_property_t bleio_characteristic_uuid_obj = {
180180
(mp_obj_t)&mp_const_none_obj },
181181
};
182182

183-
//| value: Any = ...
183+
//| value: bytearray = ...
184184
//| """The value of this characteristic."""
185185
//|
186186
STATIC mp_obj_t bleio_characteristic_get_value(mp_obj_t self_in) {
@@ -211,7 +211,7 @@ const mp_obj_property_t bleio_characteristic_value_obj = {
211211
(mp_obj_t)&mp_const_none_obj },
212212
};
213213

214-
//| descriptors: Any = ...
214+
//| descriptors: Descriptor = ...
215215
//| """A tuple of :py:class:`Descriptor` that describe this characteristic. (read-only)"""
216216
//|
217217
STATIC mp_obj_t bleio_characteristic_get_descriptors(mp_obj_t self_in) {
@@ -241,7 +241,7 @@ const mp_obj_property_t bleio_characteristic_descriptors_obj = {
241241
(mp_obj_t)&mp_const_none_obj },
242242
};
243243

244-
//| service: Any = ...
244+
//| service: Service = ...
245245
//| """The Service this Characteristic is a part of."""
246246
//|
247247
STATIC mp_obj_t bleio_characteristic_get_service(mp_obj_t self_in) {
@@ -258,7 +258,7 @@ const mp_obj_property_t bleio_characteristic_service_obj = {
258258
(mp_obj_t)&mp_const_none_obj },
259259
};
260260

261-
//| def set_cccd(self, *, notify: bool = False, indicate: float = False) -> Any:
261+
//| def set_cccd(self, *, notify: bool = False, indicate: float = False) -> None:
262262
//| """Set the remote characteristic's CCCD to enable or disable notification and indication.
263263
//|
264264
//| :param bool notify: True if Characteristic should receive notifications of remote writes
@@ -291,22 +291,22 @@ STATIC const mp_rom_map_elem_t bleio_characteristic_locals_dict_table[] = {
291291
{ MP_ROM_QSTR(MP_QSTR_set_cccd), MP_ROM_PTR(&bleio_characteristic_set_cccd_obj) },
292292

293293
// Bitmask constants to represent properties
294-
//| BROADCAST: Any = ...
294+
//| BROADCAST: int = ...
295295
//| """property: allowed in advertising packets"""
296296
//|
297-
//| INDICATE: Any = ...
297+
//| INDICATE: int = ...
298298
//| """property: server will indicate to the client when the value is set and wait for a response"""
299299
//|
300-
//| NOTIFY: Any = ...
300+
//| NOTIFY: int = ...
301301
//| """property: server will notify the client when the value is set"""
302302
//|
303-
//| READ: Any = ...
303+
//| READ: int = ...
304304
//| """property: clients may read this characteristic"""
305305
//|
306-
//| WRITE: Any = ...
306+
//| WRITE: int = ...
307307
//| """property: clients may write this characteristic; a response will be sent back"""
308308
//|
309-
//| WRITE_NO_RESPONSE: Any = ...
309+
//| WRITE_NO_RESPONSE: int = ...
310310
//| """property: clients may write this characteristic; no response will be sent back"""
311311
//|
312312
{ MP_ROM_QSTR(MP_QSTR_BROADCAST), MP_ROM_INT(CHAR_PROP_BROADCAST) },

shared-bindings/_bleio/CharacteristicBuffer.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ STATIC void raise_error_if_not_connected(bleio_characteristic_buffer_obj_t *self
4444
//| class CharacteristicBuffer:
4545
//| """Accumulates a Characteristic's incoming values in a FIFO buffer."""
4646
//|
47-
//| def __init__(self, characteristic: Characteristic, *, timeout: int = 1, buffer_size: int = 64):
47+
//| def __init__(self, characteristic: Characteristic, *, timeout: int = 1, buffer_size: int = 64) -> None:
4848
//|
4949
//| """Monitor the given Characteristic. Each time a new value is written to the Characteristic
5050
//| add the newly-written bytes to a FIFO buffer.
@@ -100,7 +100,7 @@ STATIC void check_for_deinit(bleio_characteristic_buffer_obj_t *self) {
100100

101101
// These are standard stream methods. Code is in py/stream.c.
102102
//
103-
//| def read(self, nbytes: Any = None) -> Any:
103+
//| def read(self, nbytes: int = None) -> Optional[bytes]:
104104
//| """Read characters. If ``nbytes`` is specified then read at most that many
105105
//| bytes. Otherwise, read everything that arrives until the connection
106106
//| times out. Providing the number of bytes expected is highly recommended
@@ -110,14 +110,14 @@ STATIC void check_for_deinit(bleio_characteristic_buffer_obj_t *self) {
110110
//| :rtype: bytes or None"""
111111
//| ...
112112
//|
113-
//| def readinto(self, buf: Any) -> Any:
113+
//| def readinto(self, buf: WriteableBuffer) -> Optional[int]:
114114
//| """Read bytes into the ``buf``. Read at most ``len(buf)`` bytes.
115115
//|
116116
//| :return: number of bytes read and stored into ``buf``
117117
//| :rtype: int or None (on a non-blocking error)"""
118118
//| ...
119119
//|
120-
//| def readline(self, ) -> Any:
120+
//| def readline(self) -> bytes:
121121
//| """Read a line, ending in a newline character.
122122
//|
123123
//| :return: the line read
@@ -167,7 +167,7 @@ STATIC mp_uint_t bleio_characteristic_buffer_ioctl(mp_obj_t self_in, mp_uint_t r
167167
return ret;
168168
}
169169

170-
//| in_waiting: Any = ...
170+
//| in_waiting: int = ...
171171
//| """The number of bytes in the input buffer, available to be read"""
172172
//|
173173
STATIC mp_obj_t bleio_characteristic_buffer_obj_get_in_waiting(mp_obj_t self_in) {
@@ -184,7 +184,7 @@ const mp_obj_property_t bleio_characteristic_buffer_in_waiting_obj = {
184184
(mp_obj_t)&mp_const_none_obj},
185185
};
186186

187-
//| def reset_input_buffer(self, ) -> Any:
187+
//| def reset_input_buffer(self) -> None:
188188
//| """Discard any unread characters in the input buffer."""
189189
//| ...
190190
//|
@@ -196,7 +196,7 @@ STATIC mp_obj_t bleio_characteristic_buffer_obj_reset_input_buffer(mp_obj_t self
196196
}
197197
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_buffer_reset_input_buffer_obj, bleio_characteristic_buffer_obj_reset_input_buffer);
198198

199-
//| def deinit(self, ) -> Any:
199+
//| def deinit(self) -> None:
200200
//| """Disable permanently."""
201201
//| ...
202202
//|

0 commit comments

Comments
 (0)