Skip to content

Commit

Permalink
Merge pull request #3 from chanakalin/development
Browse files Browse the repository at this point in the history
Bug fix for WebUI version 21.x.x.x
  • Loading branch information
chanakalin authored Jul 23, 2022
2 parents 587de74 + 8efa4ad commit 2aa98af
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions HiLinkAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ def __init__(self, modemname, host, username=None, password=None, logger=None):
self._deviceName = None
self._loginState = False # Logged in to the session or not
self._webuiversion = None # Has to be 10 or 17/21
# webui initialization succeeded or not
self._isWebUIInitialized = False
# in an operation or not
self._inOperation = False
# session refresh interval in seconds
Expand Down Expand Up @@ -312,7 +314,13 @@ def initialize(self):
self._deviceClassify = None
self._deviceName = None
# Initialize session
self.httpGet(endpoint="/")
try:
self.httpGet(endpoint="/")
self._isWebUIInitialized = True
except Exception as e:
# WebUI initialization failed
self._isWebUIInitialized = False
self.logger.error(e)
# get request verification token
# first webUI 10 or 21
try:
Expand Down Expand Up @@ -376,7 +384,7 @@ def initialize(self):
if "response" in hilinkLogin:
if int(hilinkLogin['response']['hilink_login']) == 0:
# wingles always comes with authentication even hilink_login==0
if str(self._deviceClassify).upper() == "WINGLE":
if str(self._deviceClassify).upper() == "WINGLE" or str(self._deviceClassify).upper() == "MOBILE-WIFI":
self._loginRequired = True
else:
self._loginRequired = False
Expand Down Expand Up @@ -639,17 +647,19 @@ def run(self):
self._lastSessionRefreshed = 0
# set default stopped into false
self._isStopped = False
# if not stop initialized
while not self._stopped:
if time.time() >= (self._lastSessionRefreshed + self.getSessionRefreshInteval()):
# validate session
self.validateSession()
# reset last session refreshed
self._lastSessionRefreshed = time.time()
# 0.5 second delay in loop
time.sleep(0.5)
####### Loop delay ###########
# stopping completed
#if webUI successfully initialized start the thread
if self._isWebUIInitialized:
# if not stop initialized
while not self._stopped:
if time.time() >= (self._lastSessionRefreshed + self.getSessionRefreshInteval()):
# validate session
self.validateSession()
# reset last session refreshed
self._lastSessionRefreshed = time.time()
# 0.5 second delay in loop
time.sleep(0.5)
####### Loop delay ###########
# at the end of termination mark as stopped
self._isStopped = True

####################################################
Expand Down

0 comments on commit 2aa98af

Please sign in to comment.