Page 1 of 2
BLE.config('rxbuf') not implemented?
Posted: Sat Jan 11, 2020 4:53 pm
by monquarter
I am working through some bluetooth examples from the documentation on the PYB-SF6W. It appears that the 'rxbuf' configuration does not yet appear to work, or perhaps I am calling it wrong?
Code: Select all
MicroPython v1.12-43-g54a2584de-dirty on 2020-01-07; PYBD-SF6W with STM32F767IIK
Type "help()" for more information.
>>>
>>> import ubluetooth
>>> ble = ubluetooth.BLE()
>>> ble.active(True)
True
>>> ble.config('mac')
b'HJ0\x01\xe6"'
>>> ble.config('rxbuf')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: unknown config param
Re: BLE.config('rxbuf') not implemented?
Posted: Sat Jan 11, 2020 10:43 pm
by jimmo
hi,
rxbuf is write-only. This is mostly for code size reasons, I don't think we thought if any reason why someone would need to query the current size (as they either set it themselves already or it's the default).
Code: Select all
# set the rx buffer size:
ble.config('rxbuf', 1024)
Re: BLE.config('rxbuf') not implemented?
Posted: Sat Jan 11, 2020 11:22 pm
by monquarter
I agree that you normally wouldn't need to query the value of the rxbuf. However, when I was working through as you suggested, I received an error noting that I must query one param.
Code: Select all
MicroPython v1.12-45-gbfbd94401-dirty on 2020-01-11; PYBD-SF6W with STM32F767IIK
Type "help()" for more information.
>>> import ubluetooth
>>> ble = ubluetooth.BLE()
>>> ble.active(True)
True
>>> ble.config('rxbuf',1024)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: must query one param
>>>
Re: BLE.config('rxbuf') not implemented?
Posted: Sat Jan 11, 2020 11:33 pm
by monquarter
That makes sense, and I did try it; howeve, it still thowms me an error:
Code: Select all
MicroPython v1.12-45-gbfbd94401-dirty on 2020-01-11; PYBD-SF6W with STM32F767IIK
Type "help()" for more information.
>>> import ubluetooth
>>> ble = ubluetooth.BLE()
>>> ble.active(True)
True
>>> ble.config('rxbuf',1024)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: must query one param
Re: BLE.config('rxbuf') not implemented?
Posted: Sun Jan 12, 2020 12:12 am
by jimmo
I just took a look at the code, it's actually using kwargs
Re: BLE.config('rxbuf') not implemented?
Posted: Sun Jan 12, 2020 12:22 am
by monquarter
Thanks so much for your help. That did it.
Re: BLE.config('rxbuf') not implemented?
Posted: Sun Jan 12, 2020 4:16 am
by monquarter
I've been working through the ble_temperature_central.py example provided, which is very helpful. I have not been able to get the _IRQ_GATTC_NOTIFY event to be raised. When I connect on my phone, I am able to read the notifications. Are there any modifications that might be required for the pyboard-d series compared to the ESP32?
Re: BLE.config('rxbuf') not implemented?
Posted: Sun Jan 12, 2020 4:28 am
by jimmo
Hi,
So you're running ble_temperature.py on one pybd, and then ble_temperature_central.py on a different pybd (with a callback registered with on_notify)?
I wrote these examples primarily on a pybd (with additional testing on an esp32), so I don't think there should be any pybd/esp32 differences. However, I wonder if it does require a write to the CCCB to configure notification (i.e. to subscribe to the notification).
I will have to test this out for myself tomorrow and get back to you.
Re: BLE.config('rxbuf') not implemented?
Posted: Sun Jan 12, 2020 4:33 am
by monquarter
Yes, that is the setup that I am working with. I am able to read fine, but when I put in a print statement to debug the events that are called in the _irq function, I never see 8192.
Code: Select all
def _irq(self, event, data):
print(event)
if event == _IRQ_SCAN_RESULT:
addr_type, addr, connectable, rssi, adv_data = data
....
Re: BLE.config('rxbuf') not implemented?
Posted: Mon Jan 13, 2020 5:01 am
by jimmo
I added the following code to the demo() function in ble_temperature_central.py
Code: Select all
def notify_callback(v):
print('Notify: ', v)
central.on_notify(notify_callback)
while central.is_connected():
print(central.value())
time.sleep_ms(2000)
I have a PYBD SF2 running an unmodified ble_temperature.py, and an SF6 running the above code. I see:
Code: Select all
>>> import ble_temperature_central
>>> ble_temperature_central.demo()
Found sensor: 0 b'HJ0\x01JB' mpy-temp
Connected
None
None
Notify: 21.58
21.58
21.58
21.58
21.58
21.58
Notify: 22.33
22.33
22.33
22.33
22.33
22.33
Are you able to send me the exact code you're running on both pyboards and I'll try and test it out here. Thanks