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

Fix for issue "Suspend causes oxide to crash on RM2 #113" #114

Merged
merged 16 commits into from
Jan 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 1 addition & 3 deletions applications/system-service/screenapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@
#include "stb_image.h"
#include "stb_image_write.h"
#include "fb2png.h"
#include "devicesettings.h"

#define DISPLAYWIDTH 1404
#define DISPLAYHEIGHT 1872
#define TEMP_USE_REMARKABLE_DRAW 0x0018
#define remarkable_color uint16_t
#define DISPLAYSIZE DISPLAYWIDTH * DISPLAYHEIGHT * sizeof(remarkable_color)
#define RDISPLAYWIDTH 1408
#define RDISPLAYHEIGHT 1920
#define RDISPLAYSIZE RDISPLAYWIDTH * RDISPLAYHEIGHT * sizeof(remarkable_color)

#define screenAPI ScreenAPI::singleton()

Expand Down
9 changes: 9 additions & 0 deletions applications/system-service/systemapi.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "systemapi.h"
#include "appsapi.h"
#include "powerapi.h"
#include "devicesettings.h"

void SystemAPI::PrepareForSleep(bool suspending){
if(suspending){
Expand All @@ -14,10 +15,18 @@ void SystemAPI::PrepareForSleep(bool suspending){
drawSleepImage();
qDebug() << "Suspending...";
buttonHandler->setEnabled(false);
if (DeviceSettings::instance().getDeviceType() == DeviceType::RM2) {
qDebug() << "Removing module";
qDebug() << "Exit code: " << system("rmmod brcmfmac");
}
releaseSleepInhibitors();
}else{
inhibitSleep();
qDebug() << "Resuming...";
if (DeviceSettings::instance().getDeviceType() == DeviceType::RM2) {
qDebug() << "Inserting module";
qDebug() << "Exit code: " << system("modprobe brcmfmac");
}
QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
if(resumeApp == nullptr){
resumeApp = appsAPI->getApplication(appsAPI->startupApplication());
Expand Down
14 changes: 12 additions & 2 deletions applications/system-service/wlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,22 @@ class Wlan : public QObject, public SysObject {
}
return "";
}
bool pingIP(std::string ip, const char* port) {
return !system(("echo -n > /dev/tcp/" + ip.substr(0, ip.length() - 1) + "/" + port).c_str());
}
bool isConnected(){
auto ip = exec("ip r | grep " + iface() + " | grep default | awk '{print $3}'");
return ip != "" && !system(("echo -n > /dev/tcp/" + ip.substr(0, ip.length() - 1) + "/53").c_str());
return ip != "" && (pingIP(ip, "53") || pingIP(ip, "80"));
}
int link(){
return std::stoi(exec("cat /proc/net/wireless | grep " + iface() + " | awk '{print $3}'"));
std::string out = exec("cat /proc/net/wireless | grep " + iface() + " | awk '{print $3}'");
try {
return std::stoi(out);
}
catch (const std::invalid_argument& e) {
qDebug() << "link failed: " << out.c_str();
return 0;
}
}
signals:
void BSSAdded(Wlan*, QDBusObjectPath, QVariantMap);
Expand Down
1 change: 0 additions & 1 deletion shared/devicesettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,4 @@ class DeviceSettings{
const char* getTouchDevicePath() const;
const char* getTouchEnvSetting() const;
DeviceType getDeviceType() const;

};