Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V31.0.0 Wombat Update #146

Merged
merged 17 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ option(DEBUG "Enable debug mode" OFF)
option(RELEASE "Enable release mode" OFF)
option(docker_cross "Cross compile option for docker container" OFF)
set(KIPR_VERSION_MAJOR 1)
set(KIPR_VERSION_MINOR 1)
set(KIPR_VERSION_MINOR 2)
set(KIPR_VERSION_PATCH 0)
cmake_minimum_required(VERSION 2.8.11)

Expand Down
1 change: 1 addition & 0 deletions include/botui/NetworkManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class NetworkManager : public QObject, public Singleton<NetworkManager>
void changeWifiBands(QString band, int channel);
void requestScan();
void deactivateAP();
void getRaspberryPiType();


bool isOn() const;
Expand Down
1 change: 1 addition & 0 deletions rc/qml.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<file>qml/loading.qml</file>
<file>qml/lock.qml</file>
<file>qml/50-screenlock.png</file>
<file>qml/disabled.png</file>
<file>qml/left.png</file>
<file>qml/right.png</file>
<file>qml/Event_Mode_Background.png</file>
Expand Down
Binary file added rc/qml/disabled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
128 changes: 125 additions & 3 deletions src/NetworkManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,6 @@ void NetworkManager::changeWifiBands(QString band, int channel)
qDebug() << "Correct connection ssid " << connectionSettings[NM_802_11_WIRELESS_KEY]["ssid"].toString();
QPair<Connection, QDBusObjectPath> correctConnectionPair = getConnection(connectionSettings[NM_802_11_WIRELESS_KEY]["ssid"].toString());



QDBusPendingReply<QDBusObjectPath> reply = m_nm->ActivateConnection(correctConnectionPair.second, devicePath, QDBusObjectPath("/"));
reply.waitForFinished();
getReply(reply);
Expand Down Expand Up @@ -325,13 +323,110 @@ bool NetworkManager::enableAP()
qDebug() << "AP Path: " << apPath.path();
qDebug() << "AP Path Connection already exists";
qDebug() << "AP Strength: " << active().strength();
qDebug() << "State: " << m_device->state();
OrgFreedesktopNetworkManagerSettingsConnectionInterface connection(NM_SERVICE, apPath.path(), QDBusConnection::systemBus());

Connection settings = connection.GetSettings().value();
QMap<QString, QVariant> wirelessSettings = settings.value("802-11-wireless");

qDebug() << "Settings before anything: " << settings;
bool containsBand = wirelessSettings.contains("band");
bool containsChannel = wirelessSettings.contains("channel");

qDebug() << "AP settings: " << settings;
qDebug() << "Contains band? : " << containsBand;
qDebug() << "Contains channel? : " << containsChannel;

// Check if the settings contain "band" and "channel"
if (!containsBand || !containsChannel)
{
qDebug() << "Missing 'band' or 'channel' in AP settings. Recreating AP configuration.";

bool activeConnectionOn = NetworkManager::ref().isActiveConnectionOn();

if (activeConnectionOn == true)
{
qDebug() << "Current active connection: " << m_device->activeConnection().path();
QDBusPendingReply<void> deactivateReply = m_nm->DeactivateConnection(m_device->activeConnection());
deactivateReply.waitForFinished();

if (deactivateReply.isError())
{
qWarning() << "Error deactivating connection:" << deactivateReply.error().message();
return false; // Handle the error appropriately
}
else
{
qDebug() << "Connection deactivated successfully.";
}
}

if (RASPBERRYPI_TYPE == "3B+")
{
settings[NM_802_11_WIRELESS_KEY]["band"] = "a";
settings[NM_802_11_WIRELESS_KEY]["channel"] = 36;
}
else if (RASPBERRYPI_TYPE == "3B")
{
settings[NM_802_11_WIRELESS_KEY]["band"] = "bg";
settings[NM_802_11_WIRELESS_KEY]["channel"] = 1;
}

qDebug() << "Modified AP settings: band and channel added.";

QDBusPendingReply<void> reply = connection.Update(settings);
reply.waitForFinished();

if (reply.isError())
{
qWarning() << "Error in Update:" << reply.error().message();
return false;
}

if (reply.isValid())
{
qDebug() << "AP settings updated successfully.";
qDebug() << "Connection after update: " << connection.GetSettings().value();
}

QDBusPendingReply<void> activateReply = m_nm->ActivateConnection(apPath, devicePath, QDBusObjectPath("/"));
activateReply.waitForFinished();

if (activateReply.isError())
{
qWarning() << "Error activating connection:" << activateReply.error().message();
return false; // Handle the error appropriately
}
else
{
qDebug() << "Connection activated successfully.";
}

qDebug() << "Device is now active. Proceeding to reapply settings.";

QDBusPendingReply<void> reapplyReply = m_device->Reapply(settings, 0, 0);
reapplyReply.waitForFinished();

if (reapplyReply.isError())
{
qWarning() << "Error in Reapply:" << reapplyReply.error().message();
return false;
}
else
{
qDebug() << "Reapply successful.";
}

return true;
}

