diff --git a/examples/meshtastic/app.pro b/examples/meshtastic/app.pro index 4f0bbff..2ce5c89 100644 --- a/examples/meshtastic/app.pro +++ b/examples/meshtastic/app.pro @@ -27,7 +27,7 @@ QMAKE_EXTRA_COMPILERS += lisp win32: PRE_TARGETDEPS = tmp/app.lib !win32: PRE_TARGETDEPS = tmp/libapp.a -QT += quick qml bluetooth sql positioning +QT += quick qml bluetooth sql positioning location TEMPLATE = app CONFIG += c++17 no_keywords release DEFINES += DESKTOP_APP BACKGROUND_INI_LISP INI_ECL_CONTRIB QT_EXTENSION @@ -73,6 +73,12 @@ android { ANDROID_MIN_SDK_VERSION = 21 ANDROID_TARGET_SDK_VERSION = 31 + # OpenSSL libs not included here, but can be downloaded from: + # https://github.com/KDAB/android_openssl/tree/master/latest + # required for downloading map tiles, please note naming convention for Qt: + SSL_PATH = ../../../platforms/android/lib + ANDROID_EXTRA_LIBS += $$SSL_PATH/libcrypto_1_1.so $$SSL_PATH/libssl_1_1.so + 32bit { ANDROID_ABIS = "armeabi-v7a" } else { @@ -92,6 +98,11 @@ ios { LIBS += -lasdf -lecl-help -ldeflate -lecl-cdb -lecl-curl -lql-minitar -lsockets LIBS += -L../../../platforms/ios/lib + # OpenSSL libs not included here, required for downloading map tiles + # either build them by yourself or find a trusted source for downloading, + # and put them here: '../../../platforms/ios/lib/' + LIBS += -lcrypto -lssl + QMAKE_INFO_PLIST = platforms/ios/Info.plist QMAKE_ASSET_CATALOGS += platforms/ios/Assets.xcassets @@ -114,6 +125,7 @@ HEADERS += \ ../../src/cpp/main.h \ cpp/ble.h \ cpp/ble_meshtastic.h \ + cpp/tile_server.h \ cpp/qt.h SOURCES += \ diff --git a/examples/meshtastic/cpp/qt.cpp b/examples/meshtastic/cpp/qt.cpp index 3db56a7..b08b8d0 100644 --- a/examples/meshtastic/cpp/qt.cpp +++ b/examples/meshtastic/cpp/qt.cpp @@ -173,12 +173,12 @@ QVariant QT::localIp() { QVariant QT::startTileServer() { static bool start = true; - int port = 1702; if (start) { start = false; + int port = 1702; new TileServer(port); } - return port; + return QVariant(); } QT_END_NAMESPACE diff --git a/examples/meshtastic/cpp/tile_server.h b/examples/meshtastic/cpp/tile_server.h index 622b4e4..962a999 100644 --- a/examples/meshtastic/cpp/tile_server.h +++ b/examples/meshtastic/cpp/tile_server.h @@ -2,6 +2,7 @@ #include #include +#include // trivial local tile web-server which doesn't need an API key @@ -9,11 +10,9 @@ class TileServer : public QTcpServer { Q_OBJECT public: - int port; - - TileServer(int p = 0, QObject* parent = nullptr) : QTcpServer(parent) { - listen(QHostAddress::Any, p); - port = serverPort(); + TileServer(int port = 0, QObject* parent = nullptr) : QTcpServer(parent) { + listen(QHostAddress::Any, port); + qDebug() << "tile server started at IP" << serverAddress() << "port" << serverPort(); } void incomingConnection(qintptr socket) override { diff --git a/examples/meshtastic/lisp/location.lisp b/examples/meshtastic/lisp/location.lisp index ccb63a0..be6bbe9 100644 --- a/examples/meshtastic/lisp/location.lisp +++ b/examples/meshtastic/lisp/location.lisp @@ -91,7 +91,7 @@ (destructuring-bind (lat lon time) (last-gps-position) (unless (zerop lat) - (qjs |setCenter| ui:*map* lat lon))) + (qjs |setCenter| ui:*map* (list lat lon)))) #-mobile (let ((my-pos (position* (lora:my-num)))) (when my-pos diff --git a/examples/meshtastic/lisp/main.lisp b/examples/meshtastic/lisp/main.lisp index 9d5a386..d6f57a9 100644 --- a/examples/meshtastic/lisp/main.lisp +++ b/examples/meshtastic/lisp/main.lisp @@ -76,7 +76,8 @@ (save-settings)) (defun my-ip () - (qrun* (qt:local-ip qt:*cpp*))) ; 'qrun*' for return value + (let ((ip (qrun* (qt:local-ip qt:*cpp*)))) ; 'qrun*' for return value + (or ip "127.0.0.1"))) ;;; toast diff --git a/examples/meshtastic/qml/ext/Map.qml b/examples/meshtastic/qml/ext/Map.qml index 4f9d333..8dd1390 100644 --- a/examples/meshtastic/qml/ext/Map.qml +++ b/examples/meshtastic/qml/ext/Map.qml @@ -65,7 +65,7 @@ Item { // local tile web-server (no API key needed), see 'cpp/tile_server.h' PluginParameter { name: "osm.mapping.providersrepository.address" - value: "http://127.0.0.1:1702/" + value: "http://" + Lisp.call("app:my-ip") + ":1702/" } }