Skip to content

Commit 71f091b

Browse files
committed
Added device status
1 parent a3382fe commit 71f091b

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

cli/device/list.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,24 @@ func (r listResult) String() string {
9292
return "No devices found."
9393
}
9494
t := table.New()
95-
t.SetHeader("Name", "ID", "Board", "FQBN", "SerialNumber", "Tags")
95+
t.SetHeader("Name", "ID", "Board", "FQBN", "SerialNumber", "Status", "Tags")
9696
for _, device := range r.devices {
9797
t.AddRow(
9898
device.Name,
9999
device.ID,
100100
device.Board,
101101
device.FQBN,
102102
device.Serial,
103+
dereferenceString(device.Status),
103104
strings.Join(device.Tags, ","),
104105
)
105106
}
106107
return t.Render()
107108
}
109+
110+
func dereferenceString(s *string) string {
111+
if s == nil {
112+
return ""
113+
}
114+
return *s
115+
}

command/device/device.go

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type DeviceInfo struct {
3131
Serial string `json:"serial_number"`
3232
FQBN string `json:"fqbn"`
3333
Tags []string `json:"tags,omitempty"`
34+
Status *string `json:"status,omitempty"`
3435
}
3536

3637
func getDeviceInfo(device *iotclient.ArduinoDevicev2) (*DeviceInfo, error) {
@@ -47,6 +48,7 @@ func getDeviceInfo(device *iotclient.ArduinoDevicev2) (*DeviceInfo, error) {
4748
Serial: device.Serial,
4849
FQBN: dereferenceString(device.Fqbn),
4950
Tags: tags,
51+
Status: device.DeviceStatus,
5052
}
5153
return dev, nil
5254
}

0 commit comments

Comments
 (0)