import { useState } from "react"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { Badge } from "@/components/ui/badge"; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "@/components/ui/accordion"; import { AlertTriangle, CheckCircle, XCircle, AlertCircle, Cpu, Wifi, HardDrive, Zap, Clock, Shield, Settings, Database, Radio, Activity, FileWarning, CircleHelp } from "lucide-react"; import { ScrollArea } from "@/components/ui/scroll-area"; import { Separator } from "@/components/ui/separator"; // ESP32-S3 Specifications const esp32Specs = { cpu: { cores: 2, frequency: "240 MHz", architecture: "Xtensa LX7" }, memory: { sram: "512 KB", rtcSram: "16 KB", rom: "384 KB" }, flash: "External (8MB configured)", gpio: 45, interfaces: { spi: 4, i2c: 2, uart: 3, i2s: 2, adc: "20 channels (12-bit)" }, wireless: { wifi: "802.11 b/g/n (2.4GHz)", bluetooth: "BLE 5.0" }, security: ["AES-128/256", "SHA", "RSA", "HMAC", "Secure Boot", "Flash Encryption"], power: ["Active", "Modem-sleep", "Light-sleep", "Deep-sleep", "Hibernation"] }; // Budget Comparison const budgetAnalysis = { ram: { allocated: 225, available: 512, budget: "60%", actual: "43.9%", status: "ok" }, flash: { allocated: 5.052, available: 8, budget: "70%", actual: "63.2%", status: "ok" }, cpu: { allocated: 42, budget: "80% peak", status: "ok" } }; // Gap Analysis Data const gapAnalysis = [ { category: "Communication (FG-COM)", severity: "critical", gaps: [ { id: "GAP-COM-001", title: "WiFi Protocol Details Missing", description: "Documents mention 'WiFi / Zigbee / LoRa' but lack specific protocol selection and rationale.", questions: [ "Which WiFi standard specifically? (802.11b/g/n all supported by ESP32-S3)", "What is the target data rate requirement?", "Is 2.4GHz band acceptable (5GHz not supported)?", "What is the expected range/coverage?" ], recommendation: "Define primary protocol as WiFi 802.11n for best throughput. Add Zigbee/LoRa as optional fallback.", esp32Impact: "ESP32-S3 supports 802.11 b/g/n at 2.4GHz up to 150 Mbps. No 5GHz support." }, { id: "GAP-COM-002", title: "TLS/DTLS Version Unspecified", description: "Security requires TLS/DTLS but version and cipher suites are not defined.", questions: [ "TLS 1.2 or TLS 1.3?", "Which cipher suites are acceptable?", "Certificate management approach?", "Key rotation policy?" ], recommendation: "Use TLS 1.2 with AES-128-GCM for ESP32-S3 hardware acceleration compatibility.", esp32Impact: "ESP32-S3 has hardware crypto accelerators for AES-128/256, SHA, RSA." }, { id: "GAP-COM-003", title: "Peer-to-Peer Protocol Undefined", description: "F-COM-03 mentions peer Sensor Hub communication but no protocol specified.", questions: [ "What transport for peer-to-peer? (WiFi Direct, BLE, ESP-NOW?)", "What is the maximum peer count?", "Discovery mechanism?" ], recommendation: "Consider ESP-NOW for low-latency peer communication (250 byte payload, no WiFi connection needed).", esp32Impact: "ESP-NOW supported natively. BLE Mesh also available." }, { id: "GAP-COM-004", title: "Heartbeat/Keep-Alive Details Missing", description: "30-second timeout mentioned but no heartbeat interval or mechanism defined.", questions: [ "What is the heartbeat interval?", "Payload content of heartbeat?", "Exponential backoff parameters for reconnection?" ], recommendation: "Define 10-second heartbeat interval with 3 missed = disconnected.", esp32Impact: "No specific hardware limitation." } ] }, { category: "Data Acquisition (FG-DAQ)", severity: "high", gaps: [ { id: "GAP-DAQ-001", title: "Specific Sensor Models Not Defined", description: "Sensor types listed (Temp, Humidity, CO2, etc.) but no specific models or part numbers.", questions: [ "What are the specific sensor models/part numbers?", "What are the I2C addresses for each sensor type?", "Are there alternative/fallback sensor models?" ], recommendation: "Create a Sensor Catalog with approved models, I2C addresses, and driver requirements.", esp32Impact: "ESP32-S3 has 2x I2C buses - ensure no address conflicts if using multiple sensors." }, { id: "GAP-DAQ-002", title: "ADC Channel Allocation Undefined", description: "Analog sensors mentioned but no ADC channel assignment or calibration approach.", questions: [ "How many analog sensors are expected?", "Which ADC channels will be used?", "What reference voltage?", "ADC calibration approach?" ], recommendation: "Define ADC channel map. Use eFuse-stored calibration for ESP32-S3 ADC linearity correction.", esp32Impact: "ESP32-S3 has 20 ADC channels, 12-bit resolution. Some GPIOs are ADC1 (usable with WiFi), some ADC2 (conflicts with WiFi)." }, { id: "GAP-DAQ-003", title: "Sensor Warm-Up Times Not Specified", description: "Many gas sensors (CO2, NH3) require warm-up periods not addressed.", questions: [ "What are warm-up time requirements per sensor type?", "How should readings during warm-up be handled?", "Power-on sequencing requirements?" ], recommendation: "Add sensor warm-up state handling. Typical: CO2 sensors 30-60 seconds, MOS sensors 24-48 hours for first use.", esp32Impact: "No specific hardware impact, software timing only." }, { id: "GAP-DAQ-004", title: "Filtering Algorithm Not Specified", description: "High-frequency sampling mentions filtering but algorithm type not defined.", questions: [ "Moving average, median filter, Kalman, or other?", "Filter window size configurable?", "Outlier rejection criteria?" ], recommendation: "Recommend median filter (robust to outliers) with configurable window size in Machine Constants.", esp32Impact: "CPU budget allows for moderate filtering complexity." } ] }, { category: "Security (FG-SEC)", severity: "critical", gaps: [ { id: "GAP-SEC-001", title: "Key Management Lifecycle Undefined", description: "Secure boot and encryption mentioned but key provisioning and rotation not specified.", questions: [ "How are keys provisioned during manufacturing?", "Key rotation policy for TLS certificates?", "Key storage location (eFuse vs NVS encrypted)?", "Revocation mechanism?" ], recommendation: "Define key provisioning during manufacturing, use eFuse for secure boot keys, NVS encrypted partition for runtime keys.", esp32Impact: "ESP32-S3 has eFuse for permanent key storage and hardware secure boot support." }, { id: "GAP-SEC-002", title: "Authentication Method Not Specified", description: "Authentication required but mechanism not defined (certificates, PSK, tokens?).", questions: [ "Mutual TLS with certificates?", "Pre-shared keys?", "Device identity provisioning?" ], recommendation: "Use X.509 certificates with device-unique identity for mutual TLS.", esp32Impact: "ESP32-S3 supports X.509, may need external crypto chip for many certificates." }, { id: "GAP-SEC-003", title: "Anti-Rollback Policy Vague", description: "Rollback prevention mentioned as 'optional future' but critical for security.", questions: [ "Is anti-rollback mandatory?", "What version tracking mechanism?", "Emergency recovery procedure?" ], recommendation: "Implement anti-rollback using ESP32-S3 eFuse version counter.", esp32Impact: "ESP32-S3 supports secure version tracking in eFuse (limited burn count)." } ] }, { category: "OTA Updates (FG-OTA)", severity: "high", gaps: [ { id: "GAP-OTA-001", title: "Partition Scheme Not Defined", description: "Dual-partition OTA implied but specific partition layout not documented.", questions: [ "What is the partition table layout?", "Factory partition included?", "Partition sizes for app0/app1?", "NVS partition size?" ], recommendation: "Define: factory (4MB) + ota_0 (4MB) or app0 + app1 if 8MB flash. Reserve 64KB for NVS.", esp32Impact: "8MB flash allows dual 3.5MB app partitions with ample NVS/data space." }, { id: "GAP-OTA-002", title: "OTA Chunk Size Not Specified", description: "Firmware transferred 'in chunks' but chunk size and protocol not defined.", questions: [ "What chunk size? (4KB, 16KB, other?)", "Acknowledgment per chunk or batch?", "Resume capability after interruption?" ], recommendation: "Use 4KB chunks with per-chunk CRC and resume from last successful chunk.", esp32Impact: "4KB aligns with flash page size for efficient writes." }, { id: "GAP-OTA-003", title: "Rollback Trigger Conditions Undefined", description: "Rollback mentioned but trigger conditions not specified.", questions: [ "What triggers automatic rollback?", "Timeout for marking update successful?", "Health check criteria?" ], recommendation: "Implement watchdog-triggered rollback if app doesn't confirm within 60 seconds of boot.", esp32Impact: "ESP32-S3 has app rollback support in bootloader." } ] }, { category: "Persistence (FG-DATA)", severity: "high", gaps: [ { id: "GAP-DATA-001", title: "SD Card File System Not Specified", description: "SD card storage mentioned but filesystem type not defined.", questions: [ "FAT32, exFAT, or custom filesystem?", "Maximum file size?", "Directory structure?", "Wear leveling approach?" ], recommendation: "Use FAT32 for compatibility. Implement circular buffer with fixed-size files for wear distribution.", esp32Impact: "ESP-IDF supports FAT32 on SD. SPI mode vs SDMMC mode?" }, { id: "GAP-DATA-002", title: "Data Retention Policy Incomplete", description: "Configurable retention mentioned but no default values or limits.", questions: [ "Default retention period?", "Maximum storage allocation per data type?", "Overwrite priority (FIFO, priority-based)?" ], recommendation: "Default 7-day retention, FIFO overwrite, 80% SD capacity for sensor data.", esp32Impact: "No specific hardware constraint." }, { id: "GAP-DATA-003", title: "NVS Partition Size and Usage Undefined", description: "NVS mentioned for machine constants but sizing not specified.", questions: [ "Expected size of machine constants?", "How many NVS entries expected?", "NVS encryption enabled?" ], recommendation: "Allocate 64KB NVS minimum. Enable NVS encryption for sensitive data.", esp32Impact: "ESP32-S3 supports NVS encryption with flash encryption enabled." } ] }, { category: "Diagnostics (FG-DIAG)", severity: "medium", gaps: [ { id: "GAP-DIAG-001", title: "Diagnostic Code Registry Not Provided", description: "Structured diagnostic codes required but no code table provided.", questions: [ "What is the diagnostic code format?", "What are all defined diagnostic codes?", "Code ranges per subsystem?" ], recommendation: "Create diagnostic code registry: 0x1xxx=DAQ, 0x2xxx=COM, 0x3xxx=SEC, etc.", esp32Impact: "No specific hardware constraint." }, { id: "GAP-DIAG-002", title: "Log Storage Capacity Undefined", description: "Persistent diagnostics mentioned but storage limits not specified.", questions: [ "Maximum log entries?", "Log rotation policy?", "Crash dump storage?" ], recommendation: "1000 diagnostic entries max, FIFO rotation, separate crash dump partition.", esp32Impact: "Consider coredump partition in flash (~64KB)." } ] }, { category: "System Management (FG-SYS)", severity: "medium", gaps: [ { id: "GAP-SYS-001", title: "Watchdog Timer Configuration Not Specified", description: "System reliability requires WDT but parameters not defined.", questions: [ "Task WDT timeout value?", "Which tasks are monitored?", "Interrupt WDT configuration?" ], recommendation: "10-second task WDT, monitor all FreeRTOS tasks, enable interrupt WDT.", esp32Impact: "ESP32-S3 has multiple WDT: Task WDT, Interrupt WDT, RTC WDT." }, { id: "GAP-SYS-002", title: "Power Management Strategy Undefined", description: "Continuous AC power assumed but brownout/UPS handling not addressed.", questions: [ "Brownout detection threshold?", "UPS/battery backup expected?", "Graceful shutdown on power loss?" ], recommendation: "Enable brownout detector at 3.0V, implement emergency data flush on brownout interrupt.", esp32Impact: "ESP32-S3 has programmable brownout detector." }, { id: "GAP-SYS-003", title: "Time Synchronization Details Missing", description: "Synchronized time mentioned but sync mechanism not specified.", questions: [ "NTP, GPS, or Main Hub time sync?", "Sync interval?", "Drift tolerance?", "RTC backup?" ], recommendation: "Sync from Main Hub on connect, resync every 1 hour, ±1 second tolerance.", esp32Impact: "ESP32-S3 has RTC. External RTC battery may be needed for power loss." } ] }, { category: "Hardware Interface (HW)", severity: "high", gaps: [ { id: "GAP-HW-001", title: "GPIO Pin Assignment Not Documented", description: "Multiple interfaces but no pin mapping provided.", questions: [ "Complete GPIO pin assignment table?", "Reserved/strapping pins identified?", "I2C pull-up resistor values?" ], recommendation: "Create comprehensive GPIO map. Avoid strapping pins (GPIO0, GPIO45, GPIO46).", esp32Impact: "ESP32-S3 has 45 GPIOs but some have restrictions (strapping, flash, PSRAM)." }, { id: "GAP-HW-002", title: "OLED Display Specifications Missing", description: "OLED via I2C mentioned but no specifications.", questions: [ "Display resolution?", "Controller chip (SSD1306, SH1106)?", "I2C address?", "Refresh rate requirements?" ], recommendation: "Recommend SSD1306 128x64 OLED at 0x3C, widely supported.", esp32Impact: "I2C bus speed consideration - 400kHz recommended for smooth updates." }, { id: "GAP-HW-003", title: "SD Card Interface Mode Unspecified", description: "SD card mentioned but interface mode not defined.", questions: [ "SPI mode or SDMMC (1-bit/4-bit)?", "Maximum SD card size supported?", "Speed class requirements?" ], recommendation: "Use SDMMC 4-bit mode for best performance if GPIOs available, else SPI.", esp32Impact: "ESP32-S3 supports both. SDMMC uses dedicated pins, SPI is more flexible." } ] }, { category: "Quality & Calibration (FG-DQC)", severity: "medium", gaps: [ { id: "GAP-DQC-001", title: "Calibration Data Format Undefined", description: "Calibration management mentioned but data structure not specified.", questions: [ "What calibration parameters per sensor type?", "Polynomial coefficients, offset/gain, or lookup tables?", "Calibration data versioning?" ], recommendation: "Define per-sensor calibration structure with version, timestamp, and polynomial coefficients.", esp32Impact: "No specific hardware constraint." }, { id: "GAP-DQC-002", title: "Sensor Validity Thresholds Not Defined", description: "Out-of-range detection mentioned but thresholds not specified.", questions: [ "Valid range per sensor type?", "Rate-of-change limits?", "Stuck sensor detection criteria?" ], recommendation: "Define per-sensor-type: min/max physical range, max rate of change, stuck duration.", esp32Impact: "No specific hardware constraint." } ] } ]; // Requirements Coverage Summary const coverageSummary = { totalFeatures: 24, totalSRs: 85, totalSWRs: 200, coverage: { fullySpecified: 156, partiallySpecified: 32, gaps: 12 } }; const SeverityBadge = ({ severity }: { severity: string }) => { const config = { critical: { color: "bg-red-500/15 text-red-700 border-red-500/30", icon: XCircle }, high: { color: "bg-orange-500/15 text-orange-700 border-orange-500/30", icon: AlertTriangle }, medium: { color: "bg-yellow-500/15 text-yellow-700 border-yellow-500/30", icon: AlertCircle }, low: { color: "bg-blue-500/15 text-blue-700 border-blue-500/30", icon: CircleHelp } }; const cfg = config[severity as keyof typeof config] || config.medium; const Icon = cfg.icon; return ( {severity.toUpperCase()} ); }; const Index = () => { const [selectedCategory, setSelectedCategory] = useState(null); const criticalGaps = gapAnalysis.filter(g => g.severity === "critical"); const highGaps = gapAnalysis.filter(g => g.severity === "high"); const totalGapCount = gapAnalysis.reduce((acc, g) => acc + g.gaps.length, 0); return (
{/* Header */}

