“Bridge.call() not finding provide() method on Arduino UNO Q”

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!

the problem might be on the MCU side. how have you uploaded the sketch to the MCU?

1. Does the app work under App Lab?

2. How have you uploaded/executed the script into MPU bypassing te App Lab? There is a procedure outlined by @ptillisch here.

3 Why do you have so many include files in the sketch -- should only the #include <Arduino_RouterBridge.h> be enough?

4. The digitalWrite() function takes HIGH or LOW for the value of LED_BUILTIN; so, should the data type of led_state be int istead of bool in the sketch?

5.

The Arduino tailoed Python Interpreter is already pre-installed in the MPU. What is Arduino Python Package? From where have you got it? Where have you installed it -- in the MPU or in your PC?

Hi @blacksta1. I gave it a try and it works just fine for me. If you are still experiencing the problem, please answer the questions asked by the other participants. I'll be happy to take another look armed with that information.

This:

I agree that it would be useful for the forum helpers to have this information from @blacksta1, in case it might be relevant to the problem they are encountering.

In case you are interested in learning how to do this for your own purposes, I did provide instructions for one way you can accomplish this in the forum topic you linked, here:

https://forum.arduino.cc/t/uno-q-possible-to-connect-python-not-containerized-with-arduino/1436102/8#p-8406708-c-install-project-dependencies-3