Emergency Beacon System for Disaster Relief
Project Phoenix is a dual-app BLE beacon system designed for emergency situations and disaster relief operations. It enables devices to broadcast their location and sensor data via Bluetooth Low Energy, allowing rescue teams to locate people in distress even when cellular networks are down.
- BLE Beacon Broadcasting: Transmits location and sensor data via Bluetooth
- Adaptive Transmission: Adjusts broadcast frequency based on battery level, motion, and emergency status
- Sensor Integration: GPS, accelerometer, gyroscope, compass, altimeter, and battery monitoring
- Emergency Flags: SOS activation, fall detection, motion detection, unstable environment detection
- Power Efficient: Smart intervals to preserve battery life
- BLE Beacon Scanning: Discovers nearby Phoenix beacons
- Precision Finding: Apple AirTag-style UI for locating beacons with real-time distance and direction
- GPS Fallback Mode: Continues tracking using GPS when BLE signal is lost
- RSSI Smoothing: Advanced filtering for stable distance calculations
- Priority Alerts: Visual indicators for SOS, fall detection, and low battery
- Multi-beacon Support: Track multiple people simultaneously
- Emitter (
apps/emitter): Broadcasts beacon data - Receiver (
apps/receiver): Scans and locates beacons
phoenix/
βββ apps/
β βββ emitter/ # Beacon transmitter app
β β βββ native-modules/ # Native BLE peripheral & sensors
β β βββ src/
β βββ receiver/ # Beacon scanner app
β βββ native-modules/ # Native BLE central
β βββ src/
βββ packages/
β βββ beacon-protocol/ # Binary beacon data encoding/decoding
β βββ ui/ # Shared UI components
β βββ utils/ # Shared utilities
βββ count-lines.sh # LOC counter script
- React Native 0.81 with Expo SDK 54
- TypeScript for type safety
- Native Modules:
- Android: Kotlin (BLE, sensors)
- iOS: Swift + Objective-C (BLE, sensors)
- Monorepo: pnpm workspaces
- BLE: Custom protocol with 20-byte payload
Run ./count-lines.sh to see detailed line counts:
Total Source Code: ~11,278 lines
- TypeScript/TSX: ~4,819 lines (43%)
- Kotlin (Android): ~2,952 lines (26%)
- Swift/Obj-C (iOS): ~2,761 lines (24%)
- Other: ~746 lines (7%)
- Node.js 18+
- pnpm 8+
- Xcode 15+ (for iOS)
- Android Studio (for Android)
# Install dependencies
pnpm install
# Generate native projects (these are gitignored)
cd apps/emitter && pnpx expo prebuild
cd ../receiver && pnpx expo prebuildEmitter:
cd apps/emitter
pnpm ios # Run on iOS
pnpm android # Run on AndroidReceiver:
cd apps/receiver
pnpm ios # Run on iOS
pnpm android # Run on Android[Device ID: 4 bytes]
[Latitude: 4 bytes (float)]
[Longitude: 4 bytes (float)]
[Altitude MSL: 2 bytes (int16)]
[Relative Altitude: 2 bytes (int16, cm)]
[Battery: 1 byte (0-100%)]
[Timestamp: 1 byte (seconds mod 256)]
[Flags: 1 byte]
[Reserved: 1 byte]
- Bit 0: GPS Valid
- Bit 1: Motion Detected
- Bit 2: Low Battery (< 20%)
- Bit 3: SOS Activated
- Bit 4: Fall Detected
- Bit 5: Unstable Environment
- Bits 6-7: Reserved
iOS Emitter β Any Receiver:
Company ID: 0x004C (Apple)
[0x004C] [0x5048 "PH"] [20-byte beacon data]
Android Emitter β Any Receiver:
Company ID: 0x0075 (Samsung)
[0x0075] [0x5048 "PH"] [20-byte beacon data]
- Dark Theme: Sleek black background with modern glassmorphism cards
- Precision Finding: Circular compass UI with directional arrow
- Real-time Updates: 250ms refresh rate (4 updates/second)
- Progressive Haptics: Vibration feedback increases as you approach target
- Imperial Units: Distance shown in feet/inches
Adaptive transmission intervals based on conditions:
- Emergency (SOS/Fall): 1 second
- Critical Battery (< 10%): 15 seconds
- Low Battery (< 20%): 10 seconds
- Active (moving): 3 seconds
- Normal (stationary): 5 seconds
packages/beacon-protocol/ # Binary encoding/decoding
βββ src/
β βββ encoder.ts # Encode sensor data to bytes
β βββ decoder.ts # Decode bytes to beacon data
β βββ config.ts # Protocol constants
Android (Kotlin):
BLEPeripheralManager.kt- BLE advertisingBLEBeaconScanner.kt- BLE scanningSensorDataModule.kt- Sensor data collectionNativeLogger.kt- Native-to-JS logging
iOS (Swift/Obj-C):
BLEPeripheralManager.swift- BLE advertisingBLEBeaconScanner.swift- BLE scanningSensorDataModule.swift- Sensor data collectionNativeLogger.swift- Native-to-JS logging
RSSI Distance Calculation:
distance = 10 ^ ((measuredPower - RSSI) / (10 * pathLossExponent))
// measuredPower = -59 dBm @ 1m
// pathLossExponent = 2.0 (free space)RSSI Smoothing:
- 10-sample moving average
- IQR outlier rejection
- Weighted averaging (recent = higher weight)
GPS Distance (Haversine):
distance = 2 * R * atan2(βa, β(1-a))
// R = Earth radius (6371 km)The iOS and Android directories are generated by expo prebuild and are not committed to git. After cloning:
# Generate native projects
cd apps/emitter && pnpx expo prebuild
cd ../receiver && pnpx expo prebuildNative module source files are committed:
apps/*/native-modules/android/*.ktapps/*/native-modules/ios/*.swiftapps/*/native-modules/ios/*.m
These are automatically copied during prebuild.
This is a disaster relief project - use it to save lives. (So, MIT)
This is an emergency response tool. Contributions that improve reliability, battery life, or location accuracy are especially welcome.
Built with β€οΈ for emergency response and disaster relief operations