From 6f4e7867f0a005b7588e16160765e23036ce7abc Mon Sep 17 00:00:00 2001 From: Joren Van Onder Date: Thu, 28 Jan 2016 15:42:11 +0100 Subject: [PATCH] [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. --- addons/hw_escpos/controllers/main.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/hw_escpos/controllers/main.py b/addons/hw_escpos/controllers/main.py index c91d17364ce..0b91dc0d37e 100644 --- a/addons/hw_escpos/controllers/main.py +++ b/addons/hw_escpos/controllers/main.py @@ -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')