Spaces:
Runtime error
Runtime error
File size: 2,584 Bytes
7566eb5 | 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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | #!/usr/bin/env python3
"""
Hikvision ISUP 5.0 Server Startup Script
Starts both the ISUP 5.0 binary protocol server and web interface
"""
import asyncio
import sys
import signal
import threading
from datetime import datetime
# Import our servers
from app_isup5 import app
from isup5_server import isup_server
import uvicorn
def signal_handler(signum, frame):
"""Handle shutdown signals"""
print(f"\nπ Received signal {signum}, shutting down...")
sys.exit(0)
def print_banner():
"""Print startup banner"""
print("=" * 60)
print("π HIKVISION ISUP 5.0 SERVER")
print("=" * 60)
print(f"π
Started: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
print(f"π Protocol: ISUP 5.0 Binary")
print(f"π§ Authentication: EHome Key + Session Key")
print(f"π‘ ISUP Port: 7660 (TCP)")
print(f"π Web Interface: http://localhost:7860")
print(f"π API Docs: http://localhost:7860/docs")
print("=" * 60)
print()
print("π§ DEVICE CONFIGURATION:")
print("Configure your Hikvision device with these settings:")
print(" β’ Platform Access Mode: ISUP")
print(" β’ Protocol Version: 5.0")
print(" β’ Server Address: your-server-ip")
print(" β’ Port: 7660")
print(" β’ Device ID: 255")
print(" β’ EHome Key: hikvision123")
print()
print("π± SUPPORTED DEVICE:")
print(" β’ Model: DS-K1T342MFX")
print(" β’ Serial: DS-K1T342MFX20220310V030305ENJ92377854")
print(" β’ Features: Face Recognition, Temperature, Mask Detection")
print()
print("π§ͺ TESTING:")
print(" β’ Run: python test/isup5_device_simulator.py")
print(" β’ Simulates authentic ISUP 5.0 device behavior")
print()
def main():
"""Main startup function"""
# Set up signal handlers
signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)
print_banner()
try:
# Start the web server (which will start ISUP server in background)
print("π Starting servers...")
uvicorn.run(
"app_isup5:app",
host="0.0.0.0",
port=7860,
reload=False, # Important: disable reload to prevent ISUP server issues
log_level="info",
access_log=True
)
except KeyboardInterrupt:
print("\nπ Shutdown requested by user")
except Exception as e:
print(f"β Server error: {e}")
finally:
print("π Server stopped")
if __name__ == "__main__":
main()
|