コード例 #1
0
ファイル: blackshrike.py プロジェクト: nullmuse/blackshrike
def get_ap_bssid(w_nic, essid):
    # Not needed if python-wifi gets fixed
    wifi = Wireless(w_nic)
    wifi.setEssid(essid)
    while wifi.getAPaddr() == '00:00:00:00:00:00)':
        time.sleep(1)
    return wifi.getAPaddr()
コード例 #2
0
ファイル: poll_wifi.py プロジェクト: OSUrobotics/wifi_info
def main():
    rospy.init_node('wifi_poller')
    poll_freq = rospy.get_param('~poll_freq', 1)
    interface = rospy.get_param('~interface', 'eth1')
    frame_id = rospy.get_param('~frame_id', 'base_link')

    pub = rospy.Publisher('wifi_info', WifiInfo)

    wifi = Wireless(interface)
    poll_rate = rospy.Rate(poll_freq)
    while not rospy.is_shutdown():
        info = WifiInfo()
        info.header.stamp = rospy.Time.now()
        info.header.frame_id = frame_id

        try:
            info.essid = wifi.getEssid()
            info.interface = interface
            info.status = WifiInfo.STATUS_DISCONNECTED
            if info.essid:
                info.frequency = float(wifi.getFrequency().split(' ')[0])
                info.APaddr = wifi.getAPaddr()
                info.status = WifiInfo.STATUS_CONNECTED
        except IOError:
            # This can happen with an invalid iface
            info.status = WifiInfo.STATUS_ERROR
        except Exception, e:
            info.status = WifiInfo.STATUS_ERROR
            rospy.logerr('Error: %s' % e)

        pub.publish(info)
        poll_rate.sleep()
コード例 #3
0
    def getStatus(self):
        ifobj = Wireless(self.iface)
        fq = Iwfreq()
        try:
            self.channel = str(fq.getChannel(str(ifobj.getFrequency()[0:-3])))
        except:
            self.channel = 0
        status = {
            'BSSID':
            str(ifobj.getAPaddr()),  #ifobj.getStatistics()
            'ESSID':
            str(ifobj.getEssid()),
            'quality':
            "%s/%s" %
            (ifobj.getStatistics()[1].quality, ifobj.getQualityMax().quality),
            'signal':
            str(ifobj.getStatistics()[1].siglevel - 0x100) + " dBm",
            'bitrate':
            str(ifobj.getBitrate()),
            'channel':
            str(self.channel),
            #'channel': str(fq.getChannel(str(ifobj.getFrequency()[0:-3]))),
        }

        for (key, item) in status.items():
            if item is "None" or item is "":
                status[key] = _("N/A")

        return status
コード例 #4
0
class Wifi(Network):
    def __init__(self, interfaceName='wlan0'):
        self.interfaceName = interfaceName
        self.wifi = Wireless(interfaceName)
        super(Wifi, self).__init__()
        self.event.broadcast('wifi.connected')

    def getSSID(self):
        return self.wifi.getEssid()

    def getMode(self):
        return self.wifi.getMode()

    def getWirelessName(self):
        return self.wifi.getWirelessName()

    def getBitRate(self):
        bitrate = self.wifi.wireless_info.getBitrate()
        return "Bit Rate :%s" % self.wifi.getBitrate()

    def getAvgSignalStrength(self):
        mq = self.wifi.getQualityAvg()
        return "quality: " + str(mq.quality) + " signal: " + str(mq.siglevel) \
                + " noise: " + str(mq.nlevel)

    def getMaxSignalStrength(self):
        mq = self.wifi.getQualityMax()
        return "quality: " + str(mq.quality) + " signal: " + str(mq.siglevel) \
                + " noise: " + str(mq.nlevel)

    def disconnect(self):
        os.system("ifconfig " + self.interfaceName + " down")
        self.event.broadcast('wifi.disconnected')
        super(Wifi, self).disconnect()

    def connect(self):
        os.system("ifconfig " + self.interfaceName + " up")
        self.event.broadcast('wifi.connected')
        super(Wifi, self).connect()

    # EFFECTS: Returns the AP address.
    def getAPAddress(self):
        self.disconnect()
        time.sleep(5)
        self.connect()
        return self.wifi.getAPaddr()

    def getConnectionStatus(self):
        raise Exception('WiFi mode doesn\'t support this call yet')

    def setAPAddress(self, ap):
        try:
            self.wifi.setAPaddr(ap)
        except:
            raise Exception('Unable to set AP address to ' + str(ap))

    def isConnected(self):
        return True
コード例 #5
0
    def _poll_nic(self, ts, nicname):
        """
        Poll one NIC

        :param ts: data timestamp
        :type ts: int
        :param nicname: NIC name
        :type nicname: str
        :return: data list of metric 3-tuples (name, value, timestamp)
        :rtype: ``list``
        """
        stats = [('%s.associated' % nicname, 1, ts)]
        logger.debug('Polling NIC: %s', nicname)
        wifi = Wireless(nicname)
        if wifi.getAPaddr() == '00:00:00:00:00:00':
            # unassociated; return that one stat now
            logger.warning('%s not associated (AP address 00:00:00:00:00:00',
                           nicname)
            return [('%s.associated' % nicname, 0, ts)]
        # tx power
        try:
            txpwr = wifi.wireless_info.getTXPower().value
        except IOError:
            try:
                txpwr = wifi.getTXPower().split(' ')[0]
            except IOError:
                logger.debug('Could not get TX Power for %s', nicname)
                txpwr = None
        if txpwr is not None:
            stats.append(('%s.txpower_dbm' % nicname, txpwr, ts))
        # bitrate
        try:
            br = wifi.wireless_info.getBitrate().value
            stats.append(('%s.bitrate' % nicname, br, ts))
        except Exception:
            logger.warning('Could not get birtate for %s', nicname, exc_info=1)
        # RTS
        try:
            rts = wifi.wireless_info.getRTS().value
            stats.append(('%s.rts' % nicname, rts, ts))
        except Exception:
            logger.warning('Could not get RTS for %s', nicname, exc_info=1)
        # statistics
        try:
            s = Iwstats(nicname)
            for k in s.discard.keys():
                stats.append(
                    ('%s.discard_%s' % (nicname, k), s.discard.get(k, 0), ts))
            stats.append(('%s.missed_beacons' % nicname, s.missed_beacon, ts))
            # Current Quality
            stats.append(('%s.quality' % nicname, s.qual.quality, ts))
            stats.append(('%s.noise_level' % nicname, s.qual.nlevel, ts))
            stats.append(('%s.signal_level' % nicname, s.qual.siglevel, ts))
        except Exception:
            logger.warning('Could not get stats for %s', nicname, exc_info=1)
        return stats
コード例 #6
0
ファイル: pycar.py プロジェクト: Afterglow/pycar
  def updateStates(self):
    try:
      wifi = Wireless('wlan0')
      ap_addr = wifi.getAPaddr()

      # Update Wifi Status
      if (ap_addr == "00:00:00:00:00:00"):
        self.ui.lblWifiStatus.setText('Not associated')
      else:
        self.ui.lblWifiStatus.setText(str(wifi.getEssid())+" connected")

      # Update 3G status
      ## Grep for route here

      # Update internet connectivity status
      response = os.system("ping -c 1 google.co.uk > /dev/null")
      if response == 0:
        self.ui.lblNetStatus.setText('Connected')
        netConnected = 1
      else:
        self.ui.lblNetStatus.setText('Not Connected')
        netConnected = 0

      # Update chef status
      response = os.system("ps auwwwx | grep -q chef-client")
      if response == 1:
        self.ui.lblChefRunStatus.setText('Running...')
      else:
        self.ui.lblChefRunStatus.setText('Not Running')
      try:
        f = open('/tmp/chef-lastrun')
        self.ui.lblChefStatus.setText(f.read())
        f.close()
      except:
        self.ui.lblChefStatus.setText('Unable to read')
      
      if netConnected:
        self.launchTimer = self.launchTimer - 1
        self.ui.btnLaunch.setEnabled(True)
      else:
        self.launchTimer = 15
        self.ui.btnLaunch.setEnabled(False)

      if self.launchTimer == 0:
        self.LoginForm = LoginForm()
        self.LoginForm.show()
        self.hide()

      self.ui.btnLaunch.setText("Launch ("+str(self.launchTimer)+")")
  
    finally:
      QtCore.QTimer.singleShot(1000, self.updateStates)
