Bluetooth BLE readbyte blocks code

I am having problems reading data sent from my ESP32. I can view the data values using a 3rd party app so I know it is being sent.
I have no problem sending data to the ESP, however when I execute the readbytes block using a timed loop, the app no longer sends any data and it retrieves no bytes into the when received block.
The app remains running as the main loop shows a visible counter.
If I simply disable the readbytes block and start the timer loop, it continues to operate as normal.

BluebeamBLE1.aia (443.9 KB)

Hi Rowifi,
It seems you are making your life too complicated.
First of all, you do not need to dig out device and device name, just use the listpicker selection.

Then, you do not need, and you should not use a Clock. Clocks are handy for BT classic, but not for BLE.
You should call readBytes once and then BytesReceived will repeatedly be triggered, assuming that your characteristics and service define this.

Ok. Thanks. I'll look through what you suggest.
Meanwhile, I've discovered that I do actually receive the messages if I register the BLE for strings on that UUID.
I am using the Nordic Serial UUIDS from an example, perhaps the service Characteristics only work this way. I tried this because the 3rd party app show it as a Notification. ( New to all this )

Well, if you register for strings, you will get strings, not bytes. Strings are anyway much more convenient to handle in App Inventor.

I tried your suggestion, but there was a runtime error because the address evidently needs to be trimmed out of the listpicker selection as it contains the name as part of the string as well as the actual Address.

Don't try to extract the MAC address from the string. Instead, call BluetoothLE1.Connect and hand it the ListPicker1.SelectionIndex. Assuming you haven't processed the original list of devices in any way the selection index will match the device you picked and connect to it. Internally the BLE extension maintains all of the device information so there needn't be any string manipulation here to make this work.

1 Like

Thanks. That worked for manual connection. You may be aware of my other thread where I'm not able to automatically connect to a specific device giving I already know it's service UUID and Device Name.

A post was split to a new topic: I'm having trouble connecting my sensor device from my esp32 to my mit app inventor via bluetoothLE1