print device ID in hex correctly in web

This commit is contained in:
proddy
2019-10-03 14:32:46 +02:00
parent a94b50ab12
commit 97ef705a88
2 changed files with 17 additions and 10 deletions

View File

@@ -1850,9 +1850,16 @@ void WebCallback(JsonObject root) {
item["version"] = (it)->version; item["version"] = (it)->version;
item["productid"] = (it)->product_id; item["productid"] = (it)->product_id;
char s[10]; char buffer[10];
itoa((it)->device_id, s, 16); // convert to hex // copy of my _hextoa() function from ems.cpp
item["deviceid"] = s; // to convert device_id into a 0xXX hex value string
char * p = buffer;
byte nib1 = ((it)->device_id >> 4) & 0x0F;
byte nib2 = ((it)->device_id >> 0) & 0x0F;
*p++ = nib1 < 0xA ? '0' + nib1 : 'A' + nib1 - 0xA;
*p++ = nib2 < 0xA ? '0' + nib2 : 'A' + nib2 - 0xA;
*p = '\0'; // null terminate just in case
item["deviceid"] = buffer;
} }
// send over Thermostat data // send over Thermostat data

View File

@@ -1966,7 +1966,7 @@ void _process_UBADevices(_EMS_RxTelegram * EMS_RxTelegram) {
/** /**
* type 0x02 - get the firmware version and type of an EMS device * type 0x02 - get the firmware version and type of an EMS device
* look up known devices via the product id and setup if not already set * look up known devices via the product id and make it active if not already setup
*/ */
void _process_Version(_EMS_RxTelegram * EMS_RxTelegram) { void _process_Version(_EMS_RxTelegram * EMS_RxTelegram) {
// ignore short messages that we can't interpret // ignore short messages that we can't interpret
@@ -1983,7 +1983,7 @@ void _process_Version(_EMS_RxTelegram * EMS_RxTelegram) {
if (EMS_RxTelegram->data[3] != 0x00) { if (EMS_RxTelegram->data[3] != 0x00) {
offset = 3; offset = 3;
} else { } else {
return; // ignore telegram return; // ignore whole telegram
} }
} }
@@ -2049,7 +2049,7 @@ void _process_Version(_EMS_RxTelegram * EMS_RxTelegram) {
if (typeFound) { if (typeFound) {
// its a known thermostat, add to list // its a known thermostat, add to list
_addDevice(EMS_MODELTYPE_THERMOSTAT, EMS_RxTelegram->src, product_id, version, i); // type 2 = thermostat _addDevice(EMS_MODELTYPE_THERMOSTAT, EMS_RxTelegram->src, product_id, version, i);
// if we don't have a thermostat set, use this one. it will pick the first one. // if we don't have a thermostat set, use this one. it will pick the first one.
if (((EMS_Thermostat.device_id == EMS_ID_NONE) || (EMS_Thermostat.model_id == EMS_MODEL_NONE) if (((EMS_Thermostat.device_id == EMS_ID_NONE) || (EMS_Thermostat.model_id == EMS_MODEL_NONE)
@@ -2088,7 +2088,7 @@ void _process_Version(_EMS_RxTelegram * EMS_RxTelegram) {
if (typeFound) { if (typeFound) {
// its a known SM, add to list // its a known SM, add to list
_addDevice(EMS_MODELTYPE_SM, EMS_RxTelegram->src, product_id, version, i); // type 3 = other _addDevice(EMS_MODELTYPE_SM, EMS_RxTelegram->src, product_id, version, i);
// myDebug_P(PSTR("Solar Module support enabled.")); // myDebug_P(PSTR("Solar Module support enabled."));
EMS_SolarModule.device_id = SolarModule_Devices[i].device_id; EMS_SolarModule.device_id = SolarModule_Devices[i].device_id;
@@ -2112,7 +2112,7 @@ void _process_Version(_EMS_RxTelegram * EMS_RxTelegram) {
if (typeFound) { if (typeFound) {
// its a known SM, add to list // its a known SM, add to list
_addDevice(EMS_MODELTYPE_HP, EMS_RxTelegram->src, product_id, version, i); // type 3 = other _addDevice(EMS_MODELTYPE_HP, EMS_RxTelegram->src, product_id, version, i);
// myDebug_P(PSTR("Heat Pump support enabled.")); // myDebug_P(PSTR("Heat Pump support enabled."));
EMS_HeatPump.device_id = SolarModule_Devices[i].device_id; EMS_HeatPump.device_id = SolarModule_Devices[i].device_id;
@@ -2133,10 +2133,10 @@ void _process_Version(_EMS_RxTelegram * EMS_RxTelegram) {
if (typeFound) { if (typeFound) {
// its a known other device, add to list // its a known other device, add to list
_addDevice(EMS_MODELTYPE_OTHER, EMS_RxTelegram->src, product_id, version, i); // type 3 = other _addDevice(EMS_MODELTYPE_OTHER, EMS_RxTelegram->src, product_id, version, i);
} else { } else {
// didn't recognize, add to list anyway // didn't recognize, add to list anyway
_addDevice(EMS_MODELTYPE_UNKNOWN, EMS_RxTelegram->src, product_id, version, 0); // type 4 = unknown _addDevice(EMS_MODELTYPE_UNKNOWN, EMS_RxTelegram->src, product_id, version, 0);
} }
} }