コード例 #7
0
 def __init__(self):
     self.clients = dict()
     w = Wireless("wlan0")
     ap = w.getAPaddr()
     self.AP = ap.lower()
     self.freq=w.getFrequency()
     self.ifname = "wlan1"
     os.system("/sbin/ifconfig %s down" % (self.ifname))
     self.wifi = Wireless(self.ifname)
     self.oldmode = self.wifi.getMode()
     self.wifi.setMode("monitor")
     os.system("/sbin/ifconfig %s up" % (self.ifname)) 
     self.wifi.setFrequency(self.freq)
コード例 #8
0
ファイル: routing.py プロジェクト: avsm/signpost
 def get_intf_details(self, ip):
     rnode = self._radix.search_best(ip)
     intf = rnode.data["intf"]
     wifi = Wireless(intf)
     res = wifi.getEssid()
     if type(res) is tuple:
         dst_mac = ""
         if rnode.data["gw"] == "0.0.0.0":
             dst_mac = self._lookup_mac(ip)
         #                print "the ns %s has a mac %s"%(ip, dst_mac)
         else:
             dst_mac = self._lookup_mac(rnode.data["gw"])
         #                print "the gw %s has a mac %s"%(rnode.ata['gw'], dst_mac)
         return dict(is_wireless=False, dst_mac=dst_mac, intf=intf, essid="", ns=ip)
     else:
         return dict(is_wireless=True, dst_mac=wifi.getAPaddr(), intf=intf, essid=res, ns=ip)
コード例 #9
0
	def queryWirelessDevice(self,iface):
		try:
			from pythonwifi.iwlibs import Wireless
			import errno
		except ImportError:
			return False
		else:
			try:
				ifobj = Wireless(iface) # a Wireless NIC Object
				wlanresponse = ifobj.getAPaddr()
			except IOError, (error_no, error_str):
				if error_no in (errno.EOPNOTSUPP, errno.ENODEV, errno.EPERM):
					return False
				else:
					print "error: ",error_no,error_str
					return True
			else:
コード例 #10
0
ファイル: Wlan.py プロジェクト: FFTEAM/enigma2-5
	def getStatus(self):
		ifobj = Wireless(self.iface)
		fq = Iwfreq()
		try:
			self.channel = str(fq.getChannel(str(ifobj.getFrequency()[0:-3])))
		except:
			self.channel = 0
		status = {
				  'BSSID': str(ifobj.getAPaddr()), #ifobj.getStatistics()
				  'ESSID': str(ifobj.getEssid()),
				  'quality': "%s/%s" % (ifobj.getStatistics()[1].quality,ifobj.getQualityMax().quality),
				  'signal': str(ifobj.getStatistics()[1].siglevel-0x100) + " dBm",
				  'bitrate': str(ifobj.getBitrate()),
				  'channel': str(self.channel),
				  #'channel': str(fq.getChannel(str(ifobj.getFrequency()[0:-3]))),
		}
		
		for (key, item) in status.items():
			if item is "None" or item is "":
					status[key] = _("N/A")
				
		return status
コード例 #11
0
ファイル: routing.py プロジェクト: vermuz/signpost
    def get_intf_details(self, ip):
        rnode = self._radix.search_best(ip)
        intf = rnode.data['intf']
        wifi = Wireless(intf)
        res = wifi.getEssid()
        if (type(res) is tuple):
            dst_mac = ""
            if (rnode.data['gw'] == "0.0.0.0"):
                dst_mac = self._lookup_mac(ip)
#                print "the ns %s has a mac %s"%(ip, dst_mac)
            else:
                dst_mac = self._lookup_mac(rnode.data['gw'])
#                print "the gw %s has a mac %s"%(rnode.ata['gw'], dst_mac)
            return dict(is_wireless=False,
                        dst_mac=dst_mac,
                        intf=intf,
                        essid="",
                        ns=ip)
        else:
            return dict(is_wireless=True,
                        dst_mac=wifi.getAPaddr(),
                        intf=intf,
                        essid=res,
                        ns=ip)
