Skip to content

Commit

Permalink
Merge pull request #54 from nielsonm236/Code-reduction
Browse files Browse the repository at this point in the history
MQTT temperature bug fix
  • Loading branch information
nielsonm236 authored Apr 13, 2021
2 parents d93ffee + bfe95b2 commit bcae1be
Show file tree
Hide file tree
Showing 7 changed files with 174 additions and 170 deletions.
2 changes: 1 addition & 1 deletion NetworkModule/.Idea_Groups/Vector_File.grp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Group File Created by IDEA
# Project: <NetworkModule>
# Mon Apr 12 07:55:28 2021
# Tue Apr 13 06:57:29 2021
#
"networkmodule_vector.o"
326 changes: 164 additions & 162 deletions NetworkModule/.Idea_Temp/COBJ.TMP

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion NetworkModule/.Idea_Temp/IDEABLD.BAT
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
REM COMMAND FILE BUILT BY IDEA
REM Mon Apr 12 07:55:24 2021
REM Tue Apr 13 06:57:26 2021
REM
cxstm8 -v -l +strict +debug +modsl0 +split +warn "networkmodule_vector.c"
cxstm8 -v -l +strict +debug +modsl0 +split +warn "ds18b20.c" "enc28j60.c" "gpio.c" "httpd.c" "main.c" "mqtt.c" "mqtt_pal.c" "spi.c" "timer.c" "uart.c" "uip.c" "uip_arp.c" "uip_tcpapphub.c"
Expand Down
4 changes: 2 additions & 2 deletions NetworkModule/DS18B20.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,10 +389,10 @@ void convert_temperature(uint8_t device_num, uint8_t degCorF)
// with the raw number which includes 4 bits of decimal
// This next equation also includes the "9" part of the
// "9 / 5" calculation. We use 180 / 100 to avoid loss
// of precision in the integer arithmatic.
// of precision in the integer arithmetic.
F_temp1 = (int32_t)((F_temp1 + 880) * 180);
// It is necessary to separate the "100" part of the
// "180 / 100" arithmatic so the compiler doesn't optimize
// "180 / 100" arithmetic so the compiler doesn't optimize
// and cause loss of precision.
F_temp2 = F_temp1 / 100;
// Now subtract 1072. This is the combination of the "+32"
Expand Down
6 changes: 3 additions & 3 deletions NetworkModule/Main.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
//---------------------------------------------------------------------------//
//---------------------------------------------------------------------------//
//---------------------------------------------------------------------------//
const char code_revision[] = "20210412 1333";
const char code_revision[] = "20210413 1254";
//---------------------------------------------------------------------------//
//---------------------------------------------------------------------------//
//---------------------------------------------------------------------------//
Expand Down Expand Up @@ -2117,8 +2117,7 @@ void publish_temperature(uint8_t sensor)
// When the Publish message is sent the sensor value must be in human
// readable form, ie, 1 to 5 (for the 5 sensors).

app_message[0] = '\0';

// Build the topic string
strcpy(topic_base, devicetype);
strcat(topic_base, stored_devicename);
strcat(topic_base, "/temp/");
Expand All @@ -2136,6 +2135,7 @@ void publish_temperature(uint8_t sensor)

// Build the application message
convert_temperature(sensor, 0); // Convert to degress C in OctetArray
strcpy(app_message, OctetArray);

// Queue publish message
mqtt_publish(&mqttclient,
Expand Down
2 changes: 1 addition & 1 deletion NetworkModule/mqtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ int16_t __mqtt_send(struct mqtt_client *client)
// check for keep-alive
{
// At about 3/4 of the timeout period perform a ping. This calculation
// uses integer arithmatic so it is only an approximation. It is assumed
// uses integer arithmetic so it is only an approximation. It is assumed
// that timeouts are not a small number (for instance, the timeout should
// be at least 15 seconds).
uint32_t keep_alive_timeout = client->time_of_last_send + (uint32_t)((client->keep_alive * 3) / 4);
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Feature Comparison of the MQTT and Browser builds:
|:------------------------|:------------:|:------------------:|
|MQTT Support | x | |
|Home Assistant Support | x | |
|Browser IO Control | x | x |
|Browser Configuration | x | x |
|Full/Half Duplex | x | x |
|Link Error Statistics | x | x |
|DS18B20 Temp Sensor | x | x |
Expand Down

0 comments on commit bcae1be

Please sign in to comment.