Skip to content

Commit 3fc03a5

Browse files
Adding band/channel if the AP config doesn't already have one
1 parent 8c0c1eb commit 3fc03a5

File tree

1 file changed

+29
-14
lines changed

1 file changed

+29
-14
lines changed

src/NetworkManager.cpp

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,12 @@
4646
QDBusObjectPath AP_PATH;
4747
Connection DEFAULT_AP;
4848
QString RASPBERRYPI_TYPE;
49-
// #ifdef WOMBAT
50-
// #define WIFI_DEVICE "wlan0" // always wlan0 for raspberry pi
51-
// #else
52-
// #define WIFI_DEVICE "wlo1" // wlo1 for dev machine
53-
// #endif
54-
49+
#ifdef WOMBAT
50+
#define WIFI_DEVICE "wlan0" // always wlan0 for raspberry pi
51+
#else
5552
#define WIFI_DEVICE "wlo1" // wlo1 for dev machine
53+
#endif
54+
5655

5756
#define AP_NAME m_dev->serial() + "-wombat"
5857
#define AP_SSID (AP_NAME).toUtf8()
@@ -336,15 +335,31 @@ bool NetworkManager::enableAP()
336335
{
337336
qDebug() << "Missing 'band' or 'channel' in AP settings. Recreating AP configuration.";
338337

339-
//Delete previous AP Configuration
340-
qDebug() << "Deleting the previous AP connection: " << apPath.path();
341-
connection.Delete();
342-
// Recreate AP configuration
343-
createAPConfig();
344-
sleep(3);
345-
apPath = getAPSettingsObjectPath();
346-
qDebug() << "New apPath" << apPath.path();
338+
if (RASPBERRYPI_TYPE == "3B+")
339+
{
340+
settings[NM_802_11_WIRELESS_KEY]["band"] = "a";
341+
settings[NM_802_11_WIRELESS_KEY]["channel"] = 36;
342+
}
343+
else if (RASPBERRYPI_TYPE == "3B")
344+
{
345+
settings[NM_802_11_WIRELESS_KEY]["band"] = "bg";
346+
settings[NM_802_11_WIRELESS_KEY]["channel"] = 1;
347+
}
348+
349+
qDebug() << "Modified AP settings: band and channel added.";
350+
351+
QDBusPendingReply<void> reply = connection.Update(settings);
352+
reply.waitForFinished();
353+
354+
if (reply.isError())
355+
{
356+
qWarning() << "Error in Update:" << reply.error().message();
357+
return false;
358+
}
359+
347360
m_nm->ActivateConnection(apPath, devicePath, QDBusObjectPath("/"));
361+
362+
qDebug() << "AP settings updated and connection activated.";
348363
return true;
349364
}
350365

0 commit comments

Comments
 (0)