├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ ├── dimens.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ └── layout │ │ │ │ └── activity_main.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── us │ │ │ └── cpluspl │ │ │ └── yonixw │ │ │ └── readheartbatmiband2 │ │ │ ├── IOHelper.java │ │ │ ├── Consts.java │ │ │ ├── HearBeatVoice.java │ │ │ ├── SoundHelper.java │ │ │ ├── MainActivity.java │ │ │ └── BLEMiBand2Helper.java │ ├── test │ │ └── java │ │ │ └── us │ │ │ └── cpluspl │ │ │ └── yonixw │ │ │ └── readheartbatmiband2 │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── us │ │ └── cpluspl │ │ └── yonixw │ │ └── readheartbatmiband2 │ │ └── ApplicationTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── yoni-voice ├── h1.wav ├── h2.wav ├── o1.wav ├── o2.wav ├── o3.wav ├── o4.wav ├── o5.wav ├── o6.wav ├── o7.wav ├── o8.wav ├── o9.wav ├── t1.wav ├── t2.wav ├── t3.wav ├── t4.wav ├── t5.wav ├── t6.wav ├── t7.wav ├── t8.wav ├── t9.wav ├── ve.wav ├── empty.wav ├── esre.wav ├── intro.wav ├── units.wav └── invalid.wav ├── .gitignore ├── README.md ├── gradle.properties ├── LICENSE ├── gradlew.bat └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /yoni-voice/h1.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yonixw/mi-band-2/HEAD/yoni-voice/h1.wav -------------------------------------------------------------------------------- /yoni-voice/h2.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yonixw/mi-band-2/HEAD/yoni-voice/h2.wav -------------------------------------------------------------------------------- /yoni-voice/o1.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yonixw/mi-band-2/HEAD/yoni-voice/o1.wav -------------------------------------------------------------------------------- /yoni-voice/o2.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yonixw/mi-band-2/HEAD/yoni-voice/o2.wav -------------------------------------------------------------------------------- /yoni-voice/o3.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yonixw/mi-band-2/HEAD/yoni-voice/o3.wav -------------------------------------------------------------------------------- /yoni-voice/o4.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yonixw/mi-band-2/HEAD/yoni-voice/o4.wav -------------------------------------------------------------------------------- /yoni-voice/o5.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yonixw/mi-band-2/HEAD/yoni-voice/o5.wav -------------------------------------------------------------------------------- /yoni-voice/o6.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yonixw/mi-band-2/HEAD/yoni-voice/o6.wav -------------------------------------------------------------------------------- /yoni-voice/o7.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yonixw/mi-band-2/HEAD/yoni-voice/o7.wav -------------------------------------------------------------------------------- /yoni-voice/o8.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yonixw/mi-band-2/HEAD/yoni-voice/o8.wav -------------------------------------------------------------------------------- /yoni-voice/o9.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yonixw/mi-band-2/HEAD/yoni-voice/o9.wav -------------------------------------------------------------------------------- /yoni-voice/t1.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yonixw/mi-band-2/HEAD/yoni-voice/t1.wav -------------------------------------------------------------------------------- /yoni-voice/t2.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yonixw/mi-band-2/HEAD/yoni-voice/t2.wav -------------------------------------------------------------------------------- /yoni-voice/t3.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yonixw/mi-band-2/HEAD/yoni-voice/t3.wav -------------------------------------------------------------------------------- /yoni-voice/t4.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yonixw/mi-band-2/HEAD/yoni-voice/t4.wav -------------------------------------------------------------------------------- /yoni-voice/t5.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yonixw/mi-band-2/HEAD/yoni-voice/t5.wav -------------------------------------------------------------------------------- /yoni-voice/t6.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yonixw/mi-band-2/HEAD/yoni-voice/t6.wav -------------------------------------------------------------------------------- /yoni-voice/t7.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yonixw/mi-band-2/HEAD/yoni-voice/t7.wav -------------------------------------------------------------------------------- /yoni-voice/t8.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yonixw/mi-band-2/HEAD/yoni-voice/t8.wav -------------------------------------------------------------------------------- /yoni-voice/t9.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yonixw/mi-band-2/HEAD/yoni-voice/t9.wav -------------------------------------------------------------------------------- /yoni-voice/ve.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yonixw/mi-band-2/HEAD/yoni-voice/ve.wav -------------------------------------------------------------------------------- /yoni-voice/empty.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yonixw/mi-band-2/HEAD/yoni-voice/empty.wav -------------------------------------------------------------------------------- /yoni-voice/esre.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yonixw/mi-band-2/HEAD/yoni-voice/esre.wav -------------------------------------------------------------------------------- /yoni-voice/intro.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yonixw/mi-band-2/HEAD/yoni-voice/intro.wav -------------------------------------------------------------------------------- /yoni-voice/units.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yonixw/mi-band-2/HEAD/yoni-voice/units.wav -------------------------------------------------------------------------------- /yoni-voice/invalid.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yonixw/mi-band-2/HEAD/yoni-voice/invalid.wav -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ReadHeartBatMiBand2 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yonixw/mi-band-2/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yonixw/mi-band-2/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yonixw/mi-band-2/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yonixw/mi-band-2/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yonixw/mi-band-2/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .idea/ 10 | gradle/ 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # mi-band-2 2 | Target: Read heart beat from mi and button press detection 3 | 4 | Committing step by step! Use it to learn. 5 | 6 | # Mi-Band-UUID Backup: 7 | https://github.com/yonixw/mi-band-2/wiki/Mi-Band-UUID 8 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/us/cpluspl/yonixw/readheartbatmiband2/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package us.cpluspl.yonixw.readheartbatmiband2; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /app/src/androidTest/java/us/cpluspl/yonixw/readheartbatmiband2/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package us.cpluspl.yonixw.readheartbatmiband2; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in C:\Users\YoniWas\AppData\Local\Android\Sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.3" 6 | 7 | defaultConfig { 8 | applicationId "us.cpluspl.yonixw.readheartbatmiband2" 9 | minSdkVersion 19 10 | targetSdkVersion 23 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | testCompile 'junit:junit:4.12' 25 | compile 'com.android.support:appcompat-v7:23.3.0' 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Yehonatan Water Man 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /app/src/main/java/us/cpluspl/yonixw/readheartbatmiband2/IOHelper.java: -------------------------------------------------------------------------------- 1 | package us.cpluspl.yonixw.readheartbatmiband2; 2 | 3 | import android.content.Context; 4 | import android.os.Environment; 5 | import android.util.Log; 6 | 7 | import java.io.File; 8 | 9 | /** 10 | * Created by YoniWas on 05/02/2017. 11 | */ 12 | public class IOHelper { 13 | /* Checks if external storage is available for read and write */ 14 | public static boolean isExternalStorageWritable() { 15 | String state = Environment.getExternalStorageState(); 16 | if (Environment.MEDIA_MOUNTED.equals(state)) { 17 | return true; 18 | } 19 | return false; 20 | } 21 | 22 | /* Checks if external storage is available to at least read */ 23 | public static boolean isExternalStorageReadable() { 24 | String state = Environment.getExternalStorageState(); 25 | if (Environment.MEDIA_MOUNTED.equals(state) || 26 | Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) { 27 | return true; 28 | } 29 | return false; 30 | } 31 | 32 | 33 | public static File getStorageDir(Context context) { 34 | // Get the directory for the app's private directory (remove @ uninstall). 35 | File file = context.getExternalFilesDir(null); 36 | if (!file.exists() && !file.mkdirs()) { 37 | Log.e(MainActivity.LOG_TAG, "Directory not created " + file.getAbsolutePath()); 38 | } 39 | return file; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 |