Bluetooth and other code issues

Hi,

There seems to be a problem with my app, whenever I try to test it, it keeps on saying "MIT app inventor is not responding. This is unusual because my other apps work fine, while this app wouldn't let me test it and keeps on getting the same error message, "MIT app inventor is not responding." Attached is the aia file for my app. Any help will be greatly appreciated.
AppInventorBug.aia (129.2 KB)

Hello Conrad

You don't tell us how you are testing your App. Emulator? Companion on your Android device?

Problems with your code:

  1. In Clock1 Timer you open another Screen without disabling the Timer first (results in App memory corruption);
  2. Opening another Screen will break the Bluetooth connection.
  3. In Screen "Alarm_and_Notifier" (which need not exist!), another instance of Screen1 is created, so then there are two Screen1's in memory. Instead, close Screen "Alarm_and_Notifier" with the close screen block and the User will be automatically returned to the original Screen1.
  4. Screen "Positive_Notifier" same issue as in (3) and again a new Screen is not necessary - it can all be done in Screen1 either using the Notifier component or via virtual screens or via a "toast" extension.
  5. Your Bluetooth calls are incorrect too. number of bytes should be an integer, not another command.

Hi, I've been testing it on my android phone and on my chromebook.

Thank you for the response, I will test this later.

So for now, I will use the notifier instead of opening another screen, and I have one question about the Bluetooth calls. So, exactly how do I get the app to receive number values from my arduino? What blocks do I use for that? Do I use the receive unsigned 1 byte number or the call Bluetooth client 1 receive text, number of bytes: call Bluetooth client 1 bytes available to recieve.

Just going through your Project now - it looks mostly OK but there are a few mistakes that prevent it from working or make it a potential crash case.

It's also bad practice to give components their own name without retaining the type name - makes your code difficult to understand.

...since the band and the sensor are sharing the data-in Clock Timer, they should share connect - disconnect buttons too. You might need to perform the connections inside another Clock Timer to allow a bit of time for connection success. If you find that is needed I will show you how.

So your Project is based on Classic Bluetooth - hopefully this is something you already know is correct, because some wristbands use BLE (Bluetooth Light Edition)

Also Conrad, you have defined your GUI components to fit in pixels - that might make them fit on your phone's screen but the GUI will not fit on anyone else's unless they have the exact same phone as you. So it is always best to define the GUI in percentages.

Your rest room Status Label on Screen1 can be used for the messages from the other two Screens, updating the Label accordingly, and the two screens can be deleted. The text does not have to be the same height as the Empire State Building :upside_down_face:

Here is an edited version of your Project, to show how to define the GUI in % and how to arrange the Blocks. Since I don't have your wristband, none of this is tested, but most code etc is commonplace for Bluetooth Classic Comms.

BTandOtherIssues.aia (128.0 KB)

That depends entirely on what data type the Wristband and Sensor are sending. The Manufacture's specifications should tell you.