GetCurrentDevice will list devices managed
Change-Id: I83202aa5b4f9af8e4b1e662b589ce8d795808a8d
diff --git a/demo_test/test.go b/demo_test/test.go
index 05582ad..d1d7ca9 100644
--- a/demo_test/test.go
+++ b/demo_test/test.go
@@ -128,8 +128,11 @@
vendorinfo.Vendor = vendor
var ret_msg *importer.EventList
ret_msg, err := cc.GetEventList(ctx, vendorinfo)
-
- return err, ret_msg.Events
+ if err != nil {
+ return err, nil
+ } else {
+ return err, ret_msg.Events
+ }
}
/*///////////////////////////////////////////////////////////////////////*/
@@ -143,8 +146,11 @@
currentdeviceinfo.IpAddress = ip_address
var ret_msg *importer.EventList
ret_msg, err := cc.GetCurrentEventList(ctx, currentdeviceinfo)
-
- return err, ret_msg.Events
+ if err != nil {
+ return err, nil
+ } else {
+ return err, ret_msg.Events
+ }
}
/*///////////////////////////////////////////////////////////////////////*/
@@ -161,6 +167,23 @@
return err
}
+/*///////////////////////////////////////////////////////////////////////*/
+// Allows user to get the current devices that are monitored
+//
+//
+/*///////////////////////////////////////////////////////////////////////*/
+func GetCurrentDevices() (error, []string) {
+ fmt.Println("Testing GetCurrentDevices\n")
+ empty := new(importer.Empty)
+ var ret_msg *importer.DeviceList
+ ret_msg, err := cc.GetCurrentDevices(ctx, empty)
+ if err != nil {
+ return err, nil
+ } else {
+ return err, ret_msg.Ip
+ }
+}
+
func init() {
Formatter := new(log.TextFormatter)
Formatter.TimestampFormat = "02-01-2006 15:04:05"
@@ -439,6 +462,26 @@
}
}
+ case "showdevices":
+ cmd_size := len(s)
+ fmt.Print("cmd is :", cmd, cmd_size)
+ if cmd_size > 2 || cmd_size < 0 {
+ fmt.Print("error event !!")
+ newmessage = "error event !!"
+ } else {
+ err, currentlist := GetCurrentDevices()
+
+ if err != nil {
+ errStatus, _ := status.FromError(err)
+ fmt.Println(errStatus.Message())
+ fmt.Println(errStatus.Code())
+ newmessage = errStatus.Message()
+ fmt.Print("showdevices error!!")
+ } else {
+ fmt.Print("showdevices ", currentlist)
+ newmessage = strings.Join(currentlist[:], ", ")
+ }
+ }
case "QUIT":
loop = false
newmessage = "QUIT"