|
1 |
| -iot-cloud-cli is a command line interface that allows to exploit the features of Arduino IoT Cloud. As of now, it is possible to provision a device. |
| 1 | +# iot-cloud-cli |
| 2 | + |
| 3 | +iot-cloud-cli is a command line interface that allows to exploit the features of Arduino IoT Cloud. As of now, it is possible to provision a device and to simulate a device to be connected to the cloud using MQTT for thoubleshooting purpose. |
2 | 4 |
|
3 | 5 | ### Requirements
|
4 | 6 |
|
5 | 7 | This is all you need to use iot-cloud-cli for device **provisioning**:
|
6 | 8 | * A client ID and a secret ID, retrievable from the [cloud](https://create.arduino.cc/iot/integrations) by creating a new API key
|
7 |
| - * The folder containing the precompiled provisioning firmwares (`binaries`) needs to be in the same location you run the command from |
| 9 | + * arduino-cli in daemon mode, use the command 'arduino-cli daemon' |
| 10 | + |
| 11 | +This is all you need to use iot-cloud-cli as a **virtual device**: |
| 12 | + * A "Generic ESP8266 Module" or "Generic ESP32 Module" device in IoT Cloud (requires a Maker plan) |
| 13 | + * A thing with a `counter` property connected to the "Generic ESP8266/ESP32 Module" device |
| 14 | + |
8 | 15 |
|
9 | 16 | ## Set a configuration
|
10 | 17 |
|
11 |
| -iot-cloud-cli needs to be configured before being used. In particular a client ID and the corresponding secret ID should be set. |
| 18 | +iot-cloud-cli should be configured before being used. In particular a client ID and the corresponding secret ID should be set. |
12 | 19 | You can retrieve them from the [cloud](https://create.arduino.cc/iot/integrations) by creating a new API key.
|
13 | 20 |
|
14 | 21 | Once you have the IDs, call this command with your parameters:
|
15 | 22 |
|
16 | 23 | `$ iot-cloud-cli config -c <clientID> -s <secretID>`
|
17 | 24 |
|
18 |
| -A file named `config.yaml` will be created in the Current Working Directory containing the login credentials. |
19 |
| -Example |
| 25 | +## Device provisioning |
| 26 | + |
| 27 | +When provisioning a device, you can optionally explicit the port which the device is connected to and its fqbn. If they are not given, then the first device found is provisioned. |
| 28 | +Use this command to provision a device: |
| 29 | + |
| 30 | +`$ iot-cloud-cli device create --name <deviceName> --port <port> --fqbn <deviceFqbn>` |
| 31 | + |
| 32 | + |
| 33 | +## Use iot-cloud-cli as a virtual device |
| 34 | + |
| 35 | +The iot-cloud-cli can be used as a virtual device for Arduino IoT Cloud for testing. |
20 | 36 |
|
21 |
| -```yaml |
22 |
| -client: 00112233445566778899aabbccddeeff |
23 |
| -secret: 00112233445566778899aabbccddeeffffeeddccbbaa99887766554433221100 |
| 37 | +``` |
| 38 | +$ iot-cloud-cli ping -u "<deviceId>" -p "<secret>" -t <thing ID>> |
| 39 | + Connected to Arduino IoT Cloud |
| 40 | + Subscribed true |
| 41 | + Property value sent successfully 81 |
| 42 | + Property value sent successfully 87 |
24 | 43 | ```
|
25 | 44 |
|
26 |
| -## Device provisioning |
| 45 | +### How to set up the device and thing in IoT Cloud |
27 | 46 |
|
28 |
| -When provisioning a device, you can optionally specify the port to which the device is connected to and its fqbn. If they are not given, then the first device found will be provisioned. |
| 47 | +#### Device |
29 | 48 |
|
30 |
| -Use this command to provision a device: |
| 49 | + * Visit https://create.arduino.cc/iot/devices and select "Add device". |
| 50 | + * Select "Set up a 3rd party device". |
| 51 | + * Select "ESP8266". |
| 52 | + * From the drop down select "Generic ESP8266 Module", and click "Continue". |
| 53 | + * Pick a nice and friendly device name. |
| 54 | + * Save the "Device ID" and "Secret Key" is a safe place, because you will not be able to see them anymore. |
| 55 | + |
| 56 | +#### Thing ID |
31 | 57 |
|
32 |
| -`$ iot-cloud-cli device create --name <deviceName> --port <port> --fqbn <deviceFqbn>` |
| 58 | + * Visit https://create.arduino.cc/iot/things and select "Create Thing". |
| 59 | + * Select "Add Variable". |
| 60 | + * Give the variable the name "counter", type "Integer Number" and leave the variable permission the value "Read & Write". |
| 61 | + * Press the "Add Variable" button to confirm. |
| 62 | + * Copy the "Thing ID" from the bottom right of the page. |
| 63 | + |
| 64 | +#### Connect the device and the thing |
| 65 | + |
| 66 | +You should connect the new device to the new thing. |
| 67 | + |
| 68 | +#### Testing |
| 69 | + |
| 70 | +##### Connect to the PROD environment |
| 71 | + |
| 72 | +```shell |
| 73 | +$ iot-cloud-cli ping -u "<Device ID>" -p "<Secret Key>" -t <Thing ID>> |
| 74 | +``` |
| 75 | + |
| 76 | +If every works as expected you should see something similar to this output: |
| 77 | +``` |
| 78 | +Connected to Arduino IoT Cloud |
| 79 | +Subscribed true |
| 80 | +Property value sent successfully 81 |
| 81 | +Property value sent successfully 87 |
| 82 | +``` |
| 83 | + |
| 84 | +If you visit https://create.arduino.cc/iot/devices the "Generic ESP8266 Module" device status should be "Online". |
| 85 | + |
| 86 | +##### Connect to the DEV environment |
| 87 | + |
| 88 | +The DEV environment is using a different broker, so you need to add the option `--host`: |
| 89 | + |
| 90 | +```shell |
| 91 | +$ iot-cloud-cli ping --host tcps://mqtts-sa.iot.oniudra.cc:8884 -u "<Device ID>" -p "<Secret Key>" -t "<thing-id>" |
| 92 | +``` |
0 commit comments