Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 40 additions & 49 deletions HeishaMon/decode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,72 +148,66 @@ String getErrorInfo(char* data) { // TOP44 //
return String(Error_string);
}

String addFractionalValue(String value, char* data, byte fractional_index, byte shift) {
int fractional = (int)((data[fractional_index] >> shift) & 0b111);
switch (fractional) {
case 1: // fractional .00
break;
case 2: // fractional .25
value += ".25";
break;
case 3: // fractional .50
value += ".50";
break;
case 4: // fractional .75
value += ".75";
break;
default:
break;
}
return value;
}

void resetlastalldatatime() {
lastalldatatime = 0;
lastallextradatatime = 0;
lastalloptdatatime = 0;
}

byte getByteForTopic(char* data, unsigned int Topic_Number) {
byte index;
memcpy_P(&index, &topicBytes[Topic_Number], sizeof(byte));
return data[index];
}

String getDataValue(char* data, unsigned int Topic_Number) {
String Topic_Value;
byte Input_Byte;
switch (Topic_Number) { //switch on topic numbers, some have special needs
case 1:
Topic_Value = getPumpFlow(data);
break;
case 5: {
byte cpy;
memcpy_P(&cpy, &topicBytes[Topic_Number], sizeof(byte));
Input_Byte = data[cpy];
Topic_Value = topicFunctions[Topic_Number](Input_Byte);
int fractional = (int)(data[118] & 0b111);
switch (fractional) {
case 1: // fractional .00
break;
case 2: // fractional .25
Topic_Value = Topic_Value + ".25";
break;
case 3: // fractional .50
Topic_Value = Topic_Value + ".50";
break;
case 4: // fractional .75
Topic_Value = Topic_Value + ".75";
break;
default:
break;
}
}
case 5:
Topic_Value = topicFunctions[Topic_Number](getByteForTopic(data, Topic_Number));
Topic_Value = addFractionalValue(Topic_Value, data, 118, 0);
break;
case 6: {
byte cpy;
memcpy_P(&cpy, &topicBytes[Topic_Number], sizeof(byte));
Input_Byte = data[cpy];
Topic_Value = topicFunctions[Topic_Number](Input_Byte);
int fractional = (int)((data[118] >> 3) & 0b111) ;
switch (fractional) {
case 1: // fractional .00
break;
case 2: // fractional .25
Topic_Value = Topic_Value + ".25";
break;
case 3: // fractional .50
Topic_Value = Topic_Value + ".50";
break;
case 4: // fractional .75
Topic_Value = Topic_Value + ".75";
break;
default:
break;
}
}
case 6:
Topic_Value = topicFunctions[Topic_Number](getByteForTopic(data, Topic_Number));
Topic_Value = addFractionalValue(Topic_Value, data, 118, 3);
break;
case 11:
Topic_Value = String(word(data[183], data[182]) - 1);
break;
case 12:
Topic_Value = String(word(data[180], data[179]) - 1);
break;
case 56:
Topic_Value = topicFunctions[Topic_Number](getByteForTopic(data, Topic_Number));
Topic_Value = addFractionalValue(Topic_Value, data, 119, 0);
break;
case 57:
Topic_Value = topicFunctions[Topic_Number](getByteForTopic(data, Topic_Number));
Topic_Value = addFractionalValue(Topic_Value, data, 119, 3);
break;
case 90:
Topic_Value = String(word(data[186], data[185]) - 1);
break;
Expand All @@ -227,10 +221,7 @@ String getDataValue(char* data, unsigned int Topic_Number) {
Topic_Value = getModel(data);
break;
default:
byte cpy;
memcpy_P(&cpy, &topicBytes[Topic_Number], sizeof(byte));
Input_Byte = data[cpy];
Topic_Value = topicFunctions[Topic_Number](Input_Byte);
Topic_Value = topicFunctions[Topic_Number](getByteForTopic(data, Topic_Number));
break;
}
return Topic_Value;
Expand Down
4 changes: 2 additions & 2 deletions ProtocolByteDecrypt.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@
| TOP | 115 | 15 | | ? |
| TOP123/124/125/126 | 116 | 5a | 1st & 2nd bit Zone 2 Pump ( b01 - OFF, b10 - ON ) , 3rd & 4th bit = Zone 1 Pump ( b01 - OFF, b10 - ON ), 5th & 6th bit = 2way Valve ( b01 - Cooling, b10 - Heating) , 7th & 8th bit = 3way Valve ( b01 - Room, b10 - Tank) | Z1 & Z2 Pump 2way & 3wa Valve staus |
| TOP69 | 117 | 05 | Sterilization on/off (bit5and6) , Z2 active (bit7) ,Z1 active (bit8)| Sterilization status Zone active information (look byte #6) |
| TOP | 118 | 12 | | fractional info for TOP5 and TOP6 values |
| TOP | 119 | 12 | | ? |
| TOP | 118 | 12 | | fractional info for TOP5 (first 3 LSB) and TOP6 (next 3 LSB) values |
| TOP | 119 | 12 | | fractional info for TOP139 (first 3 LSB) and (assumed) TOP140 (next 3 LSB) values |
| TOP | 120 | 19 | 3rd & 4th bit = b01 Heater Inactive ,b10 Heater Active<br/> 5th & 6th bit = b01 Cooling Inactive ,b10 Cooling Active<br/> | Custom menu settings<br/>Back-up Heater<br/>Cool Mode |
| TOP | 121 | 00 | | 0 byte |
| TOP | 122 | 00 | | 0 byte |
Expand Down