Runtime error <no error message> after BLE connection

I'm building an app that sends virtual button inputs to an ESP32 over BLE and receives the machine status back. When I connect to the device, the app more than often shows a dialog: "Runtime Error ", and then the Companion forces the app to close. I can't determine the cause.
I will upload the .aia project so someone can inspect it and hopefully figure out what is happening. Any ideas on what could cause this and how to debug it?

Screenshot 2025-09-16 135310

comandi_televisore.aia (580.6 KB)

If you are asking for help, I recommend you to make it as easy for others to be able to help you ...
You probably will get more feedback then...

which means in your case post a screenshot of your relevant blocks...

To download the aia file, upload it to App Inventor, open it, do some bug hunting for you, etc... this takes time, and most people will not do that...
Thank you.

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

Dear Gianluca, there are two things that seem to me a bit weird (probably they will not solve your issue, but it's worth to give'em a sight):

  1. if you use only the BLE, don't load also the BluetoothClient1, which is related to classic BT. Whether both are running they could lead to a conflict
  2. is it really necessary to run as an ActivityStarter the asking for permission ?

Or, in addition to what @Taifun has already asked, please upload also the ESP32 code to see whether there are "timing constraints" (for example) that could lead to an overload of the BLE input task, on APP's side.
Best wishes.

PS be sure to have thet most updated BLE extension.

While we wait to see your ESP code, here are some observations:
image
Your BLE extension is up to date.

Your blocks, cleaned up for easy reading:

The board should allow zooming in.

Immediate observations:

The current BLE extension is said to be handling all permissions for BlueTooth, so you don't have to.
(Correct me if I'm wrong.)

This global init won't work:

You instead need a value procedure:

then you would need to change this:


to use the new procedure:

and also change


to

Some of these blocks are draggable.

I am pretty sure you are treating the stringValues list as a piece of text here.
I will reserve judgement until I see what is being received.

1 Like

First of all, thank you for your replies.
I tried all of your suggestions: I used a procedure to check the multiple and condition, I verified my BLE extension version (which is 20240822, the latest according to the MIT website — and @ABG you were right about not needing to request permissions).

Unfortunately, none of these solved the issue, since the error message still appears.
So, I started removing some sections of the code to see if the error would persist, and I came to the conclusion that the StringReceived section might be causing the problem (following @ABG’s concerns about stringValues).

The ESP sends the following json:
{"auto":"1","homing":"0","eforw":"0","ebackw":"0","eup":"0","edown":"0","movstate":"0","err":"0","errtimeout":"0"}
and the app receives:
["{"auto":"1","homing":"0","eforw":"0","ebackw":"0","eup":"0","edown":"0","movstate":"0","err":"0","errtimeout":"0"}"]

I’m not sure if this helps in identifying the problem. I will also reupload the blocks with the recent changes along with the ESP code.

Thanks again, I’m new to both App Inventor and mcu programming, so I rely a lot on trial and error to make things work.


bt_tvcommands.ino (21.3 KB)

That's a list of one JSON object.

It makes processing it easier than what you had.

Here are replacement blocks to process the stringValues properly:


Your text functions were not needed, just select item 1 from the list and run it through the web block that decodes JSON objects into a dictionary.

P.S. The blocks are draggable.
I based them on the last aia you uploaded.

1 Like

This worked, thank you. It’s strange that there was no error message.Usually, when you pass the wrong type to some functions, the message clearly tells you what is wrong.