Skip to content

Commit

Permalink
Fix for issue "Suspend causes oxide to crash on RM2 #113" (#114)
Browse files Browse the repository at this point in the history
* Fix for issue "Suspend causes oxide to crash on RM2 #113"

Co-authored-by: Piotr Witoslawski <[email protected]>
  • Loading branch information
Witos and vewd-stb-tester authored Jan 7, 2021
1 parent 6f3d9a9 commit 49c1716
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
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;

};

0 comments on commit 49c1716

Please sign in to comment.