Browse Source

Added 404 on page not found instead of redirection to login page when not logged in, added HDSv1 protocol handler (exp)

TC pushbot 5 4 years ago
parent
commit
3392a75c4b

+ 0 - 27
arsm.go

@@ -84,31 +84,4 @@ func ArsmInit() {
 		RequireAdmin: false,
 		RequireAdmin: false,
 	})
 	})
 
 
-	/*
-		WsTerminal
-
-		The terminal that perform remote WebSocket based reverse ssh
-	*/
-	/*
-		wstRouter := prout.NewModuleRouter(prout.RouterOption{
-			ModuleName:  "System Setting",
-			AdminOnly:   true,
-			UserHandler: userHandler,
-			DeniedHandler: func(w http.ResponseWriter, r *http.Request) {
-				sendErrorResponse(w, "Permission Denied")
-			},
-		})
-
-		//Register settings
-		registerSetting(settingModule{
-			Name:         "WsTerminal",
-			Desc:         "Remote WebSocket Shell Terminal",
-			IconPath:     "SystemAO/arsm/img/wst.png",
-			Group:        "Cluster",
-			StartDir:     "SystemAO/arsm/wsterminal.html",
-			RequireAdmin: true,
-		})
-
-		log.Println("WebSocket Terminal, WIP: ", wstRouter)
-	*/
 }
 }

+ 6 - 3
examples/HomeDynamic2/Examples/Examples.ino

@@ -141,16 +141,19 @@ void handle_output() {
   server.send(200, "text/html", "OK"); 
   server.send(200, "text/html", "OK"); 
 }
 }
 
 
-
+//This function return the status of the current device. 
+//If the name of status matches one of the input endpoints, the value will be used as auto fill
 void handle_status() {
 void handle_status() {
   server.send(200, "application/json", "{\
   server.send(200, "application/json", "{\
+  \"Global Status\":\"It is working\",\
   \"String Input\":\"default value\",\
   \"String Input\":\"default value\",\
-  \"Integer Input\":1234,\
-  \"Float Input\":123.4,\
+  \"Integer Input\":8,\
+  \"Float Input\":4.5,\
   \"Boolean Input\":true\
   \"Boolean Input\":true\
 }"); 
 }"); 
 }
 }
 
 
