I have a HP DeskJet 2700 printer. This printer, which is not connected to the wider internet, offers something called Wi-Fi Direct which allows you to connect to a private wifi network created by the printer and print directly to the printer. I have managed to occasionally connect to the printer via this wifi network and print using this method from my Ubuntu 22 laptop (and printing works fine in these cases or when I connect to the printer via a USB cable, so I do not have any driver issues), but there are several problems. First, Ubuntu clearly does not like the fact that the network has no external internet connection. It continually connects and disconnects to this network, trying other networks along the way, making the connection completely unstable. Eventually, it sometimes figures it out and remains connected to the printer's own wifi network, but this can take a while and it does not seem to always happen. Second, when Ubuntu eventually connects to the Wi-Fi Direct network and detects the printer and includes it in the list of printers, it creates a couple of other printers with similar names (HP-DeskJet-2700 versus HP-DeskJet versus HP-DeskJet-2700-XXXX or similar). These do not work, making it very confusing to know which one I should use. I have similar issues with multiple non-functioning printer definitions when I connect with a USB cable.
Can someone tell me how to (a) configure the wifi connection to the printer wifi network so that it just connects without testing for an external internet connection (i.e., that it connects once and remains connected), and (b) assure that only the correct printer configuration appears in the list of printers? Any help with this type of "Wi-Fi Direct" connection to a HP printer would be appreciated.
Update based on Untested Conjecture below
I tried the suggestion below, but it did not work for me. I set the wifi connection to link-local only and to only use this connection for resources on its network. This seemed to make the connection a bit more stable, but it still sometimes disconnects after previously having been connected as in the image below:
Also, the "printer" shown in the printer settings is some kind of phantom printer with no settings or driver:
Next, when I tried to add the network printer manually, either via Ubuntu Settings or the Additional printer settings dialogue or hp-setup, it would fail to add the printer with an error:
At some point, if I waited a while and did nothing, it would add some printers, but it was so unstable that I finally gave up and used a USB cable. I also reset the WiFi connection to automatic DHCP.