Skip to content

Commit c6755c7

Browse files
authored
Merge pull request #182 from TeamOpenSmartGlasses/dev
Dev
2 parents cb87c1c + 0bd35fc commit c6755c7

File tree

290 files changed

+5560
-6924
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

290 files changed

+5560
-6924
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
server/config.json
2+
13
### REACT
24
.idea/
35
.vscode/

SmartGlassesManager/SGM_android/SmartGlassesManager/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ ext {
1313
}
1414

1515
android {
16-
namespace "com.teamopensmartglasses.smartglassesmanager"
16+
namespace "com.augmentos.smartglassesmanager"
1717
compileSdk 33
1818

1919
// aaptOptions {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.teamopensmartglasses.smartglassesmanager;
1+
package com.augmentos.smartglassesmanager;
22

33
import android.content.Context;
44

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:tools="http://schemas.android.com/tools"
4-
package="com.teamopensmartglasses.smartglassesmanager">
4+
package="com.augmentos.smartglassesmanager">
55

66
<uses-sdk android:minSdkVersion="28"
77
android:targetSdkVersion="34"

SmartGlassesManager/SGM_android/SmartGlassesManager/src/main/cpp/google_opus_stuff/jni/ogg_opus_encoder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
// https://stackoverflow.com/questions/25363027/jni-getmethodid-not-working-for-constructor-of-inner-class
2323
#define JNI_METHOD(fn) \
24-
Java_com_teamopensmartglasses_smartglassesmanager_speechrecognition_google_asr_asrhelpers_StreamingAudioEncoder_00024OggOpusEncoder_##fn // NOLINT
24+
Java_com_augmentos_smartglassesmanager_speechrecognition_google_asr_asrhelpers_StreamingAudioEncoder_00024OggOpusEncoder_##fn // NOLINT
2525

2626
extern "C" {
2727
// Create opus encoder instance. The pointer is returned in a

SmartGlassesManager/SGM_android/SmartGlassesManager/src/main/cpp/liblc3/liblc3.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313

1414
extern "C" JNIEXPORT jbyteArray JNICALL
15-
Java_com_teamopensmartglasses_smartglassesmanager_cpp_L3cCpp_decodeLC3(JNIEnv *env, jclass instance, jbyteArray lc3Data) {
15+
Java_com_augmentos_smartglassesmanager_cpp_L3cCpp_decodeLC3(JNIEnv *env, jclass instance, jbyteArray lc3Data) {
1616
// __android_log_print(ANDROID_LOG_INFO, "cpp", "JNI decodeLC3 called!");
1717
jbyte *lc3Bytes = env->GetByteArrayElements(lc3Data, nullptr);
1818
int lc3Length = env->GetArrayLength(lc3Data);
Lines changed: 90 additions & 85 deletions
Large diffs are not rendered by default.
Lines changed: 82 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.teamopensmartglasses.smartglassesmanager;
1+
package com.augmentos.smartglassesmanager;
22

33
import android.content.Context;
44

@@ -12,38 +12,38 @@
1212
//custom, our code
1313
import androidx.lifecycle.LifecycleOwner;
1414

15-
import com.teamopensmartglasses.augmentoslib.events.AudioChunkNewEvent;
16-
import com.teamopensmartglasses.smartglassesmanager.eventbusmessages.DisableBleScoAudioEvent;
17-
import com.teamopensmartglasses.augmentoslib.events.DisplayCustomContentRequestEvent;
18-
import com.teamopensmartglasses.augmentoslib.events.DoubleTextWallViewRequestEvent;
19-
import com.teamopensmartglasses.augmentoslib.events.HomeScreenEvent;
20-
import com.teamopensmartglasses.augmentoslib.events.SendBitmapViewRequestEvent;
21-
import com.teamopensmartglasses.smartglassesmanager.eventbusmessages.SetFontSizeEvent;
22-
import com.teamopensmartglasses.augmentoslib.events.TextWallViewRequestEvent;
23-
import com.teamopensmartglasses.smartglassesmanager.smartglassescommunicators.AudioWearableSGC;
24-
import com.teamopensmartglasses.smartglassesmanager.smartglassescommunicators.EvenRealitiesG1SGC;
25-
import com.teamopensmartglasses.smartglassesmanager.smartglassescommunicators.UltraliteSGC;
26-
import com.teamopensmartglasses.augmentoslib.events.BulletPointListViewRequestEvent;
27-
import com.teamopensmartglasses.augmentoslib.events.CenteredTextViewRequestEvent;
28-
import com.teamopensmartglasses.augmentoslib.events.FinalScrollingTextRequestEvent;
29-
import com.teamopensmartglasses.augmentoslib.events.IntermediateScrollingTextRequestEvent;
30-
import com.teamopensmartglasses.augmentoslib.events.ReferenceCardImageViewRequestEvent;
31-
import com.teamopensmartglasses.augmentoslib.events.ReferenceCardSimpleViewRequestEvent;
32-
import com.teamopensmartglasses.augmentoslib.events.RowsCardViewRequestEvent;
33-
import com.teamopensmartglasses.augmentoslib.events.PromptViewRequestEvent;
34-
import com.teamopensmartglasses.augmentoslib.events.ScrollingTextViewStartRequestEvent;
35-
import com.teamopensmartglasses.augmentoslib.events.ScrollingTextViewStopRequestEvent;
36-
import com.teamopensmartglasses.smartglassesmanager.hci.AudioChunkCallback;
37-
import com.teamopensmartglasses.smartglassesmanager.hci.MicrophoneLocalAndBluetooth;
38-
//import com.teamopensmartglasses.smartglassesmanager.smartglassescommunicators.ActiveLookSGC;
39-
import com.teamopensmartglasses.smartglassesmanager.smartglassescommunicators.AndroidSGC;
40-
import com.teamopensmartglasses.smartglassesmanager.smartglassescommunicators.SmartGlassesCommunicator;
41-
import com.teamopensmartglasses.smartglassesmanager.supportedglasses.SmartGlassesDevice;
42-
import com.teamopensmartglasses.augmentoslib.events.TextLineViewRequestEvent;
15+
import com.augmentos.augmentoslib.events.AudioChunkNewEvent;
16+
import com.augmentos.smartglassesmanager.eventbusmessages.DisableBleScoAudioEvent;
17+
import com.augmentos.augmentoslib.events.DisplayCustomContentRequestEvent;
18+
import com.augmentos.augmentoslib.events.DoubleTextWallViewRequestEvent;
19+
import com.augmentos.augmentoslib.events.HomeScreenEvent;
20+
import com.augmentos.augmentoslib.events.SendBitmapViewRequestEvent;
21+
import com.augmentos.smartglassesmanager.eventbusmessages.SetFontSizeEvent;
22+
import com.augmentos.augmentoslib.events.TextWallViewRequestEvent;
23+
import com.augmentos.smartglassesmanager.smartglassescommunicators.AudioWearableSGC;
24+
import com.augmentos.smartglassesmanager.smartglassescommunicators.EvenRealitiesG1SGC;
25+
import com.augmentos.smartglassesmanager.smartglassescommunicators.UltraliteSGC;
26+
import com.augmentos.augmentoslib.events.BulletPointListViewRequestEvent;
27+
import com.augmentos.augmentoslib.events.CenteredTextViewRequestEvent;
28+
import com.augmentos.augmentoslib.events.FinalScrollingTextRequestEvent;
29+
import com.augmentos.augmentoslib.events.IntermediateScrollingTextRequestEvent;
30+
import com.augmentos.augmentoslib.events.ReferenceCardImageViewRequestEvent;
31+
import com.augmentos.augmentoslib.events.ReferenceCardSimpleViewRequestEvent;
32+
import com.augmentos.augmentoslib.events.RowsCardViewRequestEvent;
33+
import com.augmentos.augmentoslib.events.PromptViewRequestEvent;
34+
import com.augmentos.augmentoslib.events.ScrollingTextViewStartRequestEvent;
35+
import com.augmentos.augmentoslib.events.ScrollingTextViewStopRequestEvent;
36+
import com.augmentos.smartglassesmanager.hci.AudioChunkCallback;
37+
import com.augmentos.smartglassesmanager.hci.MicrophoneLocalAndBluetooth;
38+
//import com.augmentos.smartglassesmanager.smartglassescommunicators.ActiveLookSGC;
39+
import com.augmentos.smartglassesmanager.smartglassescommunicators.AndroidSGC;
40+
import com.augmentos.smartglassesmanager.smartglassescommunicators.SmartGlassesCommunicator;
41+
import com.augmentos.smartglassesmanager.supportedglasses.SmartGlassesDevice;
42+
import com.augmentos.augmentoslib.events.TextLineViewRequestEvent;
43+
import com.augmentos.smartglassesmanager.utils.SmartGlassesConnectionState;
4344

4445
//rxjava
4546
import java.nio.ByteBuffer;
46-
import java.util.List;
4747

4848
import io.reactivex.rxjava3.subjects.PublishSubject;
4949

@@ -84,51 +84,67 @@ class SmartGlassesRepresentative {
8484
}
8585

8686
public void findCompatibleDeviceNames(){
87-
SmartGlassesCommunicator temporarySmartGlassesCommunicator = null;
88-
switch (smartGlassesDevice.getGlassesOs()){
89-
case ANDROID_OS_GLASSES:
90-
temporarySmartGlassesCommunicator = new AndroidSGC(context, smartGlassesDevice, dataObservable);
91-
break;
92-
case AUDIO_WEARABLE_GLASSES:
93-
temporarySmartGlassesCommunicator = new AudioWearableSGC(context, smartGlassesDevice);
94-
break;
95-
case ULTRALITE_MCU_OS_GLASSES:
96-
temporarySmartGlassesCommunicator = new UltraliteSGC(context, smartGlassesDevice, lifecycleOwner);
97-
break;
98-
case EVEN_REALITIES_G1_MCU_OS_GLASSES:
99-
temporarySmartGlassesCommunicator = new EvenRealitiesG1SGC(context, smartGlassesDevice);
100-
break;
87+
// If we have not created a communicator yet (or the device changed), create it once
88+
//if (smartGlassesCommunicator == null || !isSameDevice(smartGlassesDevice, smartGlassesCommunicator)) {
89+
if (smartGlassesCommunicator == null) {
90+
smartGlassesCommunicator = createCommunicator();
10191
}
10292

103-
temporarySmartGlassesCommunicator.findCompatibleDeviceNames();
93+
if (smartGlassesCommunicator != null) {
94+
smartGlassesCommunicator.findCompatibleDeviceNames();
95+
} else {
96+
Log.d(TAG, "SmartGlassesCommunicator is NULL, something truly awful must have transpired");
97+
}
10498
}
10599

106100
public void connectToSmartGlasses(){
107-
switch (smartGlassesDevice.getGlassesOs()){
108-
case ANDROID_OS_GLASSES:
109-
smartGlassesCommunicator = new AndroidSGC(context, smartGlassesDevice, dataObservable);
110-
break;
111-
case AUDIO_WEARABLE_GLASSES:
112-
smartGlassesCommunicator = new AudioWearableSGC(context, smartGlassesDevice);
113-
break;
114-
case ULTRALITE_MCU_OS_GLASSES:
115-
smartGlassesCommunicator = new UltraliteSGC(context, smartGlassesDevice, lifecycleOwner);
116-
break;
117-
case EVEN_REALITIES_G1_MCU_OS_GLASSES:
118-
smartGlassesCommunicator = new EvenRealitiesG1SGC(context, smartGlassesDevice);
119-
break;
101+
// Same approach: if the communicator is null, create it
102+
//if (smartGlassesCommunicator == null || !isSameDevice(smartGlassesDevice, smartGlassesCommunicator)) {
103+
if (smartGlassesCommunicator == null) {
104+
smartGlassesCommunicator = createCommunicator();
120105
}
121106

122-
smartGlassesCommunicator.connectToSmartGlasses();
107+
if (smartGlassesCommunicator != null) {
108+
smartGlassesCommunicator.connectToSmartGlasses();
109+
} else {
110+
Log.d(TAG, "SmartGlassesCommunicator is NULL, something truly awful must have transpired");
111+
}
123112

124-
//if the glasses don't support a microphone, this Representative handles local microphone
113+
// If the glasses don't support a microphone, handle local microphone
125114
if (smartGlassesDevice.useScoMic) {
126115
connectAndStreamLocalMicrophone(true);
127116
} else if (!smartGlassesDevice.getHasInMic() && !smartGlassesDevice.getHasOutMic()) {
128117
connectAndStreamLocalMicrophone(false);
129118
}
130119
}
131120

121+
/**
122+
* Helper to create the appropriate communicator once.
123+
*/
124+
private SmartGlassesCommunicator createCommunicator() {
125+
switch (smartGlassesDevice.getGlassesOs()) {
126+
case ANDROID_OS_GLASSES:
127+
return new AndroidSGC(context, smartGlassesDevice, dataObservable);
128+
case AUDIO_WEARABLE_GLASSES:
129+
return new AudioWearableSGC(context, smartGlassesDevice);
130+
case ULTRALITE_MCU_OS_GLASSES:
131+
return new UltraliteSGC(context, smartGlassesDevice, lifecycleOwner);
132+
case EVEN_REALITIES_G1_MCU_OS_GLASSES:
133+
return new EvenRealitiesG1SGC(context, smartGlassesDevice);
134+
default:
135+
return null; // or throw an exception
136+
}
137+
}
138+
139+
/**
140+
* Optional helper to check if the communicator is for the same device.
141+
* Some communicator classes might have a method or field to check device identity.
142+
*/
143+
//private boolean isSameDevice(SmartGlassesDevice device, SmartGlassesCommunicator comm) {
144+
// return comm != null && comm. != null
145+
// && comm.getDevice().equals(device);
146+
//}
147+
132148
public void updateGlassesBrightness(int brightness) {
133149
if (smartGlassesCommunicator != null) {
134150
smartGlassesCommunicator.updateGlassesBrightness(brightness);
@@ -187,13 +203,17 @@ public void destroy(){
187203
smartGlassesCommunicator = null;
188204
}
189205

206+
if (uiHandler != null) {
207+
uiHandler.removeCallbacksAndMessages(null);
208+
}
209+
190210
Log.d(TAG, "SG rep destroy complete");
191211
}
192212

193213
//are our smart glasses currently connected?
194-
public int getConnectionState(){
214+
public SmartGlassesConnectionState getConnectionState(){
195215
if (smartGlassesCommunicator == null){
196-
return 0;
216+
return SmartGlassesConnectionState.DISCONNECTED;
197217
} else {
198218
return smartGlassesCommunicator.getConnectionState();
199219
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.teamopensmartglasses.smartglassesmanager.comms;
1+
package com.augmentos.smartglassesmanager.comms;
22

33
import java.net.InetSocketAddress;
44

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.teamopensmartglasses.smartglassesmanager.comms;
1+
package com.augmentos.smartglassesmanager.comms;
22

33
import android.media.AudioFormat;
44

@@ -29,12 +29,12 @@
2929
import java.net.ServerSocket;
3030
import java.net.Socket;
3131

32-
import com.teamopensmartglasses.augmentoslib.events.AudioChunkNewEvent;
33-
import com.teamopensmartglasses.smartglassesmanager.utils.AES;
32+
import com.augmentos.augmentoslib.events.AudioChunkNewEvent;
33+
import com.augmentos.smartglassesmanager.utils.AES;
3434

3535
import android.util.Log;
3636

37-
import com.teamopensmartglasses.smartglassesmanager.R;
37+
import com.augmentos.smartglassesmanager.R;
3838

3939
public class AudioSystem {
4040
private static String TAG = "WearableAi_AudioSystem";

0 commit comments

Comments
 (0)