Skip to content
This repository has been archived by the owner on Oct 4, 2021. It is now read-only.

Scan relevant device ids only to prevent duplicate queries #30

Closed
wants to merge 1 commit into from

Conversation

sysrun
Copy link

@sysrun sysrun commented Jan 3, 2019

This prevents the scan to query duplicate devices (like 0x10)

@proddy
Copy link
Collaborator

proddy commented Jan 3, 2019

This does prevent a lot of unnecessary reads which will fail as 'noisy telegrams', and I did consider fixing it. But I think the correct way at startup is to create a dynamic list of Model_Types with all the duplicates removed. If we need another list as in your suggestion it means another place to add when a new boiler or thermostat is introduced. The trick is to try and keep it as simple as possible.

So the easiest solution without using hashmaps or merge sorts is to replace the array with a C++ vector (something I was planning to do), sort it and then let the vector do the work

like

#include <vector>
std::vector<uint8_t> v(20); // size of 20 

// copy over the IDs from Model-type to the vector v

std::sort(v.begin(), v.end()); // sort it
std::erase( std::unique(v.begin(), v.end(), v.end() );   // delete the dups

@proddy
Copy link
Collaborator

proddy commented Jan 4, 2019

I'm working on a quick test implementation

@proddy
Copy link
Collaborator

proddy commented Jan 4, 2019

Ok, did a simple fix using a std::list. Check in to version 1.2.4

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants