Skip to content

Commit c4c6a78

Browse files
Giuseppe Lumiapolldo
Giuseppe Lumia
authored andcommitted
Improve naming on ping command
With the addition of the `device` command it could be confusing what `username` and `password` refer to (are they a virtual device's ID and secret or are they an IoT API client ID and secret?).
1 parent 563043d commit c4c6a78

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Use this command to provision a device:
3636
The iot-cloud-cli can be used as a virtual device for Arduino IoT Cloud for testing.
3737

3838
```
39-
$ iot-cloud-cli ping -u "<deviceId>" -p "<secret>" -t <thing ID>>
39+
$ iot-cloud-cli ping -d "<deviceId>" -s "<secret>" -t <thing ID>>
4040
Connected to Arduino IoT Cloud
4141
Subscribed true
4242
Property value sent successfully 81
@@ -71,7 +71,7 @@ You should connect the new device to the new thing.
7171
##### Connect to the PROD environment
7272

7373
```shell
74-
$ iot-cloud-cli ping -u "<Device ID>" -p "<Secret Key>" -t <Thing ID>>
74+
$ iot-cloud-cli ping -d "<Device ID>" -s "<Secret Key>" -t <Thing ID>>
7575
```
7676

7777
If every works as expected you should see something similar to this output:
@@ -89,5 +89,5 @@ If you visit https://create.arduino.cc/iot/devices the "Generic ESP8266 Module"
8989
The DEV environment is using a different broker, so you need to add the option `--host`:
9090

9191
```shell
92-
$ iot-cloud-cli ping --host tcps://mqtts-sa.iot.oniudra.cc:8884 -u "<Device ID>" -p "<Secret Key>" -t "<thing-id>"
92+
$ iot-cloud-cli ping --host tcps://mqtts-sa.iot.oniudra.cc:8884 -d "<Device ID>" -s "<Secret Key>" -t "<thing-id>"
9393
```

cli/ping/ping.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import (
77

88
var (
99
host string
10-
username string
11-
password string
12-
thingID string
10+
device string
11+
secret string
12+
thing string
1313
troubleshooting bool
1414
)
1515

@@ -21,26 +21,26 @@ func NewCommand() *cobra.Command {
2121
RunE: runPingCommand,
2222
}
2323

24-
pingCommand.Flags().StringVarP(&host, "host", "b", "tcps://mqtts-up.iot.arduino.cc:8884", "Broker endpoint")
25-
pingCommand.Flags().StringVarP(&username, "username", "u", "", "Username (required)")
26-
pingCommand.Flags().StringVarP(&password, "password", "p", "", "Password (required)")
27-
pingCommand.Flags().StringVarP(&thingID, "thing_id", "t", "", "Thing ID (required)")
24+
pingCommand.Flags().StringVarP(&host, "host", "b", "tcps://mqtts-up.iot.arduino.cc:8884", "MQTT Broker URL")
25+
pingCommand.Flags().StringVarP(&device, "device", "d", "", "Device ID")
26+
pingCommand.Flags().StringVarP(&secret, "secret", "s", "", "Device Secret")
27+
pingCommand.Flags().StringVarP(&thing, "thing", "t", "", "Thing ID")
2828

2929
pingCommand.Flags().BoolVar(&troubleshooting, "troubleshooting", false, "Enable troubleshooting mode (full logs from the MQTT client)")
3030

31-
pingCommand.MarkFlagRequired("username")
32-
pingCommand.MarkFlagRequired("password")
33-
pingCommand.MarkFlagRequired("thing_id")
31+
pingCommand.MarkFlagRequired("device")
32+
pingCommand.MarkFlagRequired("secret")
33+
pingCommand.MarkFlagRequired("thing")
3434

3535
return pingCommand
3636
}
3737

3838
func runPingCommand(cmd *cobra.Command, args []string) error {
3939
params := &ping.Params{
4040
Host: host,
41-
Username: username,
42-
Password: password,
43-
ThingID: thingID,
41+
Username: device,
42+
Password: secret,
43+
ThingID: thing,
4444
Troubleshooting: troubleshooting,
4545
}
4646

command/ping/ping.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ import (
1515
)
1616

1717
type Params struct {
18-
Host string
19-
Username string
20-
Password string
21-
ThingID string
22-
Troubleshooting bool
18+
Host string // MQTT Broker URL
19+
Username string // Virtual device ID
20+
Password string // Virtual device secret
21+
ThingID string // ID of thing with `int` property named `counter` attached to the virtual device
22+
Troubleshooting bool // Enable/disable verbose logging of MQTT client
2323
}
2424

2525
func Ping(params *Params) error {

0 commit comments

Comments
 (0)