AzureSphere/AzureSphereSampleDevice/main.c
static void SendTelemetry(const char *jsonMessage)
{
    if (iotHubClientAuthenticationState != IoTHubClientAuthenticationState_Authenticated) {
        // AzureIoT client is not authenticated. Log a warning and return.
        Log_Debug("WARNING: Azure IoT Hub is not authenticated. Not sending telemetry.\n");
        return;
    }

    Log_Debug("Sending Azure IoT Hub telemetry: %s.\n", jsonMessage);

    // Check whether the device is connected to the internet.
    if (IsConnectionReadyToSendTelemetry() == false) {
        return;
    }

    IOTHUB_MESSAGE_HANDLE messageHandle = IoTHubMessage_CreateFromString(jsonMessage);

    if (messageHandle == 0) {
        Log_Debug("ERROR: unable to create a new IoTHubMessage.\n");
        return;
    }

    if (IoTHubDeviceClient_LL_SendEventAsync(iothubClientHandle, messageHandle, SendEventCallback,
                                             /*&callback_param*/ NULL) != IOTHUB_CLIENT_OK) {
        Log_Debug("ERROR: failure requesting IoTHubClient to send telemetry event.\n");
    } else {
        Log_Debug("INFO: IoTHubClient accepted the telemetry event for delivery.\n");
    }

    IoTHubMessage_Destroy(messageHandle);
}
/// <summary>
///     Sends telemetry to Azure IoT Hub
/// </summary>

Sends telemetry to Azure IoT Hub

Sends telemetry to Azure IoT Hub
static void SendTelemetry(const char *jsonMessage)
{
    if (iotHubClientAuthenticationState != IoTHubClientAuthenticationState_Authenticated) {
        Log_Debug("WARNING: Azure IoT Hub is not authenticated. Not sending telemetry.\n");
        return;
    }
    Log_Debug("Sending Azure IoT Hub telemetry: %s.\n", jsonMessage);
    if (IsConnectionReadyToSendTelemetry() == false) {
        return;
    }
    IOTHUB_MESSAGE_HANDLE messageHandle = IoTHubMessage_CreateFromString(jsonMessage);
    if (messageHandle == 0) {
        Log_Debug("ERROR: unable to create a new IoTHubMessage.\n");
        return;
    }
    if (IoTHubDeviceClient_LL_SendEventAsync(iothubClientHandle, messageHandle, SendEventCallback,
                                              NULL) != IOTHUB_CLIENT_OK) {
        Log_Debug("ERROR: failure requesting IoTHubClient to send telemetry event.\n");
    } else {
        Log_Debug("INFO: IoTHubClient accepted the telemetry event for delivery.\n");
    }
    IoTHubMessage_Destroy(messageHandle);
}
static void SendTelemetry ( const char * jsonMessage ) { if ( iotHubClientAuthenticationState != IoTHubClientAuthenticationState_Authenticated ) { Log_Debug ( " \n " ) ; return ; } Log_Debug ( " \n " , jsonMessage ) ; if ( IsConnectionReadyToSendTelemetry ( ) == false ) { return ; } IOTHUB_MESSAGE_HANDLE messageHandle = IoTHubMessage_CreateFromString ( jsonMessage ) ; if ( messageHandle == 0 ) { Log_Debug ( " \n " ) ; return ; } if ( IoTHubDeviceClient_LL_SendEventAsync ( iothubClientHandle , messageHandle , SendEventCallback , NULL ) != IOTHUB_CLIENT_OK ) { Log_Debug ( " \n " ) ; } else { Log_Debug ( " \n " ) ; } IoTHubMessage_Destroy ( messageHandle ) ; }
<summary>
Sends telemetry to Azure IoT Hub
</summary>
<summary > Sends telemetry to Azure IoT Hub < / summary >
// AzureIoT client is not authenticated. Log a warning and return. // Check whether the device is connected to the internet. /*&callback_param*/