Recently I posted about sending Bluetooth messages from and EV3 to an AI2 app. I decided at the time not to bother considering handling receiving IEEE754 floats as strings would work. Since then I have been thinking about how cluttered the code was, and that AI2 doesn’t easily support libraries of AI2 code. So, I started investigating writing a simple EV3Mailbox extension for AI2. After a bit of learning Java (I’m a Perl programmer at heart) I now have an extension:
The extension is still quite simple, solely handling the packing and unpacking of the message bytes. The Bluetooth comms part will still need to be performed by AI2 code. An example of using this to send/receive messages is as below:
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.
- Run the EV3 code first.
- Start the AI2 app.
- Long-press the BT button. This will bring up a settings box.
- Enter the App device’s Bluetooth name in the settings – and press ‘save’. This will be stored, and sent to the EV3. This is so that the EV3 knows where to send its messages to. This must be the same name as shown in the BT connections list on the EV3.
- Press “Connect EV3”. This will give the list of BT devices known the the Android device. Choose the correct EV3.
- Once the App is connected to the EV3, the EV3 will say “detected”.
- 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.
- The App will then display the message name and contents in the top two boxes.
- You can send string, number or boolean values back to the EV3 via the relevant boxes and buttons.
I’ve been looking for an extension just like this. Thank you for sharing.