Skip to content

Commit 6731799

Browse files
committed
audio listener retry
1 parent 4cfaf85 commit 6731799

6 files changed

Lines changed: 256 additions & 80 deletions

File tree

app/app.json

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,27 @@
3030
"android.permission.BLUETOOTH_ADMIN",
3131
"android.permission.BLUETOOTH_CONNECT",
3232
"android.permission.ACCESS_NETWORK_STATE"
33-
]
33+
],
34+
"usesCleartextTraffic": true,
35+
"networkSecurityConfig": {
36+
"domainConfig": {
37+
"cleartextTrafficPermitted": true,
38+
"domain": [
39+
{
40+
"includeSubdomains": true,
41+
"name": "localhost"
42+
},
43+
{
44+
"includeSubdomains": true,
45+
"name": "192.168.0.0/16"
46+
},
47+
{
48+
"includeSubdomains": true,
49+
"name": "100.64.0.0/10"
50+
}
51+
]
52+
}
53+
}
3454
},
3555
"newArchEnabled": true,
3656
"plugins": [
@@ -44,6 +64,11 @@
4464
"bluetoothAlwaysPermission": "This app uses Bluetooth to connect to and interact with nearby BLE devices."
4565
}
4666
]
47-
]
67+
],
68+
"extra": {
69+
"eas": {
70+
"projectId": "05d8598e-6fe7-4373-81e4-1654f3d8e181"
71+
}
72+
}
4873
}
4974
}

app/app/components/AuthSection.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ const styles = StyleSheet.create({
213213
fontSize: 14,
214214
width: '100%',
215215
marginBottom: 10,
216+
color: '#333',
216217
},
217218
button: {
218219
backgroundColor: '#007AFF',

app/app/components/BackendStatus.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ export const BackendStatus: React.FC<BackendStatusProps> = ({
169169
style={styles.textInput}
170170
value={backendUrl}
171171
onChangeText={onBackendUrlChange}
172-
placeholder="ws://localhost:8000/ws"
172+
placeholder="ws://localhost:8000/ws (simple) or ws://localhost:8080/v1/listen (advanced)"
173173
autoCapitalize="none"
174174
keyboardType="url"
175175
returnKeyType="done"
@@ -208,8 +208,8 @@ export const BackendStatus: React.FC<BackendStatusProps> = ({
208208
</TouchableOpacity>
209209

210210
<Text style={styles.helpText}>
211-
Enter the HTTP URL of your backend server (e.g., http://localhost:8000 or http://100.99.62.5:8000).
212-
The connection status will be automatically checked.
211+
Enter the WebSocket URL of your backend server. Simple backend: ws://localhost:8000/ws (no auth).
212+
Advanced backend: ws://localhost:8080/v1/listen (requires login). Status is automatically checked.
213213
</Text>
214214
</View>
215215
);
@@ -248,6 +248,7 @@ const styles = StyleSheet.create({
248248
fontSize: 14,
249249
width: '100%',
250250
marginBottom: 15,
251+
color: '#333',
251252
},
252253
statusContainer: {
253254
marginBottom: 15,

app/app/components/DeviceDetails.tsx

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ interface DeviceDetailsProps {
2828
// User ID Management
2929
userId: string;
3030
onSetUserId: (userId: string) => void;
31+
32+
// Audio Listener Retry State
33+
isAudioListenerRetrying?: boolean;
34+
audioListenerRetryAttempts?: number;
3135
}
3236

3337
export const DeviceDetails: React.FC<DeviceDetailsProps> = ({
@@ -46,7 +50,9 @@ export const DeviceDetails: React.FC<DeviceDetailsProps> = ({
4650
isConnectingAudioStreamer,
4751
audioStreamerError,
4852
userId,
49-
onSetUserId
53+
onSetUserId,
54+
isAudioListenerRetrying,
55+
audioListenerRetryAttempts
5056
}) => {
5157
if (!connectedDeviceId) return null;
5258

@@ -107,13 +113,27 @@ export const DeviceDetails: React.FC<DeviceDetailsProps> = ({
107113
{/* Audio Controls */}
108114
<View style={styles.subSection}>
109115
<TouchableOpacity
110-
style={[styles.button, isListeningAudio ? styles.buttonWarning : null, { marginTop: 15 } ]}
111-
onPress={isListeningAudio ? onStopAudioListener : onStartAudioListener}
116+
style={[
117+
styles.button,
118+
isListeningAudio || isAudioListenerRetrying ? styles.buttonWarning : null,
119+
{ marginTop: 15 }
120+
]}
121+
onPress={isListeningAudio || isAudioListenerRetrying ? onStopAudioListener : onStartAudioListener}
112122
>
113123
<Text style={styles.buttonText}>
114-
{isListeningAudio ? "Stop Audio Listener" : "Start Audio Listener"}
124+
{isListeningAudio ? "Stop Audio Listener" :
125+
isAudioListenerRetrying ? "Stop Retry" : "Start Audio Listener"}
115126
</Text>
116127
</TouchableOpacity>
128+
129+
{isAudioListenerRetrying && (
130+
<View style={styles.retryContainer}>
131+
<Text style={styles.retryText}>
132+
🔄 Retrying audio listener... (Attempt {audioListenerRetryAttempts || 0}/10)
133+
</Text>
134+
</View>
135+
)}
136+
117137
{isListeningAudio && (
118138
<View style={styles.infoContainerSM}>
119139
<Text style={styles.infoTitle}>Audio Packets Received:</Text>
@@ -289,6 +309,7 @@ const styles = StyleSheet.create({
289309
fontSize: 14,
290310
width: '100%', // Ensure input takes full width of its container
291311
marginBottom: 10,
312+
color: '#333',
292313
},
293314
statusText: { // New style for status messages
294315
marginTop: 8,
@@ -303,6 +324,20 @@ const styles = StyleSheet.create({
303324
color: 'red',
304325
fontWeight: 'bold',
305326
},
327+
retryContainer: {
328+
marginTop: 10,
329+
padding: 12,
330+
backgroundColor: '#FFF3CD',
331+
borderRadius: 8,
332+
borderLeftWidth: 4,
333+
borderLeftColor: '#FF9500',
334+
},
335+
retryText: {
336+
fontSize: 14,
337+
color: '#856404',
338+
fontWeight: '500',
339+
textAlign: 'center',
340+
},
306341
});
307342

308343
export default DeviceDetails;

0 commit comments

Comments
 (0)