Compare commits
7 Commits
1b055628c3
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| d95e123f7b | |||
| a250a28cc0 | |||
| e327e1ab21 | |||
| 02f992a97b | |||
| 53f5b78356 | |||
| 207c5e67ab | |||
| 8f951d3f73 |
@@ -179,6 +179,8 @@ char* MQTTFormat_toClientString(char* strbuf, int32_t strbuflen, uint8_t* buf, i
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(void) strindex;
|
||||||
|
|
||||||
return strbuf;
|
return strbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,6 +262,7 @@ char* MQTTFormat_toServerString(char* strbuf, int32_t strbuflen, uint8_t* buf, i
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(void) strindex;
|
||||||
strbuf[strbuflen] = '\0';
|
strbuf[strbuflen] = '\0';
|
||||||
return strbuf;
|
return strbuf;
|
||||||
}
|
}
|
||||||
|
|||||||
18
compile_flags.txt
Normal file
18
compile_flags.txt
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
-D
|
||||||
|
__AVR_ATmega2560__
|
||||||
|
-D
|
||||||
|
F_CPU=16000000UL
|
||||||
|
-D
|
||||||
|
_WIZCHIP_=W5100
|
||||||
|
-I
|
||||||
|
/usr/lib/avr/include
|
||||||
|
-I
|
||||||
|
Internet
|
||||||
|
-I
|
||||||
|
Internet/MQTT
|
||||||
|
-I
|
||||||
|
Internet/MQTT/MQTTPacket/src
|
||||||
|
-I
|
||||||
|
Ethernet
|
||||||
|
-I
|
||||||
|
Ethernet/W5500
|
||||||
13
main.c
13
main.c
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
#include "util/delay.h"
|
#include "util/delay.h"
|
||||||
|
|
||||||
#define PLC_MQTT_ENABLED 0
|
#define PLC_MQTT_ENABLED 1
|
||||||
|
|
||||||
Client mqtt_client;
|
Client mqtt_client;
|
||||||
|
|
||||||
@@ -86,7 +86,7 @@ void do_luefter(){
|
|||||||
if (read_Input(BTN_LUEFTER_PLUS, RISING) && (fan_value+STEP_SIZE <= TOP_VALUE)) {
|
if (read_Input(BTN_LUEFTER_PLUS, RISING) && (fan_value+STEP_SIZE <= TOP_VALUE)) {
|
||||||
fan_value += STEP_SIZE;
|
fan_value += STEP_SIZE;
|
||||||
#if PLC_MQTT_ENABLED
|
#if PLC_MQTT_ENABLED
|
||||||
char _msg[3];
|
char _msg[4];
|
||||||
sprintf(_msg, "%d", fan_value * 100 / 40);
|
sprintf(_msg, "%d", fan_value * 100 / 40);
|
||||||
mqtt_pub(&mqtt_client, "/Filamentanlage/04_Messmodul/state/LuefterSpeed", _msg, 3);
|
mqtt_pub(&mqtt_client, "/Filamentanlage/04_Messmodul/state/LuefterSpeed", _msg, 3);
|
||||||
#endif
|
#endif
|
||||||
@@ -96,7 +96,7 @@ void do_luefter(){
|
|||||||
if (read_Input(BTN_LUEFTER_MINUS, RISING) && (fan_value-STEP_SIZE >= STEP_SIZE)) {
|
if (read_Input(BTN_LUEFTER_MINUS, RISING) && (fan_value-STEP_SIZE >= STEP_SIZE)) {
|
||||||
fan_value -= STEP_SIZE;
|
fan_value -= STEP_SIZE;
|
||||||
#if PLC_MQTT_ENABLED
|
#if PLC_MQTT_ENABLED
|
||||||
char _msg[3];
|
char _msg[4];
|
||||||
sprintf(_msg, "%d", fan_value * 100 / 40);
|
sprintf(_msg, "%d", fan_value * 100 / 40);
|
||||||
mqtt_pub(&mqtt_client, "/Filamentanlage/04_Messmodul/state/LuefterSpeed", _msg, 3);
|
mqtt_pub(&mqtt_client, "/Filamentanlage/04_Messmodul/state/LuefterSpeed", _msg, 3);
|
||||||
#endif
|
#endif
|
||||||
@@ -207,7 +207,7 @@ int main()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("--MQTT Connected ERROR: %ld\r\n", mqtt_rc);
|
printf("--MQTT Connected ERROR: %ld\r\n", mqtt_rc);
|
||||||
//while(1); //Reboot the board
|
while(1); //Reboot the board
|
||||||
}
|
}
|
||||||
|
|
||||||
// Subscribe to all topics
|
// Subscribe to all topics
|
||||||
@@ -222,10 +222,10 @@ int main()
|
|||||||
uint32_t timer_blink_outs = millis();
|
uint32_t timer_blink_outs = millis();
|
||||||
uint32_t timer_send_uptime = millis();
|
uint32_t timer_send_uptime = millis();
|
||||||
|
|
||||||
OCR3B = 127;
|
|
||||||
|
|
||||||
#if PLC_MQTT_ENABLED
|
#if PLC_MQTT_ENABLED
|
||||||
mqtt_pub(&mqtt_client, "/Filamentanlage/04_Messmodul/state/Luefter", "aus", 3);
|
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
|
#endif
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
@@ -299,6 +299,7 @@ void timer3_init(void)
|
|||||||
TCCR3A |= (1<<WGM30); // PWM Mode with ocra top
|
TCCR3A |= (1<<WGM30); // PWM Mode with ocra top
|
||||||
TCCR3B |= (1<<WGM33);
|
TCCR3B |= (1<<WGM33);
|
||||||
OCR3A = TOP_VALUE;
|
OCR3A = TOP_VALUE;
|
||||||
|
OCR3B = 0;
|
||||||
|
|
||||||
TCCR3B |= (0<<CS32)|(1<<CS31)|(0<<CS30); // PS 1:1
|
TCCR3B |= (0<<CS32)|(1<<CS31)|(0<<CS30); // PS 1:1
|
||||||
TCCR3A |= (1<<COM3B1) | (0<<COM3B0);
|
TCCR3A |= (1<<COM3B1) | (0<<COM3B0);
|
||||||
|
|||||||
12
mqtt.c
12
mqtt.c
@@ -56,11 +56,11 @@ void mqtt_pub(Client* mqtt_client, char * mqtt_topic, char * mqtt_msg, int mqtt_
|
|||||||
{
|
{
|
||||||
printf(" - ERROR\r\n");
|
printf(" - ERROR\r\n");
|
||||||
//Reboot device after 20 continuous errors (~ 20sec)
|
//Reboot device after 20 continuous errors (~ 20sec)
|
||||||
while(1);
|
//while(1);
|
||||||
//if(mqtt_err_cnt++ > 20)
|
if(mqtt_err_cnt++ > 20)
|
||||||
//{
|
{
|
||||||
// printf("Connection with MQTT Broker was lost!!\r\nReboot the board..\r\n");
|
printf("Connection with MQTT Broker was lost!!\r\nReboot the board..\r\n");
|
||||||
// while(1);
|
while(1);
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user