Hi everyone,
I'm trying to use the Bridge between Python and the microcontroller on the Arduino UNO Q, but I'm getting an error when calling a provided function.
I'm working outside of App Lab, using my own Python virtual environment (venv) on the Linux side of the UNO Q.
I installed the Arduino Python package manually and I'm trying to use:
from arduino.app_utils import App, Bridge
I want to call a function on the MCU from Python using Bridge.call().
My python code:
from arduino.app_utils import App, Bridge
import time
led_state = True
def loop():
global led_state
Bridge.call("Risposta", led_state)
time.sleep(5)
led_state = not led_state
App.run(user_loop=loop)
My Sketch code:
#include <Arduino_RouterBridge.h>
#include <bridge.h>
#include <hci.h>
#include <monitor.h>
#include <routerbridge_provides_serial.h>
#include <tcp_client.h>
#include <tcp_server.h>
#include <udp_bridge.h>
void setup() {
pinMode(LED_BUILTIN,OUTPUT);
Bridge.begin();
delay(1000);
Bridge.provide("Risposta",Risposta);
}
void loop() {
}
void Risposta(bool led_state)
{
digitalWrite(LED_BUILTIN,led_state);
}
I get this error in Python:
raise ValueError(f"Request '{method_name}' failed: {err_msg} ({err_code})") ValueError: Request 'Risposta' failed: method Risposta not available (2)
Why is the method not available even though I used Bridge.provide() in the sketch?
Is there something different when using the Bridge outside of App Lab?
Am I missing some initialization step or service required by the Router/Bridge system?
Thanks in advance for any help!