diff --git a/examples/temperature_conversion/readme.txt b/examples/temperature_conversion/readme.txt index a706a7cc..de9d9a19 100644 --- a/examples/temperature_conversion/readme.txt +++ b/examples/temperature_conversion/readme.txt @@ -2,5 +2,5 @@ This is a simple example of the C++ library mosquittopp. It is a client that subscribes to the topic temperature/celsius which should have temperature data in text form being published to it. It reads this data as -a Celsius temperature, converts to Farenheit and republishes on -temperature/farenheit. +a Celsius temperature, converts to Fahrenheit and republishes on +temperature/fahrenheit. diff --git a/examples/temperature_conversion/temperature_conversion.cpp b/examples/temperature_conversion/temperature_conversion.cpp index 1fa6f55e..7ecf0d80 100644 --- a/examples/temperature_conversion/temperature_conversion.cpp +++ b/examples/temperature_conversion/temperature_conversion.cpp @@ -28,7 +28,7 @@ void mqtt_tempconv::on_connect(int rc) void mqtt_tempconv::on_message(const struct mosquitto_message *message) { - double temp_celsius, temp_farenheit; + double temp_celsius, temp_fahrenheit; char buf[51]; if(!strcmp(message->topic, "temperature/celsius")){ @@ -36,9 +36,9 @@ void mqtt_tempconv::on_message(const struct mosquitto_message *message) /* Copy N-1 bytes to ensure always 0 terminated. */ memcpy(buf, message->payload, 50*sizeof(char)); temp_celsius = atof(buf); - temp_farenheit = temp_celsius*9.0/5.0 + 32.0; - snprintf(buf, 50, "%f", temp_farenheit); - publish(NULL, "temperature/farenheit", strlen(buf), buf); + temp_fahrenheit = temp_celsius*9.0/5.0 + 32.0; + snprintf(buf, 50, "%f", temp_fahrenheit); + publish(NULL, "temperature/fahrenheit", strlen(buf), buf); } }