Remove Need to Refresh Modem Database #279
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
So this is pretty cool. I have reworked the Modem delete/add/modify routines so that they no longer care or require a refresh of the modem database. This means things like pair, sync, and adding links should no longer fail because the Modem db is out of date.
In short, if you try and add a link that already exists, the modem will return a nak. At which point we retry the action as an update instead. The same is true if you try to update a link that doesn't exist. The delete is a little more complicated and requires us to search the database first, but we can search specifically for these links.
The cool thing is that this all happens in less than a second, so it isn't even noticable to users.
The only real need to refresh the modem db now is if you want to run sync to delete extraneous entries. Otherwise, an out of date modem db shouldn't be an issue anymore.
This is also a prime example of how bad the insteon documentation is. The documentation about these commands is wrong a lot. I had to poke at things a fair bit to determine how it actually works.
I still have to write some tests to ensure that everything works as intended. But I have tested all of the various iterations on actual hardware and it works great.