コード例 #12
0
ファイル: iwconfig.py プロジェクト: FomkaV/wifi-arsenal
def iwconfig(interface):
    """ Get wireless information from the device driver. """
    if interface not in getWNICnames():
        print "%-8.16s  no wireless extensions." % (interface, )
    else:
        wifi = Wireless(interface)
        line = """%-8.16s  %s  """ % (interface, wifi.getWirelessName())
        if (wifi.getEssid()):
            line = line + """ESSID:"%s"  \n          """ % (wifi.getEssid(), )
        else:
            line = line + "ESSID:off/any  \n          "

        # Mode, Frequency, and Access Point
        line = line + "Mode:" + wifi.getMode()
        try:
            line = line + "  Frequency:" + wifi.getFrequency()
        except IOError, (error_number, error_string):
            # Some drivers do not return frequency info if not associated
            pass

        if (wifi.wireless_info.getMode() == pythonwifi.flags.IW_MODE_ADHOC):
            ap_type = "Cell"
        else:
            ap_type = "Access Point"
        ap_addr = wifi.getAPaddr()
        if (ap_addr == "00:00:00:00:00:00"):
            ap_addr = "Not-Associated"
        line = line + "  " + ap_type + ": " + ap_addr + "   "
        print line

        # Bit Rate, TXPower, and Sensitivity line
        line = "          "
        bitrate = getBitrate(wifi)
        if bitrate:
            line = line + bitrate
        txpower = getTXPower(wifi)
        if txpower:
            line = line + txpower
        sensitivity = getSensitivity(wifi)
        if sensitivity:
            line = line + sensitivity
        print line

        # Retry, RTS, and Fragmentation line
        line = "          "
        retry = getRetrylimit(wifi)
        if retry:
            line = line + retry
        rts = getRTS(wifi)
        if rts:
            line = line + rts
        fragment = getFragmentation(wifi)
        if fragment:
            line = line + fragment
        print line

        # Encryption line
        line = "          "
        line = line + getEncryption(wifi)
        print line

        # Power Management line
        line = "          "
        line = line + getPowerManagement(wifi)
        print line

        try:
            stat, qual, discard, missed_beacon = wifi.getStatistics()
        except IOError, (error_number, error_string):
            # Some drivers do not return statistics info if not associated
            pass
コード例 #13
0
ファイル: snarfsnare.py プロジェクト: 4ZM/snarfsnare
SIGMA_MUL = 5
SIGMA_MIN = 2
SAMPLE_FREQ_HZ = 2

if options.verbose:
    print("Scanning for rouge AP's. Ctrl-C to exit.")

# Start processing. Ctrl-C to exit
while True: 
    
    time.sleep(1 / SAMPLE_FREQ_HZ)

    # Sample the network
    stat = wifi.getStatistics()[1]
    sig_level = stat.getSignallevel()
    ap_addr = wifi.getAPaddr()
    essid = wifi.getEssid()

    # First time sample on essid
    if not essid == current_essid:
        if options.verbose:
            print("Current essid: '%s' (%s)" % (essid, ap_addr))

        current_essid = essid
        current_ap_addr = ap_addr
        sig_sample = [sig_level]
        sig_avg = None
        sig_std = None
        continue

    # Check that AP addr hasn't changed
コード例 #14
0
# pip3 install dist/python-wifi-0.6.2.tar.bz2
# pip3 uninstall python-wifi

import pythonwifi.flags
from pythonwifi.iwlibs import Wireless, Iwscan

wifi = Wireless('wlp59s0')
print(wifi.getEssid())
print(wifi.getMode())

keys = wifi.getKeys()

print(wifi.getPowermanagement())
print(wifi.getQualityAvg())
print(wifi.getWirelessName())
print(wifi.getAPaddr())
print(wifi.getBitrate())
print(wifi.getChannelInfo())
print(wifi.getEncryption())
print(wifi.getFragmentation())
print(wifi.getFrequency())
print(wifi.getQualityMax())
print(wifi.getRetrylimit())
print(wifi.getRTS())
#print(wifi.getSensitivity())
print(wifi.getStatistics())
print(wifi.getTXPower())
print(wifi.getWirelessName())

for key in keys:
    print(key)
