I am currently working on an adaptation of the BLE UART code given here https://github.com/micropython/micropyt ... ipheral.py.
But I am facing what seems to me a bug in features of https://docs.micropython.org/en/latest/ ... tooth.html.
I can't manage to lift the limit of 20 char payload in a characteristic.
Followin explantions given in the lib description :
Characteristics and descriptors have a default maximum size of 20 bytes. Anything written to them by a client will be truncated to this length. However, any local write will increase the maximum size, so if you want to allow larger writes from a client to a given characteristic, use gatts_write after registration. e.g. gatts_write(char_handle, bytes(100)).
BLE.gatts_set_buffer(value_handle, len, append=False, /)
Sets the internal buffer size for a value in bytes. This will limit the largest possible write that can be received. The default is 20.
Setting append to True will make all remote writes append to, rather than replace, the current value. At most len bytes can be buffered in this way. When you use gatts_read, the value will be cleared after reading. This feature is useful when implementing something like the Nordic UART Service.
I added these bold lines to my code :
Code: Select all
def __init__(self, ble, name="mpy-uart"):
self._ble = ble
self._ble.active(True)
self._ble.irq(self._irq)
((self._handle_tx, self._handle_rx),) = self._ble.gatts_register_services((_UART_SERVICE,))
[b]self._ble.gatts_set_buffer(self._handle_tx, _MAX_NB_BYTES, False)[/b]
[b]self._ble.gatts_set_buffer(self._handle_rx, _MAX_NB_BYTES, False)[/b]
[b]self._ble.gatts_write(self._handle_tx, bytes(_MAX_NB_BYTES))[/b]
[b]self._ble.gatts_write(self._handle_rx, bytes(_MAX_NB_BYTES))[/b]
self._connections = set()
self._write_callback = None
self._payload = advertising_payload(name=name, services=[_UART_UUID])
self._advertise()
No error reported, script is running, but reads into Rx from peripheral side are still truncated to 20 char ...
Can you help please ?