Hi everyone, I have a request for help.
The following code executes correctly in API mode “MicroPython REPL [4]”. Since I want to ensure that the module communicates with the microcontroller I change the API to Mode Without Escapes [1].
The MicroPython program executes correctly but bypasses operations related to receiving data from the xbee and processing it (in the example I omitted).
All other functions execute correctly and MicroPython sends data to relay.SERIAL. From the serial console I can send frames to MicroPython.
import utime
import xbee
from xbee import relay
def print_all(message):
print(message)
relay_ble_transmit(message)
relay_serial_transmit(message)
def relay_ble_transmit(message):
try:
relay.send(relay.BLUETOOTH, message)
except OSError as e:
print("ERR_001_ble_connection_error_{}".format(e))
def relay_serial_transmit(message):
try:
relay.send(relay.SERIAL, message)
except OSError as e:
print("ERR_002_serial_connection_error_{}".format(e))
while True:
received_msg = xbee.receive()
if received_msg: print_all(received_msg['payload'.decode()])
utime.sleep_ms(10)