コード例 #15
0
ファイル: iwconfig.py プロジェクト: reikkaps/python3-wifi
def iwconfig(interface):
    """ Get wireless information from the device driver. """
    if interface not in getWNICnames():
        print "%-8.16s  no wireless extensions." % (interface, )
    else:
        wifi = Wireless(interface)
        line = """%-8.16s  %s  """ % (interface, wifi.getWirelessName())
        if (wifi.getEssid()):
            line = line + """ESSID:"%s"  \n          """ % (wifi.getEssid(), )
        else:
            line = line + "ESSID:off/any  \n          "

        # Mode, Frequency, and Access Point
        line = line + "Mode:" + wifi.getMode()
        try:
            line = line + "  Frequency:" + wifi.getFrequency()
        except IOError, (error_number, error_string):
            # Some drivers do not return frequency info if not associated
            pass

        if (wifi.wireless_info.getMode() == IW_MODE_ADHOC):
            ap_type = "Cell"
        else:
            ap_type = "Access Point"
        ap_addr = wifi.getAPaddr()
        if (ap_addr == "00:00:00:00:00:00"):
            ap_addr = "Not-Associated"
        line = line + "  " + ap_type + ": " + ap_addr + "   "
        print line

        # Bit Rate, TXPower, and Sensitivity line
        line = "          "
        bitrate = getBitrate(wifi)
        if bitrate:
            line = line + bitrate
        txpower = getTXPower(wifi)
        if txpower:
            line = line + txpower
        sensitivity = getSensitivity(wifi)
        if sensitivity:
            line = line + sensitivity
        print line

        # Retry, RTS, and Fragmentation line
        line = "          "
        retry = getRetrylimit(wifi)
        if retry:
            line = line + retry
        rts = getRTS(wifi)
        if rts:
            line = line + rts
        fragment = getFragmentation(wifi)
        if fragment:
            line = line + fragment
        print line

        # Encryption line
        line = "          "
        line = line + getEncryption(wifi)
        print line

        # Power Management line
        line = "          "
        line = line + getPowerManagement(wifi)
        print line

        try:
            stat, qual, discard, missed_beacon = wifi.getStatistics()
        except IOError, (error_number, error_string):
            # Some drivers do not return statistics info if not associated
            pass
コード例 #16
0
def iwconfig(interface):
    """ Get wireless information from the device driver. """
    if interface not in getWNICnames():
        print "%-8.16s  no wireless extensions." % (interface, )
    else:
        wifi = Wireless(interface)
        line = """%-8.16s  %s  """ % (interface, wifi.getWirelessName())
        if (wifi.getEssid()):
            line = line + """ESSID:"%s"  \n          """ % (wifi.getEssid(), )
        else:
            line = line + "ESSID:off/any  \n          "

        # Mode, Frequency, and Access Point
        line = line + "Mode:" + wifi.getMode()
        try:
            line = line + "  Frequency:" + wifi.getFrequency()
        except IOError as e:
            if (sys.version_info[0] == 3):
                error_number, error_string = e.args
            else:
                error_number = e[0]
                error_string = e[1]
            # Some drivers do not return frequency info if not associated
            pass

        if (wifi.wireless_info.getMode() == pythonwifi.flags.IW_MODE_ADHOC):
            ap_type = "Cell"
        else:
            ap_type = "Access Point"
        ap_addr = wifi.getAPaddr()
        if (ap_addr == "00:00:00:00:00:00"):
            ap_addr = "Not-Associated"
        line = line + "  " + ap_type + ": " + ap_addr + "   "
        print line

        # Bit Rate, TXPower, and Sensitivity line
        line = "          "
        bitrate = getBitrate(wifi)
        if bitrate:
            line = line + bitrate
        txpower = getTXPower(wifi)
        if txpower:
            line = line + txpower
        sensitivity = getSensitivity(wifi)
        if sensitivity:
            line = line + sensitivity
        print line

        # Retry, RTS, and Fragmentation line
        line = "          "
        retry = getRetrylimit(wifi)
        if retry:
            line = line + retry
        rts = getRTS(wifi)
        if rts:
            line = line + rts
        fragment = getFragmentation(wifi)
        if fragment:
            line = line + fragment
        print line

        # Encryption line
        line = "          "
        line = line + getEncryption(wifi)
        print line

        # Power Management line
        line = "          "
        line = line + getPowerManagement(wifi)
        print line

        try:
            stat, qual, discard, missed_beacon = wifi.getStatistics()
        except IOError as e:
            if (sys.version_info[0] == 3):
                error_number, error_string = e.args
            else:
                error_number = e[0]
                error_string = e[1]
            # Some drivers do not return statistics info if not associated
            pass
        else:
            # Link Quality, Signal Level and Noise Level line
            line = "          "
            line = line + "Link Quality:%s/100  " % (qual.quality, )
            line = line + "Signal level:%sdBm  " % (qual.signallevel, )
            line = line + "Noise level:%sdBm" % (qual.noiselevel, )
            print line
            # Rx line
            line = "          "
            line = line + "Rx invalid nwid:%s  " % (discard['nwid'], )
            line = line + "Rx invalid crypt:%s  " % (discard['code'], )
            line = line + "Rx invalid frag:%s" % (discard['fragment'], )
            print line
            # Tx line
            line = "          "
            line = line + "Tx excessive retries:%s  " % (discard['retries'], )
            line = line + "Invalid misc:%s   " % (discard['misc'], )
            line = line + "Missed beacon:%s" % (missed_beacon, )
            print line

    print
