-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-fire-server.py
More file actions
executable file
·58 lines (50 loc) · 1.79 KB
/
start-fire-server.py
File metadata and controls
executable file
·58 lines (50 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python3
"""
Start the Arduino Fire Sensor Network WebSocket Server
"""
import sys
import os
import subprocess
def main():
print("🚀 Starting Arduino Fire Sensor Network")
print("=" * 50)
# Check if we're in the right directory
if not os.path.exists('fire-websocket-server.py'):
print("❌ Error: fire-websocket-server.py not found!")
print("Please run this script from the FlamDirect root directory.")
sys.exit(1)
# Check Python version
if sys.version_info < (3, 8):
print("❌ Error: Python 3.8+ required")
print(f"Current version: {sys.version}")
sys.exit(1)
# Install required packages
print("📦 Installing required packages...")
required_packages = [
'websockets',
'numpy',
'asyncio'
]
for package in required_packages:
try:
__import__(package)
print(f"✅ {package} already installed")
except ImportError:
print(f"📥 Installing {package}...")
subprocess.run([sys.executable, '-m', 'pip', 'install', package],
check=True, capture_output=True)
print(f"✅ {package} installed successfully")
print("\n🔥 Starting Fire Sensor Network Server...")
print("🌐 Server will be available at ws://localhost:8765")
print("📡 4,096 Arduino sensors will be deployed")
print("\nPress Ctrl+C to stop the server\n")
# Start the server
try:
subprocess.run([sys.executable, 'fire-websocket-server.py'], check=True)
except KeyboardInterrupt:
print("\n🛑 Server stopped by user")
except subprocess.CalledProcessError as e:
print(f"❌ Server error: {e}")
sys.exit(1)
if __name__ == "__main__":
main()