Skip to main content
while True:
  if (GPIO.input(17) and my_state=='AP'):
    my_state = 'normal'

= 'normal' os.system("rm /etc/network/interfaces") os.system("ln -s /etc/network/interfaces.normal /etc/network/interfaces") os.system("ifdown wlan0 && ifup wlan0") os.system("systemctl stop hostapd") os.system("systemctl stop udhcpd") os.system("systemctl disbale hostapd") os.system("systemctl disbale udhcpd")

    os.system("rm /etc/network/interfaces")
    os.system("ln -s /etc/network/interfaces.normal /etc/network/interfaces")
    os.system("ifdown wlan0 && ifup wlan0")
    os.system("systemctl stop hostapd")
    os.system("systemctl stop udhcpd")
    os.system("systemctl disbale hostapd")
    os.system("systemctl disbale udhcpd")

  if (GPIO.input(21) and my_state==normal):
    my_state = 'ap'
    os.system("rm /etc/network/interfaces")
    os.system("ln -s /etc/network/interfaces.ap /etc/network/interfaces")
    os.system("ifdown wlan0 && ifup wlan0")
    os.system("systemctl enbale hostapd")
    os.system("systemctl enbale udhcpd")
    os.system("systemctl start hostapd")
    os.system("systemctl start udhcpd")
while True:
  if (GPIO.input(17) and my_state=='AP'):
    my_state

= 'normal' os.system("rm /etc/network/interfaces") os.system("ln -s /etc/network/interfaces.normal /etc/network/interfaces") os.system("ifdown wlan0 && ifup wlan0") os.system("systemctl stop hostapd") os.system("systemctl stop udhcpd") os.system("systemctl disbale hostapd") os.system("systemctl disbale udhcpd")

  if (GPIO.input(21) and my_state==normal):
    my_state = 'ap'
    os.system("rm /etc/network/interfaces")
    os.system("ln -s /etc/network/interfaces.ap /etc/network/interfaces")
    os.system("ifdown wlan0 && ifup wlan0")
    os.system("systemctl enbale hostapd")
    os.system("systemctl enbale udhcpd")
    os.system("systemctl start hostapd")
    os.system("systemctl start udhcpd")
while True:
  if (GPIO.input(17) and my_state=='AP'):
    my_state = 'normal'
    os.system("rm /etc/network/interfaces")
    os.system("ln -s /etc/network/interfaces.normal /etc/network/interfaces")
    os.system("ifdown wlan0 && ifup wlan0")
    os.system("systemctl stop hostapd")
    os.system("systemctl stop udhcpd")
    os.system("systemctl disbale hostapd")
    os.system("systemctl disbale udhcpd")

  if (GPIO.input(21) and my_state==normal):
    my_state = 'ap'
    os.system("rm /etc/network/interfaces")
    os.system("ln -s /etc/network/interfaces.ap /etc/network/interfaces")
    os.system("ifdown wlan0 && ifup wlan0")
    os.system("systemctl enbale hostapd")
    os.system("systemctl enbale udhcpd")
    os.system("systemctl start hostapd")
    os.system("systemctl start udhcpd")
some edits in python code example
Source Link
Joe Platano
  • 852
  • 8
  • 19
while True:
  if (GPIO.input(17) and status==APmy_state=='AP'):
    os.system("rm /etc/network/interfaces")
    os.system("ln -s /etc/network/interfaces.normal /etc/network/interfaces")
    os.system("ifdown wlan0 && ifup wlan0")my_state
 

= 'normal' os.system("rm /etc/network/interfaces") os.system("ln -s /etc/network/interfaces.normal /etc/network/interfaces") os.system("ifdown wlan0 && ifup wlan0") os.system("systemctl stop hostapd") os.system("systemctl stop udhcpd") os.system("systemctl disbale hostapd") os.system("systemctl disbale udhcpd")

  if os.system("systemctl stop hostapd")
    osGPIO.systeminput("systemctl stop udhcpd"21)
    os.system("systemctl disbaleand hostapd"my_state==normal):
    os.system("systemctl disbale udhcpd")

  if (GPIO.input(21)my_state and= status==normal):'ap'
    os.system("rm /etc/network/interfaces")
    os.system("ln -s /etc/network/interfaces.ap /etc/network/interfaces")
    os.system("ifdown wlan0 && ifup wlan0")
    os.system("systemctl enbale hostapd")
    os.system("systemctl enbale udhcpd")
    os.system("systemctl start hostapd")
    os.system("systemctl start udhcpd")
