Petites modifications
This commit is contained in:
parent
743aa392f8
commit
566f0311b9
5 changed files with 37 additions and 8 deletions
|
@ -37,7 +37,7 @@
|
|||
<ConfirmationsSetting value="0" id="Add" />
|
||||
<ConfirmationsSetting value="0" id="Remove" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="JDK" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="JDK" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
|
|
@ -63,8 +63,10 @@ public class BluetoothLeService extends Service {
|
|||
public final static String EXTRA_DATA =
|
||||
"com.example.bluetooth.le.EXTRA_DATA";
|
||||
|
||||
/* TODO
|
||||
public final static UUID UUID_HEART_RATE_MEASUREMENT =
|
||||
UUID.fromString(SampleGattAttributes.HEART_RATE_MEASUREMENT);
|
||||
*/
|
||||
|
||||
// Implements callback methods for GATT events that the app cares about. For example,
|
||||
// connection change and services discovered.
|
||||
|
@ -123,6 +125,7 @@ public class BluetoothLeService extends Service {
|
|||
final BluetoothGattCharacteristic characteristic) {
|
||||
final Intent intent = new Intent(action);
|
||||
|
||||
/* TODO
|
||||
// This is special handling for the Heart Rate Measurement profile. Data parsing is
|
||||
// carried out as per profile specifications:
|
||||
// http://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.heart_rate_measurement.xml
|
||||
|
@ -140,6 +143,7 @@ public class BluetoothLeService extends Service {
|
|||
Log.d(TAG, String.format("Received heart rate: %d", heartRate));
|
||||
intent.putExtra(EXTRA_DATA, String.valueOf(heartRate));
|
||||
} else {
|
||||
*/
|
||||
// For all other profiles, writes the data formatted in HEX.
|
||||
final byte[] data = characteristic.getValue();
|
||||
if (data != null && data.length > 0) {
|
||||
|
@ -148,7 +152,9 @@ public class BluetoothLeService extends Service {
|
|||
stringBuilder.append(String.format("%02X ", byteChar));
|
||||
intent.putExtra(EXTRA_DATA, new String(data) + "\n" + stringBuilder.toString());
|
||||
}
|
||||
/* TODO
|
||||
}
|
||||
*/
|
||||
sendBroadcast(intent);
|
||||
}
|
||||
|
||||
|
@ -296,6 +302,7 @@ public class BluetoothLeService extends Service {
|
|||
}
|
||||
mBluetoothGatt.setCharacteristicNotification(characteristic, enabled);
|
||||
|
||||
/* TODO
|
||||
// This is specific to Heart Rate Measurement.
|
||||
if (UUID_HEART_RATE_MEASUREMENT.equals(characteristic.getUuid())) {
|
||||
BluetoothGattDescriptor descriptor = characteristic.getDescriptor(
|
||||
|
@ -303,6 +310,7 @@ public class BluetoothLeService extends Service {
|
|||
descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
|
||||
mBluetoothGatt.writeDescriptor(descriptor);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (C) 2013 The Android Open Source Project
|
||||
* Copyright (C) 2017 Louis-Guillaume Dubois
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -23,16 +24,26 @@ import java.util.HashMap;
|
|||
*/
|
||||
public class SampleGattAttributes {
|
||||
private static HashMap<String, String> attributes = new HashMap();
|
||||
public static String HEART_RATE_MEASUREMENT = "00002a37-0000-1000-8000-00805f9b34fb";
|
||||
public static String CLIENT_CHARACTERISTIC_CONFIG = "00002902-0000-1000-8000-00805f9b34fb";
|
||||
|
||||
static {
|
||||
// Sample Services.
|
||||
attributes.put("0000180d-0000-1000-8000-00805f9b34fb", "Heart Rate Service");
|
||||
attributes.put("0000180a-0000-1000-8000-00805f9b34fb", "Device Information Service");
|
||||
attributes.put("0000180a-0000-1000-8000-00805f9b34fb", "Device Information");
|
||||
attributes.put("00001801-0000-1000-8000-00805f9b34fb", "Generic Attribute");
|
||||
attributes.put("00001800-0000-1000-8000-00805f9b34fb", "Generic Access");
|
||||
attributes.put("0000180f-0000-1000-8000-00805f9b34fb", "Battery Service");
|
||||
|
||||
attributes.put("11223344-5566-7788-9900-aabbccddeeff", "Private Service");
|
||||
|
||||
|
||||
// Sample Characteristics.
|
||||
attributes.put(HEART_RATE_MEASUREMENT, "Heart Rate Measurement");
|
||||
attributes.put("00002a29-0000-1000-8000-00805f9b34fb", "Manufacturer Name String");
|
||||
attributes.put("00002a19-0000-1000-8000-00805f9b34fb", "Battery Level");
|
||||
attributes.put("00002a00-0000-1000-8000-00805f9b34fb", "Device Name");
|
||||
attributes.put("00002a01-0000-1000-8000-00805f9b34fb", "Appearance");
|
||||
attributes.put("00002a04-0000-1000-8000-00805f9b34fb", "Peripheral Preferred Connection Parameters");
|
||||
attributes.put("00002a29-0000-1000-8000-00805f9b34fb", "Manufacturer Name");
|
||||
|
||||
attributes.put("01020304-0506-0708-0900-0a0b0c0d0e0f", "5-byte r char.");
|
||||
attributes.put("ff020304-0506-0708-0900-0a0b0c0d0e0f", "3-byte rw notif. char.");
|
||||
}
|
||||
|
||||
public static String lookup(String uuid, String defaultName) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright 2013 The Android Open Source Project
|
||||
Copyright 2017 Louis-Guillaume Dubois
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -16,7 +17,7 @@
|
|||
-->
|
||||
|
||||
<resources>
|
||||
<string name="app_name">BluetoothLeGatt</string>
|
||||
<string name="app_name">Client BLE</string>
|
||||
<string name="intro_message">
|
||||
<![CDATA[
|
||||
|
||||
|
|
9
TODO.md
Normal file
9
TODO.md
Normal file
|
@ -0,0 +1,9 @@
|
|||
À FAIRE
|
||||
=======
|
||||
|
||||
Par ordre décroissant d’urgence :
|
||||
|
||||
- prise en charge de l’écriture des caractéristiques ;
|
||||
- prise en charge des notifications des caractéristiques ;
|
||||
- filtrage des services et caractéristiques dans l’activité « DeviceControl » ;
|
||||
- filtrage des appareils avec notre service dans l’activité « DeviceScan ».
|
Loading…
Reference in a new issue