├── .gradle
└── 1.10
│ └── taskArtifacts
│ ├── cache.properties
│ ├── cache.properties.lock
│ ├── fileHashes.bin
│ ├── fileSnapshots.bin
│ ├── outputFileStates.bin
│ └── taskArtifacts.bin
├── .idea
├── .name
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── gradle.xml
├── libraries
│ ├── support_v13_19_1_0.xml
│ └── support_v4_19_1_0.xml
├── misc.xml
├── modules.xml
├── scopes
│ └── scope_settings.xml
├── vcs.xml
└── workspace.xml
├── BluetoothLeGattSample
├── BluetoothLeGattSample.iml
├── build.gradle
├── build
│ ├── generated
│ │ └── source
│ │ │ ├── buildConfig
│ │ │ └── debug
│ │ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── android
│ │ │ │ └── bluetoothlegatt
│ │ │ │ └── BuildConfig.java
│ │ │ └── r
│ │ │ └── debug
│ │ │ └── com
│ │ │ └── example
│ │ │ └── android
│ │ │ └── bluetoothlegatt
│ │ │ └── R.java
│ ├── intermediates
│ │ ├── classes
│ │ │ └── debug
│ │ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── android
│ │ │ │ └── bluetoothlegatt
│ │ │ │ ├── BluetoothLeService$1.class
│ │ │ │ ├── BluetoothLeService$2.class
│ │ │ │ ├── BluetoothLeService$LocalBinder.class
│ │ │ │ ├── BluetoothLeService.class
│ │ │ │ ├── BuildConfig.class
│ │ │ │ ├── DeviceControlActivity$1.class
│ │ │ │ ├── DeviceControlActivity$2.class
│ │ │ │ ├── DeviceControlActivity$3.class
│ │ │ │ ├── DeviceControlActivity$4.class
│ │ │ │ ├── DeviceControlActivity.class
│ │ │ │ ├── DeviceScanActivity$1.class
│ │ │ │ ├── DeviceScanActivity$2$1.class
│ │ │ │ ├── DeviceScanActivity$2.class
│ │ │ │ ├── DeviceScanActivity$LeDeviceListAdapter.class
│ │ │ │ ├── DeviceScanActivity$ViewHolder.class
│ │ │ │ ├── DeviceScanActivity.class
│ │ │ │ ├── R$attr.class
│ │ │ │ ├── R$dimen.class
│ │ │ │ ├── R$drawable.class
│ │ │ │ ├── R$id.class
│ │ │ │ ├── R$layout.class
│ │ │ │ ├── R$menu.class
│ │ │ │ ├── R$string.class
│ │ │ │ ├── R$style.class
│ │ │ │ ├── R.class
│ │ │ │ └── SampleGattAttributes.class
│ │ ├── dex
│ │ │ └── debug
│ │ │ │ └── classes.dex
│ │ ├── incremental
│ │ │ ├── aidl
│ │ │ │ └── debug
│ │ │ │ │ └── dependency.store
│ │ │ ├── mergeAssets
│ │ │ │ └── debug
│ │ │ │ │ └── merger.xml
│ │ │ └── mergeResources
│ │ │ │ └── debug
│ │ │ │ └── merger.xml
│ │ ├── libs
│ │ │ └── BluetoothLeGattSample-debug.ap_
│ │ ├── manifests
│ │ │ └── debug
│ │ │ │ └── AndroidManifest.xml
│ │ ├── pre-dexed
│ │ │ └── debug
│ │ │ │ ├── support-v13-19.1.0-432d29bb26d6067815408d15c09d69cadf2dd68d.jar
│ │ │ │ └── support-v4-19.1.0-fe930dc68beb1e566675ce71b270d4091c6c249b.jar
│ │ └── res
│ │ │ └── debug
│ │ │ ├── drawable-hdpi-v4
│ │ │ ├── ic_launcher.png
│ │ │ └── tile.9.png
│ │ │ ├── drawable-mdpi-v4
│ │ │ └── ic_launcher.png
│ │ │ ├── drawable-xhdpi-v4
│ │ │ └── ic_launcher.png
│ │ │ ├── drawable-xxhdpi-v4
│ │ │ └── ic_launcher.png
│ │ │ ├── layout
│ │ │ ├── actionbar_indeterminate_progress.xml
│ │ │ ├── activity_main.xml
│ │ │ ├── gatt_services_characteristics.xml
│ │ │ └── listitem_device.xml
│ │ │ ├── menu
│ │ │ ├── gatt_services.xml
│ │ │ └── main.xml
│ │ │ ├── values-sw600dp-v13
│ │ │ └── values.xml
│ │ │ ├── values-v11
│ │ │ └── values.xml
│ │ │ └── values
│ │ │ └── values.xml
│ └── outputs
│ │ └── apk
│ │ ├── BluetoothLeGattSample-debug-unaligned.apk
│ │ └── BluetoothLeGattSample-debug.apk
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── example
│ │ └── android
│ │ └── bluetoothlegatt
│ │ ├── BluetoothLeService.java
│ │ ├── DeviceControlActivity.java
│ │ ├── DeviceScanActivity.java
│ │ └── SampleGattAttributes.java
│ └── res
│ ├── drawable-hdpi
│ ├── ic_launcher.png
│ └── tile.9.png
│ ├── drawable-mdpi
│ └── ic_launcher.png
│ ├── drawable-xhdpi
│ └── ic_launcher.png
│ ├── drawable-xxhdpi
│ └── ic_launcher.png
│ ├── layout
│ ├── actionbar_indeterminate_progress.xml
│ ├── activity_main.xml
│ ├── gatt_services_characteristics.xml
│ └── listitem_device.xml
│ ├── menu
│ ├── gatt_services.xml
│ └── main.xml
│ ├── values-sw600dp
│ ├── template-dimens.xml
│ └── template-styles.xml
│ ├── values-v11
│ └── template-styles.xml
│ └── values
│ ├── base-strings.xml
│ ├── strings.xml
│ ├── template-dimens.xml
│ └── template-styles.xml
├── README.txt
├── ble-android-example.iml
├── ble-android-gatt-server.iml
├── build.gradle
├── build
└── intermediates
│ ├── dex-cache
│ └── cache.xml
│ └── model_data.bin
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── local.properties
└── settings.gradle
/.gradle/1.10/taskArtifacts/cache.properties:
--------------------------------------------------------------------------------
1 | #Thu Sep 18 13:46:53 GMT-05:00 2014
2 |
--------------------------------------------------------------------------------
/.gradle/1.10/taskArtifacts/cache.properties.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/.gradle/1.10/taskArtifacts/cache.properties.lock
--------------------------------------------------------------------------------
/.gradle/1.10/taskArtifacts/fileHashes.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/.gradle/1.10/taskArtifacts/fileHashes.bin
--------------------------------------------------------------------------------
/.gradle/1.10/taskArtifacts/fileSnapshots.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/.gradle/1.10/taskArtifacts/fileSnapshots.bin
--------------------------------------------------------------------------------
/.gradle/1.10/taskArtifacts/outputFileStates.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/.gradle/1.10/taskArtifacts/outputFileStates.bin
--------------------------------------------------------------------------------
/.gradle/1.10/taskArtifacts/taskArtifacts.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/.gradle/1.10/taskArtifacts/taskArtifacts.bin
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | ble-android-example
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/libraries/support_v13_19_1_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/libraries/support_v4_19_1_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | Android API 20 Platform
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/scopes/scope_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/BluetoothLeGattSample/BluetoothLeGattSample.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build.gradle:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | buildscript {
5 | repositories {
6 | mavenCentral()
7 | }
8 |
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:0.12.2'
11 | }
12 | }
13 |
14 | apply plugin: 'android'
15 |
16 |
17 | dependencies {
18 |
19 | // Add the support lib that is appropriate for SDK 18
20 | compile "com.android.support:support-v13:19.1.+"
21 |
22 |
23 | }
24 |
25 | // The sample build uses multiple directories to
26 | // keep boilerplate and common code separate from
27 | // the main sample code.
28 | List dirs = [
29 | 'main', // main sample code; look here for the interesting stuff.
30 | 'common', // components that are reused by multiple samples
31 | 'template'] // boilerplate code that is generated by the sample template process
32 |
33 | android {
34 | compileSdkVersion 19
35 |
36 | buildToolsVersion "19.1.0"
37 |
38 | sourceSets {
39 | main {
40 | dirs.each { dir ->
41 | java.srcDirs "src/${dir}/java"
42 | res.srcDirs "src/${dir}/res"
43 | }
44 | }
45 | androidTest.setRoot('tests')
46 | androidTest.java.srcDirs = ['tests/src']
47 |
48 | }
49 | }
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/generated/source/buildConfig/debug/com/example/android/bluetoothlegatt/BuildConfig.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Automatically generated file. DO NOT MODIFY
3 | */
4 | package com.example.android.bluetoothlegatt;
5 |
6 | public final class BuildConfig {
7 | public static final boolean DEBUG = Boolean.parseBoolean("true");
8 | public static final String PACKAGE_NAME = "com.example.android.bluetoothlegatt";
9 | public static final String BUILD_TYPE = "debug";
10 | public static final String FLAVOR = "";
11 | public static final int VERSION_CODE = 1;
12 | public static final String VERSION_NAME = "";
13 | }
14 |
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/generated/source/r/debug/com/example/android/bluetoothlegatt/R.java:
--------------------------------------------------------------------------------
1 | /* AUTO-GENERATED FILE. DO NOT MODIFY.
2 | *
3 | * This class was automatically generated by the
4 | * aapt tool from the resource data it found. It
5 | * should not be modified by hand.
6 | */
7 |
8 | package com.example.android.bluetoothlegatt;
9 |
10 | public final class R {
11 | public static final class attr {
12 | }
13 | public static final class dimen {
14 | public static final int horizontal_page_margin=0x7f040000;
15 | public static final int margin_huge=0x7f040001;
16 | public static final int margin_large=0x7f040002;
17 | public static final int margin_medium=0x7f040003;
18 | public static final int margin_small=0x7f040004;
19 | public static final int margin_tiny=0x7f040005;
20 | public static final int vertical_page_margin=0x7f040006;
21 | }
22 | public static final class drawable {
23 | public static final int ic_launcher=0x7f020000;
24 | public static final int tile=0x7f020001;
25 | }
26 | public static final class id {
27 | public static final int connection_state=0x7f080001;
28 | public static final int data_value=0x7f080002;
29 | public static final int device_address=0x7f080000;
30 | public static final int device_name=0x7f080004;
31 | public static final int gatt_services_list=0x7f080003;
32 | public static final int menu_connect=0x7f080006;
33 | public static final int menu_disconnect=0x7f080007;
34 | public static final int menu_refresh=0x7f080005;
35 | public static final int menu_scan=0x7f080008;
36 | public static final int menu_stop=0x7f080009;
37 | }
38 | public static final class layout {
39 | public static final int actionbar_indeterminate_progress=0x7f030000;
40 | public static final int activity_main=0x7f030001;
41 | public static final int gatt_services_characteristics=0x7f030002;
42 | public static final int listitem_device=0x7f030003;
43 | }
44 | public static final class menu {
45 | public static final int gatt_services=0x7f070000;
46 | public static final int main=0x7f070001;
47 | }
48 | public static final class string {
49 | public static final int app_name=0x7f050000;
50 | public static final int ble_not_supported=0x7f050001;
51 | public static final int connected=0x7f050002;
52 | public static final int disconnected=0x7f050003;
53 | public static final int error_bluetooth_not_supported=0x7f050004;
54 | public static final int intro_message=0x7f050005;
55 | public static final int label_data=0x7f050006;
56 | public static final int label_device_address=0x7f050007;
57 | public static final int label_state=0x7f050008;
58 | public static final int menu_connect=0x7f050009;
59 | public static final int menu_disconnect=0x7f05000a;
60 | public static final int menu_scan=0x7f05000b;
61 | public static final int menu_stop=0x7f05000c;
62 | public static final int no_data=0x7f05000d;
63 | public static final int title_devices=0x7f05000e;
64 | public static final int unknown_characteristic=0x7f05000f;
65 | public static final int unknown_device=0x7f050010;
66 | public static final int unknown_service=0x7f050011;
67 | }
68 | public static final class style {
69 | public static final int AppTheme=0x7f060000;
70 | public static final int Theme_Base=0x7f060001;
71 | public static final int Theme_Sample=0x7f060002;
72 | public static final int Widget=0x7f060003;
73 | public static final int Widget_SampleMessage=0x7f060004;
74 | public static final int Widget_SampleMessageTile=0x7f060005;
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/BluetoothLeService$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/BluetoothLeService$1.class
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/BluetoothLeService$2.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/BluetoothLeService$2.class
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/BluetoothLeService$LocalBinder.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/BluetoothLeService$LocalBinder.class
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/BluetoothLeService.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/BluetoothLeService.class
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/BuildConfig.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/BuildConfig.class
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/DeviceControlActivity$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/DeviceControlActivity$1.class
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/DeviceControlActivity$2.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/DeviceControlActivity$2.class
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/DeviceControlActivity$3.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/DeviceControlActivity$3.class
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/DeviceControlActivity$4.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/DeviceControlActivity$4.class
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/DeviceControlActivity.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/DeviceControlActivity.class
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/DeviceScanActivity$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/DeviceScanActivity$1.class
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/DeviceScanActivity$2$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/DeviceScanActivity$2$1.class
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/DeviceScanActivity$2.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/DeviceScanActivity$2.class
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/DeviceScanActivity$LeDeviceListAdapter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/DeviceScanActivity$LeDeviceListAdapter.class
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/DeviceScanActivity$ViewHolder.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/DeviceScanActivity$ViewHolder.class
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/DeviceScanActivity.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/DeviceScanActivity.class
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/R$attr.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/R$attr.class
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/R$dimen.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/R$dimen.class
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/R$drawable.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/R$drawable.class
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/R$id.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/R$id.class
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/R$layout.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/R$layout.class
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/R$menu.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/R$menu.class
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/R$string.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/R$string.class
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/R$style.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/R$style.class
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/R.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/R.class
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/SampleGattAttributes.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/build/intermediates/classes/debug/com/example/android/bluetoothlegatt/SampleGattAttributes.class
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/dex/debug/classes.dex:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/build/intermediates/dex/debug/classes.dex
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/incremental/aidl/debug/dependency.store:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/incremental/mergeAssets/debug/merger.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/incremental/mergeResources/debug/merger.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
11 |
16 |
21 |
26 |
31 |
36 |
41 |
46 |
51 |
56 |
61 |
64 | BluetoothLeGatt
65 |
66 |
67 |
75 |
76 |
77 |
80 | BLE is not supported
81 |
82 | No data
83 |
84 | Unknown service
85 |
86 | Device address:
87 |
88 | Connected
89 |
90 | Connect
91 |
92 | BLE Device Scan
93 |
94 | Unknown characteristic
95 |
96 | Data:
97 |
98 | State:
99 |
100 | Disconnected
101 |
102 | Disconnect
103 |
104 | Unknown device
105 |
106 | Scan
107 |
108 | Bluetooth not supported.
109 |
110 | Stop
111 |
112 |
113 |
116 | 64dp
117 |
118 | 4dp
119 |
120 | @dimen/margin_medium
121 |
122 | 32dp
123 |
124 | 16dp
125 |
126 | @dimen/margin_medium
127 |
128 | 8dp
129 |
130 |
131 |
134 |
135 |
136 |
137 |
145 |
146 |
160 |
161 |
164 |
165 |
168 |
169 |
172 |
173 |
176 | @dimen/margin_huge
177 |
178 | @dimen/margin_medium
179 |
180 |
181 |
184 |
185 |
196 |
197 |
200 |
201 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/libs/BluetoothLeGattSample-debug.ap_:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/build/intermediates/libs/BluetoothLeGattSample-debug.ap_
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/manifests/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
21 |
22 |
25 |
31 |
34 |
35 |
36 |
37 |
38 |
42 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/pre-dexed/debug/support-v13-19.1.0-432d29bb26d6067815408d15c09d69cadf2dd68d.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/build/intermediates/pre-dexed/debug/support-v13-19.1.0-432d29bb26d6067815408d15c09d69cadf2dd68d.jar
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/pre-dexed/debug/support-v4-19.1.0-fe930dc68beb1e566675ce71b270d4091c6c249b.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/build/intermediates/pre-dexed/debug/support-v4-19.1.0-fe930dc68beb1e566675ce71b270d4091c6c249b.jar
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/res/debug/drawable-hdpi-v4/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/build/intermediates/res/debug/drawable-hdpi-v4/ic_launcher.png
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/res/debug/drawable-hdpi-v4/tile.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/build/intermediates/res/debug/drawable-hdpi-v4/tile.9.png
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/res/debug/drawable-mdpi-v4/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/build/intermediates/res/debug/drawable-mdpi-v4/ic_launcher.png
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/res/debug/drawable-xhdpi-v4/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/build/intermediates/res/debug/drawable-xhdpi-v4/ic_launcher.png
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/res/debug/drawable-xxhdpi-v4/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/build/intermediates/res/debug/drawable-xxhdpi-v4/ic_launcher.png
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/res/debug/layout/actionbar_indeterminate_progress.xml:
--------------------------------------------------------------------------------
1 |
16 |
20 |
23 |
24 |
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/res/debug/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
21 |
22 |
26 |
27 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/res/debug/layout/gatt_services_characteristics.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
21 |
22 |
26 |
30 |
32 |
36 |
37 |
41 |
45 |
47 |
52 |
53 |
57 |
61 |
63 |
68 |
69 |
72 |
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/res/debug/layout/listitem_device.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
20 |
24 |
28 |
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/res/debug/menu/gatt_services.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
30 |
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/res/debug/menu/main.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
30 |
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/res/debug/values-sw600dp-v13/values.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | @dimen/margin_huge
8 | @dimen/margin_medium
9 |
10 |
11 |
12 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/res/debug/values-v11/values.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/intermediates/res/debug/values/values.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | @dimen/margin_medium
8 | 64dp
9 | 32dp
10 | 16dp
11 | 8dp
12 | 4dp
13 | @dimen/margin_medium
14 |
15 |
16 |
17 | BluetoothLeGatt
18 |
19 |
20 |
21 | BLE is not supported
22 | Connected
23 | Disconnected
24 | Bluetooth not supported.
25 |
26 |
27 |
28 |
29 |
37 |
38 |
39 |
40 |
41 | Data:
42 | Device address:
43 | State:
44 | Connect
45 | Disconnect
46 | Scan
47 | Stop
48 | No data
49 | BLE Device Scan
50 | Unknown characteristic
51 | Unknown device
52 | Unknown service
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
68 |
69 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/outputs/apk/BluetoothLeGattSample-debug-unaligned.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/build/outputs/apk/BluetoothLeGattSample-debug-unaligned.apk
--------------------------------------------------------------------------------
/BluetoothLeGattSample/build/outputs/apk/BluetoothLeGattSample-debug.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/build/outputs/apk/BluetoothLeGattSample-debug.apk
--------------------------------------------------------------------------------
/BluetoothLeGattSample/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
24 |
25 |
27 |
31 |
32 |
33 |
34 |
35 |
36 |
39 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/BluetoothLeGattSample/src/main/java/com/example/android/bluetoothlegatt/BluetoothLeService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.android.bluetoothlegatt;
18 |
19 | import android.app.Service;
20 | import android.bluetooth.BluetoothAdapter;
21 | import android.bluetooth.BluetoothDevice;
22 | import android.bluetooth.BluetoothGatt;
23 | import android.bluetooth.BluetoothGattCallback;
24 | import android.bluetooth.BluetoothGattCharacteristic;
25 | import android.bluetooth.BluetoothGattDescriptor;
26 | import android.bluetooth.BluetoothGattServer;
27 | import android.bluetooth.BluetoothGattServerCallback;
28 | import android.bluetooth.BluetoothGattService;
29 | import android.bluetooth.BluetoothManager;
30 | import android.bluetooth.BluetoothProfile;
31 | import android.content.Context;
32 | import android.content.Intent;
33 | import android.os.Binder;
34 | import android.os.IBinder;
35 | import android.util.Log;
36 |
37 | import java.util.List;
38 | import java.util.UUID;
39 |
40 | /**
41 | * Service for managing connection and data communication with a GATT server hosted on a
42 | * given Bluetooth LE device.
43 | */
44 | public class BluetoothLeService extends Service {
45 | private final static String TAG = BluetoothLeService.class.getSimpleName();
46 |
47 | private BluetoothManager mBluetoothManager;
48 | private BluetoothAdapter mBluetoothAdapter;
49 | private String mBluetoothDeviceAddress;
50 | private BluetoothGatt mBluetoothGatt;
51 | private BluetoothGattServer mBluetoothGattServer;
52 | private int mConnectionState = STATE_DISCONNECTED;
53 |
54 | private static final int STATE_DISCONNECTED = 0;
55 | private static final int STATE_CONNECTING = 1;
56 | private static final int STATE_CONNECTED = 2;
57 |
58 | public final static String ACTION_GATT_CONNECTED =
59 | "com.example.bluetooth.le.ACTION_GATT_CONNECTED";
60 | public final static String ACTION_GATT_DISCONNECTED =
61 | "com.example.bluetooth.le.ACTION_GATT_DISCONNECTED";
62 | public final static String ACTION_GATT_SERVICES_DISCOVERED =
63 | "com.example.bluetooth.le.ACTION_GATT_SERVICES_DISCOVERED";
64 | public final static String ACTION_DATA_AVAILABLE =
65 | "com.example.bluetooth.le.ACTION_DATA_AVAILABLE";
66 | public final static String EXTRA_DATA =
67 | "com.example.bluetooth.le.EXTRA_DATA";
68 |
69 | public final static UUID UUID_HEART_RATE_MEASUREMENT =
70 | UUID.fromString(SampleGattAttributes.HEART_RATE_MEASUREMENT);
71 |
72 | // Implements callback methods for GATT events that the app cares about. For example,
73 | // connection change and services discovered.
74 | private final BluetoothGattCallback mGattCallback = new BluetoothGattCallback() {
75 | @Override
76 | public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
77 | String intentAction;
78 | if (newState == BluetoothProfile.STATE_CONNECTED) {
79 | intentAction = ACTION_GATT_CONNECTED;
80 | mConnectionState = STATE_CONNECTED;
81 | broadcastUpdate(intentAction);
82 | Log.i(TAG, "Connected to GATT server.");
83 | // Attempts to discover services after successful connection.
84 | Log.i(TAG, "Attempting to start service discovery:" +
85 | mBluetoothGatt.discoverServices());
86 |
87 | } else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
88 | intentAction = ACTION_GATT_DISCONNECTED;
89 | mConnectionState = STATE_DISCONNECTED;
90 | Log.i(TAG, "Disconnected from GATT server.");
91 | broadcastUpdate(intentAction);
92 | }
93 | }
94 |
95 | @Override
96 | public void onServicesDiscovered(BluetoothGatt gatt, int status) {
97 | if (status == BluetoothGatt.GATT_SUCCESS) {
98 | broadcastUpdate(ACTION_GATT_SERVICES_DISCOVERED);
99 | } else {
100 | Log.w(TAG, "onServicesDiscovered received: " + status);
101 | }
102 | }
103 |
104 | @Override
105 | public void onCharacteristicRead(BluetoothGatt gatt,
106 | BluetoothGattCharacteristic characteristic,
107 | int status) {
108 | if (status == BluetoothGatt.GATT_SUCCESS) {
109 | broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic);
110 | }
111 | }
112 |
113 | @Override
114 | public void onCharacteristicChanged(BluetoothGatt gatt,
115 | BluetoothGattCharacteristic characteristic) {
116 | broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic);
117 | }
118 | };
119 |
120 | private final BluetoothGattServerCallback mGattServerCallback = new BluetoothGattServerCallback() {
121 | @Override
122 | public void onConnectionStateChange(BluetoothDevice device, int status, int newState) {
123 | Log.d("HELLO", "Our gatt server connection state changed, new state ");
124 | Log.d("HELLO", Integer.toString(newState));
125 | super.onConnectionStateChange(device, status, newState);
126 | }
127 |
128 | @Override
129 | public void onServiceAdded(int status, BluetoothGattService service) {
130 | Log.d("HELLO", "Our gatt server service was added.");
131 | super.onServiceAdded(status, service);
132 | }
133 |
134 | @Override
135 | public void onCharacteristicReadRequest(BluetoothDevice device, int requestId, int offset, BluetoothGattCharacteristic characteristic) {
136 | Log.d("HELLO", "Our gatt characteristic was read.");
137 | super.onCharacteristicReadRequest(device, requestId, offset, characteristic);
138 | }
139 |
140 | @Override
141 | public void onCharacteristicWriteRequest(BluetoothDevice device, int requestId, BluetoothGattCharacteristic characteristic, boolean preparedWrite, boolean responseNeeded, int offset, byte[] value) {
142 | Log.d("HELLO", "We have received a write request for one of our hosted characteristics");
143 |
144 | super.onCharacteristicWriteRequest(device, requestId, characteristic, preparedWrite, responseNeeded, offset, value);
145 | }
146 |
147 | @Override
148 | public void onDescriptorReadRequest(BluetoothDevice device, int requestId, int offset, BluetoothGattDescriptor descriptor) {
149 | Log.d("HELLO", "Our gatt server descriptor was read.");
150 | super.onDescriptorReadRequest(device, requestId, offset, descriptor);
151 | }
152 |
153 | @Override
154 | public void onDescriptorWriteRequest(BluetoothDevice device, int requestId, BluetoothGattDescriptor descriptor, boolean preparedWrite, boolean responseNeeded, int offset, byte[] value) {
155 | Log.d("HELLO", "Our gatt server descriptor was written.");
156 | super.onDescriptorWriteRequest(device, requestId, descriptor, preparedWrite, responseNeeded, offset, value);
157 | }
158 |
159 | @Override
160 | public void onExecuteWrite(BluetoothDevice device, int requestId, boolean execute) {
161 | Log.d("HELLO", "Our gatt server on execute write.");
162 | super.onExecuteWrite(device, requestId, execute);
163 | }
164 | };
165 |
166 | private void broadcastUpdate(final String action) {
167 | final Intent intent = new Intent(action);
168 | sendBroadcast(intent);
169 | }
170 |
171 | private void broadcastUpdate(final String action,
172 | final BluetoothGattCharacteristic characteristic) {
173 | final Intent intent = new Intent(action);
174 |
175 | // This is special handling for the Heart Rate Measurement profile. Data parsing is
176 | // carried out as per profile specifications:
177 | // http://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.heart_rate_measurement.xml
178 | if (UUID_HEART_RATE_MEASUREMENT.equals(characteristic.getUuid())) {
179 | int flag = characteristic.getProperties();
180 | int format = -1;
181 | if ((flag & 0x01) != 0) {
182 | format = BluetoothGattCharacteristic.FORMAT_UINT16;
183 | Log.d(TAG, "Heart rate format UINT16.");
184 | } else {
185 | format = BluetoothGattCharacteristic.FORMAT_UINT8;
186 | Log.d(TAG, "Heart rate format UINT8.");
187 | }
188 | final int heartRate = characteristic.getIntValue(format, 1);
189 | Log.d(TAG, String.format("Received heart rate: %d", heartRate));
190 | intent.putExtra(EXTRA_DATA, String.valueOf(heartRate));
191 | } else {
192 | // For all other profiles, writes the data formatted in HEX.
193 | final byte[] data = characteristic.getValue();
194 | if (data != null && data.length > 0) {
195 | final StringBuilder stringBuilder = new StringBuilder(data.length);
196 | for(byte byteChar : data)
197 | stringBuilder.append(String.format("%02X ", byteChar));
198 | intent.putExtra(EXTRA_DATA, new String(data) + "\n" + stringBuilder.toString());
199 | }
200 | }
201 | sendBroadcast(intent);
202 | }
203 |
204 | public class LocalBinder extends Binder {
205 | BluetoothLeService getService() {
206 | return BluetoothLeService.this;
207 | }
208 | }
209 |
210 | @Override
211 | public IBinder onBind(Intent intent) {
212 | return mBinder;
213 | }
214 |
215 | @Override
216 | public boolean onUnbind(Intent intent) {
217 | // After using a given device, you should make sure that BluetoothGatt.close() is called
218 | // such that resources are cleaned up properly. In this particular example, close() is
219 | // invoked when the UI is disconnected from the Service.
220 | close();
221 | return super.onUnbind(intent);
222 | }
223 |
224 | private final IBinder mBinder = new LocalBinder();
225 |
226 | /**
227 | * Initializes a reference to the local Bluetooth adapter.
228 | *
229 | * @return Return true if the initialization is successful.
230 | */
231 | public boolean initialize() {
232 | // For API level 18 and above, get a reference to BluetoothAdapter through
233 | // BluetoothManager.
234 | if (mBluetoothManager == null) {
235 | mBluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
236 | if (mBluetoothManager == null) {
237 | Log.e(TAG, "Unable to initialize BluetoothManager.");
238 | return false;
239 | }
240 | }
241 |
242 | mBluetoothAdapter = mBluetoothManager.getAdapter();
243 | if (mBluetoothAdapter == null) {
244 | Log.e(TAG, "Unable to obtain a BluetoothAdapter.");
245 | return false;
246 | }
247 |
248 | //JDD - lets go ahead and start our GATT server now
249 | addDefinedGattServerServices();
250 |
251 | return true;
252 | }
253 |
254 | /**
255 | * Connects to the GATT server hosted on the Bluetooth LE device.
256 | *
257 | * @param address The device address of the destination device.
258 | *
259 | * @return Return true if the connection is initiated successfully. The connection result
260 | * is reported asynchronously through the
261 | * {@code BluetoothGattCallback#onConnectionStateChange(android.bluetooth.BluetoothGatt, int, int)}
262 | * callback.
263 | */
264 | public boolean connect(final String address) {
265 | if (mBluetoothAdapter == null || address == null) {
266 | Log.w(TAG, "BluetoothAdapter not initialized or unspecified address.");
267 | return false;
268 | }
269 |
270 | // Previously connected device. Try to reconnect.
271 | if (mBluetoothDeviceAddress != null && address.equals(mBluetoothDeviceAddress)
272 | && mBluetoothGatt != null) {
273 | Log.d(TAG, "Trying to use an existing mBluetoothGatt for connection.");
274 | if (mBluetoothGatt.connect()) {
275 | mConnectionState = STATE_CONNECTING;
276 | return true;
277 | } else {
278 | return false;
279 | }
280 | }
281 |
282 | final BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
283 | if (device == null) {
284 | Log.w(TAG, "Device not found. Unable to connect.");
285 | return false;
286 | }
287 | // We want to directly connect to the device, so we are setting the autoConnect
288 | // parameter to false.
289 | mBluetoothGatt = device.connectGatt(this, false, mGattCallback);
290 |
291 | Log.d(TAG, "Trying to create a new connection.");
292 | mBluetoothDeviceAddress = address;
293 | mConnectionState = STATE_CONNECTING;
294 | return true;
295 | }
296 |
297 | /**
298 | * Disconnects an existing connection or cancel a pending connection. The disconnection result
299 | * is reported asynchronously through the
300 | * {@code BluetoothGattCallback#onConnectionStateChange(android.bluetooth.BluetoothGatt, int, int)}
301 | * callback.
302 | */
303 | public void disconnect() {
304 | if (mBluetoothAdapter == null || mBluetoothGatt == null) {
305 | Log.w(TAG, "BluetoothAdapter not initialized");
306 | return;
307 | }
308 | mBluetoothGatt.disconnect();
309 | }
310 |
311 | /**
312 | * After using a given BLE device, the app must call this method to ensure resources are
313 | * released properly.
314 | */
315 | public void close() {
316 | if (mBluetoothGatt == null) {
317 | return;
318 | }
319 | mBluetoothGatt.close();
320 | mBluetoothGatt = null;
321 | }
322 |
323 | /**
324 | * Request a read on a given {@code BluetoothGattCharacteristic}. The read result is reported
325 | * asynchronously through the {@code BluetoothGattCallback#onCharacteristicRead(android.bluetooth.BluetoothGatt, android.bluetooth.BluetoothGattCharacteristic, int)}
326 | * callback.
327 | *
328 | * @param characteristic The characteristic to read from.
329 | */
330 | public void readCharacteristic(BluetoothGattCharacteristic characteristic) {
331 | if (mBluetoothAdapter == null || mBluetoothGatt == null) {
332 | Log.w(TAG, "BluetoothAdapter not initialized");
333 | return;
334 | }
335 | mBluetoothGatt.readCharacteristic(characteristic);
336 | }
337 |
338 | public void writeRemoteCharacteristic(BluetoothGattCharacteristic characteristic) {
339 |
340 | if (mBluetoothAdapter == null || mBluetoothGatt == null) {
341 | Log.w(TAG, "BluetoothAdapter not initialized");
342 | return;
343 | }
344 | mBluetoothGatt.writeCharacteristic(characteristic);
345 | }
346 |
347 | /**
348 | * Enables or disables notification on a give characteristic.
349 | *
350 | * @param characteristic Characteristic to act on.
351 | * @param enabled If true, enable notification. False otherwise.
352 | */
353 | public void setCharacteristicNotification(BluetoothGattCharacteristic characteristic,
354 | boolean enabled) {
355 | if (mBluetoothAdapter == null || mBluetoothGatt == null) {
356 | Log.w(TAG, "BluetoothAdapter not initialized");
357 | return;
358 | }
359 | mBluetoothGatt.setCharacteristicNotification(characteristic, enabled);
360 |
361 | // This is specific to Heart Rate Measurement.
362 | if (UUID_HEART_RATE_MEASUREMENT.equals(characteristic.getUuid())) {
363 | BluetoothGattDescriptor descriptor = characteristic.getDescriptor(
364 | UUID.fromString(SampleGattAttributes.CLIENT_CHARACTERISTIC_CONFIG));
365 | descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
366 | mBluetoothGatt.writeDescriptor(descriptor);
367 | }
368 | }
369 |
370 | /**
371 | * Retrieves a list of supported GATT services on the connected device. This should be
372 | * invoked only after {@code BluetoothGatt#discoverServices()} completes successfully.
373 | *
374 | * @return A {@code List} of supported services.
375 | */
376 | public List getSupportedGattServices() {
377 | if (mBluetoothGatt == null) return null;
378 |
379 | return mBluetoothGatt.getServices();
380 | }
381 |
382 | public void addGattServerService(BluetoothGattService service)
383 | {
384 | mBluetoothGattServer.addService(service);
385 | }
386 |
387 | public void addDefinedGattServerServices( )
388 | {
389 | mBluetoothGattServer = mBluetoothManager.openGattServer(this, mGattServerCallback);
390 | BluetoothGattService service = new BluetoothGattService(UUID.fromString(SampleGattAttributes.FAN_CONTROL_SERVICE_UUID), BluetoothGattService.SERVICE_TYPE_PRIMARY);
391 | BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(UUID.fromString(SampleGattAttributes.FAN_OPERATING_STATE), BluetoothGattCharacteristic.FORMAT_UINT8, BluetoothGattCharacteristic.PERMISSION_WRITE );
392 |
393 | service.addCharacteristic(characteristic);
394 | mBluetoothGattServer.addService(service);
395 |
396 | Log.d("HELLO", "Created our own GATT server.\r\n");
397 |
398 | }
399 | }
400 |
--------------------------------------------------------------------------------
/BluetoothLeGattSample/src/main/java/com/example/android/bluetoothlegatt/DeviceControlActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.android.bluetoothlegatt;
18 |
19 | import android.app.Activity;
20 | import android.bluetooth.BluetoothGattCharacteristic;
21 | import android.bluetooth.BluetoothGattService;
22 | import android.content.BroadcastReceiver;
23 | import android.content.ComponentName;
24 | import android.content.Context;
25 | import android.content.Intent;
26 | import android.content.IntentFilter;
27 | import android.content.ServiceConnection;
28 | import android.os.Bundle;
29 | import android.os.IBinder;
30 | import android.util.Log;
31 | import android.view.Menu;
32 | import android.view.MenuItem;
33 | import android.view.View;
34 | import android.widget.Button;
35 | import android.widget.ExpandableListView;
36 | import android.widget.SimpleExpandableListAdapter;
37 | import android.widget.TextView;
38 |
39 | import java.util.ArrayList;
40 | import java.util.HashMap;
41 | import java.util.List;
42 | import java.util.UUID;
43 |
44 | /**
45 | * For a given BLE device, this Activity provides the user interface to connect, display data,
46 | * and display GATT services and characteristics supported by the device. The Activity
47 | * communicates with {@code BluetoothLeService}, which in turn interacts with the
48 | * Bluetooth LE API.
49 | */
50 | public class DeviceControlActivity extends Activity {
51 | private final static String TAG = DeviceControlActivity.class.getSimpleName();
52 |
53 | public static final String EXTRAS_DEVICE_NAME = "DEVICE_NAME";
54 | public static final String EXTRAS_DEVICE_ADDRESS = "DEVICE_ADDRESS";
55 |
56 | private TextView mConnectionState;
57 | private TextView mDataField;
58 | private String mDeviceName;
59 | private String mDeviceAddress;
60 | private ExpandableListView mGattServicesList;
61 | private BluetoothLeService mBluetoothLeService;
62 | private ArrayList> mGattCharacteristics =
63 | new ArrayList>();
64 | private boolean mConnected = false;
65 | private BluetoothGattCharacteristic mNotifyCharacteristic;
66 |
67 | private final String LIST_NAME = "NAME";
68 | private final String LIST_UUID = "UUID";
69 |
70 | @Override
71 | public void onCreate(Bundle savedInstanceState) {
72 | super.onCreate(savedInstanceState);
73 | setContentView(R.layout.gatt_services_characteristics);
74 |
75 |
76 | final Intent intent = getIntent();
77 | mDeviceName = intent.getStringExtra(EXTRAS_DEVICE_NAME);
78 | mDeviceAddress = intent.getStringExtra(EXTRAS_DEVICE_ADDRESS);
79 |
80 | // Sets up UI references.
81 | ((TextView) findViewById(R.id.device_address)).setText(mDeviceAddress);
82 | mGattServicesList = (ExpandableListView) findViewById(R.id.gatt_services_list);
83 | mGattServicesList.setOnChildClickListener(servicesListClickListner);
84 | mConnectionState = (TextView) findViewById(R.id.connection_state);
85 | mDataField = (TextView) findViewById(R.id.data_value);
86 |
87 | getActionBar().setTitle(mDeviceName);
88 | getActionBar().setDisplayHomeAsUpEnabled(true);
89 | final Intent gattServiceIntent = new Intent(this, BluetoothLeService.class);
90 | bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE);
91 |
92 | }
93 |
94 | // Code to manage Service lifecycle.
95 | private final ServiceConnection mServiceConnection = new ServiceConnection() {
96 |
97 | @Override
98 | public void onServiceConnected(ComponentName componentName, IBinder service) {
99 | mBluetoothLeService = ((BluetoothLeService.LocalBinder) service).getService();
100 | if (!mBluetoothLeService.initialize()) {
101 | Log.e(TAG, "Unable to initialize Bluetooth");
102 | finish();
103 | }
104 | // Automatically connects to the device upon successful start-up initialization.
105 | mBluetoothLeService.connect(mDeviceAddress);
106 |
107 | }
108 |
109 | @Override
110 | public void onServiceDisconnected(ComponentName componentName) {
111 | mBluetoothLeService = null;
112 | }
113 | };
114 |
115 | // Handles various events fired by the Service.
116 | // ACTION_GATT_CONNECTED: connected to a GATT server.
117 | // ACTION_GATT_DISCONNECTED: disconnected from a GATT server.
118 | // ACTION_GATT_SERVICES_DISCOVERED: discovered GATT services.
119 | // ACTION_DATA_AVAILABLE: received data from the device. This can be a result of read
120 | // or notification operations.
121 | private final BroadcastReceiver mGattUpdateReceiver = new BroadcastReceiver() {
122 | @Override
123 | public void onReceive(Context context, Intent intent) {
124 | final String action = intent.getAction();
125 | if (BluetoothLeService.ACTION_GATT_CONNECTED.equals(action)) {
126 | mConnected = true;
127 | updateConnectionState(R.string.connected);
128 | invalidateOptionsMenu();
129 | } else if (BluetoothLeService.ACTION_GATT_DISCONNECTED.equals(action)) {
130 | mConnected = false;
131 | updateConnectionState(R.string.disconnected);
132 | invalidateOptionsMenu();
133 | clearUI();
134 | } else if (BluetoothLeService.ACTION_GATT_SERVICES_DISCOVERED.equals(action)) {
135 | // Show all the supported services and characteristics on the user interface.
136 | displayGattServices(mBluetoothLeService.getSupportedGattServices());
137 | } else if (BluetoothLeService.ACTION_DATA_AVAILABLE.equals(action)) {
138 | displayData(intent.getStringExtra(BluetoothLeService.EXTRA_DATA));
139 | }
140 | }
141 | };
142 |
143 | // If a given GATT characteristic is selected, check for supported features. This sample
144 | // demonstrates 'Read' and 'Notify' features. See
145 | // http://d.android.com/reference/android/bluetooth/BluetoothGatt.html for the complete
146 | // list of supported characteristic features.
147 | private final ExpandableListView.OnChildClickListener servicesListClickListner =
148 | new ExpandableListView.OnChildClickListener() {
149 | @Override
150 | public boolean onChildClick(ExpandableListView parent, View v, int groupPosition,
151 | int childPosition, long id) {
152 | if (mGattCharacteristics != null) {
153 | final BluetoothGattCharacteristic characteristic =
154 | mGattCharacteristics.get(groupPosition).get(childPosition);
155 | final int charaProp = characteristic.getProperties();
156 | if ((charaProp | BluetoothGattCharacteristic.PROPERTY_READ) > 0) {
157 | // If there is an active notification on a characteristic, clear
158 | // it first so it doesn't update the data field on the user interface.
159 | if (mNotifyCharacteristic != null) {
160 | mBluetoothLeService.setCharacteristicNotification(
161 | mNotifyCharacteristic, false);
162 | mNotifyCharacteristic = null;
163 | }
164 | mBluetoothLeService.readCharacteristic(characteristic);
165 | }
166 | if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) {
167 | mNotifyCharacteristic = characteristic;
168 | mBluetoothLeService.setCharacteristicNotification(
169 | characteristic, true);
170 | }
171 | return true;
172 | }
173 | return false;
174 | }
175 | };
176 |
177 | private void clearUI() {
178 | mGattServicesList.setAdapter((SimpleExpandableListAdapter) null);
179 | mDataField.setText(R.string.no_data);
180 | }
181 |
182 |
183 |
184 | @Override
185 | protected void onResume() {
186 | super.onResume();
187 | registerReceiver(mGattUpdateReceiver, makeGattUpdateIntentFilter());
188 | if (mBluetoothLeService != null) {
189 | final boolean result = mBluetoothLeService.connect(mDeviceAddress);
190 | Log.d(TAG, "Connect request result=" + result);
191 | }
192 | }
193 |
194 | @Override
195 | protected void onPause() {
196 | super.onPause();
197 | unregisterReceiver(mGattUpdateReceiver);
198 | }
199 |
200 | @Override
201 | protected void onDestroy() {
202 | super.onDestroy();
203 | unbindService(mServiceConnection);
204 | mBluetoothLeService = null;
205 | }
206 |
207 | @Override
208 | public boolean onCreateOptionsMenu(Menu menu) {
209 | getMenuInflater().inflate(R.menu.gatt_services, menu);
210 | if (mConnected) {
211 | menu.findItem(R.id.menu_connect).setVisible(false);
212 | menu.findItem(R.id.menu_disconnect).setVisible(true);
213 | } else {
214 | menu.findItem(R.id.menu_connect).setVisible(true);
215 | menu.findItem(R.id.menu_disconnect).setVisible(false);
216 | }
217 |
218 | return true;
219 | }
220 |
221 | @Override
222 | public boolean onOptionsItemSelected(MenuItem item) {
223 | switch(item.getItemId()) {
224 | case R.id.menu_connect:
225 | mBluetoothLeService.connect(mDeviceAddress);
226 | return true;
227 | case R.id.menu_disconnect:
228 | mBluetoothLeService.disconnect();
229 | return true;
230 | case android.R.id.home:
231 | onBackPressed();
232 | return true;
233 | }
234 | return super.onOptionsItemSelected(item);
235 | }
236 |
237 | private void updateConnectionState(final int resourceId) {
238 | runOnUiThread(new Runnable() {
239 | @Override
240 | public void run() {
241 | mConnectionState.setText(resourceId);
242 | }
243 | });
244 | }
245 |
246 | private void displayData(String data) {
247 | if (data != null) {
248 | mDataField.setText(data);
249 | }
250 | }
251 |
252 | // Demonstrates how to iterate through the supported GATT Services/Characteristics.
253 | // In this sample, we populate the data structure that is bound to the ExpandableListView
254 | // on the UI.
255 | private void displayGattServices(List gattServices) {
256 | if (gattServices == null) return;
257 | String uuid = null;
258 | String unknownServiceString = getResources().getString(R.string.unknown_service);
259 | String unknownCharaString = getResources().getString(R.string.unknown_characteristic);
260 | ArrayList> gattServiceData = new ArrayList>();
261 | ArrayList>> gattCharacteristicData
262 | = new ArrayList>>();
263 | mGattCharacteristics = new ArrayList>();
264 |
265 | // Loops through available GATT Services.
266 | for (BluetoothGattService gattService : gattServices) {
267 | HashMap currentServiceData = new HashMap();
268 | uuid = gattService.getUuid().toString();
269 | currentServiceData.put(
270 | LIST_NAME, SampleGattAttributes.lookup(uuid, unknownServiceString));
271 | currentServiceData.put(LIST_UUID, uuid);
272 | gattServiceData.add(currentServiceData);
273 |
274 | ArrayList> gattCharacteristicGroupData =
275 | new ArrayList>();
276 | List gattCharacteristics =
277 | gattService.getCharacteristics();
278 | ArrayList charas =
279 | new ArrayList();
280 |
281 | // Loops through available Characteristics.
282 | for (BluetoothGattCharacteristic gattCharacteristic : gattCharacteristics) {
283 | charas.add(gattCharacteristic);
284 | HashMap currentCharaData = new HashMap();
285 | uuid = gattCharacteristic.getUuid().toString();
286 | currentCharaData.put(
287 | LIST_NAME, SampleGattAttributes.lookup(uuid, unknownCharaString));
288 | currentCharaData.put(LIST_UUID, uuid);
289 | gattCharacteristicGroupData.add(currentCharaData);
290 | }
291 | mGattCharacteristics.add(charas);
292 | gattCharacteristicData.add(gattCharacteristicGroupData);
293 | }
294 |
295 | SimpleExpandableListAdapter gattServiceAdapter = new SimpleExpandableListAdapter(
296 | this,
297 | gattServiceData,
298 | android.R.layout.simple_expandable_list_item_2,
299 | new String[] {LIST_NAME, LIST_UUID},
300 | new int[] { android.R.id.text1, android.R.id.text2 },
301 | gattCharacteristicData,
302 | android.R.layout.simple_expandable_list_item_2,
303 | new String[] {LIST_NAME, LIST_UUID},
304 | new int[] { android.R.id.text1, android.R.id.text2 }
305 | );
306 | mGattServicesList.setAdapter(gattServiceAdapter);
307 | }
308 |
309 |
310 | private static IntentFilter makeGattUpdateIntentFilter() {
311 | final IntentFilter intentFilter = new IntentFilter();
312 | intentFilter.addAction(BluetoothLeService.ACTION_GATT_CONNECTED);
313 | intentFilter.addAction(BluetoothLeService.ACTION_GATT_DISCONNECTED);
314 | intentFilter.addAction(BluetoothLeService.ACTION_GATT_SERVICES_DISCOVERED);
315 | intentFilter.addAction(BluetoothLeService.ACTION_DATA_AVAILABLE);
316 | return intentFilter;
317 | }
318 |
319 | }
320 |
--------------------------------------------------------------------------------
/BluetoothLeGattSample/src/main/java/com/example/android/bluetoothlegatt/DeviceScanActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.android.bluetoothlegatt;
18 |
19 | import android.app.Activity;
20 | import android.app.ListActivity;
21 | import android.bluetooth.BluetoothAdapter;
22 | import android.bluetooth.BluetoothDevice;
23 | import android.bluetooth.BluetoothManager;
24 | import android.content.Context;
25 | import android.content.Intent;
26 | import android.content.pm.PackageManager;
27 | import android.os.Bundle;
28 | import android.os.Handler;
29 | import android.view.LayoutInflater;
30 | import android.view.Menu;
31 | import android.view.MenuItem;
32 | import android.view.View;
33 | import android.view.ViewGroup;
34 | import android.widget.BaseAdapter;
35 | import android.widget.ListView;
36 | import android.widget.TextView;
37 | import android.widget.Toast;
38 |
39 | import java.util.ArrayList;
40 |
41 | /**
42 | * Activity for scanning and displaying available Bluetooth LE devices.
43 | */
44 | public class DeviceScanActivity extends ListActivity {
45 | private LeDeviceListAdapter mLeDeviceListAdapter;
46 | private BluetoothAdapter mBluetoothAdapter;
47 | private boolean mScanning;
48 | private Handler mHandler;
49 |
50 | private static final int REQUEST_ENABLE_BT = 1;
51 | // Stops scanning after 10 seconds.
52 | private static final long SCAN_PERIOD = 10000;
53 |
54 | @Override
55 | public void onCreate(Bundle savedInstanceState) {
56 | super.onCreate(savedInstanceState);
57 | getActionBar().setTitle(R.string.title_devices);
58 | mHandler = new Handler();
59 |
60 | // Use this check to determine whether BLE is supported on the device. Then you can
61 | // selectively disable BLE-related features.
62 | if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {
63 | Toast.makeText(this, R.string.ble_not_supported, Toast.LENGTH_SHORT).show();
64 | finish();
65 | }
66 |
67 | // Initializes a Bluetooth adapter. For API level 18 and above, get a reference to
68 | // BluetoothAdapter through BluetoothManager.
69 | final BluetoothManager bluetoothManager =
70 | (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
71 | mBluetoothAdapter = bluetoothManager.getAdapter();
72 |
73 | // Checks if Bluetooth is supported on the device.
74 | if (mBluetoothAdapter == null) {
75 | Toast.makeText(this, R.string.error_bluetooth_not_supported, Toast.LENGTH_SHORT).show();
76 | finish();
77 | return;
78 | }
79 | }
80 |
81 | @Override
82 | public boolean onCreateOptionsMenu(Menu menu) {
83 | getMenuInflater().inflate(R.menu.main, menu);
84 | if (!mScanning) {
85 | menu.findItem(R.id.menu_stop).setVisible(false);
86 | menu.findItem(R.id.menu_scan).setVisible(true);
87 | menu.findItem(R.id.menu_refresh).setActionView(null);
88 | } else {
89 | menu.findItem(R.id.menu_stop).setVisible(true);
90 | menu.findItem(R.id.menu_scan).setVisible(false);
91 | menu.findItem(R.id.menu_refresh).setActionView(
92 | R.layout.actionbar_indeterminate_progress);
93 | }
94 | return true;
95 | }
96 |
97 | @Override
98 | public boolean onOptionsItemSelected(MenuItem item) {
99 | switch (item.getItemId()) {
100 | case R.id.menu_scan:
101 | mLeDeviceListAdapter.clear();
102 | scanLeDevice(true);
103 | break;
104 | case R.id.menu_stop:
105 | scanLeDevice(false);
106 | break;
107 | }
108 | return true;
109 | }
110 |
111 | @Override
112 | protected void onResume() {
113 | super.onResume();
114 |
115 | // Ensures Bluetooth is enabled on the device. If Bluetooth is not currently enabled,
116 | // fire an intent to display a dialog asking the user to grant permission to enable it.
117 | if (!mBluetoothAdapter.isEnabled()) {
118 | if (!mBluetoothAdapter.isEnabled()) {
119 | Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
120 | startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
121 | }
122 | }
123 |
124 | // Initializes list view adapter.
125 | mLeDeviceListAdapter = new LeDeviceListAdapter();
126 | setListAdapter(mLeDeviceListAdapter);
127 | scanLeDevice(true);
128 | }
129 |
130 | @Override
131 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
132 | // User chose not to enable Bluetooth.
133 | if (requestCode == REQUEST_ENABLE_BT && resultCode == Activity.RESULT_CANCELED) {
134 | finish();
135 | return;
136 | }
137 | super.onActivityResult(requestCode, resultCode, data);
138 | }
139 |
140 | @Override
141 | protected void onPause() {
142 | super.onPause();
143 | scanLeDevice(false);
144 | mLeDeviceListAdapter.clear();
145 | }
146 |
147 | @Override
148 | protected void onListItemClick(ListView l, View v, int position, long id) {
149 | final BluetoothDevice device = mLeDeviceListAdapter.getDevice(position);
150 | if (device == null) return;
151 | final Intent intent = new Intent(this, DeviceControlActivity.class);
152 | intent.putExtra(DeviceControlActivity.EXTRAS_DEVICE_NAME, device.getName());
153 | intent.putExtra(DeviceControlActivity.EXTRAS_DEVICE_ADDRESS, device.getAddress());
154 | if (mScanning) {
155 | mBluetoothAdapter.stopLeScan(mLeScanCallback);
156 | mScanning = false;
157 | }
158 | startActivity(intent);
159 | }
160 |
161 | private void scanLeDevice(final boolean enable) {
162 | if (enable) {
163 | // Stops scanning after a pre-defined scan period.
164 | mHandler.postDelayed(new Runnable() {
165 | @Override
166 | public void run() {
167 | mScanning = false;
168 | mBluetoothAdapter.stopLeScan(mLeScanCallback);
169 | invalidateOptionsMenu();
170 | }
171 | }, SCAN_PERIOD);
172 |
173 | mScanning = true;
174 | mBluetoothAdapter.startLeScan(mLeScanCallback);
175 | } else {
176 | mScanning = false;
177 | mBluetoothAdapter.stopLeScan(mLeScanCallback);
178 | }
179 | invalidateOptionsMenu();
180 | }
181 |
182 | // Adapter for holding devices found through scanning.
183 | private class LeDeviceListAdapter extends BaseAdapter {
184 | private ArrayList mLeDevices;
185 | private LayoutInflater mInflator;
186 |
187 | public LeDeviceListAdapter() {
188 | super();
189 | mLeDevices = new ArrayList();
190 | mInflator = DeviceScanActivity.this.getLayoutInflater();
191 | }
192 |
193 | public void addDevice(BluetoothDevice device) {
194 | if(!mLeDevices.contains(device)) {
195 | mLeDevices.add(device);
196 | }
197 | }
198 |
199 | public BluetoothDevice getDevice(int position) {
200 | return mLeDevices.get(position);
201 | }
202 |
203 | public void clear() {
204 | mLeDevices.clear();
205 | }
206 |
207 | @Override
208 | public int getCount() {
209 | return mLeDevices.size();
210 | }
211 |
212 | @Override
213 | public Object getItem(int i) {
214 | return mLeDevices.get(i);
215 | }
216 |
217 | @Override
218 | public long getItemId(int i) {
219 | return i;
220 | }
221 |
222 | @Override
223 | public View getView(int i, View view, ViewGroup viewGroup) {
224 | ViewHolder viewHolder;
225 | // General ListView optimization code.
226 | if (view == null) {
227 | view = mInflator.inflate(R.layout.listitem_device, null);
228 | viewHolder = new ViewHolder();
229 | viewHolder.deviceAddress = (TextView) view.findViewById(R.id.device_address);
230 | viewHolder.deviceName = (TextView) view.findViewById(R.id.device_name);
231 | view.setTag(viewHolder);
232 | } else {
233 | viewHolder = (ViewHolder) view.getTag();
234 | }
235 |
236 | BluetoothDevice device = mLeDevices.get(i);
237 | final String deviceName = device.getName();
238 | if (deviceName != null && deviceName.length() > 0)
239 | viewHolder.deviceName.setText(deviceName);
240 | else
241 | viewHolder.deviceName.setText(R.string.unknown_device);
242 | viewHolder.deviceAddress.setText(device.getAddress());
243 |
244 | return view;
245 | }
246 | }
247 |
248 | // Device scan callback.
249 | private BluetoothAdapter.LeScanCallback mLeScanCallback =
250 | new BluetoothAdapter.LeScanCallback() {
251 |
252 | @Override
253 | public void onLeScan(final BluetoothDevice device, int rssi, byte[] scanRecord) {
254 | runOnUiThread(new Runnable() {
255 | @Override
256 | public void run() {
257 | mLeDeviceListAdapter.addDevice(device);
258 | mLeDeviceListAdapter.notifyDataSetChanged();
259 | }
260 | });
261 | }
262 | };
263 |
264 | static class ViewHolder {
265 | TextView deviceName;
266 | TextView deviceAddress;
267 | }
268 | }
--------------------------------------------------------------------------------
/BluetoothLeGattSample/src/main/java/com/example/android/bluetoothlegatt/SampleGattAttributes.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.android.bluetoothlegatt;
18 |
19 | import java.util.HashMap;
20 |
21 | /**
22 | * This class includes a small subset of standard GATT attributes for demonstration purposes.
23 | */
24 | public class SampleGattAttributes {
25 | private static HashMap attributes = new HashMap();
26 | public static String HEART_RATE_MEASUREMENT = "00002a37-0000-1000-8000-00805f9b34fb";
27 | public static String CLIENT_CHARACTERISTIC_CONFIG = "00002902-0000-1000-8000-00805f9b34fb";
28 | public static String FAN_CONTROL_SERVICE_UUID = "86c86302-fc10-1399-df43-fceb24618252";
29 | public static String FAN_OPERATING_STATE = "705d627b-53e7-eda2-2649-5ecbd0bbfb85";
30 |
31 | static {
32 | // Sample Services.
33 | attributes.put("0000180d-0000-1000-8000-00805f9b34fb", "Heart Rate Service");
34 | attributes.put("0000180a-0000-1000-8000-00805f9b34fb", "Device Information Service");
35 | attributes.put("72f3d37d-c861-07ab-0341-f8cf302ca8b1", "DarkBlue Managed Service");
36 | attributes.put("f23844d8-1f57-448b-7f44-e64ae0fe15cf", "Line Cook Steps Service");
37 | //attributes.put("2cc0849e-5378-3abd-8e44-94d6fca2ed39", "Line Cook Steps Service");
38 | attributes.put("430f9940-1ff5-ca8e-d843-27c7153258a4", "Line Cook 2.0 Steps Service");
39 | attributes.put(FAN_CONTROL_SERVICE_UUID, "Fan Control Service");
40 |
41 |
42 | // Sample Characteristics.
43 | attributes.put(HEART_RATE_MEASUREMENT, "Heart Rate Measurement");
44 | attributes.put("00002a29-0000-1000-8000-00805f9b34fb", "Manufacturer Name String");
45 | attributes.put("abcbe138-a00c-6b8e-7d44-4b63a80170c3", "DarkBlue Company UUID Characteristic");
46 | attributes.put("26b8a2dc-544d-008e-c343-5d8fac910c6e", "DarkBlue Major ID Characteristic");
47 | attributes.put("0acea172-2a76-69a7-4e49-302ed371f6a8", "DarkBlue Minor ID Characteristic");
48 | attributes.put("e205929f-e016-ecbc-024b-62f0658fdacd", "DarkBlue Measured Power Characteristic");
49 | attributes.put("519fc39c-9a18-82b2-ea43-6a101ab1a8f9", "Cooking Step Characteristic");
50 | attributes.put("52812a3d-247d-77b9-6740-75748c4621c5", "Cooking Step Characteristic");
51 | attributes.put("f47e47ab-b25f-3a83-7b47-1f230b2b1a61", "Cooking Step Characteristic");
52 | attributes.put(FAN_OPERATING_STATE, "Fan Operating State Characteristic");
53 |
54 | }
55 |
56 | public static String lookup(String uuid, String defaultName) {
57 | String name = attributes.get(uuid);
58 | return name == null ? defaultName : name;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/BluetoothLeGattSample/src/main/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/src/main/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/BluetoothLeGattSample/src/main/res/drawable-hdpi/tile.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/src/main/res/drawable-hdpi/tile.9.png
--------------------------------------------------------------------------------
/BluetoothLeGattSample/src/main/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/src/main/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/BluetoothLeGattSample/src/main/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/src/main/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/BluetoothLeGattSample/src/main/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/BluetoothLeGattSample/src/main/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/BluetoothLeGattSample/src/main/res/layout/actionbar_indeterminate_progress.xml:
--------------------------------------------------------------------------------
1 |
16 |
20 |
23 |
24 |
--------------------------------------------------------------------------------
/BluetoothLeGattSample/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
21 |
22 |
26 |
27 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/BluetoothLeGattSample/src/main/res/layout/gatt_services_characteristics.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
21 |
22 |
26 |
30 |
32 |
36 |
37 |
41 |
45 |
47 |
52 |
53 |
57 |
61 |
63 |
68 |
69 |
72 |
--------------------------------------------------------------------------------
/BluetoothLeGattSample/src/main/res/layout/listitem_device.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
20 |
24 |
28 |
--------------------------------------------------------------------------------
/BluetoothLeGattSample/src/main/res/menu/gatt_services.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
30 |
--------------------------------------------------------------------------------
/BluetoothLeGattSample/src/main/res/menu/main.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
30 |
--------------------------------------------------------------------------------
/BluetoothLeGattSample/src/main/res/values-sw600dp/template-dimens.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
20 |
21 | @dimen/margin_huge
22 | @dimen/margin_medium
23 |
24 |
25 |
--------------------------------------------------------------------------------
/BluetoothLeGattSample/src/main/res/values-sw600dp/template-styles.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/BluetoothLeGattSample/src/main/res/values-v11/template-styles.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/BluetoothLeGattSample/src/main/res/values/base-strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
21 | BluetoothLeGatt
22 |
23 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/BluetoothLeGattSample/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 | BLE is not supported
18 | Data:
19 | Device address:
20 | State:
21 | No data
22 | Connected
23 | Disconnected
24 | BLE Device Scan
25 | Bluetooth not supported.
26 |
27 | Unknown device
28 | Unknown characteristic
29 | Unknown service
30 |
31 |
32 | Connect
33 | Disconnect
34 | Scan
35 | Stop
36 |
37 |
--------------------------------------------------------------------------------
/BluetoothLeGattSample/src/main/res/values/template-dimens.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
20 |
21 | 4dp
22 | 8dp
23 | 16dp
24 | 32dp
25 | 64dp
26 |
27 |
28 |
29 | @dimen/margin_medium
30 | @dimen/margin_medium
31 |
32 |
33 |
--------------------------------------------------------------------------------
/BluetoothLeGattSample/src/main/res/values/template-styles.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
34 |
35 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/README.txt:
--------------------------------------------------------------------------------
1 | Build Instructions
2 | -------------------
3 |
4 | This sample uses the Gradle build system. To build this project, use the
5 | "gradlew build" command or use "Import Project" in Android Studio.
6 |
7 | To see a list of all available commands, run "gradlew tasks".
8 |
9 | Dependencies
10 | -------------
11 |
12 | - Android SDK Build-tools v18.1
13 | - Android Support Repository v2
14 |
15 | Dependencies are available for download via the Android SDK Manager.
16 |
17 | Android Studio is available for download at:
18 | http://developer.android.com/sdk/installing/studio.html
19 |
--------------------------------------------------------------------------------
/ble-android-example.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/ble-android-gatt-server.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/build/intermediates/dex-cache/cache.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/build/intermediates/model_data.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/build/intermediates/model_data.bin
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffddrake/ble-android-gatt-server/717c7f03d46758d9e2af55e6cee88200f701ebe9/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Apr 10 15:27:10 PDT 2013
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-bin.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/local.properties:
--------------------------------------------------------------------------------
1 | ## This file is automatically generated by Android Studio.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must *NOT* be checked into Version Control Systems,
5 | # as it contains information specific to your local configuration.
6 | #
7 | # Location of the SDK. This is only used by Gradle.
8 | # For customization when using a Version Control System, please read the
9 | # header note.
10 | #Thu Sep 18 13:41:52 GMT-05:00 2014
11 | sdk.dir=/Applications/Android Studio.app/sdk
12 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | include 'BluetoothLeGattSample'
5 |
--------------------------------------------------------------------------------