Skip to content
Snippets Groups Projects
Commit 6f4e7867 authored by Joren Van Onder's avatar Joren Van Onder
Browse files

[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.
parent 29be9ae8
No related branches found
No related tags found
No related merge requests found
......@@ -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')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment