Kernel Modules
11 new Rust kernel modules providing messaging, navigation, data management, system services, and BLE capabilities. 136 FFI exports, 528 tests, all pure Rust with C-compatible interfaces.
✎ Edit on GitHubcomponents/kernel_rs/src/ and expose rs_* FFI functions through the syscall table. Each module is self-contained with its own test suite and can be used independently.
| Category | Modules | FFI Exports | Tests |
|---|---|---|---|
| Messaging | 4 | 55 | 213 |
| Navigation & Location | 2 | 16 | 92 |
| Data & Storage | 2 | 26 | 86 |
| System Services | 2 | 26 | 92 |
| BLE | 1 | 13 | 45 |
| Total | 11 | 136 | 528 |
Messaging
Contact Manager
contact_manager.rs — Address book with name, callsign, device ID, phone number, BLE address, and Ed25519 public key. JSON persistence to SD card, vCard 3.0 import/export.
- Per-contact fields: name, callsign, device ID, phone, BLE address, Ed25519 public key
- JSON persistence with
rs_contact_save() - vCard 3.0 import/export for interoperability
- Search by name, device ID, or phone number
- Emergency contact designation
16 FFI exports 65 tests
// Key FFI function signatures
pub extern "C" fn rs_contact_manager_init() -> i32;
pub unsafe extern "C" fn rs_contact_add(info: *const CContactInfo) -> i32;
pub extern "C" fn rs_contact_remove(id: u32) -> i32;
pub unsafe extern "C" fn rs_contact_find_by_device_id(...) -> i32;
pub extern "C" fn rs_contact_save() -> i32;
pub unsafe extern "C" fn rs_contact_export_vcard(...) -> i32;
pub unsafe extern "C" fn rs_contact_import_vcard(...) -> i32;
Burn Timer
burn_timer.rs — Auto-delete messages after a configurable duration. Supports per-conversation policies with a monotonic time model to prevent clock-manipulation attacks.
- Per-message burn timers with millisecond precision
- Per-conversation default policies
- Monotonic time model — immune to system clock changes
- Bulk cancel by conversation
- Active timer count and remaining time queries
12 FFI exports 47 tests
// Key FFI function signatures
pub extern "C" fn rs_burn_timer_init() -> i32;
pub extern "C" fn rs_burn_timer_set(conv_id: u8, msg_idx: u8, burn_after_ms: u64) -> i32;
pub extern "C" fn rs_burn_timer_cancel(conv_id: u8, msg_idx: u8) -> i32;
pub extern "C" fn rs_burn_timer_set_policy(conv_id: u8, burn_ms: u64, ...) -> i32;
pub extern "C" fn rs_burn_timer_tick(now_ms: u64) -> i32;
pub extern "C" fn rs_burn_timer_remaining(conv_id: u8, msg_idx: u8) -> i64;
Message Queue
msg_queue.rs — Store-and-forward message queue with exponential backoff retry. Priority ordering (Urgent/High/Normal) ensures critical messages are sent first. SD card persistence.
- Three priority levels: Urgent, High, Normal
- Exponential backoff retry with configurable max retries
- TTL-based message expiry
- SD card persistence with
rs_msg_queue_save() - Completed message purging
15 FFI exports 53 tests
// Key FFI function signatures
pub extern "C" fn rs_msg_queue_init() -> i32;
pub extern "C" fn rs_msg_queue_tick(now_ms: u64) -> i32;
pub extern "C" fn rs_msg_queue_mark_sent(id: u32) -> i32;
pub extern "C" fn rs_msg_queue_mark_failed(id: u32) -> i32;
pub extern "C" fn rs_msg_queue_save() -> i32;
pub extern "C" fn rs_msg_queue_set_defaults(max_retries: u32, ttl_ms: u64) -> i32;
Message Crypto
msg_crypto.rs — End-to-end message encryption using AES-256-CTR + HMAC-SHA256. Versioned Argon2id key derivation uses authenticated random salts; legacy v1 envelopes remain readable during migration. V2 adds 65 bytes overhead per encrypted message.
- AES-256-CTR encryption with HMAC-SHA256 authentication
- Argon2id key derivation from shared secrets with per-channel random salts
- Per-message unique nonces
- 65 bytes overhead per v2 encrypted message
- Per-contact crypto channels with session statistics
12 FFI exports 48 tests
// Key FFI function signatures
pub unsafe extern "C" fn rs_msg_crypto_init() -> i32;
pub unsafe extern "C" fn rs_msg_crypto_establish(contact_id: u32, ...) -> i32;
pub unsafe extern "C" fn rs_msg_crypto_encrypt(...) -> i32;
pub unsafe extern "C" fn rs_msg_crypto_decrypt(...) -> i32;
pub extern "C" fn rs_msg_crypto_get_overhead() -> i32;
pub unsafe extern "C" fn rs_msg_crypto_derive_key(...) -> i32;
Navigation & Location
GPS Track
gps_track.rs — Track recording with waypoint management and GPX 1.1 XML export. Haversine distance calculation for accurate total distance over recorded tracks.
- Track point recording with latitude, longitude, altitude, timestamp
- Named waypoint support
- GPX 1.1 XML export
- Haversine distance calculation (total km)
7 FFI exports 44 tests
// Key FFI function signatures
pub unsafe extern "C" fn rs_gps_track_create(name: *const c_char) -> *mut GpsTrack;
pub unsafe extern "C" fn rs_gps_track_add_point(track: *mut GpsTrack, ...) -> i32;
pub unsafe extern "C" fn rs_gps_track_add_waypoint(track: *mut GpsTrack, ...) -> i32;
pub unsafe extern "C" fn rs_gps_track_to_gpx(track: *const GpsTrack, ...) -> i32;
pub unsafe extern "C" fn rs_gps_track_distance_km(track: *const GpsTrack) -> f64;
SOS Beacon
sos_beacon.rs — Emergency beacon protocol using compact 109-byte LoRa packets. 6 status modes (OK, Moving, Stationary, Injured, Immobile, MayDay). CRC-16 checksum for packet integrity.
- 109-byte LoRa emergency packets
- 6 status modes: OK, Moving, Stationary, Injured, Immobile, MayDay
- CRC-16 checksum verification
- Position and battery level updates
- Configurable broadcast interval
9 FFI exports 48 tests
// Key FFI function signatures
pub unsafe extern "C" fn rs_sos_beacon_create(device_id: *const u8) -> *mut SosBeacon;
pub unsafe extern "C" fn rs_sos_beacon_activate(beacon: *mut SosBeacon, ...) -> i32;
pub unsafe extern "C" fn rs_sos_beacon_cancel(beacon: *mut SosBeacon) -> i32;
pub unsafe extern "C" fn rs_sos_beacon_update_position(beacon: *mut SosBeacon, ...) -> i32;
pub unsafe extern "C" fn rs_sos_beacon_next_packet(beacon: *mut SosBeacon, ...) -> i32;
Data & Storage
Data Logger
data_logger.rs — Structured CSV logging with typed columns (Int, Float, Text, Bool). Schema locking after first row. Column statistics for numeric types.
- Typed columns: Int, Float, Text, Bool
- Schema locking after first row commit
- CSV export with
rs_data_logger_to_csv() - Row and column count queries
- Per-column statistics for numeric types
14 FFI exports 42 tests
// Key FFI function signatures
pub unsafe extern "C" fn rs_data_logger_create(name: *const c_char) -> *mut DataLogger;
pub unsafe extern "C" fn rs_data_logger_add_column(logger: *mut DataLogger, ...) -> i32;
pub unsafe extern "C" fn rs_data_logger_begin_row(logger: *mut DataLogger, ...) -> i32;
pub unsafe extern "C" fn rs_data_logger_set_float(logger: *mut DataLogger, ...) -> i32;
pub unsafe extern "C" fn rs_data_logger_commit_row(logger: *mut DataLogger) -> i32;
pub unsafe extern "C" fn rs_data_logger_to_csv(logger: *const DataLogger, ...) -> i32;
Secure Wipe
secure_wipe.rs — Secure data erasure with 5 overwrite patterns (Zeros, Ones, Random, DoD 5220.22-M, Gutmann). Priority ordering for wipe targets. Progress tracking for long operations.
- 5 overwrite patterns: Zeros, Ones, Random, DoD 5220.22-M, Gutmann
- Priority ordering for wipe targets
- Progress tracking (0-100%)
- Completion and failure status per target
- Pattern block generation for direct I/O
12 FFI exports 44 tests
// Key FFI function signatures
pub unsafe extern "C" fn rs_wipe_plan_create(pattern: i32) -> *mut WipePlan;
pub unsafe extern "C" fn rs_wipe_plan_add_target(plan: *mut WipePlan, ...) -> i32;
pub unsafe extern "C" fn rs_wipe_plan_next_pending(plan: *const WipePlan) -> i32;
pub unsafe extern "C" fn rs_wipe_plan_progress(plan: *const WipePlan) -> u8;
pub unsafe extern "C" fn rs_wipe_plan_generate_block(plan: *const WipePlan, ...) -> i32;
System Services
Notification Manager
notification.rs — Priority queue for system and app notifications. 4 priority levels (Low, Normal, High, Urgent), 5 categories, auto-expiry, and per-app filtering.
- 4 priority levels: Low, Normal, High, Urgent
- 5 notification categories
- Auto-expiry with configurable TTL
- Per-app notification filtering
- Progress notifications with update support
- Unread count and urgent notification queries
10 FFI exports 38 tests
// Key FFI function signatures
pub unsafe extern "C" fn rs_notification_manager_create(max: u32) -> *mut NotificationManager;
pub unsafe extern "C" fn rs_notification_post(mgr: *mut NotificationManager, ...) -> i32;
pub unsafe extern "C" fn rs_notification_mark_read(mgr: *mut NotificationManager, id: u32) -> i32;
pub unsafe extern "C" fn rs_notification_dismiss(mgr: *mut NotificationManager, id: u32) -> i32;
pub unsafe extern "C" fn rs_notification_unread_count(mgr: *const NotificationManager) -> i32;
pub unsafe extern "C" fn rs_notification_expire(mgr: *mut NotificationManager, ...) -> i32;
Driver Reload
driver_reload.rs — Hot-reload state machine for drivers. Manages lifecycle transitions (Empty, Loaded, Running, Stopped) across 10 HAL types. Enables driver updates without rebooting.
- State machine: Empty, Loaded, Running, Stopped
- 10 HAL driver types supported
- Load, unload, reload, start, stop lifecycle operations
- State queries per registered driver
- Safe transitions with validation
16 FFI exports 54 tests
// Key FFI function signatures
pub extern "C" fn rs_driver_reload_init() -> i32;
pub extern "C" fn rs_driver_reload_load(id: u32) -> i32;
pub extern "C" fn rs_driver_reload_unload(id: u32) -> i32;
pub extern "C" fn rs_driver_reload_reload(id: u32) -> i32;
pub extern "C" fn rs_driver_reload_start(id: u32) -> i32;
pub extern "C" fn rs_driver_reload_get_state(id: u32) -> i32;
BLE
BLE Scanner
ble_scanner.rs — BLE device discovery with advertising data TLV parser. RSSI filtering to ignore distant devices. NimBLE integration for ESP32 hardware scanning.
- Active and passive scan modes
- Advertising data TLV parser (device name, service UUIDs, manufacturer data)
- RSSI threshold filtering
- Sort results by signal strength
- NimBLE stack integration
13 FFI exports 45 tests
// Key FFI function signatures
pub extern "C" fn rs_ble_scanner_init() -> i32;
pub extern "C" fn rs_ble_scanner_start(scan_type: u8, duration_ms: u32) -> i32;
pub extern "C" fn rs_ble_scanner_stop() -> i32;
pub extern "C" fn rs_ble_scanner_is_scanning() -> bool;
pub extern "C" fn rs_ble_scanner_get_count() -> i32;
pub extern "C" fn rs_ble_scanner_set_rssi_filter(min_rssi: i8) -> i32;
pub extern "C" fn rs_ble_scanner_sort_by_rssi() -> i32;