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 @@ -41,6 +41,7 @@
import com.teamopensmartglasses.smartglassesmanager.speechrecognition.ASR_FRAMEWORKS;
import com.teamopensmartglasses.smartglassesmanager.speechrecognition.SpeechRecSwitchSystem;
import com.teamopensmartglasses.smartglassesmanager.supportedglasses.AudioWearable;
import com.teamopensmartglasses.smartglassesmanager.supportedglasses.EvenRealitiesG1;
import com.teamopensmartglasses.smartglassesmanager.supportedglasses.InmoAirOne;
import com.teamopensmartglasses.smartglassesmanager.supportedglasses.SmartGlassesDevice;
import com.teamopensmartglasses.smartglassesmanager.supportedglasses.SmartGlassesOperatingSystem;
Expand Down Expand Up @@ -431,11 +432,13 @@ public int onStartCommand(Intent intent, int flags, int startId) {
// Setup for aioConnectSmartGlasses
ArrayList<SmartGlassesDevice> smartGlassesDevices = new ArrayList<>();
Handler aioRetryHandler = new Handler();
Handler connectedCheckerHandler = new Handler(); // Handler for the connected checker

Runnable aioRetryConnectionTask = new Runnable() {
@Override
public void run() {
if (smartGlassesRepresentative == null || smartGlassesRepresentative.getConnectionState() != 2) { // If still disconnected
if(!smartGlassesDevices.isEmpty()){
if (!smartGlassesDevices.isEmpty()) {
Toast.makeText(getApplicationContext(), "Searching for glasses...", Toast.LENGTH_LONG).show();
Log.d(TAG, "TRYING TO CONNECT TO: " + smartGlassesDevices.get(0).deviceModelName);

Expand All @@ -446,19 +449,33 @@ public void run() {

connectToSmartGlasses(smartGlassesDevices.get(0));
smartGlassesDevices.add(smartGlassesDevices.remove(0));
aioRetryHandler.postDelayed(this, 5000); // Schedule another retry if needed
}
else
{
aioRetryHandler.postDelayed(this, 25000); // Schedule another retry if needed
} else {
aioRetryHandler.removeCallbacks(this);
Toast.makeText(getApplicationContext(), "No glasses found", Toast.LENGTH_LONG).show();
}
}
else {
}
};

// Connected checker
Runnable connectedCheckerTask = new Runnable() {
@Override
public void run() {
if (smartGlassesRepresentative != null && smartGlassesRepresentative.getConnectionState() == 2) { // Check if connected
Toast.makeText(getApplicationContext(), "Connected to " + smartGlassesRepresentative.smartGlassesDevice.deviceModelName, Toast.LENGTH_LONG).show();
Log.d(TAG, "Connected to: " + smartGlassesRepresentative.smartGlassesDevice.deviceModelName);

// Stop all retries and connected checker
aioRetryHandler.removeCallbacks(aioRetryConnectionTask);
connectedCheckerHandler.removeCallbacks(this);
} else {
// Schedule the next check
connectedCheckerHandler.postDelayed(this, 1500);
}
}
};

public void aioConnectSmartGlasses(){
if (getChosenAsrFramework(this) == ASR_FRAMEWORKS.GOOGLE_ASR_FRAMEWORK) {
String apiKey = getApiKey(getApplicationContext());
Expand All @@ -469,7 +486,7 @@ public void aioConnectSmartGlasses(){
}

String preferred = getPreferredWearable(this.getApplicationContext());
smartGlassesDevices = new ArrayList<SmartGlassesDevice>(Arrays.asList(new VuzixUltralite(), new VuzixShield(), new InmoAirOne(), new TCLRayNeoXTwo()));
smartGlassesDevices = new ArrayList<SmartGlassesDevice>(Arrays.asList(new VuzixUltralite(), new EvenRealitiesG1(), new VuzixShield(), new InmoAirOne(), new TCLRayNeoXTwo()));
for (int i = 0; i < smartGlassesDevices.size(); i++){
if (smartGlassesDevices.get(i).deviceModelName.equals(preferred)){
// Move to start for earliest search priority
Expand All @@ -484,6 +501,7 @@ public void aioConnectSmartGlasses(){

//start loop
aioRetryConnectionTask.run();
connectedCheckerHandler.post(connectedCheckerTask); // Start connected checker
}

public void showNoGoogleAsrDialog(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.teamopensmartglasses.smartglassesmanager.eventbusmessages.SetFontSizeEvent;
import com.teamopensmartglasses.smartglassesmanager.eventbusmessages.TextWallViewRequestEvent;
import com.teamopensmartglasses.smartglassesmanager.smartglassescommunicators.AudioWearableSGC;
import com.teamopensmartglasses.smartglassesmanager.smartglassescommunicators.EvenRealitiesG1SGC;
import com.teamopensmartglasses.smartglassesmanager.smartglassescommunicators.UltraliteSGC;
import com.teamopensmartglasses.smartglassesmanager.eventbusmessages.BulletPointListViewRequestEvent;
import com.teamopensmartglasses.smartglassesmanager.eventbusmessages.CenteredTextViewRequestEvent;
Expand Down Expand Up @@ -94,6 +95,9 @@ public void connectToSmartGlasses(){
case ULTRALITE_MCU_OS_GLASSES:
smartGlassesCommunicator = new UltraliteSGC(context, lifecycleOwner);
break;
case EVEN_REALITIES_G1_MCU_OS_GLASSES:
smartGlassesCommunicator = new EvenRealitiesG1SGC(context);
break;
}

smartGlassesCommunicator.connectToSmartGlasses();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ private void handleDisconnectBluetoothDevice() {

public MicrophoneLocalAndBluetooth(Context context, boolean useBluetoothSco, AudioChunkCallback chunkCallback) {
this(context, chunkCallback);
this.shouldUseHearItBleMicrophone = true;
useBluetoothMic(useBluetoothSco);
}

Expand Down Expand Up @@ -286,7 +285,11 @@ public void run() {
}
b_buffer.order(ByteOrder.LITTLE_ENDIAN);
b_buffer.asShortBuffer().put(short_buffer);
if (hearItBleMicrophone != null && !hearItBleMicrophone.isConnected()) {
if (shouldUseHearItBleMicrophone) {
if (hearItBleMicrophone != null && !hearItBleMicrophone.isConnected()) {
mChunkCallback.onSuccess(b_buffer);
}
} else {
mChunkCallback.onSuccess(b_buffer);
}
b_buffer.clear();
Expand Down
Loading