App keeps going dark and crashing on phone

1
Hello, sorry for the silly question, but this is my first time using the app inventor. I get the list for selecting the bluetooth module, but after selecting the phone goes dark and the app crashes. Can you please point me to where I might be going wrong?

I don't see you checking if there are bytes available before trying to receive them.
You are asking for a 3 byte string, from your blocks.

Most people use a Clock Timer loop to check if bytes are available.
They won't immediately be available after asking for them from the other device.

1 Like

Oh, thank you. Will try using the clock timer loop

Hello @Epistem,
in addition to (and after having done) what has already said @ABG, please be aware that if your phone becomes dark, i.e. it goes to sleep, the BT stops working.
To avoid that, you can use the @Taifun Tools extension, which is a collection of useful "software tools", among with the "KeepScreenOn": this block allows you to maintain awake the phone, therefore avoiding it from going to sleep and the BT remains active. You can use it in the Screen1_Initialize event.
Best wishes :blush:

BTW, here below a typical receiving blockset used in a clock event to receive text from a Bluetooth sender (like @ABG says). Another hint is to set the app Clock period faster than the transmisison period otherwise you run the risk to overload the app receiving buffer.

2 Likes