diff options
| author | dherrada <dylan.herrada@gmail.com> | 2020-05-01 18:23:27 -0400 |
|---|---|---|
| committer | dherrada <dylan.herrada@gmail.com> | 2020-05-01 18:23:27 -0400 |
| commit | 0e465e63b98c3825298219e2144a145208aaff7f (patch) | |
| tree | 9858006ca4b634bafb5ce8826bcca56b7e670a87 /shared-bindings/_bleio/PacketBuffer.c | |
| parent | d65e85104431b354737d11b5ec9a29387d390cfd (diff) | |
Did audiopwmio, bitbangio, and _bleio
Diffstat (limited to 'shared-bindings/_bleio/PacketBuffer.c')
| -rw-r--r-- | shared-bindings/_bleio/PacketBuffer.c | 73 |
1 files changed, 36 insertions, 37 deletions
diff --git a/shared-bindings/_bleio/PacketBuffer.c b/shared-bindings/_bleio/PacketBuffer.c index 9e3666044..14efa022b 100644 --- a/shared-bindings/_bleio/PacketBuffer.c +++ b/shared-bindings/_bleio/PacketBuffer.c @@ -35,29 +35,30 @@ #include "shared-bindings/_bleio/UUID.h" #include "shared-bindings/util.h" -//| .. currentmodule:: _bleio +//| class PacketBuffer: +//| """.. currentmodule:: _bleio //| -//| :class:`PacketBuffer` -- Packet-oriented characteristic usage. -//| ===================================================================== +//| :class:`PacketBuffer` -- Packet-oriented characteristic usage. +//| ===================================================================== //| -//| Accumulates a Characteristic's incoming packets in a FIFO buffer and facilitates packet aware -//| outgoing writes. A packet's size is either the characteristic length or the maximum transmission -//| unit (MTU), whichever is smaller. The MTU can change so check `packet_size` before creating a -//| buffer to store data. +//| Accumulates a Characteristic's incoming packets in a FIFO buffer and facilitates packet aware +//| outgoing writes. A packet's size is either the characteristic length or the maximum transmission +//| unit (MTU), whichever is smaller. The MTU can change so check `packet_size` before creating a +//| buffer to store data. //| -//| When we're the server, we ignore all connections besides the first to subscribe to -//| notifications. +//| When we're the server, we ignore all connections besides the first to subscribe to +//| notifications.""" //| -//| .. class:: PacketBuffer(characteristic, *, buffer_size) +//| def __init__(self, characteristic: Characteristic, *, buffer_size: int): +//| """Monitor the given Characteristic. Each time a new value is written to the Characteristic +//| add the newly-written bytes to a FIFO buffer. //| -//| Monitor the given Characteristic. Each time a new value is written to the Characteristic -//| add the newly-written bytes to a FIFO buffer. -//| -//| :param Characteristic characteristic: The Characteristic to monitor. -//| It may be a local Characteristic provided by a Peripheral Service, or a remote Characteristic -//| in a remote Service that a Central has connected to. -//| :param int buffer_size: Size of ring buffer (in packets of the Characteristic's maximum -//| length) that stores incoming packets coming from the peer. +//| :param Characteristic characteristic: The Characteristic to monitor. +//| It may be a local Characteristic provided by a Peripheral Service, or a remote Characteristic +//| in a remote Service that a Central has connected to. +//| :param int buffer_size: Size of ring buffer (in packets of the Characteristic's maximum +//| length) that stores incoming packets coming from the peer.""" +//| ... //| STATIC mp_obj_t bleio_packet_buffer_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_characteristic, ARG_buffer_size }; @@ -94,13 +95,13 @@ STATIC void check_for_deinit(bleio_packet_buffer_obj_t *self) { } } -//| .. method:: readinto(buf) -//| -//| Reads a single BLE packet into the ``buf``. Raises an exception if the next packet is longer -//| than the given buffer. Use `packet_size` to read the maximum length of a single packet. +//| def readinto(self, buf: Any) -> Any: +//| """Reads a single BLE packet into the ``buf``. Raises an exception if the next packet is longer +//| than the given buffer. Use `packet_size` to read the maximum length of a single packet. //| -//| :return: number of bytes read and stored into ``buf`` -//| :rtype: int +//| :return: number of bytes read and stored into ``buf`` +//| :rtype: int""" +//| ... //| STATIC mp_obj_t bleio_packet_buffer_readinto(mp_obj_t self_in, mp_obj_t buffer_obj) { bleio_packet_buffer_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -118,12 +119,12 @@ STATIC mp_obj_t bleio_packet_buffer_readinto(mp_obj_t self_in, mp_obj_t buffer_o } STATIC MP_DEFINE_CONST_FUN_OBJ_2(bleio_packet_buffer_readinto_obj, bleio_packet_buffer_readinto); -//| .. method:: write(data, *, header=None) -//| -//| Writes all bytes from data into the same outgoing packet. The bytes from header are included -//| before data when the pending packet is currently empty. +//| def write(self, data: Any, *, header: Any = None) -> Any: +//| """Writes all bytes from data into the same outgoing packet. The bytes from header are included +//| before data when the pending packet is currently empty. //| -//| This does not block until the data is sent. It only blocks until the data is pending. +//| This does not block until the data is sent. It only blocks until the data is pending.""" +//| ... //| // TODO: Add a kwarg `merge=False` to dictate whether subsequent writes are merged into a pending // one. @@ -155,10 +156,9 @@ STATIC mp_obj_t bleio_packet_buffer_write(mp_uint_t n_args, const mp_obj_t *pos_ } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_packet_buffer_write_obj, 1, bleio_packet_buffer_write); -//| .. method:: deinit() -//| -//| Disable permanently. -//| +//| def deinit(self, ) -> Any: +//| """Disable permanently.""" +//| ... STATIC mp_obj_t bleio_packet_buffer_deinit(mp_obj_t self_in) { bleio_packet_buffer_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_bleio_packet_buffer_deinit(self); @@ -166,10 +166,9 @@ STATIC mp_obj_t bleio_packet_buffer_deinit(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_packet_buffer_deinit_obj, bleio_packet_buffer_deinit); -//| .. attribute:: packet_size -//| -//| Maximum size of each packet in bytes. This is the minimum of the Characteristic length and -//| the negotiated Maximum Transfer Unit (MTU). +//| packet_size: Any = ... +//| """Maximum size of each packet in bytes. This is the minimum of the Characteristic length and +//| the negotiated Maximum Transfer Unit (MTU).""" //| STATIC mp_obj_t bleio_packet_buffer_get_packet_size(mp_obj_t self_in) { bleio_packet_buffer_obj_t *self = MP_OBJ_TO_PTR(self_in); |