+//This function define all the endpoint accessiable in this device
 void handle_endpoints() {
 void handle_endpoints() {
   server.send(200, "application/json", "[\
   server.send(200, "application/json", "[\
   {\
   {\

+ 6 - 0
iot.go

@@ -4,6 +4,7 @@ import (
 	"net/http"
 	"net/http"
 
 
 	"imuslab.com/arozos/mod/iot"
 	"imuslab.com/arozos/mod/iot"
+	"imuslab.com/arozos/mod/iot/hds"
 	"imuslab.com/arozos/mod/iot/hdsv2"
 	"imuslab.com/arozos/mod/iot/hdsv2"
 	module "imuslab.com/arozos/mod/modules"
 	module "imuslab.com/arozos/mod/modules"
 	prout "imuslab.com/arozos/mod/prouter"
 	prout "imuslab.com/arozos/mod/prouter"
@@ -70,11 +71,16 @@ func IoTHubInit() {
 		//IoT Panel control APIs
 		//IoT Panel control APIs
 		router.HandleFunc("/system/iot/scan", iotManager.HandleScanning)
 		router.HandleFunc("/system/iot/scan", iotManager.HandleScanning)
 		router.HandleFunc("/system/iot/list", iotManager.HandleListing)
 		router.HandleFunc("/system/iot/list", iotManager.HandleListing)
+		router.HandleFunc("/system/iot/status", iotManager.HandleGetDeviceStatus)
 
 
 		//IoT Hub Info APIs
 		//IoT Hub Info APIs
 		adminRouter.HandleFunc("/system/iot/listScanner", iotManager.HandleScannerList)
 		adminRouter.HandleFunc("/system/iot/listScanner", iotManager.HandleScannerList)
 
 
 		//Start of the IoT Management Handlers
 		//Start of the IoT Management Handlers
+		//Home Dynamic v1 (Legacy)
+		hdsHandler := hds.NewProtocolHandler()
+		iotManager.RegisterHandler(hdsHandler)
+
 		//Home Dynamic v2
 		//Home Dynamic v2
 		hdsv2Handler := hdsv2.NewProtocolHandler(MDNS)
 		hdsv2Handler := hdsv2.NewProtocolHandler(MDNS)
 		iotManager.RegisterHandler(hdsv2Handler)
 		iotManager.RegisterHandler(hdsv2Handler)

+ 5 - 2
main.router.go

@@ -132,7 +132,10 @@ func mroutner(h http.Handler) http.Handler {
 
 
 		} else {
 		} else {
 			//User not logged in. Check if the path end with public/. If yes, allow public access
 			//User not logged in. Check if the path end with public/. If yes, allow public access
-			if r.URL.Path[len(r.URL.Path)-1:] != "/" && filepath.Base(filepath.Dir(r.URL.Path)) == "public" {
+			if !fs.FileExists(filepath.Join("./web", r.URL.Path)) {
+				//Requested file not exists on the server. Return not found
+				errorHandleNotFound(w, r)
+			} else if r.URL.Path[len(r.URL.Path)-1:] != "/" && filepath.Base(filepath.Dir(r.URL.Path)) == "public" {
 				//This file path end with public/. Allow public access
 				//This file path end with public/. Allow public access
 				h.ServeHTTP(w, r)
 				h.ServeHTTP(w, r)
 			} else if *allow_homepage == true && r.URL.Path[:10] == "/homepage/" {
 			} else if *allow_homepage == true && r.URL.Path[:10] == "/homepage/" {
@@ -141,7 +144,7 @@ func mroutner(h http.Handler) http.Handler {
 			} else {
 			} else {
 				//Other paths
 				//Other paths
 				if *allow_homepage {
 				if *allow_homepage {
-					//Redirect to home page
+					//Redirect to home page if home page function is enabled
 					http.Redirect(w, r, "/homepage/index.html", 307)
 					http.Redirect(w, r, "/homepage/index.html", 307)
 				} else {
 				} else {
 					//Rediect to login page
 					//Rediect to login page

+ 39 - 15
mod/iot/handlerManager.go

@@ -17,6 +17,7 @@ import (
 
 
 type Manager struct {
 type Manager struct {
 	RegisteredHandler []ProtocolHandler
 	RegisteredHandler []ProtocolHandler
+	cachedDeviceList  []*Device
 }
 }
 
 
 func NewIoTManager() *Manager {
 func NewIoTManager() *Manager {
@@ -52,6 +53,35 @@ func (m *Manager) HandleScannerList(w http.ResponseWriter, r *http.Request) {
 	sendJSONResponse(w, string(js))
 	sendJSONResponse(w, string(js))
 }
 }
 
 
+//Get status of the given device ID
+func (m *Manager) HandleGetDeviceStatus(w http.ResponseWriter, r *http.Request) {
+	devid, err := mv(r, "devid", true)
+	if err != nil {
+		sendErrorResponse(w, "Invalid device id")
+		return
+	}
+
+	//Search for that device ID
+	for _, dev := range m.cachedDeviceList {
+		if dev.DeviceUUID == devid {
+			//Found. Get it status and return
+			status, err := dev.Handler.Status(dev)
+			if err != nil {
+				sendErrorResponse(w, err.Error())
+				return
+			}
+
+			//Return the status
+			js, _ := json.Marshal(status)
+			sendJSONResponse(w, string(js))
+			return
+		}
+	}
+
+	//Not found
+	sendErrorResponse(w, "Given device ID does not match any scanned devices")
+}
+
 //Handle IoT Scanning Request
 //Handle IoT Scanning Request
 func (m *Manager) HandleScanning(w http.ResponseWriter, r *http.Request) {
 func (m *Manager) HandleScanning(w http.ResponseWriter, r *http.Request) {
 	scannedDevices := []*Device{}
 	scannedDevices := []*Device{}
@@ -68,26 +98,20 @@ func (m *Manager) HandleScanning(w http.ResponseWriter, r *http.Request) {
 		}
 		}
 	}
 	}
 
 
+	//Cache the scan record
+	m.cachedDeviceList = scannedDevices
 	js, _ := json.Marshal(scannedDevices)
 	js, _ := json.Marshal(scannedDevices)
 	sendJSONResponse(w, string(js))
 	sendJSONResponse(w, string(js))
 }
 }
 
 
 //Handle IoT Listing Request
 //Handle IoT Listing Request
 func (m *Manager) HandleListing(w http.ResponseWriter, r *http.Request) {
 func (m *Manager) HandleListing(w http.ResponseWriter, r *http.Request) {
-	listedDevices := []*Device{}
-	for _, ph := range m.RegisteredHandler {
-		//Scan devices using this handler
-		thisProtcolDeviceList, err := ph.List()
-		if err != nil {
-			continue
-		}
-
-		//Append it to list
-		for _, dev := range thisProtcolDeviceList {
-			listedDevices = append(listedDevices, dev)
-		}
+	if m.cachedDeviceList == nil || len(m.cachedDeviceList) == 0 {
+		//Scan results not exists. Scan again
+		m.HandleScanning(w, r)
+	} else {
+		//Cache already exists. Return it
+		js, _ := json.Marshal(m.cachedDeviceList)
+		sendJSONResponse(w, string(js))
 	}
 	}
-
-	js, _ := json.Marshal(listedDevices)
-	sendJSONResponse(w, string(js))
 }
 }

+ 130 - 0
mod/iot/hds/hds.go

@@ -0,0 +1,130 @@
+package hds
+
+import (
+	"errors"
+	"log"
+	"strconv"
+	"strings"
+	"sync"
+
+	"imuslab.com/arozos/mod/iot"
+)
+
+/*
+	Home Dynamic System
+	Author: tobychui
+
+	This is a compaitbility module for those who are still using HDSv1 protocol
+	If you are still using HDSv1, you should consider upgrading it to the latest
+	version of HDS protocols.
+*/
+
+type Handler struct {
+	lastScanTime int64
+}
+
+//Create a new HDS Protocol Handler
+func NewProtocolHandler() *Handler {
+	//Create a new MDNS Host
+	return &Handler{}
+}
+
+//Start the HDSv1 scanner, which no startup process is required
+func (h *Handler) Start() error {
+	log.Println("*IoT* Home Dynamic System (Legacy) Loaded")
+	return nil
+}
+
+//Scan all the HDS devices in LAN using the legacy ip scanner methods
+func (h *Handler) Scan() ([]*iot.Device, error) {
+	//Get the current local IP address
+	ip := getLocalIP()
+	if ip == "" {
+		//Not connected to a network?
+		return nil, errors.New("Unable to get ip address of host device")
+	}
+
+	//Only handle a small subset of ip ranges (Last 255 addfress)
+	scanBase := ""
+	valid := false
+	if ip[:8] == "192.168." {
+		tmp := strings.Split(ip, ".")
+		tmp = tmp[:len(tmp)-1]
+		scanBase = strings.Join(tmp, ".") + "." //Return 192.168.0.
+		valid = true
+	} else if ip[:4] == "172." {
+		//Handle 172.16.x.x - 172.31.x.x
+		tmp := strings.Split(ip, ".")
+		val, err := strconv.Atoi(tmp[1])
+		if err == nil {
+			if val >= 16 && val <= 31 {
+				//Private addr range
+				valid = true
+				scanBase = strings.Join(tmp, ".") + "." //Return 172.16.0.
+			}
+		}
+	}
+
+	//Check if the IP range is supported by HDS protocol
+	if !valid {
+		log.Println("*IoT* Home Dynamic Protocol requirement not satisfied. Skipping Scan")
+		return nil, nil
+	}
+
+	//Create a IP scanner
+	var wg sync.WaitGroup
+	for i := 1; i < 256; i++ {
+		wg.Add(1)
+		go tryGetHDSUUID(&wg, scanBase+strconv.Itoa(i))
+	}
+
+	log.Println("*IoT* Home Dynamic waiting for responses")
+	wg.Wait()
+
+	log.Println("*IoT* Home Dynamic - DONE")
+	return nil, nil
+}
+
+//Home Dynamic system's devices no need to established conenction before executing anything
+func (h *Handler) Connect(device *iot.Device, authInfo *iot.AuthInfo) error {
+	return nil
+}
+
+//Same rules also apply to disconnect
+func (h *Handler) Disconnect(device *iot.Device) error {
+	return nil
+}
+
+//Get the status of the device
+func (h *Handler) Execute(device *iot.Device, endpoint *iot.Endpoint, payload interface{}) (interface{}, error) {
+	var result interface{}
+	return result, nil
+}
+
+//Get the status of the device
+func (h *Handler) Status(device *iot.Device) (map[string]interface{}, error) {
+	resp, err := tryGet("http://" + device.IPAddr + "/status")
+	if err != nil {
+		return map[string]interface{}{}, err
+	}
+
+	//Convert the resp into map string itnerface
+	result := map[string]interface{}{}
+	result["status"] = resp
+
+	return result, nil
+}
+
+//Return the specification of this protocol handler
+func (h *Handler) Stats() iot.Stats {
+	return iot.Stats{
+		Name:          "Home Dynamic",
+		Desc:          "A basic IoT communication protocol for ESP8266 for ArOZ Online Beta",
+		Version:       "1.0",
+		ProtocolVer:   "1.0",
+		Author:        "tobychui",
+		AuthorWebsite: "https://git.hkwtc.org/TC/HomeDynamic",
+		AuthorEmail:   "",
+		ReleaseDate:   1576094199,
+	}
+}

+ 66 - 0
mod/iot/hds/utils.go

@@ -0,0 +1,66 @@
+package hds
+
+import (
+	"encoding/json"
+	"errors"
+	"io/ioutil"
+	"net"
+	"net/http"
+	"strconv"
+	"sync"
+	"time"
+)
+
+func isJSON(s string) bool {
+	var js map[string]interface{}
+	return json.Unmarshal([]byte(s), &js) == nil
+}
+
+func tryGet(url string) (string, error) {
+	client := http.Client{
+		Timeout: 5 * time.Second,
+	}
+
+	resp, err := client.Get(url)
+	if err != nil {
+		return "", err
+	}
+
+	if resp.StatusCode != 200 {
+		return "", errors.New("Server side return status code " + strconv.Itoa(resp.StatusCode))
+	}
+
+	content, err := ioutil.ReadAll(resp.Body)
+	if err != nil {
+		return "", err
+	}
+
+	return string(content), nil
+}
+
+//Check if the given ip address is HDS device, return its UUID if true
+func tryGetHDSUUID(wg *sync.WaitGroup, ip string) (string, error) {
+	defer wg.Done()
+	uuid, err := tryGet("http://" + ip + "/uuid")
+	if err != nil {
+		return "", err
+	}
+
+	return uuid, nil
+}
+
+func getLocalIP() string {
+	addrs, err := net.InterfaceAddrs()
+	if err != nil {
+		return ""
+	}
+	for _, address := range addrs {
+		// check the address type and if it is not a loopback the display it
+		if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
+			if ipnet.IP.To4() != nil {
+				return ipnet.IP.String()
+			}
+		}
+	}
+	return ""
+}

+ 0 - 9
mod/iot/hdsv2/hdsv2.go

@@ -23,7 +23,6 @@ import (
 
 
 type Handler struct {
 type Handler struct {
 	scanner      *mdns.MDNSHost
 	scanner      *mdns.MDNSHost
-	historyList  []*iot.Device
 	lastScanTime int64
 	lastScanTime int64
 }
 }
 
 
@@ -32,7 +31,6 @@ func NewProtocolHandler(scanner *mdns.MDNSHost) *Handler {
 	//Create a new MDNS Host
 	//Create a new MDNS Host
 	return &Handler{
 	return &Handler{
 		scanner,
 		scanner,
-		[]*iot.Device{},
 		0,
 		0,
 	}
 	}
 }
 }
@@ -83,16 +81,9 @@ func (h *Handler) Scan() ([]*iot.Device, error) {
 		foundDevices = append(foundDevices, &thisDevice)
 		foundDevices = append(foundDevices, &thisDevice)
 	}
 	}
 
 
-	h.historyList = foundDevices
-
 	return foundDevices, nil
 	return foundDevices, nil
 }
 }
 
 
-//Return the history scan list from the handler
-func (h *Handler) List() ([]*iot.Device, error) {
-	return h.historyList, nil
-}
-
 //Home Dynamic system's devices no need to established conenction before executing anything
 //Home Dynamic system's devices no need to established conenction before executing anything
 func (h *Handler) Connect(device *iot.Device, authInfo *iot.AuthInfo) error {
 func (h *Handler) Connect(device *iot.Device, authInfo *iot.AuthInfo) error {
 	return nil
 	return nil

+ 1 - 2
mod/iot/iot.go

@@ -63,8 +63,7 @@ var (
 
 
 type ProtocolHandler interface {
 type ProtocolHandler interface {
 	Start() error                                                                         //Run Startup check. This IoT Protocl Handler will not load if this return any error (e.g. required wireless hardware not found) **TRY NOT TO USE BLOCKING LOGIC HERE**
 	Start() error                                                                         //Run Startup check. This IoT Protocl Handler will not load if this return any error (e.g. required wireless hardware not found) **TRY NOT TO USE BLOCKING LOGIC HERE**
-	Scan() ([]*Device, error)                                                             //Scan the nearby devices
-	List() ([]*Device, error)                                                             //Return the previous scanned list
+	Scan() ([]*Device, error)                                                             //Scan the nearby devices                                                        //Return the previous scanned list
 	Connect(device *Device, authInfo *AuthInfo) error                                     //Connect to the device
 	Connect(device *Device, authInfo *AuthInfo) error                                     //Connect to the device
 	Status(device *Device) (map[string]interface{}, error)                                //Get status of the IoT device
 	Status(device *Device) (map[string]interface{}, error)                                //Get status of the IoT device
 	Execute(device *Device, endpoint *Endpoint, payload interface{}) (interface{}, error) //Execute an endpoint for a device
 	Execute(device *Device, endpoint *Endpoint, payload interface{}) (interface{}, error) //Execute an endpoint for a device

+ 2 - 0
mod/subservice/subservice.go

@@ -172,11 +172,13 @@ func (sr *SubServiceRouter) Launch(servicePath string, startupMode bool) error {
 
 
 	//Clean the module info and append it into the module list
 	//Clean the module info and append it into the module list
 	serviceLaunchInfo := strings.TrimSpace(string(out))
 	serviceLaunchInfo := strings.TrimSpace(string(out))
+
 	thisModuleInfo := modules.ModuleInfo{}
 	thisModuleInfo := modules.ModuleInfo{}
 	err := json.Unmarshal([]byte(serviceLaunchInfo), &thisModuleInfo)
 	err := json.Unmarshal([]byte(serviceLaunchInfo), &thisModuleInfo)
 	if err != nil {
 	if err != nil {
 		if startupMode {
 		if startupMode {
 			log.Fatal("Failed to load subservice: "+serviceRoot+"\n", err.Error())
 			log.Fatal("Failed to load subservice: "+serviceRoot+"\n", err.Error())
+
 		} else {
 		} else {
 			return errors.New("Failed to load subservice: " + serviceRoot)
 			return errors.New("Failed to load subservice: " + serviceRoot)
 		}
 		}

+ 0 - 10
network.go

@@ -50,16 +50,6 @@ func NetworkServiceInit() {
 		})
 		})
 	}
 	}
 
 
-	/*
-		registerSetting(settingModule{
-			Name:     "Ping test",
-			Desc:     "System Information",
-			IconPath: "SystemAO/network/img/ethernet.png",
-			Group:    "Network",
-			StartDir: "SystemAO/network/ping.html",
-		})
-	*/
-
 	//Start the services that depends on network interface
 	//Start the services that depends on network interface
 	StartNetworkServices()
 	StartNetworkServices()
 
 

+ 10 - 0
startup.flags.go

@@ -18,6 +18,16 @@ import (
 
 
 func StartupFlagsInit() {
 func StartupFlagsInit() {
 	//Create a admin permission router for handling requests
 	//Create a admin permission router for handling requests
+	//Register a boot flag modifier
+	registerSetting(settingModule{
+		Name:         "Startup",
+		Desc:         "Platform Startup Flags",
+		IconPath:     "SystemAO/info/img/small_icon.png",
+		Group:        "Info",
+		StartDir:     "SystemAO/boot/bootflags.html",
+		RequireAdmin: true,
+	})
+
 	adminRouter := prout.NewModuleRouter(prout.RouterOption{
 	adminRouter := prout.NewModuleRouter(prout.RouterOption{
 		AdminOnly:   true,
 		AdminOnly:   true,
 		UserHandler: userHandler,
 		UserHandler: userHandler,

+ 1 - 1
startup.go

@@ -44,7 +44,7 @@ func RunStartup() {
 	RegisterSystemInit()   //See register.go
 	RegisterSystemInit()   //See register.go
 	GroupStoragePoolInit() //Register permission groups's storage pool, require permissionInit()
 	GroupStoragePoolInit() //Register permission groups's storage pool, require permissionInit()
 
 
-	//6.Start Modules and Package Manager
+	//6. Start Modules and Package Manager
 	ModuleServiceInit() //Module Handler
 	ModuleServiceInit() //Module Handler
 	PackagManagerInit() //Start APT service agent
 	PackagManagerInit() //Start APT service agent
 
 

+ 0 - 8
system.info.go

@@ -91,14 +91,6 @@ func SystemInfoInit() {
 
 
 	}
 	}
 
 
-	//Register a boot flag modifier
-	registerSetting(settingModule{
-		Name:     "Startup",
-		Desc:     "Platform Startup Flags",
-		IconPath: "SystemAO/info/img/small_icon.png",
-		Group:    "Info",
-		StartDir: "SystemAO/boot/bootflags.html",
-	})
 }
 }
 
 
 func InfoHandleTaskInfo(w http.ResponseWriter, r *http.Request) {
 func InfoHandleTaskInfo(w http.ResponseWriter, r *http.Request) {

+ 0 - 0
system/receiptTool.db.lock


+ 54 - 2
web/SystemAO/iot/hub/index.html

@@ -131,6 +131,10 @@
 			  Device Actions
 			  Device Actions
 		   </div>
 		   </div>
 		   <br>
 		   <br>
+		   <div class="ts horizontal form" id="statusList">
+				<h3>No Status</h3>
+		   </div>
+		   <div class="ts divider"></div>
 		   <div class="ts horizontal form" id="actionForm">
 		   <div class="ts horizontal form" id="actionForm">
 
 
 			</div>
 			</div>
@@ -290,7 +294,7 @@
 					var deviceID = deviceData.DeviceUUID;
 					var deviceID = deviceData.DeviceUUID;
 					var name = ept.Name;
 					var name = ept.Name;
 					if (ept.Type == "string"){
 					if (ept.Type == "string"){
-						$("#actionForm").append(`<div devid="${deviceID}" epd="${encodedEptData}" class="field">
+						$("#actionForm").append(`<div name="${ept.Name}" devid="${deviceID}" epd="${encodedEptData}" class="field">
 							<label>${ept.Desc}</label>
 							<label>${ept.Desc}</label>
 							<div class="ts action input">
 							<div class="ts action input">
 								<input type="text" placeholder="${name}">
 								<input type="text" placeholder="${name}">
@@ -308,7 +312,7 @@
 							max = ept.Max;
 							max = ept.Max;
 						}
 						}
 
 
-						$("#actionForm").append(`<div devid="${deviceID}" epd="${encodedEptData}" class="field">
+						$("#actionForm").append(`<div name="${ept.Name}" devid="${deviceID}" epd="${encodedEptData}" class="field">
 							<label>${ept.Desc}</label>
 							<label>${ept.Desc}</label>
 							<div class="ts action input">
 							<div class="ts action input">
 								<input type="number" min="${min}" max="${max}" placeholder="${name}">
 								<input type="number" min="${min}" max="${max}" placeholder="${name}">
@@ -352,7 +356,55 @@
 						</div>`);
 						</div>`);
 					}
 					}
 				});
 				});
+
+				//Get its status
+				$.ajax({
+					url: "../../../system/iot/status",
+					data: {devid: deviceData.DeviceUUID},
+					success: function(data){
+						//Look for fields that have the same name. If not, append it to status field
+						if (data.error !== undefined){
+							$("#statusList").html(`<h3>Connection Lost</h3><br><p>${data.error}</p>`);
+						}else{
+							//OK! Append it
+							$("#statusList").html("");
+							for (var key in data) {
+								var found = false;
+								$("#actionForm").find(".field").each(function(){
+									var thisName = $(this).attr("name");
+									if (thisName == key){
+										//Set its value
+										var targetInput = $(this).find("input");
+										if (targetInput.attr('type') == "checkbox"){
+											//For handling checkbox
+											if (data[key] == true){
+												targetInput[0].checked = true;
+											}else{
+												targetInput[0].checked = false;
+											}
+										}else{
+											//For handling other input fields
+											$(this).find("input").val(data[key]);
+										}
+										
+										found = true;
+									}
+								});
+
+								if (found == false){
+									//Append to status field
+									$("#statusList").append(`<div class="ts header">
+										${data[key]}
+										<div class="sub header"><i class="marker icon"></i> ${key}</div>
+									</div>`);
+								}
+							}
+
+						}
+					}
+				})
 			}
 			}
+
 			console.log(deviceData);
 			console.log(deviceData);
 
 
 			$("#actioninterface").fadeIn('fast');
 			$("#actioninterface").fadeIn('fast');