envy / esp-knx-ip

A KNX/IP library for the ESP8266 with Arduino
MIT License
135 stars 49 forks source link

Delete Functions needed #53

Closed ascillato closed 6 years ago

ascillato commented 6 years ago

Hi @envy ,

When using and configuring the ESP-KNX-IP Library but only by code and not using the ESP-KNX-IP webpage, are needed new functions:

Can be added to the library?

Thanks a lot for your time! Great Library.

ascillato commented 6 years ago

Made the PR #54 and #55 for adding this functions.

envy commented 6 years ago

Deleting callback (and config and feedback) registrations that way this tricky, as it shifts the ids of callbacks that were registered after the to-be-deleted callback was registered. An application would then need to shift (some) of their saved ids so that it matches again. Example:

callback_id_t id1 = callback_register(...); // id1 = 0
callback_id_t id2 = callback_register(...); // id2 = 1
callback_id_t id3 = callback_register(...); // id3 = 2
callback_id_t id4 = callback_register(...); // id4 = 3
...
callback_delete_register(id2); // Moves the last two callbacks one slot up

// Now the callback that was id3 took the spot of id2 and id4 is now invalid

For assignments this is fine, as the application does not receive an id on assignment. So we can shift sstuff around. But having the callback_delete_assignment would take an argument, that the application does not even have as callback_assign returns void and not callback_assignment_t.

In the end, the structures could be modified to allow this, e.g., mark deleted spots as deleted and don't shift others. But then we would also need to reclaim them, skip deleted spots during iteration, etc.

I will add this.

ascillato commented 6 years ago

Like your approach! :+1:

ascillato commented 6 years ago

Tested and works really good !

Thanks !!!!! :+1: