python script for RaspberryPi to connect wifi automatically

后端 未结 3 1737
清酒与你
清酒与你 2021-02-03 13:01

I want to operate a WiFi dongle with RaspberryPi, (it\'s like a CPU without built-in WiFi). I need to write a python script which automatically scan for WiFi networks and a conn

3条回答
  •  死守一世寂寞
    2021-02-03 13:54

    Thank you all for your answers i made simple solution like below

    def wifiscan():
    
       allSSID = Cell.all('wlan0')
       print allSSID # prints all available WIFI SSIDs
       myssid= 'Cell(ssid=vivekHome)' # vivekHome is my wifi name
    
       for i in range(len(allSSID )):
            if str(allSSID [i]) == myssid:
                    a = i
                    myssidA = allSSID [a]
                    print b
                    break
            else:
                    print "getout"
    
       # Creating Scheme with my SSID.
       myssid= Scheme.for_cell('wlan0', 'home', myssidA, 'vivek1234') # vive1234 is the password to my wifi myssidA is the wifi name 
    
       print myssid
       myssid.save()
       myssid.activate()
    
    wifiscan()   
    

提交回复
热议问题