File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import RPi .GPIO as GPIO
22import os
3+ import re
34import time
45import subprocess
56import reset_lib
67
8+ def get_serial ():
9+ pattern = r'^Serial\s*:\s*(\w+)$'
10+ cpuinfo = subprocess .check_output (['cat' , '/proc/cpuinfo' ]).decode ()
11+ lines = cpuinfo .split ('\n ' )
12+
13+ for line in lines :
14+ match = re .match (pattern , line .strip ())
15+ if not match :
16+ continue
17+ return match .group (1 )
18+
19+ return ''
20+
21+
722GPIO .setmode (GPIO .BCM )
823GPIO .setup (18 , GPIO .IN , pull_up_down = GPIO .PUD_DOWN )
924
1025counter = 0
11- serial_last_four = subprocess .check_output (['cat' , '/proc/cpuinfo' ])[- 5 :- 1 ].decode ('utf-8' )
26+ serial_last_four = get_serial ()
27+ serial_last_four = serial_last_four [- 4 :] if len (serial_last_four ) > 4 else serial_last_four # get last 4 characters of serial
1228config_hash = reset_lib .config_file_hash ()
13- ssid_prefix = config_hash ['ssid_prefix' ] + " "
29+ ssid_prefix = config_hash ['ssid_prefix' ]
1430reboot_required = False
1531
1632
You can’t perform that action at this time.
0 commit comments