mirror of
https://github.com/ruvnet/RuView
synced 2026-08-11 20:41:44 +00:00
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.
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import type { RssiService, WifiNetwork } from './rssi.service';
|
||||
|
||||
class WebRssiService implements RssiService {
|
||||
private timer: ReturnType<typeof setInterval> | null = null;
|
||||
private listeners = new Set<(networks: WifiNetwork[]) => void>();
|
||||
|
||||
startScanning(intervalMs: number): void {
|
||||
console.warn('Web RSSI scanning not available; returning synthetic network data.');
|
||||
this.stopScanning();
|
||||
this.timer = setInterval(() => {
|
||||
this.broadcast([
|
||||
{ ssid: 'WiFi-DensePose', bssid: 'AA:BB:CC:DD:EE:01', level: -55 },
|
||||
{ ssid: 'WiFi-Guest', bssid: 'AA:BB:CC:DD:EE:02', level: -72 },
|
||||
]);
|
||||
}, intervalMs);
|
||||
this.broadcast([
|
||||
{ ssid: 'WiFi-DensePose', bssid: 'AA:BB:CC:DD:EE:01', level: -55 },
|
||||
]);
|
||||
}
|
||||
|
||||
stopScanning(): void {
|
||||
if (this.timer) {
|
||||
clearInterval(this.timer);
|
||||
this.timer = null;
|
||||
}
|
||||
}
|
||||
|
||||
subscribe(listener: (networks: WifiNetwork[]) => void): () => void {
|
||||
this.listeners.add(listener);
|
||||
return () => {
|
||||
this.listeners.delete(listener);
|
||||
};
|
||||
}
|
||||
|
||||
private broadcast(networks: WifiNetwork[]): void {
|
||||
this.listeners.forEach((listener) => {
|
||||
try {
|
||||
listener(networks);
|
||||
} catch {
|
||||
// listener safety
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export const rssiService = new WebRssiService();
|
||||
Reference in New Issue
Block a user