Skip to content

Commit 3119f37

Browse files
committed
v2.1
1 parent 7b25a16 commit 3119f37

File tree

6 files changed

+112
-77
lines changed

6 files changed

+112
-77
lines changed

arduino-altherma-controller/01-interfaces.ino

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,12 @@ void (*resetFunc)(void) = 0; //declare reset function at address 0
7373
#ifdef ENABLE_DHCP
7474
void maintainDhcp() {
7575
if (data.config.enableDhcp && dhcpSuccess == true) { // only call maintain if initial DHCP request by startEthernet was successfull
76-
byte maintainResult = Ethernet.maintain();
77-
if (maintainResult == 1 || maintainResult == 3) { // renew failed or rebind failed
78-
dhcpSuccess = false;
79-
startEthernet(); // another DHCP request, fallback to static IP
80-
}
76+
Ethernet.maintain();
8177
}
8278
}
8379
#endif /* ENABLE_DHCP */
8480

85-
#ifdef ENABLE_EXTRA_DIAG
81+
#ifdef ENABLE_EXTENDED_WEBUI
8682
void maintainUptime() {
8783
uint32_t milliseconds = millis();
8884
if (last_milliseconds > milliseconds) {
@@ -96,7 +92,7 @@ void maintainUptime() {
9692
//We add the "remaining_seconds", so that we can continue measuring the time passed from the last boot of the device.
9793
seconds = (milliseconds / 1000) + remaining_seconds;
9894
}
99-
#endif /* ENABLE_EXTRA_DIAG */
95+
#endif /* ENABLE_EXTENDED_WEBUI */
10096

10197
const uint32_t ROLLOVER = 0xFFFFFF00;
10298
bool rollover() {
@@ -106,7 +102,7 @@ bool rollover() {
106102
return true;
107103
}
108104
}
109-
#ifdef ENABLE_EXTRA_DIAG
105+
#ifdef ENABLE_EXTENDED_WEBUI
110106
for (byte i = 0; i < UDP_LAST; i++) {
111107
if (data.udpCnt[i] > ROLLOVER) {
112108
return true;
@@ -115,18 +111,18 @@ bool rollover() {
115111
if (seconds > ROLLOVER) {
116112
return true;
117113
}
118-
#endif /* ENABLE_EXTRA_DIAG */
114+
#endif /* ENABLE_EXTENDED_WEBUI */
119115
return false;
120116
}
121117

122118
// resets counters to 0: data.p1p2Cnt, data.udpCnt
123119
void resetStats() {
124120
memset(data.statsDate, 0, sizeof(data.statsDate));
125121
memset(data.p1p2Cnt, 0, sizeof(data.p1p2Cnt));
126-
#ifdef ENABLE_EXTRA_DIAG
122+
#ifdef ENABLE_EXTENDED_WEBUI
127123
memset(data.udpCnt, 0, sizeof(data.udpCnt));
128124
remaining_seconds = -(millis() / 1000);
129-
#endif /* ENABLE_EXTRA_DIAG */
125+
#endif /* ENABLE_EXTENDED_WEBUI */
130126
}
131127

132128
void resetEepromStats() {
@@ -291,14 +287,14 @@ void manageController() {
291287
cmdQueue.push(0);
292288
indoorInQueue = true;
293289
}
294-
#ifdef ENABLE_EXTRA_DIAG
290+
#ifdef ENABLE_EXTENDED_WEBUI
295291
if (daikinOutdoor[0] == '\0' && outdoorInQueue == false) {
296292
cmdQueue.push(2);
297293
cmdQueue.push(PACKET_TYPE_OUTDOOR_NAME);
298294
cmdQueue.push(0);
299295
outdoorInQueue = true;
300296
}
301-
#endif /* ENABLE_EXTRA_DIAG */
297+
#endif /* ENABLE_EXTENDED_WEBUI */
302298
break;
303299
default:
304300
break;

arduino-altherma-controller/02-UDP.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ void recvUdp() {
3434
}
3535
Udp.read(command, sizeof(command));
3636
checkCommand(command, byte(udpLen));
37-
#ifdef ENABLE_EXTRA_DIAG
37+
#ifdef ENABLE_EXTENDED_WEBUI
3838
data.udpCnt[UDP_RECEIVED]++;
39-
#endif /* ENABLE_EXTRA_DIAG */
39+
#endif /* ENABLE_EXTENDED_WEBUI */
4040
}
4141
}
4242

arduino-altherma-controller/03-P1P2.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ void processParseRead(uint16_t n, uint16_t delta) {
7575
Udp.beginPacket(remIp, data.config.udpPort);
7676
Udp.write(RB, n);
7777
Udp.endPacket();
78-
#ifdef ENABLE_EXTRA_DIAG
78+
#ifdef ENABLE_EXTENDED_WEBUI
7979
data.udpCnt[UDP_SENT]++;
80-
#endif /* ENABLE_EXTRA_DIAG */
80+
#endif /* ENABLE_EXTENDED_WEBUI */
8181
}
8282
}
8383
// Parse time and date
@@ -105,15 +105,15 @@ void processParseRead(uint16_t n, uint16_t delta) {
105105
if (daikinIndoor[0] == '\0') daikinIndoor[0] = '-'; // if response from heat pup is empty, write '-' in order to prevent repeated requests from us
106106
}
107107

108-
#ifdef ENABLE_EXTRA_DIAG
108+
#ifdef ENABLE_EXTENDED_WEBUI
109109
if ((RB[0] == 0x40) && (RB[1] == 0x00) && (RB[2] == PACKET_TYPE_OUTDOOR_NAME)) {
110110
for (byte i = 0; i < NAME_SIZE - 1; i++) {
111111
if (RB[i + 4] == 0) break;
112112
daikinOutdoor[i] = RB[i + 4];
113113
}
114114
if (daikinOutdoor[0] == '\0') daikinOutdoor[0] = '-'; // if response from heat pup is empty, write '-' in order to prevent repeated requests from us
115115
}
116-
#endif /* ENABLE_EXTRA_DIAG */
116+
#endif /* ENABLE_EXTENDED_WEBUI */
117117

118118
// check for other auxiliary controllers and get controller ID
119119
if (((RB[1] & 0xFE) == 0xF0) && ((RB[2] & PACKET_TYPE_HANDSHAKE) == PACKET_TYPE_HANDSHAKE)) {

arduino-altherma-controller/05-pages.ino

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,11 @@ void contentInfo(ChunkedPrint &chunked) {
231231
}
232232
tagDivClose(chunked);
233233

234-
#ifdef ENABLE_EXTRA_DIAG
234+
#ifdef ENABLE_EXTENDED_WEBUI
235235
tagLabelDiv(chunked, F("Ethernet Sockets"));
236236
chunked.print(maxSockNum);
237237
tagDivClose(chunked);
238-
#endif /* ENABLE_EXTRA_DIAG */
238+
#endif /* ENABLE_EXTENDED_WEBUI */
239239

240240
tagLabelDiv(chunked, F("MAC Address"));
241241
for (byte i = 0; i < 6; i++) {
@@ -269,11 +269,11 @@ void contentStatus(ChunkedPrint &chunked) {
269269
tagLabelDiv(chunked, F("Daikin Indoor Unit"));
270270
tagSpan(chunked, JSON_DAIKIN_INDOOR);
271271
tagDivClose(chunked);
272-
#ifdef ENABLE_EXTRA_DIAG
272+
#ifdef ENABLE_EXTENDED_WEBUI
273273
tagLabelDiv(chunked, F("Daikin Outdoor Unit"));
274274
tagSpan(chunked, JSON_DAIKIN_OUTDOOR);
275275
tagDivClose(chunked);
276-
#endif /* ENABLE_EXTRA_DIAG */
276+
#endif /* ENABLE_EXTENDED_WEBUI */
277277
tagLabelDiv(chunked, F("Date"));
278278
tagSpan(chunked, JSON_DATE);
279279
tagDivClose(chunked);
@@ -308,21 +308,21 @@ void contentStatus(ChunkedPrint &chunked) {
308308
tagSpan(chunked, JSON_WRITE_P1P2);
309309
tagDivClose(chunked);
310310
chunked.print(F("</form><form method=post>"));
311-
#ifdef ENABLE_EXTRA_DIAG
311+
#ifdef ENABLE_EXTENDED_WEBUI
312312
tagLabelDiv(chunked, F("Run Time"));
313313
tagSpan(chunked, JSON_RUNTIME);
314314
tagDivClose(chunked);
315-
#endif /* ENABLE_EXTRA_DIAG */
315+
#endif /* ENABLE_EXTENDED_WEBUI */
316316
tagLabelDiv(chunked, F("P1P2 Packets"));
317317
tagButton(chunked, F("Reset"), ACT_RESET_STATS);
318318
chunked.print(F(" Stats since "));
319319
tagSpan(chunked, JSON_P1P2_STATS);
320320
tagDivClose(chunked);
321-
#ifdef ENABLE_EXTRA_DIAG
321+
#ifdef ENABLE_EXTENDED_WEBUI
322322
tagLabelDiv(chunked, F("UDP Messages"));
323323
tagSpan(chunked, JSON_UDP_STATS);
324324
tagDivClose(chunked);
325-
#endif /* ENABLE_EXTRA_DIAG */
325+
#endif /* ENABLE_EXTENDED_WEBUI */
326326
}
327327

328328
// IP Settings
@@ -403,7 +403,7 @@ void contentP1P2(ChunkedPrint &chunked) {
403403
tagSelect(chunked, POST_CONTROL_MODE, optionsList, 3, data.config.controllerMode);
404404
tagDivClose(chunked);
405405
tagLabelDiv(chunked, F("Connection Timeout"));
406-
tagInputNumber(chunked, POST_TIMEOUT, F0THRESHOLD, 60, data.config.connectTimeout, F("secs"));
406+
tagInputNumber(chunked, POST_TIMEOUT, F0THRESHOLD, 60, data.config.connectTimeout, F("s"));
407407
tagDivClose(chunked);
408408
tagLabelDiv(chunked, F("EEPROM Write Quota"));
409409
tagInputNumber(chunked, POST_QUOTA, 0, 100, data.config.writeQuota, F("writes per day"));
@@ -639,7 +639,7 @@ void stringDate(ChunkedPrint &chunked, byte myDate[]) {
639639

640640
void jsonVal(ChunkedPrint &chunked, const byte JSONKEY) {
641641
switch (JSONKEY) {
642-
#ifdef ENABLE_EXTRA_DIAG
642+
#ifdef ENABLE_EXTENDED_WEBUI
643643
case JSON_RUNTIME:
644644
chunked.print(seconds / (3600UL * 24L));
645645
chunked.print(F(" days, "));
@@ -668,19 +668,19 @@ void jsonVal(ChunkedPrint &chunked, const byte JSONKEY) {
668668
}
669669
}
670670
break;
671-
#endif /* ENABLE_EXTRA_DIAG */
671+
#endif /* ENABLE_EXTENDED_WEBUI */
672672
case JSON_DAIKIN_INDOOR:
673673
{
674674
chunked.print(daikinIndoor);
675675
}
676676
break;
677-
#ifdef ENABLE_EXTRA_DIAG
677+
#ifdef ENABLE_EXTENDED_WEBUI
678678
case JSON_DAIKIN_OUTDOOR:
679679
{
680680
chunked.print(daikinOutdoor);
681681
}
682682
break;
683-
#endif /* ENABLE_EXTRA_DIAG */
683+
#endif /* ENABLE_EXTENDED_WEBUI */
684684
case JSON_DATE:
685685
{
686686
stringDate(chunked, date);
@@ -692,7 +692,11 @@ void jsonVal(ChunkedPrint &chunked, const byte JSONKEY) {
692692
chunked.print(F("<br>"));
693693
chunked.print(data.eepromDaikin.total);
694694
chunked.print(F(" Total Commands<br>"));
695-
chunked.print((uint16_t)(data.eepromDaikin.total / (days(date) - days(data.eepromDaikin.date) + 1)));
695+
if (date[5] != 0) { // day can not be zero
696+
chunked.print((uint16_t)(data.eepromDaikin.total / (days(date) - days(data.eepromDaikin.date) + 1)));
697+
} else {
698+
chunked.print(F("-"));
699+
}
696700
chunked.print(F(" Daily Average (should be bellow 19)<br>"));
697701
chunked.print(data.eepromDaikin.yesterday);
698702
chunked.print(F(" Yesterday<br>"));

arduino-altherma-controller/advanced_settings.h

Lines changed: 47 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,52 @@
1-
/* Advanced settings, extra functions and default config forDaikin P1P2 ⇔ UDP Gateway
1+
/* Advanced settings, extra functions and default config
22
*/
33

4+
/****** FUNCTIONALITY ******/
5+
6+
// #define ENABLE_EXTENDED_WEBUI // Enable extended Web UI (additional items and settings), consumes FLASH memory
7+
// uncomment ENABLE_EXTENDED_WEBUI if you have a board with large FLASH memory (Arduino Mega)
8+
9+
// #define ENABLE_DHCP // Enable DHCP (Auto IP settings), consumes a lot of FLASH memory
10+
11+
12+
/****** DEFAULT CONFIGURATION ******/
13+
/*
14+
Arduino loads user settings stored in EEPROM, even if you flash new program to it.
15+
16+
Arduino loads factory defaults if:
17+
1) User clicks "Load default settings" in WebUI (factory reset configuration, keeps MAC)
18+
2) VERSION_MAJOR changes (factory reset configuration AND generates new MAC)
19+
*/
20+
21+
/****** IP Settings ******/
22+
const bool DEFAULT_AUTO_IP = false; // Default Auto IP setting (only used if ENABLE_DHCP)
23+
#define DEFAULT_STATIC_IP \
24+
{ 192, 168, 1, 254 } // Default Static IP
25+
#define DEFAULT_SUBMASK \
26+
{ 255, 255, 255, 0 } // Default Submask
27+
#define DEFAULT_GATEWAY \
28+
{ 192, 168, 1, 1 } // Default Gateway
29+
#define DEFAULT_DNS \
30+
{ 192, 168, 1, 1 } // Default DNS Server (only used if ENABLE_DHCP)
31+
32+
/****** TCP/UDP Settings ******/
33+
#define DEFAULT_REMOTE_IP \
34+
{ 192, 168, 1, 22 } // Default Remote IP (only used if ENABLE_EXTENDED_WEBUI)
35+
const bool DEFAULT_BROADCAST = true; // Default UDP Broadcast setting (Send and Receive UDP)
36+
const uint16_t DEFAULT_UDP_PORT = 10000; // Default UDP Port
37+
const uint16_t DEFAULT_WEB_PORT = 80; // Default WebUI Port
38+
39+
/****** P1P2 Settings ******/
40+
const byte DEFAULT_COTROLLER_MODE = CONTROL_MANUAL; // Default Controller Mode (CONTROL_DISABLED, CONTROL_MANUAL or CONTROL_AUTO)
41+
const byte DEFAULT_EEPROM_QUOTA = 24; // Default EEPROM Write Quota
42+
const byte DEFAUT_TEMPERATURE_HYSTERESIS = 1; // Default Target Temperature Hysteresis
43+
44+
/****** Packet Filter ******/
45+
const bool DEFAULT_SEND_ALL = false; // Default Send All Packet Types
46+
const byte DEFAULT_COUNTER_PERIOD = 10; // Default Counters Packet Request Period
47+
const byte DEFAULT_DATA_PACKETS_MODE = DATA_CHANGE_AND_REQUEST; // Default Data Packets Mode (DATA_ALWAYS, DATA_CHANGE_AND_REQUEST or DATA_ONLY_CHANGE)
48+
49+
450
/****** ADVANCED SETTINGS ******/
551

652
const byte MAX_QUEUE_DATA = 64; // total length of UDP commands stored in a queue (in bytes)
@@ -51,37 +97,3 @@ const uint16_t FETCH_INTERVAL = 2000; // Fetch API interval (ms) for
5197
const byte DATA_START = 96; // Start address where config and counters are saved in EEPROM
5298
const byte EEPROM_INTERVAL = 6; // Interval (hours) for saving Modbus statistics to EEPROM (in order to minimize writes to EEPROM)
5399

54-
/****** EXTRA FUNCTIONS ******/
55-
56-
// these do not fit into the limited flash memory of Arduino Uno/Nano, uncomment if you have a board with more memory
57-
// #define ENABLE_DHCP // Enable DHCP (Auto IP settings)
58-
// #define ENABLE_EXTRA_DIAG // Enable outdoor unit name, runtime counter and UDP statistics.
59-
60-
/****** DEFAULT FACTORY SETTINGS ******/
61-
62-
/*
63-
Please note that after boot, Arduino loads user settings stored in EEPROM, even if you flash new program to it!
64-
Arduino loads factory defaults if:
65-
1) User clicks "Load default settings" in WebUI (factory reset configuration, keeps MAC)
66-
2) VERSION_MAJOR changes (factory reset configuration AND generates new MAC)
67-
*/
68-
const config_t DEFAULT_CONFIG = {
69-
{ 192, 168, 1, 254 }, // ip
70-
{ 255, 255, 255, 0 }, // subnet
71-
{ 192, 168, 1, 1 }, // gateway
72-
{ 192, 168, 1, 1 }, // Dns (only used if ENABLE_DHCP)
73-
false, // enableDhcp (only used if ENABLE_DHCP)
74-
{ 192, 168, 1, 22 }, // remoteIp
75-
true, // udpBroadcast
76-
503, // udpPort
77-
80, // webPort
78-
CONTROL_MANUAL, // controllerMode
79-
(F0THRESHOLD * 2), // connectTimeout
80-
false, // notSupported
81-
1, // hysteresis
82-
24, // writeQuota
83-
false, // sendAllPackets
84-
10, // counterPeriod
85-
DATA_CHANGE_AND_REQUEST, // sendDataPackets
86-
{} // packetStatus
87-
};

0 commit comments

Comments
 (0)