Skip to content

Commit

Permalink
Added fix for MTM-37025
Browse files Browse the repository at this point in the history
  • Loading branch information
Kumar Pallav committed Feb 25, 2021
1 parent 2d20204 commit e0fce46
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
6 changes: 6 additions & 0 deletions MQTT-SDK/src/Cumulocity.SDK.MQTT/Model/MqttTopics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ public class MqttTopics
// smartrest downlink template creation
public const string BASE_SMARTREST_TEMPLATE_CREATION_SUBSCRIBE = "s/dt";

// uplink device credentials
public const string BASE_DEVICE_CREDENTIALS_PUBLISH = "s/ucr";

// downlink device credentials
public const string BASE_DEVICE_CREDENTIALS_SUBSCRIBE = "s/dcr";

// JSON via MQTT
public static readonly List<string> BASE_JSON_via_MQTT_TEMPLATE_ENDPOINTS = new List<string>() { "event/events", "alarm/alarms", "measurement/measurements", "inventory/managedObjects", "error" };
}
Expand Down
14 changes: 12 additions & 2 deletions MQTT-SDK/src/Cumulocity.SDK.MQTT/Util/MqttTopicValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static bool IsTopicValidForPublish(string topic)
return false;
}

return IsSmartRestStaticPublishTopic(topic) || IsSmartRestLegacyPublishTopic(topic) || IsSmartRestPublishTopic(topic) || IsSmartRestTemplateCreationPublishTopic(topic) || IsJsonViaMqttTopic(topic);
return IsSmartRestStaticPublishTopic(topic) || IsSmartRestLegacyPublishTopic(topic) || IsSmartRestPublishTopic(topic) || IsSmartRestTemplateCreationPublishTopic(topic) || IsJsonViaMqttTopic(topic) || IsDeviceCredentialsPublishTopic(topic);
}


Expand All @@ -27,7 +27,7 @@ public static bool IsTopicValidForSubscribe(string topic)
return false;
}

return IsSmartRestExceptionsTopic(topic) || IsSmartRestStaticSubscribeTopic(topic) || IsSmartRestLegacySubscribeTopic(topic) || IsSmartRestSubscribeTopic(topic) || IsSmartRestTemplateCreationSubscribeTopic(topic) || IsSmartRestLegacyOperationsTopic(topic) || IsJsonViaMqttTopic(topic);
return IsSmartRestExceptionsTopic(topic) || IsSmartRestStaticSubscribeTopic(topic) || IsSmartRestLegacySubscribeTopic(topic) || IsSmartRestSubscribeTopic(topic) || IsSmartRestTemplateCreationSubscribeTopic(topic) || IsSmartRestLegacyOperationsTopic(topic) || IsJsonViaMqttTopic(topic) || IsDeviceCredentialsSubscribeTopic(topic);
}


Expand Down Expand Up @@ -81,6 +81,16 @@ private static bool IsSmartRestTemplateCreationSubscribeTopic(string topic)
return topic.Contains(MqttTopics.BASE_SMARTREST_TEMPLATE_CREATION_SUBSCRIBE);
}

private static bool IsDeviceCredentialsPublishTopic(string topic)
{
return topic.Contains(MqttTopics.BASE_DEVICE_CREDENTIALS_PUBLISH);
}

private static bool IsDeviceCredentialsSubscribeTopic(string topic)
{
return topic.Contains(MqttTopics.BASE_DEVICE_CREDENTIALS_SUBSCRIBE);
}

private static bool IsJsonViaMqttTopic(string topic)
{
return MqttTopics.BASE_JSON_via_MQTT_TEMPLATE_ENDPOINTS.Any(l => topic.Contains(l));
Expand Down

0 comments on commit e0fce46

Please sign in to comment.