-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactor networking layer * Switch all tests to unicast addresses (so they work on all platforms) * Add equality for device state, and tests * Adding log data for firmware and temp offset selection
- Loading branch information
Showing
12 changed files
with
884 additions
and
778 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
class DeviceInfo: | ||
"""Device information class, used to identify and connect | ||
Attributes | ||
ip: IP address (ipv4 only) of the physical device | ||
port: Usually this will always be 7000 | ||
mac: mac address, in the format 'aabbcc112233' | ||
name: Name of unit, if available | ||
""" | ||
|
||
def __init__(self, ip, port, mac, name, brand=None, model=None, version=None): | ||
self.ip = ip | ||
self.port = port | ||
self.mac = mac | ||
self.name = name if name else mac.replace(":", "") | ||
self.brand = brand | ||
self.model = model | ||
self.version = version | ||
|
||
def __str__(self): | ||
return f"Device: {self.name} @ {self.ip}:{self.port} (mac: {self.mac})" | ||
|
||
def __eq__(self, other): | ||
"""Check equality based on Device Info properties""" | ||
if isinstance(other, DeviceInfo): | ||
return ( | ||
self.mac == other.mac | ||
and self.name == other.name | ||
and self.brand == other.brand | ||
and self.model == other.model | ||
and self.version == other.version | ||
) | ||
return False | ||
|
||
def __ne__(self, other): | ||
"""Check inequality based on Device Info properties""" | ||
return not self.__eq__(other) | ||
|
Oops, something went wrong.