Search found 111 matches

by prem111
Thu Mar 05, 2020 8:07 am
Forum: General Discussion and Questions
Topic: ubluetooth - async ? 'BLE' object isn't iterable
Replies: 22
Views: 3118

Re: ubluetooth - async ? 'BLE' object isn't iterable

Yes im connectable to bluetooth. def _irq(self, event, data): global ctrl_buf if event == _IRQ_CENTRAL_CONNECT: conn_handle, _, _, = data self._connections.add(conn_handle) print("Connect client: "+str(conn_handle)) elif event == _IRQ_CENTRAL_DISCONNECT: conn_handle, _, _, = data self._connections.r...
by prem111
Thu Mar 05, 2020 7:42 am
Forum: General Discussion and Questions
Topic: ubluetooth - async ? 'BLE' object isn't iterable
Replies: 22
Views: 3118

Re: ubluetooth - async ? 'BLE' object isn't iterable

but still ctrl_buf is empty... ctrl_buf = bytearray() class BLEInit: def __init__(self, ble, name='tests', rxbuf=100): self._ble = ble self._ble.active(True) self._ble.irq(handler=self._irq) ... def _irq(self, event, data): global ctrl_buf if event == _IRQ_GATTS_WRITE: conn_handle, attr_handle, = da...
by prem111
Thu Mar 05, 2020 6:52 am
Forum: General Discussion and Questions
Topic: ubluetooth - async ? 'BLE' object isn't iterable
Replies: 22
Views: 3118

Re: ubluetooth - async ? 'BLE' object isn't iterable

Thank you for the clarification - it should work! I have a question, how to get data from the buffer now, the global variable does not work in this case: ctrl_buf = bytearray() def _irq(self, event, data): if event == _IRQ_GATTS_WRITE: conn_handle, attr_handle, = data ctrl_buf = "test".encode() asyn...
by prem111
Wed Mar 04, 2020 6:18 pm
Forum: General Discussion and Questions
Topic: ubluetooth - async ? 'BLE' object isn't iterable
Replies: 22
Views: 3118

Re: ubluetooth - async ? 'BLE' object isn't iterable

What do you mean, waiting for the new version of uasyncio? I can't do it without Future?
What are my options? Do I have to use threads (I wouldn't want to)? Or is there a simpler way to solve my problem?
by prem111
Wed Mar 04, 2020 2:16 pm
Forum: General Discussion and Questions
Topic: ubluetooth - async ? 'BLE' object isn't iterable
Replies: 22
Views: 3118

Re: ubluetooth - async ? 'BLE' object isn't iterable

Example: ble_advertising.py ble_temperature.py Maybe I'll explain what I want to do, maybe I have a bad idea ... I want to receive data from bluetooth and send it to UART. When the data comes from UART I send it to bluetooth (client). At the moment I have two tasks running (uasyncio). One is ping (e...
by prem111
Wed Mar 04, 2020 1:40 pm
Forum: General Discussion and Questions
Topic: ubluetooth - async ? 'BLE' object isn't iterable
Replies: 22
Views: 3118

Re: ubluetooth - async ? 'BLE' object isn't iterable

Thanks for reply.

I work on this example:
https://github.com/micropython/micropyt ... /bluetooth

Can you suggest how to do it?
by prem111
Wed Mar 04, 2020 12:58 pm
Forum: General Discussion and Questions
Topic: ubluetooth - async ? 'BLE' object isn't iterable
Replies: 22
Views: 3118

Re: ubluetooth - async ? 'BLE' object isn't iterable

Sorry in: time.sleep_ms(1000) its my mistake, this line is not there.
by prem111
Wed Mar 04, 2020 12:05 pm
Forum: General Discussion and Questions
Topic: ubluetooth - async ? 'BLE' object isn't iterable
Replies: 22
Views: 3118

ubluetooth - async ? 'BLE' object isn't iterable

Hi, can uasyncio be implemented for ubluetooth? async def ble_listen(): ble = await bluetooth.BLE() ble_conn = BLEInit(ble) while True: #print("OK") for conn_handle in ble_conn._connections: ble.gatts_notify(conn_handle, ble_conn.ping) ble.gatts_write(ble_conn.ping, "TEST") await uasyncio.sleep(0) l...
by prem111
Tue Mar 03, 2020 11:54 am
Forum: Programs, Libraries and Tools
Topic: Read from UART - Problem.
Replies: 5
Views: 944

Re: Read from UART - Problem.

What if when the second part comes with the second packet ?
by prem111
Tue Mar 03, 2020 9:44 am
Forum: Programs, Libraries and Tools
Topic: Read from UART - Problem.
Replies: 5
Views: 944

Re: Read from UART - Problem.

reading a single byte is slow or just seems to me?

read 200 (singly) bytes = 3 seconds:
recv = await sreader.read(1)

read 200 (together) bytes = 1 seconds.
recv = await sreader.read(200)