Skip to content

Commit 9b2210c

Browse files
authored
Merge pull request #199 from AugmentOS-Community/dev
AugmentOS v1.2.0
2 parents 8576285 + 3bffb53 commit 9b2210c

File tree

21 files changed

+319
-105
lines changed

21 files changed

+319
-105
lines changed

SmartGlassesManager/SGM_android/SmartGlassesManager/src/main/AndroidManifest.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
<uses-permission android:name="android.permission.RECORD_AUDIO" />
2929
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
3030

31+
<!-- CALENDAR-->
32+
<uses-permission android:name="android.permission.READ_CALENDAR"/>
33+
<uses-permission android:name="android.permission.WRITE_CALENDAR"/>
34+
3135
<queries>
3236
<intent>
3337
<action android:name="android.intent.action.TTS_SERVICE" />

SmartGlassesManager/SGM_android/SmartGlassesManager/src/main/java/com/augmentos/smartglassesmanager/smartglassescommunicators/EvenRealitiesG1SGC.java

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -231,63 +231,70 @@ public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState
231231
} else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
232232
Log.d(TAG, side + " glass disconnected, stopping heartbeats");
233233

234-
//set services as not ready
234+
// Mark both sides as not ready (you could also clear both if one disconnects)
235235
leftServicesWaiter.setTrue();
236236
rightServicesWaiter.setTrue();
237237

238+
// Force disconnection from the other side if necessary
238239
if ("Left".equals(side)) {
239240
isLeftConnected = false;
240241
leftReconnectAttempts++;
241242
leftGlassGatt = null;
242-
} else {
243+
// If right is still connected, disconnect it too
244+
if (rightGlassGatt != null) {
245+
Log.d(TAG, "Left glass disconnected - forcing disconnection from right glass.");
246+
rightGlassGatt.disconnect();
247+
rightGlassGatt.close();
248+
rightGlassGatt = null;
249+
isRightConnected = false;
250+
rightReconnectAttempts++;
251+
}
252+
} else { // side equals "Right"
243253
isRightConnected = false;
244254
rightReconnectAttempts++;
245255
rightGlassGatt = null;
256+
// If left is still connected, disconnect it too
257+
if (leftGlassGatt != null) {
258+
Log.d(TAG, "Right glass disconnected - forcing disconnection from left glass.");
259+
leftGlassGatt.disconnect();
260+
leftGlassGatt.close();
261+
leftGlassGatt = null;
262+
isLeftConnected = false;
263+
leftReconnectAttempts++;
264+
}
246265
}
247266

267+
// Stop any periodic transmissions
248268
stopHeartbeat();
249269
stopMicBeat();
250270
sendQueue.clear();
251271
updateConnectionState();
252272

253-
long delay;
254-
if ("Left".equals(side)) {
255-
delay = Math.min(BASE_RECONNECT_DELAY_MS * (1L << leftReconnectAttempts), MAX_RECONNECT_DELAY_MS);
256-
Log.d(TAG, side + " glass disconnected. Attempting to reconnect " + side + " in " + delay + " ms (Attempt " + leftReconnectAttempts + ")");
257-
} else {
258-
delay = Math.min(BASE_RECONNECT_DELAY_MS * (1L << rightReconnectAttempts), MAX_RECONNECT_DELAY_MS);
259-
Log.d(TAG, side + " glass disconnected. Attempting to reconnect " + side + " in " + delay + " ms (Attempt " + rightReconnectAttempts + ")");
260-
}
261-
// reconnectHandler.postDelayed(() -> {
262-
// if (gatt.getDevice() != null) {
263-
// gatt.close();
264-
// Log.d(TAG, "Reconnecting to gatt. Are we scanning?: " + isScanning);
265-
// reconnectToGatt(gatt.getDevice());
266-
// }
267-
// }, delay);
268-
269-
// Do this ~carefully~ to compensate for old BLE stacks
270-
// reconnectHandler.postDelayed(() -> {
271-
//Log.d(TAG, "Manually disconnecting gatt. Are we scanning?: " + isScanning);
272-
// gatt.disconnect();
273-
// }, 0);
273+
// Compute reconnection delay for both sides (here you could choose the maximum of the two delays or a new delay)
274+
long delayLeft = Math.min(BASE_RECONNECT_DELAY_MS * (1L << leftReconnectAttempts), MAX_RECONNECT_DELAY_MS);
275+
long delayRight = Math.min(BASE_RECONNECT_DELAY_MS * (1L << rightReconnectAttempts), MAX_RECONNECT_DELAY_MS);
276+
long delay = Math.max(delayLeft, delayRight); // or choose another strategy
277+
278+
Log.d(TAG, side + " glass disconnected. Scheduling reconnection for both glasses in " + delay + " ms (Left attempts: " + leftReconnectAttempts + ", Right attempts: " + rightReconnectAttempts + ")");
274279

