Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions notecard/notecard.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,19 +192,16 @@ class Notecard:
to reset the Notecard via Serial or I2C.
"""

_user_agent = {
'agent': 'note-python',
'os_name': sys.implementation.name,
'os_platform': sys.platform,
'os_version': sys.version
}
_user_agent_app = None
_user_agent_sent = False

def __init__(self):
"""Initialize the Notecard through a reset and configure user agent."""
self.Reset()

"""Configure user agent."""
self._user_agent_app = None
self._user_agent_sent = False
self._user_agent = {
'agent': 'note-python',
'os_name': sys.implementation.name,
'os_platform': sys.platform,
'os_version': sys.version
}
if sys.implementation.name == 'cpython':
self._user_agent['os_family'] = os.name
else:
Expand Down Expand Up @@ -284,6 +281,7 @@ def Reset(self):

def __init__(self, uart_id, debug=False):
"""Initialize the Notecard before a reset."""
super().__init__()
self._user_agent['req_interface'] = 'serial'
self._user_agent['req_port'] = str(uart_id)

Expand All @@ -292,7 +290,8 @@ def __init__(self, uart_id, debug=False):

if use_serial_lock:
self.lock = FileLock('serial.lock', timeout=1)
super().__init__()

self.Reset()


class OpenI2C(Notecard):
Expand Down Expand Up @@ -445,6 +444,7 @@ def unlock(self):

def __init__(self, i2c, address, max_transfer, debug=False):
"""Initialize the Notecard before a reset."""
super().__init__()
self._user_agent['req_interface'] = 'i2c'
self._user_agent['req_port'] = address

Expand All @@ -458,4 +458,5 @@ def __init__(self, i2c, address, max_transfer, debug=False):
self.max = 255
else:
self.max = max_transfer
super().__init__()

self.Reset()