diff --git a/QOpenHD.pro b/QOpenHD.pro index b8a5680fd..f330404c4 100755 --- a/QOpenHD.pro +++ b/QOpenHD.pro @@ -213,6 +213,7 @@ iOSBuild { } MacBuild { + QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.15 QMAKE_INFO_PLIST = mac/Info.plist ICON = $${BASEDIR}/icons/macos.icns DISTFILES += mac/Info.plist diff --git a/app/common/openhd-util.hpp b/app/common/openhd-util.hpp index f93081f7e..8ce184757 100644 --- a/app/common/openhd-util.hpp +++ b/app/common/openhd-util.hpp @@ -9,10 +9,10 @@ #include #include -#ifdef __linux__ +#if defined(__linux__) || defined(__macos__) #include #include -#endif // __linux__ +#endif // __linux__ || __macos__ namespace OHDUtil { @@ -27,7 +27,7 @@ namespace OHDUtil { * NOTE: Used to use boost, there were issues with that, I changed it to use c standard library. */ static bool run_command(const std::string &command, const std::vector &args,bool print_debug=true) { -#ifdef __linux__ +#if defined(__linux__) || defined(__macos__) std::stringstream ss; ss << command; for (const auto &arg: args) { @@ -51,7 +51,7 @@ static bool run_command(const std::string &command, const std::vector run_command_out(const char* command){ -#ifdef __linux__ +#if defined(__linux__) || defined(__macos__) std::string raw_value; std::array buffer{}; std::unique_ptr pipe(popen(command, "r"), pclose); @@ -83,7 +83,7 @@ static std::optional run_command_out(const char* command){ } return raw_value; #else - std::cerr<<"run_command only supported on linux\n"; + std::cerr<<"run_command only supported on linux and macos\n"; return std::nullopt; #endif } @@ -93,7 +93,7 @@ static std::string yes_or_no(bool yes){ } static bool is_valid_ip(const std::string& ip) { -#ifdef __linux__ +#if defined(__linux__) || defined(__macos__) unsigned char buf[sizeof(struct in6_addr)]; auto result = inet_pton(AF_INET, ip.c_str(), buf); return result == 1; diff --git a/app/telemetry/models/aohdsystem.cpp b/app/telemetry/models/aohdsystem.cpp index 309554d6e..78253a5fe 100644 --- a/app/telemetry/models/aohdsystem.cpp +++ b/app/telemetry/models/aohdsystem.cpp @@ -458,8 +458,8 @@ void AOHDSystem::update_alive() // come through, not only a heartbeat // AIR: Quite lossy, and r.n we send about 2 to 3 telemetry packets per second // GROUND: OpenHD (can) send a lot of data to QOpenHD, since there are no bw constraints - const int tmp=m_last_message_ms; - if(tmp<=-1){ + const int64_t tmp=m_last_message_ms; + if(tmp<=-1) { update_alive_status_with_hud_message(false); return; } diff --git a/app/telemetry/models/aohdsystem.h b/app/telemetry/models/aohdsystem.h index 6be2553e0..4ef6a3854 100644 --- a/app/telemetry/models/aohdsystem.h +++ b/app/telemetry/models/aohdsystem.h @@ -143,8 +143,8 @@ class AOHDSystem : public QObject void process_sys_status1(const mavlink_openhd_sys_status1_t& msg); void process_op_mode(const mavlink_openhd_wifbroadcast_gnd_operating_mode_t& msg); private: - std::atomic m_last_heartbeat_ms = -1; - std::atomic m_last_message_ms= -1; + std::atomic m_last_heartbeat_ms = -1; + std::atomic m_last_message_ms= -1; // QString m_curr_incoming_bitrate="Bitrate NA"; QString m_curr_incoming_tele_bitrate="Bitrate NA"; diff --git a/app/telemetry/models/fcmavlinksystem.h b/app/telemetry/models/fcmavlinksystem.h index bd9649dc2..81e6a154d 100644 --- a/app/telemetry/models/fcmavlinksystem.h +++ b/app/telemetry/models/fcmavlinksystem.h @@ -209,8 +209,8 @@ class FCMavlinkSystem : public QObject std::unique_ptr m_flight_time_timer = nullptr; // std::unique_ptr m_alive_timer = nullptr; - std::atomic m_last_heartbeat_ms = -1; - std::atomic m_last_message_ms= -1; + std::atomic m_last_heartbeat_ms = -1; + std::atomic m_last_message_ms= -1; void update_alive(); std::chrono::steady_clock::time_point m_last_update_update_rate_mavlink_message_attitude=std::chrono::steady_clock::now(); int m_n_messages_update_rate_mavlink_message_attitude=0; diff --git a/app/telemetry/models/rcchannelsmodel.h b/app/telemetry/models/rcchannelsmodel.h index f15a69b5b..150b30973 100644 --- a/app/telemetry/models/rcchannelsmodel.h +++ b/app/telemetry/models/rcchannelsmodel.h @@ -50,7 +50,7 @@ public slots: QList m_data{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}; private: // We need thread saftey on the alive - std::atomic m_last_update_ms = -1; + std::atomic m_last_update_ms = -1; std::unique_ptr m_alive_timer; void update_alive(); }; diff --git a/app/telemetry/models/wificard.h b/app/telemetry/models/wificard.h index 1b0dd89ba..d9ae011bc 100644 --- a/app/telemetry/models/wificard.h +++ b/app/telemetry/models/wificard.h @@ -54,7 +54,7 @@ class WiFiCard : public QObject int64_t m_last_packets_in_X_second_value=-1; // Card alive - ONLY USED FOR GROUND CARD(s) std::unique_ptr m_alive_timer = nullptr; - std::atomic m_last_mavlink_message=0; + std::atomic m_last_mavlink_message=0; void update_alive(); }; diff --git a/app/util/qopenhd.cpp b/app/util/qopenhd.cpp index 114dc60c9..c996473ba 100644 --- a/app/util/qopenhd.cpp +++ b/app/util/qopenhd.cpp @@ -11,7 +11,7 @@ #include #include -#ifdef __linux__ +#if defined(__linux__) || defined(__macos__) #include "common/openhd-util.hpp" #endif @@ -227,6 +227,9 @@ QString QOpenHD::show_local_ip() #ifdef __linux__ auto res=OHDUtil::run_command_out("hostname -I"); return QString(res->c_str()); +#elif defined(__macos__) + auto res=OHDUtil::run_command_out("ifconfig -l | xargs -n1 ipconfig getifaddr"); + return QString(res->c_str()); #else return QString("Only works on linux"); #endif @@ -246,6 +249,15 @@ bool QOpenHD::is_linux() return false; } +bool QOpenHD::is_mac() +{ +#if defined(__macos__) + return true; +#else + return false; +#endif +} + bool QOpenHD::is_android() { #if defined(__android__) diff --git a/app/util/qopenhd.h b/app/util/qopenhd.h index c03365185..8836d05d7 100644 --- a/app/util/qopenhd.h +++ b/app/util/qopenhd.h @@ -54,6 +54,7 @@ class QOpenHD : public QObject // some settings an stuff depend on that, called from .qml // NOTE: android is not linux in this definition ! Q_INVOKABLE bool is_linux(); + Q_INVOKABLE bool is_mac(); Q_INVOKABLE bool is_android(); Q_INVOKABLE void android_open_tethering_settings(); // runs systemctl start/stop/enable/disable openhd diff --git a/app/videostreaming/vscommon/rtp/RTP.hpp b/app/videostreaming/vscommon/rtp/RTP.hpp index 7c1cf3151..35e03d5d2 100644 --- a/app/videostreaming/vscommon/rtp/RTP.hpp +++ b/app/videostreaming/vscommon/rtp/RTP.hpp @@ -10,7 +10,12 @@ #include // This code is written for little endian (aka ARM,x86) byte order +#if defined(__macos__) +static_assert(__BYTE_ORDER__==LITTLE_ENDIAN); +#else static_assert(__BYTE_ORDER__==__LITTLE_ENDIAN); +#endif + // RTP uses big endian (network) byte order. Therefore, most of the structs here // are actually declared in 'reverse order' such that the compiler can do the work // of 'interpreting bits the right way' for us