1

So I made this little script in python that when the individual would connect to the WiFi it would tell me about their connection I am planning to write commands when someone connects however when I have my phone unlocked it follows the try and says the phone is connected printing "up". However, when I lock my phone it turns to the except and prints down. I assume this is because packets aren't being sent when my phone is locked but I don't know I am still pretty new to programming in some aspects, are there any suggestions on how to fix this? Thanks

import nmap
import time

nm = nmap.PortScanner()

Status = "up"
while 1:
    try:
        nm.scan("192.168.1.160", "22")
        Status = nm["192.168.1.160"].state()

    except:
        Status = "down"

    print(Status)
    time.sleep(5)
Dev
  • 11
  • 1
  • Welcome to StackOveflow! Could you tell us what platform you are on? Android/IOS/Windows and from where you are executing your python-code? – wuerfelfreak Dec 30 '20 at 17:18
  • I am on Windows 10 and the device I am checking for is an iPhone I am using visual studio code to execute the code – Dev Dec 30 '20 at 18:57

0 Answers0