[IMP] hw_escpos: add the MAC address to the ticket printed at startup

Usually when setting up a POSBox you want it to have a static IP. The
best way to do that is by configuring whatever DHCP server is
used (usually just on the router) to always assign the same IP to a
certain MAC address (naming depends on what is being used, sometimes
it's called static DHCP but it's also known as DHCP reservations and a
bunch of other names).

The process of setting this up is complicated for a non-technical user,
and this attempts to make it a little bit easier to do by immediately
giving them the correct MAC address they should use. To avoid confusion
this only prints the MAC addresses for interfaces which have an IP
address.
This commit is contained in:
Joren Van Onder 2016-01-28 15:42:11 +01:00
parent 29be9ae80b
commit 6f4e7867f0
1 changed files with 2 additions and 0 deletions

View File

@ -195,6 +195,7 @@ class EscposDriver(Thread):
localips = ['0.0.0.0','127.0.0.1','127.0.1.1']
hosting_ap = os.system('pgrep hostapd') == 0
ssid = subprocess.check_output('iwconfig 2>&1 | grep \'ESSID:"\' | sed \'s/.*"\\(.*\\)"/\\1/\'', shell=True).rstrip()
mac = subprocess.check_output('ifconfig | grep -B 1 \'inet addr\' | grep -o \'HWaddr .*\' | sed \'s/HWaddr //\'', shell=True).rstrip()
ips = [ c.split(':')[1].split(' ')[0] for c in commands.getoutput("/sbin/ifconfig").split('\n') if 'inet addr' in c ]
ips = [ ip for ip in ips if ip not in localips ]
eprint.text('\n\n')
@ -218,6 +219,7 @@ class EscposDriver(Thread):
eprint.text(ip+'\n')
if len(ips) >= 1:
eprint.text('\nMAC Address:\n' + mac + '\n')
eprint.text('\nHomepage:\nhttp://'+ips[0]+':8069\n')
eprint.text('\n\n')