AzureSphere/AzureSphereSampleDevice/main.c
void SendSimulatedTelemetry(void)
{
    static char telemetryBuffer[TELEMETRY_BUFFER_SIZE];

    // Generate a simulated temperature.
    static float temperature = 50.0f;                    // starting temperature
    float delta = ((float)(rand() % 41)) / 20.0f - 1.0f; // between -1.0 and +1.0
    temperature += delta;

    int len =
        snprintf(telemetryBuffer, TELEMETRY_BUFFER_SIZE, "{\"Temperature\":%3.2f}", temperature);
    if (len < 0 || len >= TELEMETRY_BUFFER_SIZE) {
        Log_Debug("ERROR: Cannot write telemetry to buffer.\n");
        return;
    }
    SendTelemetry(telemetryBuffer);
}
/// <summary>
///     Generate simulated telemetry and send to Azure IoT Hub.
/// </summary>

Generate simulated telemetry and send to Azure IoT Hub.
Generate simulated telemetry and send to Azure IoT Hub .
void SendSimulatedTelemetry(void)
{
    static char telemetryBuffer[TELEMETRY_BUFFER_SIZE];
    static float temperature = 50.0f;                    
    float delta = ((float)(rand() % 41)) / 20.0f - 1.0f; 
    temperature += delta;
    int len =
        snprintf(telemetryBuffer, TELEMETRY_BUFFER_SIZE, "{\"Temperature\":%3.2f}", temperature);
    if (len < 0 || len >= TELEMETRY_BUFFER_SIZE) {
        Log_Debug("ERROR: Cannot write telemetry to buffer.\n");
        return;
    }
    SendTelemetry(telemetryBuffer);
}
void SendSimulatedTelemetry ( void ) { static char telemetryBuffer [ TELEMETRY_BUFFER_SIZE ] ; static float temperature = 50.0f ; float delta = ( ( float ) ( rand ( ) % 41 ) ) / 20.0f - 1.0f ; temperature += delta ; int len = snprintf ( telemetryBuffer , TELEMETRY_BUFFER_SIZE , " \" \" " , temperature ) ; if ( len < 0 || len >= TELEMETRY_BUFFER_SIZE ) { Log_Debug ( " \n " ) ; return ; } SendTelemetry ( telemetryBuffer ) ; }
<summary>
Generate simulated telemetry and send to Azure IoT Hub.
<summary > Generate simulated telemetry and send to Azure IoT Hub .
// Generate a simulated temperature. // starting temperature // between -1.0 and +1.0