Ligne 57 : |
Ligne 57 : |
| | | |
| == Assigner une adresse IP Fixe == | | == Assigner une adresse IP Fixe == |
− | If you want your WiPy to connect to your home router after boot-up, and with a fixed IP address so that you can access it via telnet or FTP, use the following script as {{fname|/flash/boot.py}}:
| + | Vous pouvez utiliser le script {{fname|/flash/boot.py}} suivant si vous voulez que votre WiPy se connecter sur le routeur WiFi de votre maison en utilisant une adresse IP Fixe. |
| + | |
| + | Une adresse IP Fixe facilite les connexion Telnet et/ou FTP car vous connaissez l'adresse IP de votre WiPy: |
| | | |
| <syntaxhighlight lang="python"> | | <syntaxhighlight lang="python"> |
| import machine | | import machine |
| from network import WLAN | | from network import WLAN |
− | wlan = WLAN() # get current object, without changing the mode | + | wlan = WLAN() # Obtenir l'objet actuel, sans changer le mode |
| | | |
| + | # Configurer le WiFi uniquement sur on redemarre le WiPy. |
| + | # Ne pas modifier la config WiFi si on fait une réinitialisation logicielle avec CTRL-D |
| if machine.reset_cause() != machine.SOFT_RESET: | | if machine.reset_cause() != machine.SOFT_RESET: |
| wlan.init(WLAN.STA) | | wlan.init(WLAN.STA) |
− | # configuration below MUST match your home router settings!! | + | # La configuration ci-dessous DOIT CORRESPONDRE A VOTRE ROUTEUR WIFI!! |
| wlan.ifconfig(config=('192.168.178.107', '255.255.255.0', '192.168.178.1', '8.8.8.8')) | | wlan.ifconfig(config=('192.168.178.107', '255.255.255.0', '192.168.178.1', '8.8.8.8')) |
| | | |
| if not wlan.isconnected(): | | if not wlan.isconnected(): |
− | # change the line below to match your network ssid, security and password | + | # Modifiez la ligne suivante pour utiliser le ssid, sécurité et mot de passe de votre réseau WiFi |
− | wlan.connect('mywifi', auth=(WLAN.WPA2, 'mywifikey'), timeout=5000) | + | wlan.connect('mon_wifi', auth=(WLAN.WPA2, 'ma_cle_wifi'), timeout=5000) |
| while not wlan.isconnected(): | | while not wlan.isconnected(): |
− | machine.idle() # save power while waiting | + | machine.idle() # économiser de l'énergie pendant l'attente |
| </syntaxhighlight> | | </syntaxhighlight> |
| | | |
− | {{ambox|text=Notice how we check for the reset cause and the connection status, this is crucial in order to be able to soft reset the WiPy during a telnet session without breaking the connection.}} | + | {{ambox|text=Avez-vous remarqué le test sur la cause du réset et le statut de la connexion? Ces tests sont cruciaux pour permettre de faire un soft-reset (avec CTRL-D) durant un session REPL '''sans interrompre''' la connexion en cours.}} |
| | | |
| {{WIPY-TRAILER}} | | {{WIPY-TRAILER}} |