From f4726735cf9607c4d77edf83f81a11a0e2ab5c98 Mon Sep 17 00:00:00 2001 From: Thomas Friebel Date: Wed, 1 Jan 2020 21:43:23 +0100 Subject: [PATCH] extmod/modbluetooth: Implement config getter for BLE rxbuf size. Knowing the buffer size can be important, to ensure that valid data will be received. --- docs/library/ubluetooth.rst | 2 +- extmod/modbluetooth.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/library/ubluetooth.rst b/docs/library/ubluetooth.rst index e3f4e13828..88dc98ecac 100644 --- a/docs/library/ubluetooth.rst +++ b/docs/library/ubluetooth.rst @@ -49,7 +49,7 @@ Configuration (e.g. PYBD) then it will be returned. Otherwise (e.g. ESP32) a random address will be generated when the BLE interface is made active. - - ``'rxbuf'``: Set the size in bytes of the internal buffer used to store + - ``'rxbuf'``: Get/set the size in bytes of the internal buffer used to store incoming events. This buffer is global to the entire BLE driver and so handles incoming data for all events, including all characteristics. Increasing this allows better handling of bursty incoming data (for diff --git a/extmod/modbluetooth.c b/extmod/modbluetooth.c index ef6bdff17d..af0289a0a6 100644 --- a/extmod/modbluetooth.c +++ b/extmod/modbluetooth.c @@ -293,6 +293,8 @@ STATIC mp_obj_t bluetooth_ble_config(size_t n_args, const mp_obj_t *args, mp_map mp_bluetooth_get_device_addr(addr); return mp_obj_new_bytes(addr, MP_ARRAY_SIZE(addr)); } + case MP_QSTR_rxbuf: + return mp_obj_new_int(self->ringbuf.size); default: mp_raise_ValueError("unknown config param"); }