Further AI2/EV3 Bluetooth Coding

As my recent posts, Receiving BT Mailboxes from EV3 by an AI2 App & Updated BT comms between EV3 and AI2, have indicated, I’ve been working on getting AI2 app sending and receiving EV3 Mailbox messages via Bluetooth.

One of the annoyances I’d had is that the EV3 needs to know the name of the AI2 device in order to send messages to it. Up until now that name has had to be entered in to the AI2 app by the user. This of course is prone to error in different ways. There wasn’t a way of getting this information via the available AI2 components. So, I’ve added to my EV3Mailbox extension. It now has a GetDeviceName call which will extract that information to be used however one wishes. In my code I use this name to send a message to the EV3 on connection, for it to use in return messages. Example AI2 code is as below:

AI2 BT Test Code

Downloads

As usual, I am making my code available for use under the Creative Commons Attribution-ShareAlike 4.0 International License

The sample .aia file should include the extension .aix file, but I am also making that specifically available for use in other people’s projects.

  1. Run the EV3 code first.
  2. Start the AI2 app.
  3. Press “Connect EV3”. This will give the list of BT devices known the the Android device. Choose the correct EV3.
  4. Once the App is connected to the EV3, the EV3 will say “detected”.
  5. Pressing the top, middle, or bottom buttons on the EV3 will send a BT message to the App:
    • A string for the top button
    • A number for the middle button
    • A boolean for the bottom button.
  6. The App will then display the message name and contents in the top two boxes.
  7. You can send string, number or boolean values back to the EV3 via the relevant boxes and buttons.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.