Skip to content

Commit

Permalink
Merge pull request #2278 from reubenmiller/fix-azure-cloud-to-device-…
Browse files Browse the repository at this point in the history
…topic

feat(az): extend supported topics on Azure IoT Hub bridge
  • Loading branch information
reubenmiller authored Sep 21, 2023
2 parents d7ef2bd + 65edbc2 commit 09b7d30
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions crates/core/tedge/src/cli/connect/bridge_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ bridge_attempt_unsubscribe false
use_agent: false,
topics: vec![
r#"messages/events/ out 1 az/ devices/alpha/"#.into(),
r##"messages/devicebound/# out 1 az/ devices/alpha/"##.into(),
r##"messages/devicebound/# in 1 az/ devices/alpha/"##.into(),
],
try_private: false,
start_type: "automatic".into(),
Expand Down Expand Up @@ -291,7 +291,7 @@ bridge_attempt_unsubscribe false
expected.insert("bridge_attempt_unsubscribe false");

expected.insert("topic messages/events/ out 1 az/ devices/alpha/");
expected.insert("topic messages/devicebound/# out 1 az/ devices/alpha/");
expected.insert("topic messages/devicebound/# in 1 az/ devices/alpha/");
assert_eq!(config_set, expected);
Ok(())
}
Expand Down
18 changes: 14 additions & 4 deletions crates/core/tedge/src/cli/connect/bridge_config_azure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl From<BridgeConfigAzureParams> for BridgeConfig {
);
let pub_msg_topic = format!("messages/events/# out 1 az/ devices/{}/", remote_clientid);
let sub_msg_topic = format!(
"messages/devicebound/# out 1 az/ devices/{}/",
"messages/devicebound/# in 1 az/ devices/{}/",
remote_clientid
);
Self {
Expand All @@ -57,10 +57,17 @@ impl From<BridgeConfigAzureParams> for BridgeConfig {
notification_topic: "tedge/health/mosquitto-az-bridge".into(),
bridge_attempt_unsubscribe: false,
topics: vec![
// See Azure IoT Hub documentation for detailed explanation on the topics
// https://learn.microsoft.com/en-us/azure/iot/iot-mqtt-connect-to-iot-hub#receiving-cloud-to-device-messages
pub_msg_topic,
sub_msg_topic,
// Direct methods (request/response)
r##"topic methods/POST/# in 1 az/ $iothub/"##.into(),
r##"topic methods/res/# out 1 az/ $iothub/"##.into(),
// Digital twin
r##"twin/res/# in 1 az/ $iothub/"##.into(),
r#"twin/GET/?$rid=1 out 1 az/ $iothub/"#.into(),
r##"twin/GET/# out 1 az/ $iothub/"##.into(),
r##"twin/PATCH/# out 1 az/ $iothub/"##.into(),
],
}
}
Expand Down Expand Up @@ -97,9 +104,12 @@ fn test_bridge_config_from_azure_params() -> anyhow::Result<()> {
use_agent: false,
topics: vec![
r#"messages/events/# out 1 az/ devices/alpha/"#.into(),
r##"messages/devicebound/# out 1 az/ devices/alpha/"##.into(),
r##"messages/devicebound/# in 1 az/ devices/alpha/"##.into(),
r##"topic methods/POST/# in 1 az/ $iothub/"##.into(),
r##"topic methods/res/# out 1 az/ $iothub/"##.into(),
r##"twin/res/# in 1 az/ $iothub/"##.into(),
r#"twin/GET/?$rid=1 out 1 az/ $iothub/"#.into(),
r##"twin/GET/# out 1 az/ $iothub/"##.into(),
r##"twin/PATCH/# out 1 az/ $iothub/"##.into(),
],
try_private: false,
start_type: "automatic".into(),
Expand Down

1 comment on commit 09b7d30

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

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

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
281 0 3 281 100 1h0m18.049s

Please sign in to comment.