|
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 |
| 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 | 54 |
|
| 55 | +#define WIFI_DEVICE "wlo1" // wlo1 for dev machine |
55 | 56 |
|
56 | 57 | #define AP_NAME m_dev->serial() + "-wombat"
|
57 | 58 | #define AP_SSID (AP_NAME).toUtf8()
|
@@ -275,8 +276,6 @@ void NetworkManager::changeWifiBands(QString band, int channel)
|
275 | 276 | qDebug() << "Correct connection ssid " << connectionSettings[NM_802_11_WIRELESS_KEY]["ssid"].toString();
|
276 | 277 | QPair<Connection, QDBusObjectPath> correctConnectionPair = getConnection(connectionSettings[NM_802_11_WIRELESS_KEY]["ssid"].toString());
|
277 | 278 |
|
278 |
| - |
279 |
| - |
280 | 279 | QDBusPendingReply<QDBusObjectPath> reply = m_nm->ActivateConnection(correctConnectionPair.second, devicePath, QDBusObjectPath("/"));
|
281 | 280 | reply.waitForFinished();
|
282 | 281 | getReply(reply);
|
@@ -325,6 +324,29 @@ bool NetworkManager::enableAP()
|
325 | 324 | qDebug() << "AP Path: " << apPath.path();
|
326 | 325 | qDebug() << "AP Path Connection already exists";
|
327 | 326 | qDebug() << "AP Strength: " << active().strength();
|
| 327 | + OrgFreedesktopNetworkManagerSettingsConnectionInterface connection(NM_SERVICE, apPath.path(), QDBusConnection::systemBus()); |
| 328 | + |
| 329 | + Connection settings = connection.GetSettings().value(); |
| 330 | + |
| 331 | + bool containsBand = settings.contains("band"); |
| 332 | + bool containsChannel = settings.contains("channel"); |
| 333 | + |
| 334 | + // Check if the settings contain "band" and "channel" |
| 335 | + if (!containsBand || !containsChannel) |
| 336 | + { |
| 337 | + qDebug() << "Missing 'band' or 'channel' in AP settings. Recreating AP configuration."; |
| 338 | + |
| 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(); |
| 347 | + m_nm->ActivateConnection(apPath, devicePath, QDBusObjectPath("/")); |
| 348 | + return true; |
| 349 | + } |
328 | 350 |
|
329 | 351 | if (NetworkManager::ref().isActiveConnectionOn() == true)
|
330 | 352 | {
|
@@ -684,30 +706,29 @@ NetworkManager::NetworkManager()
|
684 | 706 |
|
685 | 707 | void NetworkManager::getRaspberryPiType()
|
686 | 708 | {
|
687 |
| - QStringList arguments; |
688 |
| - arguments << "-c" << "cat /proc/cpuinfo | grep Revision | awk '{print $3}'"; |
689 |
| - |
690 |
| - QProcess *myProcess = new QProcess(this); |
691 |
| - myProcess->start("/bin/sh", arguments); // Use /bin/sh or /bin/bash to interpret the command |
692 |
| - myProcess->waitForFinished(); |
693 |
| - QByteArray output = myProcess->readAllStandardOutput(); |
694 |
| - |
695 |
| - qDebug() << "Revision code output: " << output; |
696 |
| - if (output.trimmed() == "a020d3" || output.trimmed() == "a020d4") |
697 |
| - { |
698 |
| - RASPBERRYPI_TYPE = "3B+"; |
699 |
| - } |
700 |
| - else if (output.trimmed() == "a02082" || output.trimmed() == "a22082" || output.trimmed() == "a32082" || output.trimmed() == "a52082" || output.trimmed() == "a22083") |
701 |
| - { |
702 |
| - RASPBERRYPI_TYPE = "3B"; |
703 |
| - } |
704 |
| - else |
705 |
| - { |
706 |
| - RASPBERRYPI_TYPE = "Unknown"; |
707 |
| - } |
708 |
| - |
709 |
| - qDebug() << "RASPBERRYPI_TYPE: " << RASPBERRYPI_TYPE; |
| 709 | + QStringList arguments; |
| 710 | + arguments << "-c" << "cat /proc/cpuinfo | grep Revision | awk '{print $3}'"; |
| 711 | + |
| 712 | + QProcess *myProcess = new QProcess(this); |
| 713 | + myProcess->start("/bin/sh", arguments); // Use /bin/sh or /bin/bash to interpret the command |
| 714 | + myProcess->waitForFinished(); |
| 715 | + QByteArray output = myProcess->readAllStandardOutput(); |
| 716 | + |
| 717 | + qDebug() << "Revision code output: " << output; |
| 718 | + if (output.trimmed() == "a020d3" || output.trimmed() == "a020d4") |
| 719 | + { |
| 720 | + RASPBERRYPI_TYPE = "3B+"; |
| 721 | + } |
| 722 | + else if (output.trimmed() == "a02082" || output.trimmed() == "a22082" || output.trimmed() == "a32082" || output.trimmed() == "a52082" || output.trimmed() == "a22083") |
| 723 | + { |
| 724 | + RASPBERRYPI_TYPE = "3B"; |
| 725 | + } |
| 726 | + else |
| 727 | + { |
| 728 | + RASPBERRYPI_TYPE = "Unknown"; |
| 729 | + } |
710 | 730 |
|
| 731 | + qDebug() << "RASPBERRYPI_TYPE: " << RASPBERRYPI_TYPE; |
711 | 732 | }
|
712 | 733 |
|
713 | 734 | void NetworkManager::nmAccessPointAdded(const QDBusObjectPath &accessPoint)
|
|
0 commit comments