Closed PropGit closed 7 years ago
As it relates to Issue #94, a history list will be used to retain the original Name (as well as IP and MAC) of a wireless port and will contain also a UID and Life field used by this issue to form a more stable and unique list of wireless port identifiers.
The process of making a new entry unique is as follows:
Return Wi-Fi Identifier list as a sorted list of UID values appended to the wired ports list.
NOTE: Issue #94 describes the trimming of the history list; an important part where the Life field comes into play.
Solved and merged via PR #96!
The official process of generating a port list (including features of Issue #86 and Issue #94) is: wiredMaxLife is 2 wirelessMaxLife is 4 portRec is a list containing fields UID, Name, IP, MAC, and Life
Return Wi-Fi Identifier list as a sorted list of UID values appended to the wired ports list.
For each "Create new portRec entry..." step: MAC = entry's MAC address stripped of colons (:) UID = Name Size = 1
Future Enhancement:
Prevent duplicate "names" from appearing in port list. This is a possibility now since users can custom-name their Wi-Fi Modules. Since BlocklyProp's Editor doesn't keep track of the port's IP address, only the name is passed between BPClient and BP. This means that BPClient can be asked to download to a port name that resolves to two or more IP addresses if there happens to be two or more Wi-Fi Modules in the with exactly the same name.
Suggestion: Enhance to adjust names upon the get_ports() request, to be guaranteed unique (within that particular list) by using part of the device's MAC address appended to the name(s) when, and only when, a duplicate is found. Keep the modification as short as practical.
Sample, but yet imperfect, code (copy and paste into IDLE and run). This code doesn't handle possibility that the new modification can match another existing module name and, rather than spend more time now, it's added here as just a potential starting point for a future enhancement.
NOTE: This includes some helper functions that already exist in BlocklyLoader.py... they are only included here to facilitate quick, isolated development in IDLE. See the "Main Code" section for the real point.