Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 6021

General • Re: Static IP on Raspberry Pico

$
0
0
Well, great work @hippy ! No idea what "I think we have been chasing a Snark and it has turned out to be a Boojum." Is that similar to a snipe hunt?
"Snipe hunt" was new to me but, yes, seems the same; chasing down a non-existent problem.

My reference is to Lewis Carroll's poem, The Hunting of the Snark - An Agony, in Eight fits, where a ship's crew hunt for a Snark only to find it is something else, a Boojum - https://www.poetryfoundation.org/poems/43909/the-hunting-of-the-snark
Anyway, I would love to see your finished proof of concept code.
It is as simple as doing 'ifconfig' before 'connect' -

Code:

import secretsimport networkimport timeFIXED_IP = "192.168.0.150", "255.255.255.0", "192.168.0.1", "192.168.0.1"print("Starting")wlan = network.WLAN(network.STA_IF)wlan.active(True)wlan.ifconfig(FIXED_IP)wlan.connect(secrets.SSID, secrets.PASSWORD)while wlan.status() != 3:  print("Waiting for connection")  time.sleep(1)print("Connected")while wlan.isconnected():  print(wlan.ifconfig())  time.sleep(1)print("Disconnected")
I think to know if it works, just watch your DHCP server log real-time and if you don't see any discover nor requests from the Pico W then it worked!
Unfortunately my router doesn't log DHCP requests. So I imagine I will need a 'print' within the DHCP server, find a router which does, or would have to watch with WireShark or similar. With a mod to my MicroPython source code, LwIP tells me the IP Address I end up with wasn't assigned by DHCP but that's not proof it never sent any DHCP request.

Statistics: Posted by hippy — Sat Jan 27, 2024 12:26 pm



Viewing all articles
Browse latest Browse all 6021

Latest Images

Trending Articles



Latest Images