Skip to content

Commit 9b98d48

Browse files
committed
switch to ReadableBuffer and WriteableBuffer
1 parent 3c10dd8 commit 9b98d48

1 file changed

Lines changed: 20 additions & 20 deletions

File tree

ports/espressif/bindings/espnow/ESPNow.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,10 @@ static uint8_t *_get_bytes_len(mp_obj_t obj, size_t len, mp_uint_t rw) {
255255
return (uint8_t *)bufinfo.buf;
256256
}
257257

258-
//| def set_pmk(self, pmk: bytes) -> None:
258+
//| def set_pmk(self, pmk: ReadableBuffer) -> None:
259259
//| """Set the ESP-NOW Primary Master Key (pmk) for encrypted communications.
260260
//|
261-
//| :param bytes pmk: The ESP-NOW Primary Master Key (length = 16 bytes)."""
261+
//| :param ReadableBuffer pmk: The ESP-NOW Primary Master Key (length = 16 bytes)."""
262262
//| ...
263263
STATIC mp_obj_t espnow_set_pmk(mp_obj_t self_in, mp_obj_t key) {
264264
check_esp_err(esp_now_set_pmk(_get_bytes_len(key, ESP_NOW_KEY_LEN, MP_BUFFER_READ)));
@@ -426,14 +426,14 @@ static void _wait_for_pending_responses(espnow_obj_t *self) {
426426

427427
//| def send(
428428
//| self,
429-
//| message: Union[bytearray, bytes, str],
430-
//| mac: Optional[bytes],
429+
//| message: ReadableBuffer,
430+
//| mac: Optional[ReadableBuffer],
431431
//| sync: bool = True,
432432
//| ) -> bool:
433433
//| """Send a message to the peer's mac address. Optionally wait for a response.
434434
//|
435-
//| :param Union[bytearray, bytes, str] message: The message to send (length < 250 bytes).
436-
//| :param bytes mac: The peer's address (length = 6 bytes). If `None` or any non-true value, send to all registered peers.
435+
//| :param ReadableBuffer message: The message to send (length <= 250 bytes).
436+
//| :param ReadableBuffer mac: The peer's address (length = 6 bytes). If `None` or any non-true value, send to all registered peers.
437437
//| :param bool sync: If `True`, wait for response from peer(s) after sending.
438438
//|
439439
//| :returns:
@@ -498,15 +498,15 @@ STATIC mp_obj_t espnow_send(size_t n_args, const mp_obj_t *pos_args, mp_map_t *k
498498
}
499499
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(espnow_send_obj, 2, espnow_send);
500500

501-
//| def recv(self, buffers: List[bytearray]) -> int:
501+
//| def recv(self, buffers: List[WriteableBuffer]) -> int:
502502
//| """Loads mac, message, rssi and timestamp into the provided buffers.
503503
//|
504504
//| If buffers is 2 elements long, the mac and message will be
505505
//| loaded into the 1st and 2nd elements.
506506
//| If buffers is 4 elements long, the rssi and timestamp values will be
507507
//| loaded into the 3rd and 4th elements.
508508
//|
509-
//| :param List[bytearray] buffers: List of buffers to be loaded.
509+
//| :param List[WriteableBuffer] buffers: List of buffers to be loaded.
510510
//|
511511
//| :returns: Length of the message."""
512512
//| ...
@@ -651,16 +651,16 @@ static void _update_peer_count(espnow_obj_t *self) {
651651

652652
//| def add_peer(
653653
//| self,
654-
//| mac: bytes,
655-
//| lmk: Optional[bytes],
654+
//| mac: ReadableBuffer,
655+
//| lmk: Optional[ReadableBuffer],
656656
//| channel: int = 0,
657657
//| interface: int = 0,
658658
//| encrypt: bool = False,
659659
//| ) -> None:
660660
//| """Add peer.
661661
//|
662-
//| :param bytes mac: The mac address of the peer.
663-
//| :param bytes lmk: The Local Master Key (lmk) of the peer.
662+
//| :param ReadableBuffer mac: The mac address of the peer.
663+
//| :param ReadableBuffer lmk: The Local Master Key (lmk) of the peer.
664664
//| :param int channel: The peer's channel. Default: 0 ie. use the current channel.
665665
//| :param int interface: The WiFi interface to use. Default: 0 ie. STA.
666666
//| :param bool encrypt: Whether or not to use encryption."""
@@ -678,16 +678,16 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(espnow_add_peer_obj, 2, espnow_add_peer);
678678

679679
//| def mod_peer(
680680
//| self,
681-
//| mac: bytes,
682-
//| lmk: Optional[bytes],
681+
//| mac: ReadableBuffer,
682+
//| lmk: Optional[ReadableBuffer],
683683
//| channel: int = 0,
684684
//| interface: int = 0,
685685
//| encrypt: bool = False,
686686
//| ) -> None:
687687
//| """Modify peer.
688688
//|
689-
//| :param bytes mac: The mac address of the peer.
690-
//| :param bytes lmk: The Local Master Key (lmk) of the peer.
689+
//| :param ReadableBuffer mac: The mac address of the peer.
690+
//| :param ReadableBuffer lmk: The Local Master Key (lmk) of the peer.
691691
//| :param int channel: The peer's channel. Default: 0 ie. use the current channel.
692692
//| :param int interface: The WiFi interface to use. Default: 0 ie. STA.
693693
//| :param bool encrypt: Whether or not to use encryption."""
@@ -702,10 +702,10 @@ STATIC mp_obj_t espnow_mod_peer(size_t n_args, const mp_obj_t *pos_args, mp_map_
702702
}
703703
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(espnow_mod_peer_obj, 2, espnow_mod_peer);
704704

705-
//| def del_peer(self, mac: bytes) -> None:
705+
//| def del_peer(self, mac: ReadableBuffer) -> None:
706706
//| """Delete peer.
707707
//|
708-
//| :param bytes mac: The mac address of the peer."""
708+
//| :param ReadableBuffer mac: The mac address of the peer."""
709709
//| ...
710710
STATIC mp_obj_t espnow_del_peer(mp_obj_t self_in, mp_obj_t mac) {
711711
espnow_obj_t *self = MP_OBJ_TO_PTR(self_in);
@@ -732,10 +732,10 @@ static mp_obj_t _peer_info_to_tuple(const esp_now_peer_info_t *peer) {
732732
mp_obj_new_bool(peer->encrypt));
733733
}
734734

735-
//| def get_peer(self, mac: bytes) -> Tuple[bytes, int, int, bool]:
735+
//| def get_peer(self, mac: ReadableBuffer) -> Tuple[bytes, int, int, bool]:
736736
//| """Get the peer info for mac as a `tuple`.
737737
//|
738-
//| :param bytes mac: The mac address of the peer.
738+
//| :param ReadableBuffer mac: The mac address of the peer.
739739
//|
740740
//| :returns: A `tuple` of (mac, lmk, channel, interface, encrypt)."""
741741
//| ...

0 commit comments

Comments
 (0)