Skip to content

Commit

Permalink
Pass channel and max back to RRF in wifi scan data
Browse files Browse the repository at this point in the history
  • Loading branch information
dc42 committed Apr 13, 2023
1 parent 9390d0c commit 672e198
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/SocketServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1355,13 +1355,15 @@ void ProcessRequest()
if (wifiScanNum > 0) {
// By default the records are sorted by signal strength, so just
// send all ap records that fit the transfer buffer.
for(int i = 0; i < wifiScanNum && data_sz <= sizeof(transferBuffer); i++, data_sz += sizeof(WiFiScanData))
for (int i = 0; i < wifiScanNum && data_sz <= sizeof(transferBuffer); i++, data_sz += sizeof(WiFiScanData))
{
const wifi_ap_record_t& ap = wifiScanAPs[i];
WiFiScanData &d = reinterpret_cast<WiFiScanData*>(transferBuffer)[i];
SafeStrncpy((char*)(d.ssid), (char*)ap.ssid,
std::min(sizeof(d.ssid), sizeof(ap.ssid)));
SafeStrncpy((char*)(d.ssid), (const char*)ap.ssid, std::min(sizeof(d.ssid), sizeof(ap.ssid)));
d.rssi = ap.rssi;
d.primaryChannel = ap.primary;
memcpy(d.mac, ap.bssid, sizeof(d.mac));
memset(d.spare, 0, sizeof(d.spare));

if (ap.phy_11n) {
d.phymode = EspWiFiPhyMode::N;
Expand Down
3 changes: 3 additions & 0 deletions src/include/MessageFormats.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ struct WiFiScanData
int8_t rssi; /* signal strength from -100 to 0 in dB */
EspWiFiPhyMode phymode;
WiFiAuth auth;
uint8_t primaryChannel;
uint8_t mac[6];
uint8_t spare[2]; // spare fore future use
char ssid[SsidLength + 1];
};

Expand Down

0 comments on commit 672e198

Please sign in to comment.