while True:
  if (GPIO.input(17) and status==AP):
    os.system("rm /etc/network/interfaces")
    os.system("ln -s /etc/network/interfaces.normal /etc/network/interfaces")
    os.system("ifdown wlan0 && ifup wlan0")
    os.system("systemctl stop hostapd")
    os.system("systemctl stop udhcpd")
    os.system("systemctl disbale hostapd")
    os.system("systemctl disbale udhcpd")

  if (GPIO.input(21) and status==normal):
    os.system("rm /etc/network/interfaces")
    os.system("ln -s /etc/network/interfaces.ap /etc/network/interfaces")
    os.system("ifdown wlan0 && ifup wlan0")
    os.system("systemctl enbale hostapd")
    os.system("systemctl enbale udhcpd")
    os.system("systemctl start hostapd")
    os.system("systemctl start udhcpd")
while True:
  if (GPIO.input(17) and my_state=='AP'):
    my_state

= 'normal' os.system("rm /etc/network/interfaces") os.system("ln -s /etc/network/interfaces.normal /etc/network/interfaces") os.system("ifdown wlan0 && ifup wlan0") os.system("systemctl stop hostapd") os.system("systemctl stop udhcpd") os.system("systemctl disbale hostapd") os.system("systemctl disbale udhcpd")

  if (GPIO.input(21) and my_state==normal):
    my_state = 'ap'
    os.system("rm /etc/network/interfaces")
    os.system("ln -s /etc/network/interfaces.ap /etc/network/interfaces")
    os.system("ifdown wlan0 && ifup wlan0")
    os.system("systemctl enbale hostapd")
    os.system("systemctl enbale udhcpd")
    os.system("systemctl start hostapd")
    os.system("systemctl start udhcpd")
added 13 characters in body
Source Link
Joe Platano
  • 852
  • 8
  • 19
while True:
  if (GPIO.input(17) and status==AP):
    os.system("rm /etc/network/interfaces")
    os.system("ln -s /etc/network/interfaces.normal /etc/network/interfaces")
    os.system("ifdown wlan0 && ifup wlan0")
    os.system("systemctl stop hostapd")
    os.system("systemctl stop udhcpd")
    os.system("systemctl disbale hostapd")
    os.system("systemctl disbale udhcpd")

  if (GPIO.input(21) and Astatus==normal):
    os.system("rm /etc/network/interfaces")
    os.system("ln -s /etc/network/interfaces.ap /etc/network/interfaces")
    os.system("ifdown wlan0 && ifup wlan0")
    os.system("systemctl enbale hostapd")
    os.system("systemctl enbale udhcpd")
    os.system("systemctl start hostapd")
    os.system("systemctl start udhcpd")
while True:
  if (GPIO.input(17) and status==AP):
    os.system("rm /etc/network/interfaces")
    os.system("ln -s /etc/network/interfaces.normal /etc/network/interfaces")
    os.system("ifdown wlan0 && ifup wlan0")
    os.system("systemctl stop hostapd")
    os.system("systemctl stop udhcpd")
    os.system("systemctl disbale hostapd")
    os.system("systemctl disbale udhcpd")

  if (GPIO.input(21) and A):
    os.system("rm /etc/network/interfaces")
    os.system("ln -s /etc/network/interfaces.ap /etc/network/interfaces")
    os.system("ifdown wlan0 && ifup wlan0")
    os.system("systemctl enbale hostapd")
    os.system("systemctl enbale udhcpd")
    os.system("systemctl start hostapd")
    os.system("systemctl start udhcpd")
while True:
  if (GPIO.input(17) and status==AP):
    os.system("rm /etc/network/interfaces")
    os.system("ln -s /etc/network/interfaces.normal /etc/network/interfaces")
    os.system("ifdown wlan0 && ifup wlan0")
    os.system("systemctl stop hostapd")
    os.system("systemctl stop udhcpd")
    os.system("systemctl disbale hostapd")
    os.system("systemctl disbale udhcpd")

  if (GPIO.input(21) and status==normal):
    os.system("rm /etc/network/interfaces")
    os.system("ln -s /etc/network/interfaces.ap /etc/network/interfaces")
    os.system("ifdown wlan0 && ifup wlan0")
    os.system("systemctl enbale hostapd")
    os.system("systemctl enbale udhcpd")
    os.system("systemctl start hostapd")
    os.system("systemctl start udhcpd")
Source Link
Joe Platano
  • 852
  • 8
  • 19
Loading