Skip to content

Commit 40734fc

Browse files
authored
Merge pull request #411 from BlueSCSI/eric/wifi-info-bssid
Wire up bssid and wifi auth flags
2 parents ad49caf + 8c8cb70 commit 40734fc

3 files changed

Lines changed: 31 additions & 1 deletion

File tree

lib/BlueSCSI_platform_RP2MCU/BlueSCSI_platform_network.cpp

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ static uint32_t wifi_security_auth(uint8_t security)
8383
}
8484
}
8585

86+
// Whether the current association was made with a passphrase. The CYW43 driver
87+
// has no getter for the auth mode of a live association, so remember what was
88+
// asked for at join time.
89+
static bool wifi_join_secured = false;
90+
8691
bool platform_network_supported()
8792
{
8893
/* from cores/rp2040/RP2040Support.h */
@@ -180,6 +185,8 @@ bool platform_network_wifi_join(char *ssid, char *password, bool reconnect)
180185
wifi_reconnect_time = platform_millis();
181186
}
182187

188+
wifi_join_secured = (password != NULL && password[0] != 0);
189+
183190
if (password == NULL || password[0] == 0)
184191
{
185192
if (!reconnect)
@@ -437,11 +444,28 @@ char * platform_network_wifi_bssid()
437444

438445
memset(bssid, 0, sizeof(bssid));
439446

440-
/* TODO */
447+
int ret = cyw43_wifi_get_bssid(&cyw43_state, (uint8_t *)bssid);
448+
if (ret)
449+
{
450+
dbgmsg("Failed getting Wi-Fi BSSID: ", ret);
451+
return NULL;
452+
}
441453

442454
return bssid;
443455
}
444456

457+
uint8_t platform_network_wifi_flags()
458+
{
459+
if (!wifi_join_secured)
460+
return 0;
461+
462+
// Only claim authentication for an association that actually happened
463+
if (cyw43_wifi_link_status(&cyw43_state, CYW43_ITF_STA) < CYW43_LINK_JOIN)
464+
return 0;
465+
466+
return WIFI_NETWORK_FLAG_AUTH;
467+
}
468+
445469
int platform_network_wifi_channel()
446470
{
447471
int32_t channel = 0;

lib/BlueSCSI_platform_RP2MCU/BlueSCSI_platform_network.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright (c) 2023 joshua stein <jcs@jcs.org>
3+
* Copyright (c) 2026 Eric Helgeson <eric@bluescsi.com>
34
*
45
* Permission to use, copy, modify, and distribute this software for any
56
* purpose with or without fee is hereby granted, provided that the above
@@ -35,6 +36,8 @@ void platform_network_wifi_dump_scan_list();
3536
int platform_network_wifi_rssi();
3637
char * platform_network_wifi_ssid();
3738
char * platform_network_wifi_bssid();
39+
// WIFI_NETWORK_FLAG_* bits describing the current association
40+
uint8_t platform_network_wifi_flags();
3841
int platform_network_wifi_channel();
3942
int platform_network_send(uint8_t *buf, size_t len);
4043
// Test if the communication between the network device and the BlueIDE works

lib/SCSI2SD/src/firmware/network.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright (c) 2023-2026 joshua stein <jcs@jcs.org>
3+
* Copyright (c) 2026 Eric Helgeson <eric@bluescsi.com>
34
*
45
* Permission to use, copy, modify, and distribute this software for any
56
* purpose with or without fee is hereby granted, provided that the above
@@ -181,6 +182,8 @@ void scsiNetworkWifiInfo(void)
181182

182183
wifi_cur.channel = platform_network_wifi_channel();
183184

185+
wifi_cur.flags = platform_network_wifi_flags();
186+
184187
scsiDev.data[0] = (entrysize >> 8) & 0xff;
185188
scsiDev.data[1] = entrysize & 0xff;
186189
memcpy(scsiDev.data + 2, (char *)&wifi_cur, entrysize);

0 commit comments

Comments
 (0)