support for multiple productids - #278

This commit is contained in:
Paul
2020-01-03 13:10:26 +01:00
parent 0af60a320d
commit 5ce0b64bb4
4 changed files with 29 additions and 16 deletions

View File

@@ -1709,11 +1709,20 @@ void _process_Version(_EMS_RxTelegram * EMS_RxTelegram) {
// scan through known devices matching the productid
uint8_t product_id = EMS_RxTelegram->data[offset];
uint8_t i = 0;
uint8_t found_index = 0;
bool typeFound = false;
while (i < _EMS_Devices_max) {
while ((i < _EMS_Devices_max) || (!typeFound)) {
if (EMS_Devices[i].product_id == product_id) {
typeFound = true; // we have a matching product id. i is the index.
break;
// we have a matching product id
// now lets see if there is a matching device_id since product_id can be on multiple devices
// e.g. with UBAMasters, there is only one device_id 0x08. To avoid https://github.com/proddy/EMS-ESP/issues/271
_EMS_DEVICE_TYPE device_type = EMS_Devices[i].type;
for (uint8_t j = 0; j < _EMS_Devices_Types_max; j++) {
if ((EMS_Devices_Types[j].device_type == device_type) && (EMS_Devices_Types[j].device_id == device_id)) {
typeFound = true;
found_index = i;
}
}
}
i++;
}
@@ -1724,18 +1733,17 @@ void _process_Version(_EMS_RxTelegram * EMS_RxTelegram) {
return;
}
const char * device_desc_p = (EMS_Devices[i].device_desc); // pointer to the full description of the device
_EMS_DEVICE_TYPE type = EMS_Devices[i].type; // type
const char * device_desc_p = (EMS_Devices[found_index].device_desc); // pointer to the full description of the device
_EMS_DEVICE_TYPE type = EMS_Devices[found_index].type; // type
// we recognized it, see if we already have it in our recognized list
if (_addDevice(type, product_id, device_id, device_desc_p, version)) {
return; // already in list
}
uint8_t flags = EMS_Devices[i].flags; // its a new entry, set the specifics
uint8_t flags = EMS_Devices[found_index].flags; // it's a new entry, set the specifics
if ((type == EMS_DEVICE_TYPE_BOILER) && (device_id == EMS_ID_BOILER)) {
// with UBAMasters, there is only one device_id 0x08. To avoid https://github.com/proddy/EMS-ESP/issues/271
if (type == EMS_DEVICE_TYPE_BOILER) {
EMS_Boiler.device_id = device_id;
EMS_Boiler.product_id = product_id;
EMS_Boiler.device_flags = flags;

View File

@@ -211,6 +211,7 @@ typedef enum : uint8_t {
EMS_DEVICE_TYPE_SWITCH,
EMS_DEVICE_TYPE_CONTROLLER,
EMS_DEVICE_TYPE_CONNECT,
EMS_DEVICE_TYPE_MODEM,
EMS_DEVICE_TYPE_UNKNOWN
} _EMS_DEVICE_TYPE;

View File

@@ -26,6 +26,7 @@
#define EMS_ID_THERMOSTAT1 0x10 // Thermostat
#define EMS_ID_THERMOSTAT2 0x17 // Thermostat
#define EMS_ID_THERMOSTAT3 0x18 // Thermostat
#define EMS_ID_MODEM 0x19 // Modem
// mapping for EMS_Devices_Type
const _EMS_Device_Types EMS_Devices_Types[] = {
@@ -44,7 +45,8 @@ const _EMS_Device_Types EMS_Devices_Types[] = {
{EMS_ID_SWITCH, EMS_DEVICE_TYPE_SWITCH, "Switching Module"},
{EMS_ID_CONTROLLER, EMS_DEVICE_TYPE_CONTROLLER, "Controller"},
{EMS_ID_CONNECT1, EMS_DEVICE_TYPE_CONNECT, "Connect"},
{EMS_ID_CONNECT2, EMS_DEVICE_TYPE_CONNECT, "Connect"}
{EMS_ID_CONNECT2, EMS_DEVICE_TYPE_CONNECT, "Connect"},
{EMS_ID_MODEM, EMS_DEVICE_TYPE_MODEM, "Modem"}
};
@@ -257,7 +259,7 @@ static const _EMS_Device EMS_Devices[] = {
{159, EMS_DEVICE_TYPE_MIXING, "MM50 Mixing Module", EMS_DEVICE_FLAG_NONE},
{79, EMS_DEVICE_TYPE_MIXING, "MM100 Mixer Module", EMS_DEVICE_FLAG_NONE},
{80, EMS_DEVICE_TYPE_MIXING, "MM200 Mixer Module", EMS_DEVICE_FLAG_NONE},
//{78, EMS_DEVICE_TYPE_MIXING, "MM400 Mixer Module", EMS_DEVICE_FLAG_NONE},
{78, EMS_DEVICE_TYPE_MIXING, "MM400 Mixer Module", EMS_DEVICE_FLAG_NONE},
//
// HeatPump - type 0x38
@@ -266,7 +268,8 @@ static const _EMS_Device EMS_Devices[] = {
{200, EMS_DEVICE_TYPE_HEATPUMP, "HeatPump Module", EMS_DEVICE_FLAG_NONE},
//
// Other devices, like 0x11 for Switching, 0x09 for controllers, 0x02 for Connect, 0x48 for Gateway
// Other devices like controllers and modems
// such as 0x11 for Switching, 0x09 for controllers, 0x02 for Connect, 0x48 for Gateway
//
{71, EMS_DEVICE_TYPE_SWITCH, "WM10 Switch Module", EMS_DEVICE_FLAG_NONE}, // 0x11
{68, EMS_DEVICE_TYPE_CONTROLLER, "BC10/RFM20 Receiver", EMS_DEVICE_FLAG_NONE}, // 0x09
@@ -283,6 +286,7 @@ static const _EMS_Device EMS_Devices[] = {
{206, EMS_DEVICE_TYPE_CONNECT, "Bosch Easy Connect", EMS_DEVICE_FLAG_NONE}, // 0x02
{171, EMS_DEVICE_TYPE_CONNECT, "EMS-OT OpenTherm converter", EMS_DEVICE_FLAG_NONE}, // 0x02
{189, EMS_DEVICE_TYPE_GATEWAY, "Web Gateway KM200", EMS_DEVICE_FLAG_NONE}, // 0x48
{94, EMS_DEVICE_TYPE_MODEM, "RC Remote Device", EMS_DEVICE_FLAG_NONE}, // 0x19
//
// Thermostats, typically device id of 0x10, 0x17, 0x18 and 0x39 (easy)
@@ -296,10 +300,10 @@ static const _EMS_Device EMS_Devices[] = {
// Buderus/Nefit
{79, EMS_DEVICE_TYPE_THERMOSTAT, "RC10/Moduline 100", EMS_DEVICE_FLAG_RC10}, // 0x17
{77, EMS_DEVICE_TYPE_THERMOSTAT, "RC20/Moduline 300", EMS_DEVICE_FLAG_RC20}, // 0x17
{93, EMS_DEVICE_TYPE_THERMOSTAT, "RC20RF", EMS_DEVICE_FLAG_RC20}, // 0x18
{67, EMS_DEVICE_TYPE_THERMOSTAT, "RC30", EMS_DEVICE_FLAG_RC30}, // 0x10
{78, EMS_DEVICE_TYPE_THERMOSTAT, "RC30/Moduline 400", EMS_DEVICE_FLAG_RC30}, // 0x10
{86, EMS_DEVICE_TYPE_THERMOSTAT, "RC35", EMS_DEVICE_FLAG_RC35}, // 0x10
{93, EMS_DEVICE_TYPE_THERMOSTAT, "RC20RF", EMS_DEVICE_FLAG_RC20}, // 0x18
{158, EMS_DEVICE_TYPE_THERMOSTAT, "RC300/RC310/Moduline 3000/Bosch CW400/W-B Sense II", EMS_DEVICE_FLAG_RC300}, // 0x10
{165, EMS_DEVICE_TYPE_THERMOSTAT, "RC100/Moduline 1010", EMS_DEVICE_FLAG_RC300 | EMS_DEVICE_FLAG_NO_WRITE}, // 0x18, cannot write

View File

@@ -1 +1 @@
#define APP_VERSION "1.9.5b10"
#define APP_VERSION "1.9.5b11"