ASF Sensor Hub - Requirements Gap Analysis

DIPFECS ESP32-S3 Sub-Hub | ISO/IEC/IEEE 29148 Compliance Review

ESP32-S3 {totalGapCount} Gaps Identified
{/* Summary Cards */}
Critical Gaps
{criticalGaps.reduce((acc, g) => acc + g.gaps.length, 0)}

in {criticalGaps.length} categories

High Priority Gaps
{highGaps.reduce((acc, g) => acc + g.gaps.length, 0)}

in {highGaps.length} categories

Requirements Coverage
{Math.round((coverageSummary.coverage.fullySpecified / coverageSummary.totalSWRs) * 100)}%

{coverageSummary.coverage.fullySpecified}/{coverageSummary.totalSWRs} SWRs complete

ESP32-S3 Compatibility
Compatible

All budgets within limits

Gap Analysis ESP32-S3 Specs Resource Budgets Recommendations {/* Gap Analysis Tab */} Requirements Gap Analysis by Feature Group Identified gaps requiring clarification or additional requirements {gapAnalysis.map((category, idx) => (
{category.category} {category.gaps.length} gaps
{category.gaps.map((gap, gapIdx) => (
{gap.id}: {gap.title} {gap.description}

Questions to Resolve:

    {gap.questions.map((q, qIdx) => (
  • {q}
  • ))}

Recommendation:

{gap.recommendation}

ESP32-S3 Impact:

{gap.esp32Impact}

))}
))}
{/* ESP32-S3 Specs Tab */}
CPU
Architecture {esp32Specs.cpu.architecture}
Cores {esp32Specs.cpu.cores}
Frequency {esp32Specs.cpu.frequency}
Memory
SRAM {esp32Specs.memory.sram}
RTC SRAM {esp32Specs.memory.rtcSram}
ROM {esp32Specs.memory.rom}
External Flash {esp32Specs.flash}
Wireless
WiFi {esp32Specs.wireless.wifi}
Bluetooth {esp32Specs.wireless.bluetooth}
Interfaces
GPIO {esp32Specs.gpio} pins
SPI {esp32Specs.interfaces.spi} buses
I2C {esp32Specs.interfaces.i2c} buses
UART {esp32Specs.interfaces.uart}
ADC {esp32Specs.interfaces.adc}
Security Features
{esp32Specs.security.map((feature, idx) => ( {feature} ))}
Power Modes
{esp32Specs.power.map((mode, idx) => ( {mode} ))}
ESP32-S3 Limitations to Consider
  • No 5GHz WiFi: Only 2.4GHz band supported
  • ADC2 + WiFi conflict: ADC2 channels cannot be used while WiFi is active
  • Touch sensor limitation: Has not passed Conducted Susceptibility test
  • Strapping pins: GPIO0, GPIO45, GPIO46 have boot mode restrictions
  • eFuse burns: Secure boot version counter has limited increments
{/* Budgets Tab */}
RAM Budget
Allocated {budgetAnalysis.ram.allocated} KB
Available (ESP32-S3) {budgetAnalysis.ram.available} KB
Budget: ≤{budgetAnalysis.ram.budget} (of 307KB doc) Actual: {budgetAnalysis.ram.actual}
Within Budget - ESP32-S3 has 512KB vs 307KB assumed
Flash Budget
Allocated {budgetAnalysis.flash.allocated} MB
Available {budgetAnalysis.flash.available} MB
Budget: ≤{budgetAnalysis.flash.budget} Actual: {budgetAnalysis.flash.actual}
Within Budget
CPU Budget
Normal Operation {budgetAnalysis.cpu.allocated}%
Peak Allowed {budgetAnalysis.cpu.budget}
Within Budget
Timing Constraints Summary
{[ { op: "Sensor Acquisition Cycle", time: "100ms/sensor", status: "ok" }, { op: "All Sensors (5 max)", time: "500ms", status: "ok" }, { op: "State Transition", time: "50ms", status: "ok" }, { op: "Main Hub Request", time: "100ms", status: "ok" }, { op: "OTA Update Duration", time: "10 min max", status: "ok" }, { op: "Heartbeat Timeout", time: "30s", status: "warning" } ].map((item, idx) => (
{item.op}
{item.time} {item.status === "ok" ? ( ) : ( )}
))}
{/* Recommendations Tab */} Priority Action Items Critical and high-priority items requiring immediate attention
{[ { priority: "P1", title: "Define WiFi Protocol Specifics", category: "Communication", action: "Document: WiFi 802.11n, 2.4GHz, TLS 1.2 with AES-128-GCM", severity: "critical" }, { priority: "P1", title: "Create Key Management Specification", category: "Security", action: "Define key provisioning, storage (eFuse/NVS), rotation, and revocation procedures", severity: "critical" }, { priority: "P1", title: "Define Authentication Mechanism", category: "Security", action: "Specify X.509 mutual TLS with device certificates", severity: "critical" }, { priority: "P2", title: "Create Sensor Catalog", category: "Data Acquisition", action: "Document specific sensor models, I2C addresses, drivers, warm-up times", severity: "high" }, { priority: "P2", title: "Define OTA Partition Scheme", category: "OTA Updates", action: "Specify partition table: factory + ota_0/ota_1 + nvs + coredump", severity: "high" }, { priority: "P2", title: "Create GPIO Pin Assignment Table", category: "Hardware", action: "Complete mapping avoiding strapping pins, document I2C/SPI/UART assignments", severity: "high" }, { priority: "P2", title: "Define SD Card Interface Mode", category: "Hardware", action: "Specify SDMMC 4-bit vs SPI mode, file system (FAT32), wear strategy", severity: "high" }, { priority: "P3", title: "Create Diagnostic Code Registry", category: "Diagnostics", action: "Define code format and complete registry (0x1xxx=DAQ, 0x2xxx=COM, etc.)", severity: "medium" }, { priority: "P3", title: "Define Time Sync Mechanism", category: "System", action: "Specify sync from Main Hub, interval (1hr), drift tolerance (±1s)", severity: "medium" } ].map((item, idx) => (
{item.priority}

{item.title}

{item.category}

{item.action}

))}
ESP32-S3 Compatibility Summary

Memory: ESP32-S3 has 512KB SRAM (vs 307KB assumed) - exceeds requirements

Flash: 8MB external flash supports dual OTA partitions

Security: Hardware crypto accelerators support all required algorithms

Interfaces: 2x I2C, 4x SPI, 3x UART, 20x ADC channels exceed sensor requirements

WiFi: 802.11 b/g/n at 2.4GHz meets communication requirements

Note: Ensure ADC channels use ADC1 (not ADC2) when WiFi is active

); }; export default Index;