Compare commits

...

5 Commits

Author SHA1 Message Date
d95e123f7b publish default values on startup 2022-04-05 12:48:12 +02:00
a250a28cc0 reboot on error 2022-04-05 12:47:45 +02:00
e327e1ab21 fix crash 2022-04-05 12:46:50 +02:00
02f992a97b dos2unix 2022-04-02 11:48:04 +02:00
53f5b78356 suppress warnings 2022-04-02 11:47:00 +02:00
4 changed files with 374 additions and 370 deletions

View File

@@ -179,6 +179,8 @@ char* MQTTFormat_toClientString(char* strbuf, int32_t strbuflen, uint8_t* buf, i
break;
}
(void) strindex;
return strbuf;
}
@@ -260,6 +262,7 @@ char* MQTTFormat_toServerString(char* strbuf, int32_t strbuflen, uint8_t* buf, i
break;
}
(void) strindex;
strbuf[strbuflen] = '\0';
return strbuf;
}

11
main.c
View File

@@ -86,7 +86,7 @@ void do_luefter(){
if (read_Input(BTN_LUEFTER_PLUS, RISING) && (fan_value+STEP_SIZE <= TOP_VALUE)) {
fan_value += STEP_SIZE;
#if PLC_MQTT_ENABLED
char _msg[3];
char _msg[4];
sprintf(_msg, "%d", fan_value * 100 / 40);
mqtt_pub(&mqtt_client, "/Filamentanlage/04_Messmodul/state/LuefterSpeed", _msg, 3);
#endif
@@ -96,7 +96,7 @@ void do_luefter(){
if (read_Input(BTN_LUEFTER_MINUS, RISING) && (fan_value-STEP_SIZE >= STEP_SIZE)) {
fan_value -= STEP_SIZE;
#if PLC_MQTT_ENABLED
char _msg[3];
char _msg[4];
sprintf(_msg, "%d", fan_value * 100 / 40);
mqtt_pub(&mqtt_client, "/Filamentanlage/04_Messmodul/state/LuefterSpeed", _msg, 3);
#endif
@@ -207,7 +207,7 @@ int main()
else
{
printf("--MQTT Connected ERROR: %ld\r\n", mqtt_rc);
//while(1); //Reboot the board
while(1); //Reboot the board
}
// Subscribe to all topics
@@ -222,10 +222,10 @@ int main()
uint32_t timer_blink_outs = millis();
uint32_t timer_send_uptime = millis();
OCR3B = 127;
#if PLC_MQTT_ENABLED
mqtt_pub(&mqtt_client, "/Filamentanlage/04_Messmodul/state/Luefter", "aus", 3);
mqtt_pub(&mqtt_client, "/Filamentanlage/04_Messmodul/state/LuefterSpeed", "50", 2);
mqtt_pub(&mqtt_client, "/Filamentanlage/04_Messmodul/state/Zumbach", "aus", 3);
#endif
while(1)
@@ -299,6 +299,7 @@ void timer3_init(void)
TCCR3A |= (1<<WGM30); // PWM Mode with ocra top
TCCR3B |= (1<<WGM33);
OCR3A = TOP_VALUE;
OCR3B = 0;
TCCR3B |= (0<<CS32)|(1<<CS31)|(0<<CS30); // PS 1:1
TCCR3A |= (1<<COM3B1) | (0<<COM3B0);

12
mqtt.c
View File

@@ -56,11 +56,11 @@ void mqtt_pub(Client* mqtt_client, char * mqtt_topic, char * mqtt_msg, int mqtt_
{
printf(" - ERROR\r\n");
//Reboot device after 20 continuous errors (~ 20sec)
while(1);
//if(mqtt_err_cnt++ > 20)
//{
// printf("Connection with MQTT Broker was lost!!\r\nReboot the board..\r\n");
// while(1);
//}
//while(1);
if(mqtt_err_cnt++ > 20)
{
printf("Connection with MQTT Broker was lost!!\r\nReboot the board..\r\n");
while(1);
}
}
}