MIT app inventor keeps giving me an error and I don't know why

so I am trying to build this app that takes a Bluetooth connection and makes that a global value so that I can use it across multiple screens and its not working. in the app inventor it shows that there is no errors or anything but when I download it onto an android device via the barcode it just gives this error

It seems you have a ">" operator comparing a "false" and "1000"....

(Canned Reply: ABG- Export & Upload .aia)
Export your .aia file and upload it here.

export_and_upload_aia

.

Roof_Tracker_copy_1.aia (377.9 KB)

Your app has

  • too many Screens
  • too many Clocks.

Cut it down to a single Screen, with just one Clock, to avoid disconnects on screen switches.

Use stacked Vertical Arrangements, only one visible at a time, to stay in Screen1.

Apply Message Delimiter techniques to your input:
Be sure to use println() at the end of each message to send from the sending device, to signal end of message.

Only use print() in the middle of a message.

Be sure not to println() in the middle of a message, or you will break it into two short messages and mess up the item count after you split the message in AI2.

Do not rely on timing for this, which is unreliable.

In the AI2 Designer, set the Delimiter attribute of the BlueTooth Client component to 10 to recognize the End of Line character.
BlueToothClient1_Properties
Also, return data is not immediately available after sending a request,
you have to start a Clock Timer repeating and watch for its arrival in the Clock Timer event. The repeat rate of the Clock Timer should be faster than the transmission rate in the sending device, to not flood the AI2 buffers.

In your Clock Timer, you should check

  Is the BlueTooth Client still Connected?
  Is Bytes Available > 0?
     IF Bytes Available > 0 THEN
       set message var  to BT.ReceiveText(-1) 

This takes advantage of a special case in the ReceiveText block:

ReceiveText(numberOfBytes)
Receive text from the connected Bluetooth device. If numberOfBytes is less than 0, read until a delimiter byte value is received.

For good measure, also upload your sketch.

wait is it possible to type out the code instead of using the drag and drop boxes?

thank you sooo much for all your help

Are you referring to typeblocking?

Here is a simple BlueTooth text receiver sample, for single value per line:
blocks
initialize global message to

...

1 Like

I guesss I don't know exactly what its called but in the MIT app inventor 2 I didnt think there was a way to type out code. and up above it looked like you were typing out codes so I was wondering if there was a way to do that because I think that might be easier.

That was pseudocode; ABG used it to outline what you needed to do.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.