Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 4 months ago.
BLE samples in Android Studio with matching mbed samples
I'm looking for a "simple" pair of an App written in Android Studio and code in mbed that work together, and allow: - send app to mbed (LED On/Off/Brightness) - send mbed to app (Button Status) - notify mbed to app, (ring when button pressed)
Any pointers or guidance appreciated, and I'll make resulting mbed code and app source public here on mbed.
I've worked through several of the examples here on mbed (HTM, HTM, UART, more...), but have only used them with the Nordic sample Apps (nRF-MCP, Toolbox, etc.) and a bit of iOS LightBlue. Those Apps were written in an older Eclipse, and when imported into new Android Studio the result is quite cryptic code versus what a beginner needs. I've looked at Apps from other suppliers but they tend to use custom older libraries, not latest mbed, Android Studio, or Android SDK.
The only Android Studio sample code I've found for BLE is BlueToothLeGatt, it is a generic starting point to connect and list services, but nothing past that: http://developer.android.com/samples/BluetoothLeGatt/index.html
I am quite willing to share the resulting generic Android-mbed pair for "LED-Button-Notify" here on mbed. Later I would add an example with more BLE traffic like setup tables and retrieving log data, but first should be appropriately simple for beginners as I am now. When I get equipment for writing iOS Apps I would add matching iOS App as well.
Paul
Question relating to:
2 Answers
9 years, 4 months ago.
Here's an app, which might be a bit out of date, but could serve as a reference: https://developer.mbed.org/teams/Bluetooth-Low-Energy/code/BLE_GroveColourSensor/
9 years, 4 months ago.
Have just put together an Android App in Android Studio that does most of what you describe. The source for this is available here https://github.com/bennthomsen/BLE_mbed_Remote
The matching mbed program for the nRF51822 mbed KIT can be found here http://developer.mbed.org/teams/UCL-IoT/code/BLE_LED_Controller/
The Android App currently implements: send text, an LED on/off switch and the slider to control LED intensity.
Adding new controls is relatively straight forward.
1. In layout/main.xml add your new control widget
2. In mainActivity.java implement an on change handler similar to those implemented for LED Switch and LED level.
Then run and hope.
FYI: I have published an mbed project and put a zip of matching Android Studio App on the wiki, see: http://developer.mbed.org/users/prussell/code/bleIOv04_pr/ This uses Characteristics for transferring button status and LED PWM (versus BLE serial).
posted by Paul Russell 30 Dec 2014