Example Android Studio project for the Munich TechFest.
- Android Studio
- Android SDK v24.0.0
- An Android device (at least 4.4) with Bluetooth Low Energy support
- Import the project into your Android Studio
- Run the app using the "play" or "debug" button
- Make sure the application has the Location permission
The ball will advertise over BT LE, specifically advertising the service AD04. See SelectBallActivity.java how to scan for balls.
See BallInfoActivity.java on how to retrieve additional ball Information such as battery, firmware revision, status, etc ...
To capture kick information the ball needs to be "in a still position" and in the "logging" state. To do so you need to follow steps bellow.
-
- Obtain a SmartBallService instance with Sensor#obtainService(context, SmartBallService.class)
-
Get the sampling rate; if not what is desired (i.e. 1kHZ) then set the ball sampling rate via SmartBallService#setSamplingRate
-
Once the ball is still, call sendSoftResetCommand to clear any left-over state (old kick data)
-
Set the KickListener instance with SmartBallService#setOnKickListener
-
Put the ball into logging mode with SmartBallService#startLogging
-
KickListener#onReadyToKick will be invoked when the ball is ready to be kicked
-
(kick happens here ...)
-
KickListener#onKickDetected when the kick was detected and logged by the ball
-
Now you ready to download the data.
Once a kick has been detected you can download the data by calling SmartBallService#downloadKickData and passing in DataDownloaderListener. During the download the listener will be notified of progress via updateProgress. DataDownloaderListener#downloadFinished once all the data has been downloaded.
To retry a download send a soft reset command and call downloadKickData again.
The KickData instance will contain all the acceleration data for x,y,z axes. The acceleration is in milli-g, i.e 1000 milli-g is equal to "free-fall". See https://en.wikipedia.org/wiki/G-force#Measuring_g-force_using_an_accelerometer for more information. To get the time in milliseconds between two samples call KickData#getSamplePeriod.
The KickData class implements Parcelable so it's easy to pass to other Activities and also has utility methods to save/load data to a file.