Skip to content

Commit

Permalink
fix typos in examples
Browse files Browse the repository at this point in the history
Fix typos

Signed-off-by: HowJMay <[email protected]>
  • Loading branch information
howjmay authored and ralight committed Jun 17, 2020
1 parent 0946dc3 commit 40a2398
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions examples/temperature_conversion/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
8 changes: 4 additions & 4 deletions examples/temperature_conversion/temperature_conversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ 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")){
memset(buf, 0, 51*sizeof(char));
/* 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);
}
}

Expand Down

0 comments on commit 40a2398

Please sign in to comment.