Lolin/Wemos D1 Mini won't connect to router

This is my first attempt at Arduino-related wireless stuff, and I'm just at a loss why it doesn't work. Here's the code:

#include <ESP8266WiFi.h>

#ifndef STASSID
#define STASSID "DATACENTER"
#define STAPSK  "aardvark"
#endif

const char* ssid     = STASSID;
const char* password = STAPSK;

const char* host = "djxmmx.net";
const uint16_t port = 17;

void setup() {
  delay(10000);
  Serial.begin(115200);

  // We start by connecting to a WiFi network

  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  /* Explicitly set the ESP8266 to be a WiFi-client, otherwise, it by default,
     would try to act as both a client and an access-point and could cause
     network-issues with your other WiFi-devices on your WiFi-network. */
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

The flashing goes fine, but I just get a never-ending series of dots on serial from that While loop. So it's not connecting to the router. My computer and phone both connect fine to the router using the same SSID and password. And yes, I'm sure the SSID is uppercase, and the password is lowercase.

So here's what I have:

Genuine Lolin D1 Mini (from their Aliexpress store), v3.1. Brand new.
Arduino 1.8.8, Portable
ESP8266 by Community v2.5.2
Buffalo router - 802.11g, 2.4GHz only, WPA2, channel 11
Windows 7/64

I guess it could be a bad Mini, but more likely it's something I'm doing wrong, or something isn't compatible. But I'm at a loss. Can anyone bail me out here?

Edit: I looked at my router's log, and found this entry repeated over and over again every four seconds while trying to connect with the Mini:

2019/10/27 20:56:08 WIRELESS wl0: 11g : DeAuthentication (rcvd. station leaving) User - 2c:f4:32:4a:5f:45 \

That User MAC addrress is the address of my Mini. So the wifi is working, and it is trying to connect, but apparently is being dumped by the router. No indication of why.

I removed v2.5.2 and installed v2.4.2, then reflashed. That didn't help. Instead of the dots, I had it print the wifi status, which repeats "6" over and over. I think thats Disconnected. The router log shows repeated DeAuthentications, as previously described.

Any help with this? Any ideas at all?

Edit:

I enabled serial debug for wifi in the board options, and get this. Can anyone explain what's happening?

SDK:2.2.1(cfd48f3)/Core:2.4.2/lwIP:2.0.3(STABLE-2_0_3_RELEASE/glue:arduino-2.4.1-13-g163bb82)/BearSSL:6d1cefc

Connecting to DATACENTER
scandone
6
6
6
6
6
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 0 (19)
wifi evt: 1
STA disconnect: 203
6
6
reconnect
6
6
6
6
6
6
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 0 (19)
wifi evt: 1
STA disconnect: 203
6
6

and so forth, over and over.

In case anyone with a similar problem should ever see this in the future:

I finally tried messing with the only router setting that I hadn't messed with. My router is 802.11g, and since the ESP8266 supposedly supports b/g/n, I had left the router set to g only. But finally I also allowed b connections, and now it works. I don't understand why b works and g doesn't, and I think g ought to work, but at least it's working now.

I'm running IDE v1.8.8 on Windows 7, ESP8266 core v2.5.2. The router is a Buffalo WHR-HP-G54 with bios dated 2006 - barely broken in.

Thanks for all the help.