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:
Binary file not shown.
Binary file not shown.
@@ -93,6 +93,7 @@ public class SdDataSourceBLE extends SdDataSource {
|
|||||||
public final static UUID UUID_HEART_RATE_MEASUREMENT = UUID.fromString(CHAR_HEART_RATE_MEASUREMENT);
|
public final static UUID UUID_HEART_RATE_MEASUREMENT = UUID.fromString(CHAR_HEART_RATE_MEASUREMENT);
|
||||||
private BluetoothGatt mGatt;
|
private BluetoothGatt mGatt;
|
||||||
private BluetoothGattCharacteristic mBattChar;
|
private BluetoothGattCharacteristic mBattChar;
|
||||||
|
private BluetoothGattCharacteristic mOsdChar;
|
||||||
|
|
||||||
|
|
||||||
public SdDataSourceBLE(Context context, Handler handler,
|
public SdDataSourceBLE(Context context, Handler handler,
|
||||||
@@ -174,6 +175,9 @@ public class SdDataSourceBLE extends SdDataSource {
|
|||||||
Log.w(TAG, "BluetoothAdapter not initialized");
|
Log.w(TAG, "BluetoothAdapter not initialized");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// Un-register for BLE Notifications.
|
||||||
|
setCharacteristicNotification(mOsdChar, false);
|
||||||
|
|
||||||
mBluetoothGatt.disconnect();
|
mBluetoothGatt.disconnect();
|
||||||
if (mBluetoothGatt == null) {
|
if (mBluetoothGatt == null) {
|
||||||
return;
|
return;
|
||||||
@@ -253,6 +257,7 @@ public class SdDataSourceBLE extends SdDataSource {
|
|||||||
String charUuidStr = gattCharacteristic.getUuid().toString();
|
String charUuidStr = gattCharacteristic.getUuid().toString();
|
||||||
if (charUuidStr.equals(CHAR_OSD_ACC_DATA)) {
|
if (charUuidStr.equals(CHAR_OSD_ACC_DATA)) {
|
||||||
Log.v(TAG, "Subscribing to Acceleration Data Change Notifications");
|
Log.v(TAG, "Subscribing to Acceleration Data Change Notifications");
|
||||||
|
mOsdChar = gattCharacteristic;
|
||||||
setCharacteristicNotification(gattCharacteristic,true);
|
setCharacteristicNotification(gattCharacteristic,true);
|
||||||
}
|
}
|
||||||
else if (charUuidStr.equals(CHAR_OSD_BATT_DATA)) {
|
else if (charUuidStr.equals(CHAR_OSD_BATT_DATA)) {
|
||||||
@@ -368,15 +373,28 @@ public class SdDataSourceBLE extends SdDataSource {
|
|||||||
Log.w(TAG, "BluetoothAdapter not initialized");
|
Log.w(TAG, "BluetoothAdapter not initialized");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Log.v(TAG,"setCharacteristicNotification - Requesting notifications");
|
if (enabled) {
|
||||||
mBluetoothGatt.setCharacteristicNotification(characteristic, 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
|
// 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.
|
// BangleJS widget did not work without it so do it for everything.
|
||||||
BluetoothGattDescriptor descriptor = characteristic.getDescriptor(
|
BluetoothGattDescriptor descriptor = characteristic.getDescriptor(
|
||||||
UUID.fromString(GattAttributes.CLIENT_CHARACTERISTIC_CONFIG));
|
UUID.fromString(GattAttributes.CLIENT_CHARACTERISTIC_CONFIG));
|
||||||
descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
|
descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
|
||||||
mBluetoothGatt.writeDescriptor(descriptor);
|
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() {
|
public SdServer() {
|
||||||
super();
|
super();
|
||||||
Log.i(TAG, "SdServer Created");
|
Log.i(TAG, "SdServer Created");
|
||||||
mSdData = new SdData();
|
|
||||||
mToneGenerator = new ToneGenerator(AudioManager.STREAM_ALARM, 100);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -186,6 +184,9 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
Log.i(TAG, "onCreate()");
|
Log.i(TAG, "onCreate()");
|
||||||
mHandler = new Handler();
|
mHandler = new Handler();
|
||||||
|
mSdData = new SdData();
|
||||||
|
mToneGenerator = new ToneGenerator(AudioManager.STREAM_ALARM, 100);
|
||||||
|
|
||||||
mUtil = new OsdUtil(getApplicationContext(), mHandler);
|
mUtil = new OsdUtil(getApplicationContext(), mHandler);
|
||||||
mUtil.writeToSysLogFile("SdServer.onCreate()");
|
mUtil.writeToSysLogFile("SdServer.onCreate()");
|
||||||
|
|
||||||
@@ -824,7 +825,7 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.i(TAG, "sendSMSAlarm() - Phone Alarms Disabled - not doing anything!");
|
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" />
|
android:title="@string/test_sms_alarm_notification" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
|
android:enabled="false"
|
||||||
android:id="@+id/action_test_phone_alarm"
|
android:id="@+id/action_test_phone_alarm"
|
||||||
android:icon="@drawable/stop_server"
|
android:icon="@drawable/stop_server"
|
||||||
android:showAsAction="never|withText"
|
android:showAsAction="never|withText"
|
||||||
android:title="@string/test_phone_alarm_notification" />
|
android:title="@string/test_phone_alarm_notification" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
|
android:enabled="false"
|
||||||
android:id="@+id/action_logmanager"
|
android:id="@+id/action_logmanager"
|
||||||
android:icon="@drawable/ic_action_settings"
|
android:icon="@drawable/ic_action_settings"
|
||||||
android:showAsAction="never|withText"
|
android:showAsAction="never|withText"
|
||||||
android:title="@string/data_log_manager"
|
android:title="@string/data_log_manager"
|
||||||
android:enabled="true"
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
@@ -69,11 +70,11 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
|
android:enabled="false"
|
||||||
android:id="@+id/action_export"
|
android:id="@+id/action_export"
|
||||||
android:icon="@drawable/ic_action_settings"
|
android:icon="@drawable/ic_action_settings"
|
||||||
android:showAsAction="never|withText"
|
android:showAsAction="never|withText"
|
||||||
android:title="@string/export_data"
|
android:title="@string/export_data"
|
||||||
android:enabled="true"
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
|
|||||||
Reference in New Issue
Block a user