Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.androidplot.xy.XYStepMode;
import com.shimmerresearch.android.Shimmer;
import com.shimmerresearch.android.shimmerService.ShimmerService;
import com.shimmerresearch.android.manager.ShimmerBluetoothManagerAndroid;
import com.shimmerresearch.androidinstrumentdriver.R;
import com.shimmerresearch.bluetooth.ShimmerBluetooth;
import com.shimmerresearch.driver.CallbackObject;
Expand Down Expand Up @@ -222,9 +223,11 @@ public void handleMessage(Message msg) {
deviceState="Streaming";
textViewDeviceName.setText(mBluetoothAddress);
textViewDeviceState.setText(deviceState);
List<String> sensorList = shimmerService.getBluetoothManager().getListofEnabledSensors(mBluetoothAddress);
// No BluetoothManager (Bluetooth was off when the service started) means no sensor list
ShimmerBluetoothManagerAndroid btManager = shimmerService.getBluetoothManager();
List<String> sensorList = btManager == null ? null : btManager.getListofEnabledSensors(mBluetoothAddress);
if(sensorList!=null){
if(shimmerService.getBluetoothManager().getShimmerVersion(mBluetoothAddress)== ShimmerVerDetails.HW_ID.SHIMMER_3){
if(btManager.getShimmerVersion(mBluetoothAddress)== ShimmerVerDetails.HW_ID.SHIMMER_3){
sensorList.remove("ECG");
sensorList.remove("EMG");
if(sensorList.contains("EXG1")){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import androidx.annotation.Nullable;

import com.androidplot.xy.XYPlot;
import com.shimmerresearch.android.manager.ShimmerBluetoothManagerAndroid;
import com.shimmerresearch.android.shimmerService.ShimmerService;
import com.shimmerresearch.androidinstrumentdriver.R;
import com.shimmerresearch.driver.ShimmerDevice;
Expand Down Expand Up @@ -90,10 +89,10 @@ public void buildSignalsToPlotList(Context context, final ShimmerService service
this.context = context;
shimmerService = service;
dynamicPlot = plot;
ShimmerBluetoothManagerAndroid btManager = shimmerService.getBluetoothManager();
final ShimmerDevice device = btManager.getShimmer(bluetoothAddress);
// Null when the service has no BluetoothManager (Bluetooth off) or does not know the device
final ShimmerDevice device = shimmerService.getShimmer(bluetoothAddress);

if(device.isStreaming()) {
if(device != null && device.isStreaming()) {

device.getListofEnabledChannelSignalsandFormats();
channelsMap = device.getMapOfEnabledChannelsForStreaming();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.androidplot.xy.XYStepMode;
import com.shimmerresearch.android.Shimmer;
import com.shimmerresearch.android.shimmerService.ShimmerService;
import com.shimmerresearch.android.manager.ShimmerBluetoothManagerAndroid;
import com.shimmerresearch.androidinstrumentdriver.R;
import com.shimmerresearch.bluetooth.ShimmerBluetooth;
import com.shimmerresearch.driver.CallbackObject;
Expand Down Expand Up @@ -264,9 +265,11 @@ public void handleMessage(Message msg) {
deviceState="Streaming";
textViewDeviceName.setText(mBluetoothAddress);
textViewDeviceState.setText(deviceState);
List<String> sensorList = shimmerService.getBluetoothManager().getListofEnabledSensors(mBluetoothAddress);
// No BluetoothManager (Bluetooth was off when the service started) means no sensor list
ShimmerBluetoothManagerAndroid btManager = shimmerService.getBluetoothManager();
List<String> sensorList = btManager == null ? null : btManager.getListofEnabledSensors(mBluetoothAddress);
if(sensorList!=null){
if(shimmerService.getBluetoothManager().getShimmerVersion(mBluetoothAddress)== ShimmerVerDetails.HW_ID.SHIMMER_3){
if(btManager.getShimmerVersion(mBluetoothAddress)== ShimmerVerDetails.HW_ID.SHIMMER_3){
sensorList.remove("ECG");
sensorList.remove("EMG");
if(sensorList.contains("EXG1")){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import android.widget.ListView;

import com.androidplot.xy.XYPlot;
import com.shimmerresearch.android.manager.ShimmerBluetoothManagerAndroid;
import com.shimmerresearch.android.shimmerService.ShimmerService;
import com.shimmerresearch.androidinstrumentdriver.R;
import com.shimmerresearch.driver.ShimmerDevice;
Expand Down Expand Up @@ -84,10 +83,10 @@ public void buildSignalsToPlotList(Context context, final ShimmerService service
this.context = context;
shimmerService = service;
dynamicPlot = plot;
ShimmerBluetoothManagerAndroid btManager = shimmerService.getBluetoothManager();
final ShimmerDevice device = btManager.getShimmer(bluetoothAddress);
// Null when the service has no BluetoothManager (Bluetooth off) or does not know the device
final ShimmerDevice device = shimmerService.getShimmer(bluetoothAddress);

if(device.isStreaming()) {
if(device != null && device.isStreaming()) {

device.getListofEnabledChannelSignalsandFormats();
channelsMap = device.getMapOfEnabledChannelsForStreaming();
Expand Down
Loading
Loading