Closed mikewhetzel closed 1 year ago
I have solved my issue, for anyone wondering about this in the future.
I appended
class BLE():
def __init__(self, name):
self.name = name
self.ble = ubluetooth.BLE()
self.ble.active(True)
self.led = Pin(2, Pin.OUT)
self.timer1 = Timer(0)
self.timer2 = Timer(1)
self.disconnected()
self.ble.irq(self.ble_irq)
self.register()
self.advertiser()
to read:
class BLE():
def __init__(self, name, rxbuf=200):
self.name = name
self.ble = ubluetooth.BLE()
self.ble.active(True)
self.led = Pin(2, Pin.OUT)
self.timer1 = Timer(0)
self.timer2 = Timer(1)
self.disconnected()
self.ble.irq(self.ble_irq)
self.register()
self.ble.gatts_set_buffer(self.rx, rxbuf, True)
self.advertiser()
Note the self.ble.gatts_set_buffer(self.rx, rxbuf, True)
added after self.register()
As well as the , rxbuf=200
added just below class BLE():
Seems to be working well now with longer strings. The highest number of characters I seem to be able to get is 253, suggesting a max 256 byte packet length. Default is 20, so this will allow a good deal more flexibility. Adjussting the buffer setting is described in the ubluetooth documentation as the following:
BLE.gatts_set_buffer(value_handle, len, append=False)
Set internal buffer size (in bytes). This will limit the maximum value that can be received. The default value is 20. Setting append to True will append all remote writes to the current value instead of replacing the current value. This can buffer up to len bytes. Upon using gatts_read ,the value will be cleared after reading. This feature is useful when implementing something, such as Nordic UART service。
Hello, first of all thanks for this great demo. There aren't many good examples of bluetooth implementation on ESP32 in micropython currently.
I am attempting to use BLE for a project involving using a BT serial connection from a smartphone to input user-provided text into my micropython script running on ESP32. I would eventually like to make this an app that handles the BLE serial data part of things behind a GUI. The project is still very much in a prototype alpha stage.
My basic premise is working well, but the problem I'm having currently is that the text cuts off at a certain length, and the remaining data from the user input is truncated and lost. I basically need the capability to input a few sentences at a time without losing characters.
I see in the ubluetooth documentation that a parameter called "rxbuf" is provided to adjust the buffer for received bluetooth events. Is there a way to adjust the rx buffer in this library?
Edit: after further investigation, it is cutting off after 20 characters of text
Thank you