コード例 #17
0
ファイル: iwconfig.py プロジェクト: Thearith/cg3002py
def iwconfig(interface):
    """ Get wireless information from the device driver. """
    if interface not in getWNICnames():
        print "%-8.16s  no wireless extensions." % (interface, )
    else:
        wifi = Wireless(interface)
        print """%-8.16s  %s  ESSID:"%s" """ % (interface,
            wifi.getWirelessName(), wifi.getEssid())
        if (wifi.wireless_info.getMode() == pythonwifi.flags.IW_MODE_ADHOC):
            ap_type = "Cell"
        else:
            ap_type = "Access Point"
        ap_addr = wifi.getAPaddr()
        if (ap_addr == "00:00:00:00:00:00"):
            ap_addr = "Not-Associated"
        print """          Mode:%s  Frequency:%s  %s: %s""" % (
            wifi.getMode(), wifi.getFrequency(), ap_type, ap_addr)

        # Bit Rate, TXPower, and Sensitivity line
        line = "          "
        bitrate = getBitrate(wifi)
        if bitrate:
            line = line + bitrate
        txpower = getTXPower(wifi)
        if txpower:
            line = line + txpower
        sensitivity = getSensitivity(wifi)
        if sensitivity:
            line = line + sensitivity
        print line

        # Retry, RTS, and Fragmentation line
        line = "          "
        retry = getRetrylimit(wifi)
        if retry:
            line = line + retry
        rts = getRTS(wifi)
        if rts:
            line = line + rts
        fragment = getFragmentation(wifi)
        if fragment:
            line = line + fragment
        print line

        # Encryption line
        line = "          "
        line = line + getEncryption(wifi)
        print line

        # Power Management line
        line = "          "
        line = line + getPowerManagement(wifi)
        print line

        stat, qual, discard, missed_beacon = wifi.getStatistics()

        # Link Quality, Signal Level and Noise Level line
        line = "          "
        line = line + "Link Quality:%s/100  " % (qual.quality, )
        line = line + "Signal level:%sdBm  " % (qual.signallevel, )
        line = line + "Noise level:%sdBm" % (qual.noiselevel, )
        print line

        # Rx line
        line = "          "
        line = line + "Rx invalid nwid:%s  " % (discard['nwid'], )
        line = line + "Rx invalid crypt:%s  " % (discard['code'], )
        line = line + "Rx invalid frag:%s" % (discard['fragment'], )
        print line

        # Tx line
        line = "          "
        line = line + "Tx excessive retries:%s  " % (discard['retries'], )
        line = line + "Invalid misc:%s   " % (discard['misc'], )
        line = line + "Missed beacon:%s" % (missed_beacon, )
        print line

    print