275280
if (gatt.getDevice() != null) {
276-
Log.d(TAG, "Closing gatt. Are we scanning?: " + isScanning);
277-
//gatt.disconnect();
281+
// Close the current gatt connection
278282
gatt.close();
279283
}
280284

285+
// Schedule a reconnection for both devices after the delay
281286
reconnectHandler.postDelayed(() -> {
282-
if (gatt.getDevice() != null) {
283-
if (isKilled){
284-
return;
287+
if (gatt.getDevice() != null && !isKilled) {
288+
Log.d(TAG, "Reconnecting to both glasses.");
289+
// Assuming you have stored references to both devices:
290+
if (leftDevice != null) {
291+
reconnectToGatt(leftDevice);
292+
}
293+
if (rightDevice != null) {
294+
reconnectToGatt(rightDevice);
285295
}
286-
Log.d(TAG, "Reconnecting to gatt. Are we scanning?: " + isScanning);
287-
reconnectToGatt(gatt.getDevice());
288296
}
289-
}, delay); // 2 seconds after close
290-
297+
}, delay);
291298
}
292299
} else {
293300
stopHeartbeat();
@@ -1746,7 +1753,7 @@ public void run() {
17461753
// Constants for text wall display
17471754
private static final int TEXT_COMMAND = 0x4E; // Text command
17481755
private static final int DISPLAY_WIDTH = 640; // Display width in pixels
1749-
private static final int DISPLAY_USE_WIDTH = 340; // How much of the display to use
1756+
private static final int DISPLAY_USE_WIDTH = 380; // How much of the display to use
17501757
private static final int FONT_SIZE = 21; // Font size
17511758
private static final float FONT_DIVIDER = 2.0f;
17521759
private static final int LINES_PER_SCREEN = 5; // Lines per screen

SmartGlassesManager/SGM_android/SmartGlassesManager/src/main/java/com/augmentos/smartglassesmanager/speechrecognition/augmentos/AudioInputStream.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.augmentos.smartglassesmanager.speechrecognition.augmentos;
22

3+
import android.util.Log;
4+
35
import com.microsoft.cognitiveservices.speech.audio.AudioStreamFormat;
46
import com.microsoft.cognitiveservices.speech.audio.PullAudioInputStreamCallback;
57

SmartGlassesManager/SGM_android/SmartGlassesManager/src/main/java/com/augmentos/smartglassesmanager/speechrecognition/augmentos/SpeechRecAugmentos.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public void onInterimTranscript(String text, String language, long timestamp) {
114114

115115
@Override
116116
public void onFinalTranscript(String text, String language, long timestamp) {
117-
// Log.d(TAG, "Got final transcription: " + text + " (language: " + language + ")");
117+
Log.d(TAG, "Got final transcription: " + text + " (language: " + language + ")");
118118
if (text != null && !text.trim().isEmpty()) {
119119
EventBus.getDefault().post(new SpeechRecOutputEvent(text, language, timestamp, true));
120120
}

augmentos_android_library/AugmentOSLib/src/main/java/com/augmentos/augmentoslib/SmartGlassesAndroidService.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ public int onStartCommand(Intent intent, int flags, int startId) {
9292
// start the service in the foreground
9393
Log.d("TEST", "starting foreground");
9494
startForeground(NOTIFICATION_ID, updateNotification());
95+
setup();
9596
break;
9697
case ACTION_STOP_FOREGROUND_SERVICE:
9798
stopForeground(true);
@@ -146,4 +147,6 @@ public void onDestroy(){
146147
super.onDestroy();
147148
Log.d(TAG, "ran onDestroy");
148149
}
150+
151+
public abstract void setup();
149152
}

augmentos_android_library/AugmentOSLib/src/main/java/com/augmentos/augmentoslib/SpeechRecUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ public static String languageToLocale(String localeString) {
153153
return "eu-ES";
154154
case "Persian (Iran)":
155155
return "fa-IR";
156+
case "Finnish":
156157
case "Finnish (Finland)":
157158
return "fi-FI";
158159
case "Filipino (Philippines)":
@@ -311,5 +312,4 @@ public static String languageToLocale(String localeString) {
311312
return "en-US";
312313
}
313314
}
314-
315315
}

augmentos_android_library/AugmentOSLib/src/main/java/com/augmentos/augmentoslib/TPABroadcastSender.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ public void onSendDataFromManagerToCore(ManagerToCoreRequestEvent e){
140140
sendEventToAugmentOS(e.eventId, e);
141141
}
142142

143-
144143
@Subscribe
145144
public void onSendHomeScreen(HomeScreenEvent e){
146145
sendEventToAugmentOS(e.eventId, e);

0 commit comments

Comments
 (0)