Added extra KNX configuration check at startup

This commit is contained in:
Adrian Scillato 2018-08-20 00:12:37 -03:00 committed by GitHub
parent 6d1ce5bd69
commit 9e6ea1840d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 26 additions and 2 deletions

View File

@ -400,6 +400,7 @@ void KNX_DEL_CB( byte CBnum )
bool KNX_CONFIG_NOT_MATCH()
{
// Check for configured parameters that the device does not have (module changed)
for (byte i = 0; i < KNX_MAX_device_param; ++i)
{
if ( !device_param[i].show ) { // device has this parameter ?
@ -407,19 +408,42 @@ bool KNX_CONFIG_NOT_MATCH()
// Checks all GA
if ( KNX_GA_Search(i+1) != KNX_Empty ) { return true; }
// Check all CB
if ( i < 8 ) // check relays (i from 8 to 15 are toggle relays parameters)
{
if ( KNX_CB_Search(i+1) != KNX_Empty ) { return true; }
if ( KNX_CB_Search(i+9) != KNX_Empty ) { return true; }
}
if ( i > 15 ) // check sensors and others
// check sensors and others
if ( i > 15 )
{
if ( KNX_CB_Search(i+1) != KNX_Empty ) { return true; }
}
}
}
// Check for invalid or erroneous configuration (tasmota flashed without clearing the memory)
for (byte i = 0; i < Settings.knx_GA_registered; ++i)
{
if ( Settings.knx_GA_param[i] != 0 ) // the GA[i] have a parameter defined?
{
if ( Settings.knx_GA_addr[i] == 0 ) // the GA[i] with parameter have the 0/0/0 as address?
{
return true; // So, it is invalid. Reset KNX configuration
}
}
}
for (byte i = 0; i < Settings.knx_CB_registered; ++i)
{
if ( Settings.knx_CB_param[i] != 0 ) // the CB[i] have a parameter defined?
{
if ( Settings.knx_CB_addr[i] == 0 ) // the CB[i] with parameter have the 0/0/0 as address?
{
return true; // So, it is invalid. Reset KNX configuration
}
}
}
return false;
}