Microsoft Azure IoTHub client MQTT transport

Dependents:   STM32F746_iothub_client_sample_mqtt FXOS8700CQ_To_Azure_IoT f767zi_mqtt FXOS8700CQ_To_Azure_IoT ... more

Revision:
10:c61c16bb63e6
Parent:
9:50744bd8239e
Child:
11:31ebaeb51e1e
--- a/iothubtransportmqtt.c	Fri Sep 09 13:37:32 2016 -0700
+++ b/iothubtransportmqtt.c	Thu Sep 22 18:16:06 2016 -0700
@@ -914,10 +914,14 @@
             }
             else
             {
-                /* Codes_SRS_IOTHUB_MQTT_TRANSPORT_07_008: [The hostname shall be constructed using the iothubname and iothubSuffix.] */
+                /* Codes_SRS_IOTHUB_MQTT_TRANSPORT_07_008: [If the upperConfig contains a valid protocolGatewayHostName value the this shall be used for the hostname, otherwise the hostname shall be constructed using the iothubname and iothubSuffix.] */
                 char tempAddress[DEFAULT_TEMP_STRING_LEN];
-                (void)snprintf(tempAddress, DEFAULT_TEMP_STRING_LEN, "%s.%s", upperConfig->iotHubName, upperConfig->iotHubSuffix);
-                if ((state->hostAddress = STRING_construct(tempAddress)) == NULL)
+                if (upperConfig->protocolGatewayHostName == NULL)
+                {
+                    (void)snprintf(tempAddress, DEFAULT_TEMP_STRING_LEN, "%s.%s", upperConfig->iotHubName, upperConfig->iotHubSuffix);
+                }
+                
+                if ((state->hostAddress = STRING_construct(upperConfig->protocolGatewayHostName == NULL ? tempAddress : upperConfig->protocolGatewayHostName)) == NULL)
                 {
                     LogError("failure constructing host address.");
                     STRING_delete(state->devicesPath);