if (NetworkManager::ref().isActiveConnectionOn() == true)
{
m_nm->DeactivateConnection(m_device->activeConnection()); // Deactivate current connection
}
else if (NetworkManager::ref().isActiveConnectionOn() == false)
{

turnOn();
uint stateReply;
while (true)
Expand Down Expand Up @@ -619,7 +714,7 @@ NetworkManager::NetworkManager()
m_device(0), m_wifi(0), m_dev(nullptr)
{


getRaspberryPiType();
// Register our metatype with dbus
qDBusRegisterMetaType<Connection>();
qDBusRegisterMetaType<StringVariantMap>();
Expand Down Expand Up @@ -682,6 +777,33 @@ NetworkManager::NetworkManager()
qDebug() << "Active strength: " << active().strength();
}

void NetworkManager::getRaspberryPiType()
{
QStringList arguments;
arguments << "-c" << "cat /proc/cpuinfo | grep Revision | awk '{print $3}'";

QProcess *myProcess = new QProcess(this);
myProcess->start("/bin/sh", arguments); // Use /bin/sh or /bin/bash to interpret the command
myProcess->waitForFinished();
QByteArray output = myProcess->readAllStandardOutput();

qDebug() << "Revision code output: " << output;
if (output.trimmed() == "a020d3" || output.trimmed() == "a020d4")
{
RASPBERRYPI_TYPE = "3B+";
}
else if (output.trimmed() == "a02082" || output.trimmed() == "a22082" || output.trimmed() == "a32082" || output.trimmed() == "a52082" || output.trimmed() == "a22083")
{
RASPBERRYPI_TYPE = "3B";
}
else
{
RASPBERRYPI_TYPE = "Unknown";
}

qDebug() << "RASPBERRYPI_TYPE: " << RASPBERRYPI_TYPE;
}

void NetworkManager::nmAccessPointAdded(const QDBusObjectPath &accessPoint)
{
Network network = createAccessPoint(accessPoint);
Expand Down
16 changes: 11 additions & 5 deletions src/NetworkSettingsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,12 @@ void NetworkSettingsWidget::eventModeDisabledState()
getWombatName(); // Get Wombat name

INITIAL_CONNECTION_CONFIG = getConnectionConfig(); // Get initial connection config
RASPBERRYPI_TYPE_SETTINGS = "3B+";
RASPBERRYPI_TYPE_SETTINGS = getRaspberryPiType();

if (RASPBERRYPI_TYPE_SETTINGS == "3B+") // if RaspberryPi is 3B+
{

ui->TwoFourGHZLabel->setEnabled(true); // Enable 2.4GHz label
ui->FiveGHZLabel->setEnabled(true); // Enable 5GHz label
if (INITIAL_CONNECTION_CONFIG.contains("band=a")) // If currently on 5GHz band
{
ui->toggleSwitch->setChecked(true); // 5GHz toggle side
Expand All @@ -118,6 +119,8 @@ void NetworkSettingsWidget::eventModeDisabledState()
{
ui->toggleSwitch->setChecked(false); // 2.4GHz toggle side
ui->toggleSwitch->setEnabled(false); // If 3B, can only use 2.4GHz
ui->TwoFourGHZLabel->setEnabled(false); //Grey out 2.4GHz label
ui->FiveGHZLabel->setEnabled(false); //Grey out 5GHz label
}

ui->connectionModeSelect->clear();
Expand Down Expand Up @@ -156,15 +159,18 @@ QString NetworkSettingsWidget::getRaspberryPiType()
QByteArray output = myProcess->readAllStandardOutput();

qDebug() << "Revision code output: " << output;

if (output.contains("a020d3"))
if (output.trimmed() == "a020d3" || output.trimmed() == "a020d4")
{
RASPBERRYPI_TYPE_SETTINGS = "3B+";
}
else if (output.contains("a02082") || output.contains("a22082"))
else if (output.trimmed() == "a02082" || output.trimmed() == "a22082" || output.trimmed() == "a32082" || output.trimmed() == "a52082" || output.trimmed() == "a22083")
{
RASPBERRYPI_TYPE_SETTINGS = "3B";
}
else
{
RASPBERRYPI_TYPE_SETTINGS = "Unknown";
}

qDebug() << "RASPBERRYPI_TYPE_SETTINGS: " << RASPBERRYPI_TYPE_SETTINGS;
return RASPBERRYPI_TYPE_SETTINGS;
Expand Down
Loading