Build of V3.5.0a for testing. Includes fix of BLE datasource not shutting down on request, and possible fix of the 'mToneGenerator is null' error.
This commit is contained in:
@@ -93,6 +93,7 @@ public class SdDataSourceBLE extends SdDataSource {
|
||||
public final static UUID UUID_HEART_RATE_MEASUREMENT = UUID.fromString(CHAR_HEART_RATE_MEASUREMENT);
|
||||
private BluetoothGatt mGatt;
|
||||
private BluetoothGattCharacteristic mBattChar;
|
||||
private BluetoothGattCharacteristic mOsdChar;
|
||||
|
||||
|
||||
public SdDataSourceBLE(Context context, Handler handler,
|
||||
@@ -174,6 +175,9 @@ public class SdDataSourceBLE extends SdDataSource {
|
||||
Log.w(TAG, "BluetoothAdapter not initialized");
|
||||
return;
|
||||
}
|
||||
// Un-register for BLE Notifications.
|
||||
setCharacteristicNotification(mOsdChar, false);
|
||||
|
||||
mBluetoothGatt.disconnect();
|
||||
if (mBluetoothGatt == null) {
|
||||
return;
|
||||
@@ -253,6 +257,7 @@ public class SdDataSourceBLE extends SdDataSource {
|
||||
String charUuidStr = gattCharacteristic.getUuid().toString();
|
||||
if (charUuidStr.equals(CHAR_OSD_ACC_DATA)) {
|
||||
Log.v(TAG, "Subscribing to Acceleration Data Change Notifications");
|
||||
mOsdChar = gattCharacteristic;
|
||||
setCharacteristicNotification(gattCharacteristic,true);
|
||||
}
|
||||
else if (charUuidStr.equals(CHAR_OSD_BATT_DATA)) {
|
||||
@@ -368,15 +373,28 @@ public class SdDataSourceBLE extends SdDataSource {
|
||||
Log.w(TAG, "BluetoothAdapter not initialized");
|
||||
return;
|
||||
}
|
||||
Log.v(TAG,"setCharacteristicNotification - Requesting notifications");
|
||||
mBluetoothGatt.setCharacteristicNotification(characteristic, enabled);
|
||||
if (enabled) {
|
||||
Log.v(TAG, "setCharacteristicNotification - Requesting notifications");
|
||||
mBluetoothGatt.setCharacteristicNotification(characteristic, true);
|
||||
|
||||
// Tell the device we want notifications? The sample from Google said we only need this for Heart Rate, but the
|
||||
// BangleJS widget did not work without it so do it for everything.
|
||||
// Tell the device we want notifications? The sample from Google said we only need this for Heart Rate, but the
|
||||
// BangleJS widget did not work without it so do it for everything.
|
||||
BluetoothGattDescriptor descriptor = characteristic.getDescriptor(
|
||||
UUID.fromString(GattAttributes.CLIENT_CHARACTERISTIC_CONFIG));
|
||||
descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
|
||||
mBluetoothGatt.writeDescriptor(descriptor);
|
||||
} else {
|
||||
Log.v(TAG, "setCharacteristicNotification - De-registering notifications");
|
||||
mBluetoothGatt.setCharacteristicNotification(characteristic, false);
|
||||
|
||||
// Tell the device we want notifications? The sample from Google said we only need this for Heart Rate, but the
|
||||
// BangleJS widget did not work without it so do it for everything.
|
||||
BluetoothGattDescriptor descriptor = characteristic.getDescriptor(
|
||||
UUID.fromString(GattAttributes.CLIENT_CHARACTERISTIC_CONFIG));
|
||||
descriptor.setValue(BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE);
|
||||
mBluetoothGatt.writeDescriptor(descriptor);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -161,8 +161,6 @@ public class SdServer extends Service implements SdDataReceiver {
|
||||
public SdServer() {
|
||||
super();
|
||||
Log.i(TAG, "SdServer Created");
|
||||
mSdData = new SdData();
|
||||
mToneGenerator = new ToneGenerator(AudioManager.STREAM_ALARM, 100);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -186,6 +184,9 @@ public class SdServer extends Service implements SdDataReceiver {
|
||||
public void onCreate() {
|
||||
Log.i(TAG, "onCreate()");
|
||||
mHandler = new Handler();
|
||||
mSdData = new SdData();
|
||||
mToneGenerator = new ToneGenerator(AudioManager.STREAM_ALARM, 100);
|
||||
|
||||
mUtil = new OsdUtil(getApplicationContext(), mHandler);
|
||||
mUtil.writeToSysLogFile("SdServer.onCreate()");
|
||||
|
||||
@@ -824,7 +825,7 @@ public class SdServer extends Service implements SdDataReceiver {
|
||||
}
|
||||
} else {
|
||||
Log.i(TAG, "sendSMSAlarm() - Phone Alarms Disabled - not doing anything!");
|
||||
mUtil.showToast(getString(R.string.phone_alarm_disabled));
|
||||
//mUtil.showToast(getString(R.string.phone_alarm_disabled));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,17 +47,18 @@
|
||||
android:title="@string/test_sms_alarm_notification" />
|
||||
|
||||
<item
|
||||
android:enabled="false"
|
||||
android:id="@+id/action_test_phone_alarm"
|
||||
android:icon="@drawable/stop_server"
|
||||
android:showAsAction="never|withText"
|
||||
android:title="@string/test_phone_alarm_notification" />
|
||||
|
||||
<item
|
||||
android:enabled="false"
|
||||
android:id="@+id/action_logmanager"
|
||||
android:icon="@drawable/ic_action_settings"
|
||||
android:showAsAction="never|withText"
|
||||
android:title="@string/data_log_manager"
|
||||
android:enabled="true"
|
||||
/>
|
||||
|
||||
<item
|
||||
@@ -69,11 +70,11 @@
|
||||
/>
|
||||
|
||||
<item
|
||||
android:enabled="false"
|
||||
android:id="@+id/action_export"
|
||||
android:icon="@drawable/ic_action_settings"
|
||||
android:showAsAction="never|withText"
|
||||
android:title="@string/export_data"
|
||||
android:enabled="true"
|
||||
/>
|
||||
|
||||
<item
|
||||
|
||||
Reference in New Issue
Block a user