Skip to content

Commit 05691cf

Browse files
committed
feat: single connection to either mqtt service or core mqtt and not both
Connecting to Cumulocity now establishes a single MQTT connection either to the the core MQTT endpoint or the MQTT service, but not both. Connecting to MQTT service requires SmartREST proxy to be enabled on it, so that messaging over SmartREST and JSON over MQTT still works.
1 parent bafbd05 commit 05691cf

File tree

12 files changed

+216
-396
lines changed

12 files changed

+216
-396
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pub const MQTT_CORE_TLS_PORT: u16 = 8883;
2+
pub const MQTT_SVC_TLS_PORT: u16 = 9883;

crates/common/tedge_config/src/tedge_toml/models/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
pub mod apt_config;
22
pub mod auth_method;
33
pub mod auto;
4+
pub mod c8y;
45
pub mod c8y_software_management;
56
pub mod connect_url;
67
pub mod cryptoki;
@@ -24,10 +25,10 @@ use strum::Display;
2425

2526
pub const HTTPS_PORT: u16 = 443;
2627
pub const MQTT_TLS_PORT: u16 = 8883;
27-
pub const MQTT_SVC_TLS_PORT: u16 = 9883;
2828

2929
pub use self::apt_config::*;
3030
pub use self::auto::*;
31+
pub use self::c8y::*;
3132
pub use self::c8y_software_management::*;
3233
pub use self::connect_url::*;
3334
pub use self::cryptoki::Cryptoki;

crates/common/tedge_config/src/tedge_toml/tedge_config.rs

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use super::models::SoftwareManagementApiFlag;
2020
use super::models::TemplatesSet;
2121
use super::models::TopicPrefix;
2222
use super::models::HTTPS_PORT;
23-
use super::models::MQTT_SVC_TLS_PORT;
2423
use super::models::MQTT_TLS_PORT;
2524
use super::tedge_config_location::TEdgeConfigLocation;
2625
use crate::models::AbsolutePath;
@@ -474,20 +473,9 @@ define_tedge_config! {
474473
#[tedge_config(example = "true", default(value = false))]
475474
enabled: bool,
476475

477-
/// MQTT service endpoint for the Cumulocity tenant, with optional port.
478-
#[tedge_config(example = "mqtt.your-tenant.cumulocity.com:9883")]
479-
#[tedge_config(default(from_optional_key = "c8y.mqtt"))]
480-
url: HostPort<MQTT_SVC_TLS_PORT>,
481-
482-
/// The topic prefix that will be used for the Cumulocity MQTT service endpoint connection.
483-
/// For instance, if set to "c8y-mqtt", then messages published to `c8y-mqtt/xyz`
484-
/// will be forwarded to the MQTT service endpoint on the `xyz` topic
485-
#[tedge_config(example = "c8y-mqtt", default(function = "c8y_mqtt_service_topic_prefix"))]
486-
topic_prefix: TopicPrefix,
487-
488476
/// Set of MQTT topics the bridge should subscribe to on the Cumulocity MQTT service endpoint
489477
#[tedge_config(example = "incoming/topic,another/topic,test/topic")]
490-
#[tedge_config(default(value = "$demo/$error"))]
478+
#[tedge_config(default(function = "TemplatesSet::default"))]
491479
topics: TemplatesSet,
492480
}
493481
},
@@ -1218,16 +1206,6 @@ fn c8y_topic_prefix() -> TopicPrefix {
12181206
TopicPrefix::try_new("c8y").unwrap()
12191207
}
12201208

1221-
fn c8y_mqtt_service_topic_prefix() -> TopicPrefix {
1222-
TopicPrefix::try_new("c8y-mqtt").unwrap()
1223-
}
1224-
1225-
impl From<HostPort<MQTT_TLS_PORT>> for HostPort<MQTT_SVC_TLS_PORT> {
1226-
fn from(value: HostPort<MQTT_TLS_PORT>) -> Self {
1227-
HostPort::try_from(value.host().to_string()).expect("Source hostname must have been valid")
1228-
}
1229-
}
1230-
12311209
fn az_topic_prefix() -> TopicPrefix {
12321210
TopicPrefix::try_new("az").unwrap()
12331211
}

crates/common/tedge_config/src/tedge_toml/tedge_config/append_remove.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ impl_append_remove_for_single_value!(
4040
ConnectUrl,
4141
HostPort<HTTPS_PORT>,
4242
HostPort<MQTT_TLS_PORT>,
43-
HostPort<MQTT_SVC_TLS_PORT>,
4443
bool,
4544
IpAddr,
4645
u16,

crates/core/tedge/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ mockall = { workspace = true }
7777
mockito = { workspace = true }
7878
mqtt_tests = { workspace = true }
7979
predicates = { workspace = true }
80+
pretty_assertions = { workspace = true }
8081
rcgen = { workspace = true }
8182
tedge_config = { workspace = true, features = ["test"] }
8283
tedge_test_utils = { workspace = true }

0 commit comments

Comments
 (0)