summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRina Fujino <18257209+rina23q@users.noreply.github.com>2022-03-01 15:10:05 +0100
committerGitHub <noreply@github.com>2022-03-01 15:10:05 +0100
commit178dd58cc395d9b40ead1b1820d9f3d2e66fac74 (patch)
tree3f8b38248c6501c2a20fca3e5ff6bc0a84685a8a
parent9ee1f25e7aab46a54e7eb8a7baefce0cce1dcc35 (diff)
parente2061a5cf9189467b7279fa5c3dd519f6f5be3d9 (diff)
Merge pull request #940 Update the output of tedge connect, tutorial and how-to guide
-rw-r--r--crates/core/tedge/src/cli/disconnect/disconnect_bridge.rs17
-rw-r--r--docs/src/howto-guides/004_connect.md46
-rw-r--r--docs/src/tutorials/connect-azure.md28
-rw-r--r--docs/src/tutorials/connect-c8y.md11
4 files changed, 60 insertions, 42 deletions
diff --git a/crates/core/tedge/src/cli/disconnect/disconnect_bridge.rs b/crates/core/tedge/src/cli/disconnect/disconnect_bridge.rs
index 9831976e..be6d1df9 100644
--- a/crates/core/tedge/src/cli/disconnect/disconnect_bridge.rs
+++ b/crates/core/tedge/src/cli/disconnect/disconnect_bridge.rs
@@ -1,6 +1,7 @@
use crate::cli::disconnect::error::*;
use crate::command::*;
use crate::system_services::*;
+use std::fmt;
use std::sync::Arc;
use tedge_config::TEdgeConfigLocation;
use which::which;
@@ -22,11 +23,11 @@ impl Cloud {
}
}
-impl From<Cloud> for String {
- fn from(val: Cloud) -> Self {
- match val {
- Cloud::C8y => "Cumulocity".into(),
- Cloud::Azure => "Azure".into(),
+impl fmt::Display for Cloud {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ match self {
+ Cloud::C8y => write!(f, "Cumulocity"),
+ Cloud::Azure => write!(f, "Azure"),
}
}
}
@@ -43,7 +44,7 @@ pub struct DisconnectBridgeCommand {
impl Command for DisconnectBridgeCommand {
fn description(&self) -> String {
- format!("remove the bridge to disconnect {:?} cloud", self.cloud)
+ format!("remove the bridge to disconnect {} cloud", self.cloud)
}
fn execute(&self) -> anyhow::Result<()> {
@@ -98,7 +99,7 @@ impl DisconnectBridgeCommand {
.join(TEDGE_BRIDGE_CONF_DIR_PATH)
.join(&self.config_file);
- println!("Removing {:?} bridge.\n", self.cloud);
+ println!("Removing {} bridge.\n", self.cloud);
match std::fs::remove_file(&bridge_conf_path) {
// If we find the bridge config file we remove it
// and carry on to see if we need to restart mosquitto.
@@ -127,7 +128,7 @@ impl DisconnectBridgeCommand {
.service_manager()
.restart_service_if_running(SystemService::Mosquitto)?
{
- println!("{:?} Bridge successfully disconnected!\n", self.cloud);
+ println!("{} Bridge successfully disconnected!\n", self.cloud);
}
Ok(())
}
diff --git a/docs/src/howto-guides/004_connect.md b/docs/src/howto-guides/004_connect.md
index fb65fb5f..470b3b48 100644
--- a/docs/src/howto-guides/004_connect.md
+++ b/docs/src/howto-guides/004_connect.md
@@ -70,7 +70,7 @@ Successfully created bridge connection!
Sending packets to check connection. This may take up to 2 seconds.
-Connection check is successfull.
+Connection check is successful.
Checking if tedge-mapper is installed.
@@ -119,21 +119,26 @@ Applying changes to mosquitto.
Cumulocity Bridge successfully disconnected!
-Stopping tedge-mapper service.
+Stopping tedge-mapper-c8y service.
-Disabling tedge-mapper service.
+Disabling tedge-mapper-c8y service.
-tedge-mapper service successfully stopped and disabled!
+tedge-mapper-c8y service successfully stopped and disabled!
+Stopping tedge-agent service.
+
+Disabling tedge-agent service.
+
+tedge-agent service successfully stopped and disabled!
```
> Note: `tedge disconnect c8y` also stops and disable **tedge-mapper** service if it is installed on the device.
And now you can issue [`tedge connect c8y`](../references/tedge-connect.md) to create new bridge.
-#### Connection check failure
+#### Connection check warning
-Sample output of tedge connect when this error occurs:
+Sample output of tedge connect when this warning occurs:
```shell
$ sudo tedge connect c8y
@@ -143,32 +148,43 @@ Checking if configuration for requested bridge already exists.
Validating the bridge certificates.
+Creating the device in Cumulocity cloud.
+
Saving configuration for requested bridge.
Restarting mosquitto service.
Awaiting mosquitto to start. This may take up to 5 seconds.
-Persisting mosquitto on reboot.
+Enabling mosquitto service on reboots.
Successfully created bridge connection!
+Sending packets to check connection. This may take up to 2 seconds.
+
+ERROR: Local MQTT publish has timed out.
+Warning: Bridge has been configured, but Cumulocity connection check failed.
+
Checking if tedge-mapper is installed.
-Starting tedge-mapper service.
+Starting tedge-mapper-c8y service.
-Persisting tedge-mapper on reboot.
+Persisting tedge-mapper-c8y on reboot.
-tedge-mapper service successfully started and enabled!
+tedge-mapper-c8y service successfully started and enabled!
-Sending packets to check connection. This may take up to 10 seconds.
+Enabling software management.
-Try 1 / 2: Sending a message to Cumulocity. ... No response. If the device is new, it's normal to get no response in the first try.
-Try 2 / 2: Sending a message to Cumulocity. ... No response.
-Warning: Bridge has been configured, but Cumulocity connection check failed.
+Checking if tedge-agent is installed.
+
+Starting tedge-agent service.
+
+Persisting tedge-agent on reboot.
+
+tedge-agent service successfully started and enabled!
```
-This error may be caused by some of the following reasons:
+This warning may be caused by some of the following reasons:
- No access to Internet connection
diff --git a/docs/src/tutorials/connect-azure.md b/docs/src/tutorials/connect-azure.md
index e3da8d8e..d3e7661d 100644
--- a/docs/src/tutorials/connect-azure.md
+++ b/docs/src/tutorials/connect-azure.md
@@ -29,7 +29,7 @@ This identifier will be used to uniquely identify your devices among others in y
This identifier will be also used as the Common Name (CN) of the certificate.
Indeed, this certificate aims to authenticate that this device is the device with that identity.
-```
+```shell
$ sudo tedge cert create --device-id my-device
```
@@ -37,7 +37,7 @@ $ sudo tedge cert create --device-id my-device
You can then check the content of that certificate.
-```
+```shell
$ sudo tedge cert show
Device certificate: /etc/tedge/device-certs/tedge-certificate.pem
Subject: CN=my-device, O=Thin Edge, OU=Test Device
@@ -77,7 +77,7 @@ To connect the device to the Azure IoT Hub, one needs to set the URL/Hostname of
Set the URL/Hostname of your Azure IoT Hub.
-```
+```shell
sudo tedge config set az.url your-iot-hub-name.azure-devices.net
```
@@ -85,7 +85,7 @@ The URL/Hostname can be found in the Azure web portal, clicking on the overview
Set the path to the root certificate if necessary. The default is `/etc/ssl/certs`.
-```
+```shell
sudo tedge config set az.root.cert.path /etc/ssl/certs/Baltimore_CyberTrust_Root.pem
```
@@ -102,9 +102,8 @@ This command configures the MQTT broker:
Also, if you have installed `tedge_mapper`, this command starts and enables the tedge-mapper-az systemd service.
At last, it sends packets to Azure IoT Hub to check the connection.
-```
+```shell
$ sudo tedge connect az
-
Checking if systemd is available.
Checking if configuration for requested bridge already exists.
@@ -117,21 +116,22 @@ Restarting mosquitto service.
Awaiting mosquitto to start. This may take up to 5 seconds.
-Persisting mosquitto on reboot.
+Enabling mosquitto service on reboots.
Successfully created bridge connection!
-Checking if tedge-mapper is installed.
+Sending packets to check connection. This may take up to 2 seconds.
-Starting tedge-mapper service.
+Connection check is successful.
-Persisting tedge-mapper on reboot.
+Checking if tedge-mapper is installed.
-tedge-mapper service successfully started and enabled!
+Starting tedge-mapper-az service.
-Sending packets to check connection. This may take up to 10 seconds.
+Persisting tedge-mapper-az on reboot.
+
+tedge-mapper-az service successfully started and enabled!
-Received expected response message, connection check is successful.
```
## Sending your first telemetry data
@@ -140,7 +140,7 @@ Sending data to Azure is done using MQTT over topics prefixed with `az`.
Any messages sent on the topic will be forwarded to Azure.
Here, we use `tedge mqtt pub az/messages/events/` a message to be understood as a temperature of 20 Degree.
-```
+```shell
$ tedge mqtt pub az/messages/events/ '{"temperature": 20}'
```
To view the messages that were sent from the device to the cloud, follow this [document](https://docs.microsoft.com/en-us/azure/iot-hub/quickstart-send-telemetry-cli#create-and-monitor-a-device).
diff --git a/docs/src/tutorials/connect-c8y.md b/docs/src/tutorials/connect-c8y.md
index 9202e1b9..7f5c6a4d 100644
--- a/docs/src/tutorials/connect-c8y.md
+++ b/docs/src/tutorials/connect-c8y.md
@@ -112,6 +112,8 @@ Checking if configuration for requested bridge already exists.
Validating the bridge certificates.
+Creating the device in Cumulocity cloud.
+
Saving configuration for requested bridge.
Restarting mosquitto service.
@@ -122,6 +124,10 @@ Enabling mosquitto service on reboots.
Successfully created bridge connection!
+Sending packets to check connection. This may take up to 2 seconds.
+
+Connection check is successful.
+
Checking if tedge-mapper is installed.
Starting tedge-mapper-c8y service.
@@ -130,11 +136,6 @@ Persisting tedge-mapper-c8y on reboot.
tedge-mapper-c8y service successfully started and enabled!
-Sending packets to check connection. This may take up to 10 seconds.
-
-Try 1 / 2: Sending a message to Cumulocity.
-Received expected response message, connection check is successful.
-
Enabling software management.
Checking if tedge-agent is installed.