From 7713ce57a66062e4fba35cbb61ba0c55e1d2e349 Mon Sep 17 00:00:00 2001 From: "pls.153" Date: Wed, 2 Aug 2023 11:11:56 +0200 Subject: [PATCH] revisions --- examples/meshtastic/lisp/lora.lisp | 15 +-------------- examples/meshtastic/lisp/messages.lisp | 17 +++++++++++++++++ examples/meshtastic/lisp/package.lisp | 1 + examples/meshtastic/qml/ext/Group.qml | 10 ++++++---- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/examples/meshtastic/lisp/lora.lisp b/examples/meshtastic/lisp/lora.lisp index 28c996e..154ed7b 100644 --- a/examples/meshtastic/lisp/lora.lisp +++ b/examples/meshtastic/lisp/lora.lisp @@ -195,20 +195,7 @@ (qsingle-shot 2000 (lambda () (send-message (x:cc "echo:" (subseq text #.(length ":e"))))))) (progn (when (x:starts-with "echo:" text) - ;; send convenient response containing signal info, position, distance - (let ((pos (getf loc:*positions* (me:from packet))) - (my-pos #+mobile (loc:last-gps-position) - #-mobile nil)) - (setf text (format nil "~A~%~%snr: ~F rssi: ~D~%lat: ~,5F lon: ~,5F~%distance: ~:D m" - text - (me:rx-snr packet) - (me:rx-rssi packet) - (if my-pos (first my-pos) "-") - (if my-pos (second my-pos) "-") - (if (and pos my-pos) - (loc:distance (cons (first my-pos) (second my-pos)) - (cons (getf pos :lat) (getf pos :lon))) - "-"))))) + (setf text (msg:echo-message text (me:from packet) (me:rx-snr packet) (me:rx-rssi packet)))) (msg:add-message (list :receiver (my-name) :sender (node-to-name (me:from packet)) diff --git a/examples/meshtastic/lisp/messages.lisp b/examples/meshtastic/lisp/messages.lisp index 675938c..6270d44 100644 --- a/examples/meshtastic/lisp/messages.lisp +++ b/examples/meshtastic/lisp/messages.lisp @@ -107,3 +107,20 @@ (format s "~A" (subseq text e (+ e len))))))) +(defun echo-message (text from snr rssi) + "Meant for radio signal testing: one static node (with GPS module), while + another mobile node is moving to different places (using GPS of phone), + sending an ':e ...' text message, which will be echoed with info about signal + strength, position and distance." + (let ((from-pos (getf loc:*positions* from)) + (my-pos #+mobile (loc:last-gps-position) + #-mobile nil)) + (format nil "~A~%~%snr: ~F rssi: ~D~%lat: ~,5F lon: ~,5F~%distance: ~:D m" + text snr rssi + (if my-pos (first my-pos) "-") + (if my-pos (second my-pos) "-") + (if (and from-pos my-pos) + (loc:distance (cons (first my-pos) (second my-pos)) + (cons (getf from-pos :lat) (getf from-pos :lon))) + "-")))) + diff --git a/examples/meshtastic/lisp/package.lisp b/examples/meshtastic/lisp/package.lisp index fda5cfd..4999aad 100644 --- a/examples/meshtastic/lisp/package.lisp +++ b/examples/meshtastic/lisp/package.lisp @@ -77,6 +77,7 @@ #:change-state #:check-utf8-length #:clear-find + #:echo-message #:find-text #:message-press-and-hold #:receiver-changed diff --git a/examples/meshtastic/qml/ext/Group.qml b/examples/meshtastic/qml/ext/Group.qml index ea33d70..6b29175 100644 --- a/examples/meshtastic/qml/ext/Group.qml +++ b/examples/meshtastic/qml/ext/Group.qml @@ -85,9 +85,11 @@ Rectangle { } } } - move(index, to, 1) - view.currentIndex = to - view.positionViewAtIndex(to, ListView.Contain) + if (to !== -1) { + move(index, to, 1) + view.currentIndex = to + view.positionViewAtIndex(to, ListView.Contain) + } } function radioNames() { @@ -186,7 +188,7 @@ Rectangle { readOnly = true if (text === "") text = qsTr("Anonym") group.setProperty(index, "customName", text) - group.sortRenamed(text, index) + Qt.callLater(group.sortRenamed, text, index) Lisp.call("group:name-edited", model.radioName, text) } }