Skip to content

feat: tedge connect to c8y mqtt service endpoint #3707

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
40d34b4
spec: c8y mqtt service connection spec
albinsuresh Jun 25, 2025
9979965
feat: tedge connect to c8y mqtt service endpoint
albinsuresh Jul 3, 2025
4a980a0
fix basic auth based connection to mqtt service
albinsuresh Jul 3, 2025
8675e0f
configurable remote sub topics
albinsuresh Jul 3, 2025
64467ab
System test skeleton
albinsuresh Jul 4, 2025
813f335
fixup! feat: tedge connect to c8y mqtt service endpoint
albinsuresh Jul 4, 2025
86654d9
refactor core mqtt bridge config definition
albinsuresh Jul 4, 2025
6c8700b
feat: builtin bridge support for mqtt service endpoint
albinsuresh Jul 4, 2025
0a06606
fixup! feat: builtin bridge support for mqtt service endpoint
albinsuresh Jul 9, 2025
015ee3d
fixup! feat: tedge connect to c8y mqtt service endpoint
albinsuresh Jul 15, 2025
b25610a
fixup! feat: builtin bridge support for mqtt service endpoint
albinsuresh Jul 15, 2025
7a4975c
doc: tedge connect c8y mqtt service documentation
albinsuresh Jul 15, 2025
b5d55b1
fixup! doc: tedge connect c8y mqtt service documentation
albinsuresh Jul 17, 2025
702e370
Include MQTT service in tedge c8y connection test
albinsuresh Jul 17, 2025
510ca24
fixup! feat: builtin bridge support for mqtt service endpoint
albinsuresh Jul 17, 2025
a1098e8
Remove mqtt service bridge file on tedge disconnect
albinsuresh Jul 17, 2025
ad03d81
fixup! doc: tedge connect c8y mqtt service documentation
albinsuresh Jul 17, 2025
9d4ebb0
fixup! fixup! doc: tedge connect c8y mqtt service documentation
albinsuresh Jul 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/common/tedge_config/src/tedge_toml/models/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use strum::Display;

pub const HTTPS_PORT: u16 = 443;
pub const MQTT_TLS_PORT: u16 = 8883;
pub const MQTT_SVC_TLS_PORT: u16 = 9883;

pub use self::apt_config::*;
pub use self::auto::*;
Expand Down
31 changes: 31 additions & 0 deletions crates/common/tedge_config/src/tedge_toml/tedge_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use super::models::SoftwareManagementApiFlag;
use super::models::TemplatesSet;
use super::models::TopicPrefix;
use super::models::HTTPS_PORT;
use super::models::MQTT_SVC_TLS_PORT;
use super::models::MQTT_TLS_PORT;
use super::tedge_config_location::TEdgeConfigLocation;
use crate::models::AbsolutePath;
Expand Down Expand Up @@ -226,6 +227,10 @@ define_tedge_config! {
#[tedge_config(reader(private))]
url: ConnectUrl,

/// Cumulocity tenant ID
#[tedge_config(example = "t12345678")]
tenant_id: String,

/// The path where Cumulocity root certificate(s) are stored
#[tedge_config(note = "The value can be a directory path as well as the path of the certificate file.")]
#[tedge_config(example = "/etc/tedge/c8y-trusted-root-certificates.pem", default(function = "default_root_cert_path"))]
Expand Down Expand Up @@ -433,6 +438,28 @@ define_tedge_config! {
#[tedge_config(example = "60m", default(from_str = "60m"))]
interval: SecondsOrHumanTime,
},

mqtt_service: {
/// Wheather to connect to the MQTT service endpoint or not
#[tedge_config(example = "true", default(value = false))]
enabled: bool,

/// MQTT service endpoint for the Cumulocity tenant, with optional port.
#[tedge_config(example = "mqtt.your-tenant.cumulocity.com:9883")]
#[tedge_config(default(from_optional_key = "c8y.url"))]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this not better derived from c8y.mqtt, which will likely already have the correct domain for MQTT connections (I'm assuming this is the same issue as for standard MQTT connections)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved by 015ee3d

url: HostPort<MQTT_SVC_TLS_PORT>,

/// The topic prefix that will be used for the Cumulocity MQTT service endpoint connection.
/// For instance, if set to "c8y-mqtt", then messages published to `c8y-mqtt/xyz`
/// will be forwarded to the MQTT service endpoint on the `xyz` topic
#[tedge_config(example = "c8y-mqtt", default(function = "c8y_mqtt_service_topic_prefix"))]
topic_prefix: TopicPrefix,

/// Set of MQTT topics the bridge should subscribe to on the Cumulocity MQTT service endpoint
#[tedge_config(example = "incoming/topic,another/topic,test/topic")]
#[tedge_config(default(value = "$demo/$error"))]
topics: TemplatesSet,
}
},

#[tedge_config(deprecated_name = "azure")] // for 0.1.0 compatibility
Expand Down Expand Up @@ -1114,6 +1141,10 @@ fn c8y_topic_prefix() -> TopicPrefix {
TopicPrefix::try_new("c8y").unwrap()
}

fn c8y_mqtt_service_topic_prefix() -> TopicPrefix {
TopicPrefix::try_new("c8y-mqtt").unwrap()
}

fn az_topic_prefix() -> TopicPrefix {
TopicPrefix::try_new("az").unwrap()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ impl_append_remove_for_single_value!(
ConnectUrl,
HostPort<HTTPS_PORT>,
HostPort<MQTT_TLS_PORT>,
HostPort<MQTT_SVC_TLS_PORT>,
bool,
IpAddr,
u16,
Expand Down
Loading
Loading