Micropython real time forwarding (stdout.write) of received data

I have the following setup for controlling a robot:

  • Remote control (xBee3 ZigBee [firmware 100A] + Arduino)
  • Robot main part (xBee3 ZigBee [firmware 100A] + Arduino)
  • Robot rotating part (BLE device / Adafruit feather) which exchanges data only with the main part (which forwards some values to the remote control)
    In order to send data via BLE I have set up MicroPython in the xBee and the connection works well.
    As the AP mode has to be set to 4 (MicroPython REPL) for Micropython to see the traffic, the connected Arduino does not receive the data from the remote control unless I forward it via sys.stdout.write inside the permanent loop.
    Sometimes this leads to lags in the transmission (as analog signals for 2 joysticks have to be sent) and in case the BLE connection is closed, the reconnect blocks everything for at least 500ms. This floods the Arduino with all commands in the buffer afterwards.
    Is there some way to avoid this (i.e. use AP 0 mode and MicroPython only “listens” to the traffic and can add packets if necessary)?
    Or can there at least be a “parallel” process be called for the ble.gap_connect routine so it does not block the code?
    Any hint/source/example is appreciated (also a “cannot work” as it could save me lots of time)

The BLE and RF port are both accessible via the API interface of the XBee modules UART. What I would suggest is that you update your Library on your Arduino to support the new BLE API frames.

1 Like

Dear MVUT,
Thanks for your quick reply!
I had a look at the userguide (90001539) and found a short description on the BLE API. This seems to aim at a fully remote access to the config of the xBee via BLE. The related encryption process with SRP in order to make BLE communication possible is a bit overkill for my purpose (I also could not find an existing Arduino example). As I can establish the BLE connection with MicroPython already (and data received via BLE can also be forwarded to the second xBee even in transparent mode): Is there a way to use the BLE API frames in a way without the encryption process etc.?
My intention is to forward data via BLE from the Arduino connected locally by UART, so can the BLE relay frames work with the connection established within MicroPython (i.e. would such data be processed in AP 1 mode)?
I am not yet familiar with xBee API, so sorry if I am overlooking something…
Thanks in advance for further input on the topic!

If I recall, you can do it without encryption bit you can’t modify settings on the XBee without using encryption.

I am using the API frames with data relay to BLE now. As the “normal” data is transmitted to the UART directly it seems to work without issues in case BLE disconnects etc.