43 lines
1.8 KiB
TypeScript
43 lines
1.8 KiB
TypeScript
export const RSRP_THRESHOLDS = {
|
|
EXCELLENT: -70,
|
|
GOOD: -85,
|
|
FAIR: -100,
|
|
POOR: -110,
|
|
WEAK: -120,
|
|
NO_SERVICE: -120,
|
|
} as const;
|
|
|
|
export type SignalQuality = 'excellent' | 'good' | 'fair' | 'poor' | 'weak' | 'no-service';
|
|
|
|
export function getSignalQuality(rsrp: number): SignalQuality {
|
|
if (rsrp >= RSRP_THRESHOLDS.EXCELLENT) return 'excellent';
|
|
if (rsrp >= RSRP_THRESHOLDS.GOOD) return 'good';
|
|
if (rsrp >= RSRP_THRESHOLDS.FAIR) return 'fair';
|
|
if (rsrp >= RSRP_THRESHOLDS.POOR) return 'poor';
|
|
if (rsrp >= RSRP_THRESHOLDS.WEAK) return 'weak';
|
|
return 'no-service';
|
|
}
|
|
|
|
// Purple → Orange palette: dark purple = weak, bright orange = strong
|
|
export const SIGNAL_COLORS: Record<string, string> = {
|
|
excellent: '#ffb74d', // Bright orange (excellent)
|
|
good: '#ff6f00', // Dark orange (strong)
|
|
fair: '#ff8a65', // Peach (fair)
|
|
poor: '#ab47bc', // Light purple (weak)
|
|
weak: '#7b1fa2', // Purple (very weak)
|
|
'no-service': '#4a148c', // Dark purple (no coverage)
|
|
} as const;
|
|
|
|
export function getRSRPColor(rsrp: number): string {
|
|
return SIGNAL_COLORS[getSignalQuality(rsrp)] ?? '#1a0033';
|
|
}
|
|
|
|
export const RSRP_LEGEND = [
|
|
{ label: 'Excellent', range: '> -70 dBm', color: '#ffb74d', description: 'Very strong signal', min: -70 },
|
|
{ label: 'Good', range: '-70 to -85 dBm', color: '#ff6f00', description: 'Strong signal', min: -85 },
|
|
{ label: 'Fair', range: '-85 to -100 dBm', color: '#ff8a65', description: 'Acceptable signal', min: -100 },
|
|
{ label: 'Poor', range: '-100 to -110 dBm', color: '#ab47bc', description: 'Weak signal', min: -110 },
|
|
{ label: 'Weak', range: '-110 to -120 dBm', color: '#7b1fa2', description: 'Very weak signal', min: -120 },
|
|
{ label: 'No Service', range: '< -120 dBm', color: '#1a0033', description: 'No coverage', min: -140 },
|
|
] as const;
|