Skip to content
Merged
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 @@ -206,23 +206,30 @@ public void run(){
thread.start();
}

public void connectShimmerThroughBTAddress(final String bluetoothAddress, BT_TYPE btType) {
public void connectShimmerThroughBTAddress(final String bluetoothAddress, final String deviceName, BT_TYPE btType) {
if(btType.equals(BT_TYPE.BT_CLASSIC)){
connectShimmerThroughBTAddress(bluetoothAddress);
}else{
connectShimmer3BLEThroughBTAddress(bluetoothAddress,"",null);
connectShimmer3BLEThroughBTAddress(bluetoothAddress,deviceName,null);
}
}
@Override
public void connectShimmerThroughBTAddress(final String bluetoothAddress) {

//scanLeDevice(bluetoothAddress);
//doDiscovery();
connectShimmerThroughBTAddress(bluetoothAddress,"",null);
connectShimmerThroughBTAddress(bluetoothAddress,"", (Context) null);
}

public void connectShimmer3BLEThroughBTAddress(final String bluetoothAddress, final String deviceName, Context context){
final Shimmer3BLEAndroid shimmer3BLE = new Shimmer3BLEAndroid(bluetoothAddress, mHandler);
Shimmer3BLEAndroid shimmer3BLE;
if (deviceName.contains(HwDriverShimmerDeviceDetails.DEVICE_TYPE.SHIMMER3R.toString())){
shimmer3BLE = new Shimmer3BLEAndroid(ShimmerVerDetails.HW_ID.SHIMMER_3R,bluetoothAddress, mHandler);

} else {
shimmer3BLE = new Shimmer3BLEAndroid(ShimmerVerDetails.HW_ID.SHIMMER_3, bluetoothAddress, mHandler);

}
shimmer3BLE.setMacIdFromUart(bluetoothAddress);
initializeNewShimmerCommon(shimmer3BLE);
Thread thread = new Thread(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public void connectShimmer(final String bluetoothAddress,final String deviceName
if (isVerisense){
btManager.connectVerisenseDevice(new BluetoothDeviceDetails("",bluetoothAddress,deviceName));
} else {
btManager.connectShimmerThroughBTAddress(bluetoothAddress, preferredBtType); //Connect to the selected device
btManager.connectShimmerThroughBTAddress(bluetoothAddress, deviceName, preferredBtType); //Connect to the selected device
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.shimmerresearch.driver.shimmer2r3.ConfigByteLayoutShimmer3;
import com.shimmerresearch.driverUtilities.ChannelDetails;
import com.shimmerresearch.driverUtilities.SensorDetails;
import com.shimmerresearch.driverUtilities.ShimmerVerDetails;
import com.shimmerresearch.driverUtilities.UtilShimmer;
import com.shimmerresearch.exceptions.ShimmerException;
import com.shimmerresearch.sensors.kionix.SensorKionixAccel;
Expand All @@ -52,12 +53,18 @@

public class Shimmer3BLEAndroid extends ShimmerBluetooth implements Serializable {
transient BleDevice mBleDevice;
String TxID = "49535343-8841-43f4-a8d4-ecbe34729bb3";
String RxID = "49535343-1e4d-4bd9-ba61-23c647249616";
String ServiceID = "49535343-fe7d-4ae5-8fa9-9fafd205e455";
UUID sid = UUID.fromString(ServiceID);
UUID txid = UUID.fromString(TxID);
UUID rxid = UUID.fromString(RxID);
final String TxID_Shimmer3 = "49535343-8841-43f4-a8d4-ecbe34729bb3";
final String RxID_Shimmer3 = "49535343-1e4d-4bd9-ba61-23c647249616";
final String ServiceID_Shimmer3 = "49535343-fe7d-4ae5-8fa9-9fafd205e455";
final String TxID_Shimmer3R = "65333333-A115-11E2-9E9A-0800200CA101";
final String RxID_Shimmer3R = "65333333-A115-11E2-9E9A-0800200CA102";
final String ServiceID_Shimmer3R = "65333333-A115-11E2-9E9A-0800200CA100";
String TxID = "";
String RxID = "";
String ServiceID = "";
UUID sid = null;
UUID txid = null;
UUID rxid = null;
String mMac;
String uuid;
transient ThreadSafeByteFifoBuffer mBuffer;
Expand All @@ -78,7 +85,22 @@ public Shimmer3BLEAndroid(String mac) {
mHandler = null;
}

public Shimmer3BLEAndroid(String mac, Handler handler){
/** Only support Shimmer3 and Shimmer3R
*
* @param hardwareID e.g. ShimmerVerDetails.HW_ID.SHIMMER_3R or ShimmerVerDetails.HW_ID.SHIMMER_3
* @param mac
* @param handler
*/
public Shimmer3BLEAndroid(int hardwareID, String mac, Handler handler){
if (hardwareID== ShimmerVerDetails.HW_ID.SHIMMER_3R){
sid = UUID.fromString(ServiceID_Shimmer3R);
txid = UUID.fromString(TxID_Shimmer3R);
rxid = UUID.fromString(RxID_Shimmer3R);
} else if (hardwareID== ShimmerVerDetails.HW_ID.SHIMMER_3) {
sid = UUID.fromString(ServiceID_Shimmer3);
txid = UUID.fromString(TxID_Shimmer3);
rxid = UUID.fromString(RxID_Shimmer3);
}
mMac = mac;
mHandler = handler;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import java.util.Collection;

import static com.shimmerresearch.android.guiUtilities.ShimmerBluetoothDialog.EXTRA_DEVICE_ADDRESS;
import static com.shimmerresearch.android.guiUtilities.ShimmerBluetoothDialog.EXTRA_DEVICE_NAME;

/**
* This example demonstrates the use of the {@link ShimmerBluetoothManagerAndroid} to:
Expand Down Expand Up @@ -370,7 +371,8 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
showBtTypeConnectionOption();
//Get the Bluetooth mac address of the selected device:
String macAdd = data.getStringExtra(EXTRA_DEVICE_ADDRESS);
btManager.connectShimmerThroughBTAddress(macAdd, preferredBtType); //Connect to the selected device
String deviceName = data.getStringExtra(EXTRA_DEVICE_NAME);
btManager.connectShimmerThroughBTAddress(macAdd, deviceName, preferredBtType); //Connect to the selected device
shimmerBtAdd = macAdd;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package shimmerresearch.com.shimmer3blebasicexample;

import static com.shimmerresearch.android.guiUtilities.ShimmerBluetoothDialog.EXTRA_DEVICE_ADDRESS;
import static com.shimmerresearch.android.guiUtilities.ShimmerBluetoothDialog.EXTRA_DEVICE_NAME;

import android.Manifest;
import android.app.Activity;
Expand Down Expand Up @@ -29,6 +30,8 @@
import com.shimmerresearch.driver.ObjectCluster;
import com.shimmerresearch.driver.ShimmerMsg;
import com.shimmerresearch.driverUtilities.ChannelDetails;
import com.shimmerresearch.driverUtilities.HwDriverShimmerDeviceDetails;
import com.shimmerresearch.driverUtilities.ShimmerVerDetails;
import com.shimmerresearch.exceptions.ShimmerException;
import com.shimmerresearch.sensors.kionix.SensorKionixAccel;

Expand Down Expand Up @@ -239,7 +242,13 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK) {
//Get the Bluetooth mac address of the selected device:
String macAdd = data.getStringExtra(EXTRA_DEVICE_ADDRESS);
shimmer1 = new Shimmer3BLEAndroid(macAdd, this.mHandler);
String name = data.getStringExtra(EXTRA_DEVICE_NAME);
if (name!=null && name.contains(HwDriverShimmerDeviceDetails.DEVICE_TYPE.SHIMMER3R.toString())){
shimmer1 = new Shimmer3BLEAndroid(ShimmerVerDetails.HW_ID.SHIMMER_3R, macAdd, this.mHandler);
} else {
shimmer1 = new Shimmer3BLEAndroid(ShimmerVerDetails.HW_ID.SHIMMER_3, macAdd, this.mHandler);
}

SensorDataReceived sdr = this.new SensorDataReceived();
sdr.setWaitForData(shimmer1);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public class MainActivity extends AppCompatActivity implements ConnectedShimmers
final static String LOG_TAG = "Shimmer";
final static String SERVICE_TAG = "ShimmerService";
final static int REQUEST_CONNECT_SHIMMER = 2;
public static APP_RELEASE_TYPE appReleaseType = APP_RELEASE_TYPE.PUBLIC;
public static APP_RELEASE_TYPE appReleaseType = APP_RELEASE_TYPE.INTERNAL;
public enum APP_RELEASE_TYPE{
INTERNAL,
PUBLIC,
Expand Down