|
46 | 46 | QDBusObjectPath AP_PATH;
|
47 | 47 | Connection DEFAULT_AP;
|
48 | 48 | 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 |
55 | 52 | #define WIFI_DEVICE "wlo1" // wlo1 for dev machine
|
| 53 | +#endif |
| 54 | + |
56 | 55 |
|
57 | 56 | #define AP_NAME m_dev->serial() + "-wombat"
|
58 | 57 | #define AP_SSID (AP_NAME).toUtf8()
|
@@ -336,15 +335,31 @@ bool NetworkManager::enableAP()
|
336 | 335 | {
|
337 | 336 | qDebug() << "Missing 'band' or 'channel' in AP settings. Recreating AP configuration.";
|
338 | 337 |
|
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 | + |
347 | 360 | m_nm->ActivateConnection(apPath, devicePath, QDBusObjectPath("/"));
|
| 361 | + |
| 362 | + qDebug() << "AP settings updated and connection activated."; |
348 | 363 | return true;
|
349 | 364 | }
|
350 | 365 |
|
|
0 commit comments