fix typos in examples

Fix typos

Signed-off-by: HowJMay <vulxj0j8j8@gmail.com>
pull/1737/head
HowJMay 5 years ago committed by Roger Light
parent 0946dc3a8d
commit 40a23981d3

@ -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 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 have temperature data in text form being published to it. It reads this data as
a Celsius temperature, converts to Farenheit and republishes on a Celsius temperature, converts to Fahrenheit and republishes on
temperature/farenheit. temperature/fahrenheit.

@ -28,7 +28,7 @@ void mqtt_tempconv::on_connect(int rc)
void mqtt_tempconv::on_message(const struct mosquitto_message *message) void mqtt_tempconv::on_message(const struct mosquitto_message *message)
{ {
double temp_celsius, temp_farenheit; double temp_celsius, temp_fahrenheit;
char buf[51]; char buf[51];
if(!strcmp(message->topic, "temperature/celsius")){ 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. */ /* Copy N-1 bytes to ensure always 0 terminated. */
memcpy(buf, message->payload, 50*sizeof(char)); memcpy(buf, message->payload, 50*sizeof(char));
temp_celsius = atof(buf); temp_celsius = atof(buf);
temp_farenheit = temp_celsius*9.0/5.0 + 32.0; temp_fahrenheit = temp_celsius*9.0/5.0 + 32.0;
snprintf(buf, 50, "%f", temp_farenheit); snprintf(buf, 50, "%f", temp_fahrenheit);
publish(NULL, "temperature/farenheit", strlen(buf), buf); publish(NULL, "temperature/fahrenheit", strlen(buf), buf);
} }
} }

Loading…
Cancel
Save