Skip to content
This repository has been archived by the owner on Apr 8, 2023. It is now read-only.

Commit

Permalink
publishing new verison, small bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
marcolivierarsenault committed Mar 14, 2015
1 parent 67c7aeb commit ec9b94c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.marco45.polarheartmonitor"
android:versionCode="5"
android:versionName="1.4" >
android:versionCode="6"
android:versionName="1.5" >

<uses-sdk
android:minSdkVersion="15"
Expand Down
11 changes: 11 additions & 0 deletions src/org/marco45/polarheartmonitor/H7ConnectThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class H7ConnectThread extends Thread{
MainActivity ac;
private BluetoothGatt gat; //gat server
private final String HRUUID = "0000180D-0000-1000-8000-00805F9B34FB";
static BluetoothGattDescriptor descriptor;
static BluetoothGattCharacteristic cc;

public H7ConnectThread(BluetoothDevice device, MainActivity ac) {
Log.i("H7ConnectThread", "Starting H7 reader BTLE");
Expand All @@ -33,6 +35,10 @@ public H7ConnectThread(BluetoothDevice device, MainActivity ac) {

/** Will cancel an in-progress connection, and close the socket */
public void cancel() {
gat.setCharacteristicNotification(cc,false);
descriptor.setValue( BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE);
gat.writeDescriptor(descriptor);

gat.disconnect();
gat.close();
Log.i("H7ConnectThread", "Closing HRsensor");
Expand Down Expand Up @@ -76,6 +82,11 @@ public void onServicesDiscovered(final BluetoothGatt gatt, final int status) {
for (BluetoothGattDescriptor descriptor : cc.getDescriptors()) {
//find descriptor UUID that matches Client Characteristic Configuration (0x2902)
// and then call setValue on that descriptor

//Those two line set the value for the disconnection
H7ConnectThread.descriptor=descriptor;
H7ConnectThread.cc=cc;

gatt.setCharacteristicNotification(cc,true);//Register to updates
descriptor.setValue( BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
gatt.writeDescriptor(descriptor);
Expand Down
4 changes: 2 additions & 2 deletions src/org/marco45/polarheartmonitor/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,14 @@ public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,
if(arg2!=0){
//Actual work
DataHandler.getInstance().setID(arg2);
if(!h7 && ((BluetoothDevice) pairedDevices.toArray()[DataHandler.getInstance().getID()-1]).getName().contains("H7"))
if(!h7 && ((BluetoothDevice) pairedDevices.toArray()[DataHandler.getInstance().getID()-1]).getName().contains("H7") && DataHandler.getInstance().getReader()==null)
{

Log.i("Main Activity", "Starting h7");
DataHandler.getInstance().setH7(new H7ConnectThread((BluetoothDevice) pairedDevices.toArray()[DataHandler.getInstance().getID()-1], this));
h7=true;
}
else{
else if (!normal && DataHandler.getInstance().getH7()==null){

Log.i("Main Activity", "Starting normal");
DataHandler.getInstance().setReader(new ConnectThread((BluetoothDevice) pairedDevices.toArray()[arg2-1], this));
Expand Down

0 comments on commit ec9b94c

Please sign in to comment.