Browse Source

Enlève les boutons « (dé)connecter »

master
Louis-Guillaume DUBOIS 9 years ago
parent
commit
8202921a6d
No known key found for this signature in database GPG Key ID: 96472D986598B31E
  1. 9
      Application/src/main/java/fr/centralesupelec/students/clientble/BluetoothLeService.java
  2. 5
      Application/src/main/java/fr/centralesupelec/students/clientble/SimpleDetailActivity.java

9
Application/src/main/java/fr/centralesupelec/students/clientble/BluetoothLeService.java

@ -37,6 +37,8 @@ import java.util.List;
import java.util.StringTokenizer;
import java.util.UUID;
import static java.lang.Thread.sleep;
/**
* Service for managing connection and data communication with a GATT server hosted on a
* given Bluetooth LE device.
@ -318,7 +320,12 @@ public class BluetoothLeService extends Service {
enabled ? BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE
: BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE
);
while (!mBluetoothGatt.writeDescriptor(descriptor)) ;
try {
while (!mBluetoothGatt.writeDescriptor(descriptor))
sleep(500);
} catch (Exception e) {
e.printStackTrace();
}
}
mBluetoothGatt.setCharacteristicNotification(characteristic, enabled);
}

5
Application/src/main/java/fr/centralesupelec/students/clientble/SimpleDetailActivity.java

@ -144,6 +144,7 @@ public class SimpleDetailActivity extends Activity {
mBluetoothLeService = null;
}
/*
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.gatt_services, menu);
@ -156,16 +157,19 @@ public class SimpleDetailActivity extends Activity {
}
return true;
}
*/
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
/*
case R.id.menu_connect:
mBluetoothLeService.connect(mDeviceAddress);
return true;
case R.id.menu_disconnect:
mBluetoothLeService.disconnect();
return true;
*/
case android.R.id.home:
onBackPressed();
return true;
@ -173,6 +177,7 @@ public class SimpleDetailActivity extends Activity {
return super.onOptionsItemSelected(item);
}
private void updateConnectionState(final int resourceId) {
runOnUiThread(new Runnable() {
@Override

Loading…
Cancel
Save