Skip to content

Commit

Permalink
Added getRaspberryPiType() to NetworkManager
Browse files Browse the repository at this point in the history
  • Loading branch information
erinharrington-12 committed Nov 15, 2024
1 parent 810136e commit 1447471
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
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
30 changes: 29 additions & 1 deletion src/NetworkManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,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 +682,34 @@ 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

0 comments on commit 1447471

Please sign in to comment.