Skip to main content

Crate wifi_densepose_wasm

Crate wifi_densepose_wasm 

Source
Expand description

WiFi-DensePose WebAssembly bindings

This crate provides WebAssembly bindings for browser-based applications using WiFi-DensePose technology. It includes:

  • mat: WiFi-Mat disaster response dashboard module for browser integration

§Features

  • mat - Enable WiFi-Mat disaster detection WASM bindings
  • console_error_panic_hook - Better panic messages in browser console

§Building for WASM

# Build with wasm-pack
wasm-pack build --target web --features mat

# Or with cargo
cargo build --target wasm32-unknown-unknown --features mat

§Example Usage (JavaScript)

import init, { MatDashboard, initLogging } from './wifi_densepose_wasm.js';

async function main() {
    await init();
    initLogging('info');

    const dashboard = new MatDashboard();

    // Create a disaster event
    const eventId = dashboard.createEvent('earthquake', 37.7749, -122.4194, 'Bay Area Earthquake');

    // Add scan zones
    dashboard.addRectangleZone('Building A', 50, 50, 200, 150);
    dashboard.addCircleZone('Search Area B', 400, 200, 80);

    // Subscribe to events
    dashboard.onSurvivorDetected((survivor) => {
        console.log('Survivor detected:', survivor);
        updateUI(survivor);
    });

    dashboard.onAlertGenerated((alert) => {
        showNotification(alert);
    });

    // Render to canvas
    const canvas = document.getElementById('map');
    const ctx = canvas.getContext('2d');

    function render() {
        ctx.clearRect(0, 0, canvas.width, canvas.height);
        dashboard.renderZones(ctx);
        dashboard.renderSurvivors(ctx);
        requestAnimationFrame(render);
    }
    render();
}

main();

Re-exports§

pub use mat::*;

Modules§

mat
WiFi-Mat WASM bindings for browser-based disaster response dashboard.
types

Functions§

get_timestamp
Get current timestamp in milliseconds (for performance measurements).
get_version
Get the library version.
init
Initialize the WASM module. Call this once at startup before using any other functions.
init_logging
Initialize logging with specified level.
is_mat_enabled
Check if the MAT feature is enabled.