Page 1 of 2

Setting hostname on Pico W

Posted: Wed Jul 13, 2022 9:30 pm
by scruss
Can the hostname be set on cyw43-based boards? My Raspberry Pi Pico W's all want to appear as PYBD, which seems to be the hard-coded hostname in the driver:

netif_set_hostname(n, "PYBD");

WLAN.config(dhcp_hostname="...") or WLAN.config(hostname="...") are not supported as parameters, either.

Re: Setting hostname on Pico W

Posted: Thu Jul 14, 2022 12:42 am
by jimmo
scruss wrote:
Wed Jul 13, 2022 9:30 pm
Can the hostname be set on cyw43-based boards?
Not at the moment. Same issue (unsurprisingly) on the pybd.

It's quite a simple fix - just need to wire up the plumbing to ultimately call netif_set_hostname like you say. It's been on my TODO list for a while because I have a project with several pyboards on the same network... but just haven't got to it yet.

Re: Setting hostname on Pico W

Posted: Thu Jul 14, 2022 2:52 pm
by scruss
Thanks, Jim. This is a nice to have enhancement rather than an i-can't-connect issue.

I've put a feature request here: Set hostname on cyw43-based boards - Issue #8910 - micropython/micropython. Sorry I can't contribute code or sponsorship, and cakes don't travel well.

Re: Setting hostname on Pico W

Posted: Thu Jul 21, 2022 10:07 pm
by zeit0dn1
+1 needing this.

I have a project where I will have at least 2 pico W's on the same network, probably many more once I get more familiar with them.

Re: Setting hostname on Pico W

Posted: Fri Jul 22, 2022 9:16 pm
by scruss
There's a PR, but it hasn't been accepted yet: CYW43: Allow setting hostname. #8918

and of course, despite searching, my issue was a duplicate. Here's the live issue: Can't set hostname in AP mode

Re: Setting hostname on Pico W

Posted: Fri Aug 05, 2022 11:56 pm
by cubbieco
The pull request has been closed which I think means it is merged in. I downloaded the latest build v1.19.1-240-g9dfabcd6d (2022-08-05) .uf2 and I've tried setting the hostname:

Code: Select all

sta_if.config("hostname")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: unknown config param
So now I don't know if the parameter "hostname" is wrong or if it just isn't in the latest build yet. Any ideas?

Re: Setting hostname on Pico W

Posted: Sun Aug 07, 2022 5:08 pm
by scruss
I don't think it's in the nightlies yet. I just tried the same uf2 as you did, and the only known config parameters are channel, mac, security, ssid and txpower:

Code: Select all

# check WLAN config values
# table from
# https://docs.micropython.org/en/latest/library/network.WLAN.html

import network
sta_if = network.WLAN(network.STA_IF)

for i in ("channel", "hidden", "hostname", "key", "mac",
          "reconnects", "security", "ssid", "txpower"):
    try:
        cfg=sta_if.config(i)
    except:
        cfg="unknown config parameter"
    print(i, ":", cfg)


Re: Setting hostname on Pico W

Posted: Mon Aug 08, 2022 7:17 pm
by emjellema
Hi, just tried build rp2-pico-w-20220808-unstable-v1.19.1-241-g6baeded32.uf2

But unfortunately no success.

Anyone any clues?

Re: Setting hostname on Pico W

Posted: Mon Aug 08, 2022 7:54 pm
by Roberthh
Looking into the sources, there are two variants of the CYW43 driver, one in lib/cyw43-drivers, one in drivers/cyw43. And there is a compile switch controlling which of both is used. Only the driver in drivers/cyw43 supports setting the hostname, but the standard compile uses the other driver.
Trying to build the other variant fails. Looks messy!

Re: Setting hostname on Pico W

Posted: Thu Aug 11, 2022 1:25 am
by jimmo
The drivers/cyw43 driver will be merged into the one in lib soon, hopefully for the 1.20 release.