Commit a3493db11efa99d3d80cecdded748b834b16b40e

Authored by Adhidarma Hadiwinoto
1 parent 3bc160d88b

min signal

Showing 1 changed file with 10 additions and 0 deletions Side-by-side Diff

... ... @@ -35,6 +35,7 @@ SLEEP_BETWEEN_BALANCE_N_TOPUP = config.getint('globals', 'SLEEP_BETWEEN_BALANCE_
35 35 TOPUP_USSD_TIMEOUT = config.getint('globals', 'TOPUP_USSD_TIMEOUT')
36 36 SLEEP_AFTER_USSD_ERROR = 180
37 37  
  38 +MIN_SIGNAL_STRENGTH = 15
38 39 MIN_BALANCE = config.getint('globals', 'MIN_BALANCE')
39 40  
40 41 PULL_COUNT = 0
... ... @@ -440,10 +441,19 @@ def saveBalanceToRedis(balance):
440 441 redis_pipe.execute()
441 442  
442 443 def pull(modem):
  444 + global PRODUCTS
443 445 global PULL_COUNT
444 446 global BALANCE
445 447 global DISABLE_SEM
  448 + global MIN_SIGNAL_STRENGTH
446 449  
  450 + if not PRODUCTS:
  451 + return
  452 +
  453 + signalStrength = modem.signalStrength
  454 + if signalStrength < MIN_SIGNAL_STRENGTH:
  455 + logger.warn('Signal strength {0} < {1}, skipping pull'.format(signalStrength, MIN_SIGNAL_STRENGTH))
  456 + return
447 457  
448 458 pull_per_minute = 60 / PULL_INTERVAL
449 459