Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fdc7142

Browse files
committed
feat: Implement RSSI service for iOS and Web platforms
- Added IosRssiService to handle synthetic RSSI data for iOS. - Created WebRssiService to simulate RSSI scanning on the web. - Defined shared types for WifiNetwork and RssiService in rssi.service.ts. - Introduced simulation service to generate synthetic sensing data. - Implemented WebSocket service for real-time data handling with reconnection logic. - Established Zustand stores for managing application state related to MAT and pose data. - Developed theme context and utility functions for consistent styling and formatting. - Added type definitions for various application entities including API responses and sensing data. - Created utility functions for color mapping and URL validation. - Configured TypeScript settings for the mobile application.
1 parent 02192b0 commit fdc7142

131 files changed

Lines changed: 24090 additions & 0 deletions

File tree

Some content is hidden

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

docs/adr/ADR-034-expo-mobile-app.md

Lines changed: 688 additions & 0 deletions
Large diffs are not rendered by default.

ui/mobile/.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
EXPO_PUBLIC_DEFAULT_SERVER_URL=http://192.168.1.100:8080

ui/mobile/.eslintrc.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module.exports = {
2+
root: true,
3+
parser: '@typescript-eslint/parser',
4+
parserOptions: {
5+
ecmaVersion: 'latest',
6+
sourceType: 'module',
7+
ecmaFeatures: {
8+
jsx: true,
9+
},
10+
},
11+
plugins: ['@typescript-eslint', 'react', 'react-hooks'],
12+
extends: [
13+
'eslint:recommended',
14+
'plugin:react/recommended',
15+
'plugin:react-hooks/recommended',
16+
'plugin:@typescript-eslint/recommended',
17+
],
18+
settings: {
19+
react: {
20+
version: 'detect',
21+
},
22+
},
23+
rules: {
24+
'react/react-in-jsx-scope': 'off',
25+
},
26+
};

ui/mobile/.gitignore

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files
2+
3+
# dependencies
4+
node_modules/
5+
6+
# Expo
7+
.expo/
8+
dist/
9+
web-build/
10+
expo-env.d.ts
11+
12+
# Native
13+
.kotlin/
14+
*.orig.*
15+
*.jks
16+
*.p8
17+
*.p12
18+
*.key
19+
*.mobileprovision
20+
21+
# Metro
22+
.metro-health-check*
23+
24+
# debug
25+
npm-debug.*
26+
yarn-debug.*
27+
yarn-error.*
28+
29+
# macOS
30+
.DS_Store
31+
*.pem
32+
33+
# local env files
34+
.env*.local
35+
36+
# typescript
37+
*.tsbuildinfo
38+
39+
# generated native folders
40+
/ios
41+
/android

ui/mobile/.prettierrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all"
4+
}

ui/mobile/App.tsx

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import { useEffect } from 'react';
2+
import { NavigationContainer, DarkTheme } from '@react-navigation/native';
3+
import { GestureHandlerRootView } from 'react-native-gesture-handler';
4+
import { StatusBar } from 'expo-status-bar';
5+
import { SafeAreaProvider } from 'react-native-safe-area-context';
6+
import { apiService } from '@/services/api.service';
7+
import { rssiService } from '@/services/rssi.service';
8+
import { wsService } from '@/services/ws.service';
9+
import { ThemeProvider } from './src/theme/ThemeContext';
10+
import { usePoseStore } from './src/stores/poseStore';
11+
import { useSettingsStore } from './src/stores/settingsStore';
12+
import { RootNavigator } from './src/navigation/RootNavigator';
13+
14+
export default function App() {
15+
const serverUrl = useSettingsStore((state) => state.serverUrl);
16+
const rssiScanEnabled = useSettingsStore((state) => state.rssiScanEnabled);
17+
18+
useEffect(() => {
19+
apiService.setBaseUrl(serverUrl);
20+
const unsubscribe = wsService.subscribe(usePoseStore.getState().handleFrame);
21+
wsService.connect(serverUrl);
22+
23+
return () => {
24+
unsubscribe();
25+
wsService.disconnect();
26+
};
27+
}, [serverUrl]);
28+
29+
useEffect(() => {
30+
if (!rssiScanEnabled) {
31+
rssiService.stopScanning();
32+
return;
33+
}
34+
35+
const unsubscribe = rssiService.subscribe(() => {
36+
// Consumers can subscribe elsewhere for RSSI events.
37+
});
38+
rssiService.startScanning(2000);
39+
40+
return () => {
41+
unsubscribe();
42+
rssiService.stopScanning();
43+
};
44+
}, [rssiScanEnabled]);
45+
46+
useEffect(() => {
47+
(globalThis as { __appStartTime?: number }).__appStartTime = Date.now();
48+
}, []);
49+
50+
const navigationTheme = {
51+
...DarkTheme,
52+
colors: {
53+
...DarkTheme.colors,
54+
background: '#0A0E1A',
55+
card: '#0D1117',
56+
text: '#E2E8F0',
57+
border: '#1E293B',
58+
primary: '#32B8C6',
59+
},
60+
};
61+
62+
return (
63+
<GestureHandlerRootView style={{ flex: 1 }}>
64+
<SafeAreaProvider>
65+
<ThemeProvider>
66+
<NavigationContainer theme={navigationTheme}>
67+
<RootNavigator />
68+
</NavigationContainer>
69+
</ThemeProvider>
70+
</SafeAreaProvider>
71+
<StatusBar style="light" />
72+
</GestureHandlerRootView>
73+
);
74+
}

0 commit comments

Comments
 (0)