package main import ( "log" "net/http" "imuslab.com/arozos/mod/iot" "imuslab.com/arozos/mod/iot/hdsv2" prout "imuslab.com/arozos/mod/prouter" ) /* IoT Hub Author: tobychui This script handle the IoT service start up and mangement IoT Manager: Manage who can have access to certain IoT devices IoT Panel: The panel for controlling the devices */ var iotManager *iot.Manager func IoTHubInit() { if *allow_iot && *allow_mdns && MDNS != nil { //Create a new ioT Manager iotManager = iot.NewIoTManager() //Register IoT Setting Interfaces registerSetting(settingModule{ Name: "IoT Manager", Desc: "Manage IoT Devices Permission", IconPath: "SystemAO/iot/img/small_icon.png", Group: "Device", StartDir: "SystemAO/iot/manager.html", }) //Register IoT Devices Endpoints router := prout.NewModuleRouter(prout.RouterOption{ ModuleName: "IoT Panel", AdminOnly: false, UserHandler: userHandler, DeniedHandler: func(w http.ResponseWriter, r *http.Request) { sendErrorResponse(w, "Permission Denied") }, }) adminRouter := prout.NewModuleRouter(prout.RouterOption{ ModuleName: "System Setting", AdminOnly: true, UserHandler: userHandler, DeniedHandler: func(w http.ResponseWriter, r *http.Request) { sendErrorResponse(w, "Permission Denied") }, }) router.HandleFunc("/system/iot/scan", iotManager.HandleScanning) log.Println("Work in progress breakpoint: ", router, adminRouter) //Start of the IoT Management Handlers //Home Dynamic v2 hdsv2Handler := hdsv2.NewProtocolHandler(MDNS) iotManager.RegisterHandler(hdsv2Handler) //Add more here if needed } }