コード例 #18
0
ファイル: Clocking.py プロジェクト: HviorForgeFlow/ras
class Clocking:
    def __init__(self, odoo, hardware):
        self.card = False  # currently swipped card code

        self.Odoo = odoo
        self.Buzz = hardware[0]  # Passive Buzzer
        self.Disp = hardware[1]  # Display
        self.Reader = hardware[2]  # Card Reader

        self.wifi = False
        self.wifi_con = Wireless('wlan0')

        self.card_logging_time_min = 1.5
        # minimum amount of seconds allowed for
        # the card logging process
        # making this time smaller means the terminal
        # is sooner ready to process the next card
        # making this time bigger allows
        # the user more time to read the message
        # shown in the display

        self.msg = False
        # Message that is used to Play a Melody or
        # Display which kind of Event happened: for example check in,
        # check out, communication with odoo not possible ...

        self.can_connect = odoo.can_connect

        self.minutes = 99
        self.checkodoo_wifi = True
        self.odoo_m = " "
        self.wifi_m = " "
        _logger.debug("Clocking Class Initialized")

    # ___________________

    def wifi_active(self):
        return self.wifi_con.getAPaddr() != "00:00:00:00:00:00"

    def get_status(self):
        return self.wifi_con.getTXPower().split(' ')[0]

    def wifi_signal_msg(self):
        if not self.wifi_active():
            msg = "    No WiFi signal"
            _logger.warn(msg)
        else:
            strength = int(self.get_status())  # in dBm
            if strength >= 79:
                msg = " " * 9 + "WiFi: " + "\u2022" * 1 + "o" * 4
                self.wifi = False
            elif strength >= 75:
                msg = " " * 9 + "WiFi: " + "\u2022" * 2 + "o" * 3
                self.wifi = True
            elif strength >= 65:
                msg = " " * 9 + "WiFi: " + "\u2022" * 3 + "o" * 2
                self.wifi = True
            elif strength >= 40:
                msg = " " * 9 + "WiFi: " + "\u2022" * 4 + "o" * 1
                self.wifi = True
            else:
                msg = " " * 9 + "WiFi: " + "\u2022" * 5
                self.wifi = True
        return msg

    def wifi_stable(self):
        msg = self.wifi_signal_msg()
        return self.wifi

    def odoo_msg(self):
        msg = "NO Odoo connected"
        self.odoo_conn = False
        if self.wifi_stable():
            if self.Odoo._get_user_id():
                msg = "           Odoo OK"
                self.odoo_conn = True
                return msg
        _logger.warn(msg)
        return msg

    def clock_sync(self):
        if not self.Odoo.uid:
            self.Odoo.set_params()  # be sure that always uid is set to
            # the last Odoo status (if connected)
        if self.can_connect(self.Odoo.url_template):
            self.Disp.display_msg("connecting")
            try:
                res = self.Odoo.check_attendance(self.card)
                if res:
                    self.msg = res["action"]
                    _logger.debug(res)
                else:
                    self.msg = "comm_failed"
            except Exception as e:
                _logger.exception(e)
                # Reset parameters for Odoo connection because fails
                # when start and odoo is not running
                self.Odoo.set_params()
                self.msg = "comm_failed"
        else:
            self.msg = "ContactAdm"  # No Odoo Connection: Contact Your Admin
        _logger.info("Clocking sync returns: %s" % self.msg)

    def get_messages(self):
        self.wifi_m = self.wifi_signal_msg()  # get wifi strength signal
        if not self.wifi:
            self.odoo_m = "NO Odoo connected"
            self.odoo_conn = False
        else:
            self.odoo_m = self.odoo_msg()  # get odoo connection msg

    def clocking(self):
        # Main Functions of the Terminal:
        # Show Time and do the clockings (check in/out)

        _logger.debug("Clocking")

        self.get_messages()

        while not (self.card == self.Odoo.adm):

            if self.checkodoo_wifi:  # odoo connected and wifi strength
                if time.localtime().tm_sec == 30:  # messages are checked
                    self.get_messages()  # only once per minute
            else:  # (on the 30s spot)
                if time.localtime().tm_sec == 31:
                    self.checkodoo_wifi = True

            if not (time.localtime().tm_min == self.minutes):  # Display is
                self.minutes = time.localtime().tm_min  # refreshed only
                self.Disp._display_time(self.wifi_m,
                                        self.odoo_m)  # once every minute

            self.card = self.Reader.scan_card()  # detect and store the UID

            # if an RFID  card is swipped
            time.sleep(0.01)

            if self.card and not (self.card.lower() == self.Odoo.adm.lower()):

                begin_card_logging = time.perf_counter()
                # store the time when the card logging process begin
                self.wifi_m = self.wifi_signal_msg()

                if not self.wifi:
                    self.msg = "ContactAdm"
                else:
                    self.clock_sync()  # synchronous: when odoo not
                    # connected, clocking not possible
                    self.odoo_m = self.odoo_msg()  # show actual status

                self.Disp.display_msg(self.msg)  # clocking message
                self.Buzz.Play(self.msg)  # clocking acoustic feedback

                rest_time = self.card_logging_time_min - (time.perf_counter() -
                                                          begin_card_logging)
                # calculating the minimum rest time
                # allowed for the user to read the display
                if rest_time < 0:
                    rest_time = 0  # the rest time can not be negative

                time.sleep(rest_time)
                self.Disp._display_time(self.wifi_m, self.odoo_m)

        self.card = False  # Reset the value of the card, in order to allow