mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-23 18:56:38 +00:00
Update esp-knx-ip.cpp
This commit is contained in:
parent
1c4f63fcb5
commit
99a0b58189
@ -207,46 +207,6 @@ callback_assignment_id_t ESPKNXIP::__callback_register_assignment(address_t addr
|
||||
return aid;
|
||||
}
|
||||
|
||||
void ESPKNXIP::callback_delete_register(callback_id_t id)
|
||||
{
|
||||
/*if (id >= registered_callback_assignments)
|
||||
return;
|
||||
|
||||
uint32_t dest_offset = 0;
|
||||
uint32_t src_offset = 0;
|
||||
uint32_t len = 0;
|
||||
if (id == 0)
|
||||
{
|
||||
// start of array, so delete first entry
|
||||
src_offset = 1;
|
||||
// registered_ga_callbacks will be 1 in case of only one entry
|
||||
// registered_ga_callbacks will be 2 in case of two entries, etc..
|
||||
// so only copy anything, if there is it at least more then one element
|
||||
len = (registered_callback_assignments - 1);
|
||||
}
|
||||
else if (id == registered_callback_assignments - 1)
|
||||
{
|
||||
// last element, don't do anything, simply decrement counter
|
||||
}
|
||||
else
|
||||
{
|
||||
// somewhere in the middle
|
||||
// need to calc offsets
|
||||
|
||||
// skip all prev elements
|
||||
dest_offset = id; // id is equal to how many element are in front of it
|
||||
src_offset = dest_offset + 1; // start after the current element
|
||||
len = (registered_callback_assignments - 1 - id);
|
||||
}
|
||||
|
||||
if (len > 0)
|
||||
{
|
||||
memmove(callback_assignments + dest_offset, callback_assignments + src_offset, len * sizeof(callback_assignment_t));
|
||||
}
|
||||
|
||||
registered_callback_assignments--;*/
|
||||
}
|
||||
|
||||
void ESPKNXIP::callback_delete_assignment(callback_assignment_id_t id)
|
||||
{
|
||||
__callback_delete_assignment(id);
|
||||
@ -313,6 +273,46 @@ callback_id_t ESPKNXIP::callback_register(String name, callback_fptr_t cb, void
|
||||
return id;
|
||||
}
|
||||
|
||||
void ESPKNXIP::callback_delete_register(callback_id_t id)
|
||||
{
|
||||
if (id >= registered_callbacks)
|
||||
return;
|
||||
|
||||
uint32_t dest_offset = 0;
|
||||
uint32_t src_offset = 0;
|
||||
uint32_t len = 0;
|
||||
if (id == 0)
|
||||
{
|
||||
// start of array, so delete first entry
|
||||
src_offset = 1;
|
||||
// registered_ga_callbacks will be 1 in case of only one entry
|
||||
// registered_ga_callbacks will be 2 in case of two entries, etc..
|
||||
// so only copy anything, if there is it at least more then one element
|
||||
len = (registered_callbacks - 1);
|
||||
}
|
||||
else if (id == registered_callbacks - 1)
|
||||
{
|
||||
// last element, don't do anything, simply decrement counter
|
||||
}
|
||||
else
|
||||
{
|
||||
// somewhere in the middle
|
||||
// need to calc offsets
|
||||
|
||||
// skip all prev elements
|
||||
dest_offset = id; // id is equal to how many element are in front of it
|
||||
src_offset = dest_offset + 1; // start after the current element
|
||||
len = (registered_callbacks - 1 - id);
|
||||
}
|
||||
|
||||
if (len > 0)
|
||||
{
|
||||
memmove(callbacks + dest_offset, callbacks + src_offset, len * sizeof(callback_t));
|
||||
}
|
||||
|
||||
registered_callbacks--;
|
||||
}
|
||||
|
||||
void ESPKNXIP::callback_assign(callback_id_t id, address_t val)
|
||||
{
|
||||
if (id >= registered_callbacks)
|
||||
|
Loading…
x
Reference in New Issue
Block a user