[nibeheatpump] Support 16-bit addressing (#13752)

* [nibeheatpump] Support for 16-bit addressing

Signed-off-by: Pauli Anttila <pauli.anttila@gmail.com>
This commit is contained in:
pali
2022-12-02 00:15:34 +02:00
committed by GitHub
parent 8d39875219
commit 383b5137e4
6 changed files with 31 additions and 41 deletions

View File

@@ -24,6 +24,7 @@
* 3.7.2022 v4.00 Send messages to IP address received from the UDP messages
* 13.7.2022 v4.01 Fixed target IP address issue
* 29.7.2022 v5.00 New configuration model and PRODINo ESP32 Ethernet v1 support with OTA update
* 19.11.2022 v5.10 Support 16-bit addressing.
*/
#define VERSION "5.00"

View File

@@ -279,12 +279,6 @@ int NibeGw::checkNibeMessage(const byte* const data, byte len)
if (data[0] != 0x5C)
return -1;
if (len >= 2)
{
if (data[1] != 0x00)
return -1;
}
if (len >= 6)
{
int datalen = data[4];
@@ -295,7 +289,7 @@ int NibeGw::checkNibeMessage(const byte* const data, byte len)
byte checksum = 0;
// calculate XOR checksum
for (int i = 2; i < (datalen + 5); i++)
for (int i = 1; i < (datalen + 5); i++)
checksum ^= data[i];
byte msg_checksum = data[datalen + 5];

View File

@@ -13,15 +13,16 @@
* ----------------------------------------------------------------------------
*
* Frame format:
* +----+----+------+-----+-----+----+----+-----+
* | 5C | 00 | ADDR | CMD | LEN | DATA | CHK |
* +----+----+------+-----+-----+----+----+-----+
* |------------ CHK -----------|
* +----+------+------+-----+-----+----+----+-----+
* | 5C | ADDR | ADDR | CMD | LEN | DATA | CHK |
* +----+------+------+-----+-----+----+----+-----+
*
* |------------ CHK ------------------|
*
* Address:
* 0x16 = SMS40
* 0x19 = RMU40
* 0x20 = MODBUS40
* 0x0016 = SMS40
* 0x0019 = RMU40
* 0x0020 = MODBUS40
*
* Checksum: XOR
*

View File

@@ -12,7 +12,7 @@
*
* ----------------------------------------------------------------------------
*
* This application listening data from Nibe F1145/F1245/F1155/F1255 heat pumps (RS485 bus)
* This application listening data from various Nibe heat pumps (RS485 bus)
* and send valid frames to configurable IP/port address by UDP packets.
* Application also acknowledge the valid packets to heat pump.
*
@@ -21,18 +21,18 @@
* MODBUS module support should be turned ON from the heat pump.
*
* Frame format:
* +----+----+------+-----+-----+----+----+-----+
* | 5C | 00 | ADDR | CMD | LEN | DATA | CHK |
* +----+----+------+-----+-----+----+----+-----+
* +----+------+------+-----+-----+----+----+-----+
* | 5C | ADDR | ADDR | CMD | LEN | DATA | CHK |
* +----+------+------+-----+-----+----+----+-----+
*
* |------------ CHK -----------|
* |------------ CHK ------------------|
*
* Address:
* 0x16 = SMS40
* 0x19 = RMU40
* 0x20 = MODBUS40
* Address:
* 0x0016 = SMS40
* 0x0019 = RMU40
* 0x0020 = MODBUS40
*
* Checksum: XOR
* Checksum: XOR
*
* When valid data is received (checksum ok),
* ACK (0x06) should be sent to the heat pump.
@@ -56,6 +56,7 @@
* 30.6.2015 v1.21 Some fixes.
* 20.2.2017 v1.22 Separated read and write token support.
* 7.2.2021 v1.23 Fixed compile error in RasPi.
* 19.11.2022 v1.30 Support 16-bit addressing.
*/
#include <signal.h>
@@ -273,12 +274,6 @@ int checkMessage(const unsigned char* const data, int len)
if (data[0] != 0x5C)
return -1;
if (len >= 2)
{
if (data[1] != 0x00)
return -1;
}
if (len >= 6)
{
int datalen = data[4];
@@ -289,7 +284,7 @@ int checkMessage(const unsigned char* const data, int len)
unsigned char calc_checksum = 0;
// calculate XOR checksum
for(int i = 2; i < (datalen + 5); i++)
for(int i = 1; i < (datalen + 5); i++)
calc_checksum ^= data[i];
unsigned char msg_checksum = data[datalen + 5];