From 7adbebffae7c624d2de52747775f55637ef2aa0a Mon Sep 17 00:00:00 2001 From: "pls.153" Date: Mon, 3 Jul 2023 19:46:57 +0200 Subject: [PATCH] example 'meshtastic': fix utf8 bug to correctly display emojis; revisions --- examples/meshtastic/lisp/lora.lisp | 8 ++++---- examples/meshtastic/lisp/messages.lisp | 2 +- examples/meshtastic/lisp/ui-vars.lisp | 2 ++ examples/meshtastic/qml/ext/Messages.qml | 1 + examples/meshtastic/readme.md | 12 +++++++----- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/examples/meshtastic/lisp/lora.lisp b/examples/meshtastic/lisp/lora.lisp index f1d7539..836ad12 100644 --- a/examples/meshtastic/lisp/lora.lisp +++ b/examples/meshtastic/lisp/lora.lisp @@ -67,7 +67,7 @@ :want-ack t :decoded (me:make-data :portnum :text-message-app - :payload (babel:string-to-octets text))))) + :payload (qto-utf8 text))))) (msg:add-message (list :receiver (node-to-name *receiver*) :sender (my-name) @@ -146,7 +146,7 @@ :sender (node-to-name (me:from packet)) :timestamp (princ-to-string timestamp) ; STRING for JS :hour (timestamp-to-hour timestamp) - :text (babel:octets-to-string payload) + :text (qfrom-utf8 payload) :mid (princ-to-string mid))))) ; STRING for JS ;; for :ack-state (acknowledgement state) (:routing-app @@ -276,7 +276,7 @@ (string-right-trim "=" (substitute #\- #\+ (substitute #\_ #\/ base64)))))) (defun url-to-channel (url &optional (set t)) - (let ((base64 (+ 2 (subseq "/#" url)))) + (let ((base64 (subseq url (+ 2 (search "/#" url))))) ;; re-add padding (setf base64 (x:cc base64 (make-string (mod (length base64) 4) :initial-element #\=))) @@ -287,7 +287,7 @@ channel)))) (defun change-receiver (receiver) ; called from QML - (setf *receiver* (parse-integer receiver)) ; STRING because of JS + (setf *receiver* (parse-integer receiver)) ; STRING for JS (app:change-setting :latest-receiver (node-to-name *receiver*)) (msg:receiver-changed) (group:receiver-changed) diff --git a/examples/meshtastic/lisp/messages.lisp b/examples/meshtastic/lisp/messages.lisp index 12f57b1..937bf53 100644 --- a/examples/meshtastic/lisp/messages.lisp +++ b/examples/meshtastic/lisp/messages.lisp @@ -9,7 +9,7 @@ (string= user (getf message :sender)))))) (defun add-message (message &optional loading) - "Adds passed MESSAGE (a PLIST) to both the QML item model and *MESSAGES*. + "Adds passed MESSAGE (a PLIST) to the QML item model and saves it to the DB. The model keys are: :receiver :sender :sender-name :timestamp :hour :text :mid :ack-state :me" (unless (or loading (getf message :me)) diff --git a/examples/meshtastic/lisp/ui-vars.lisp b/examples/meshtastic/lisp/ui-vars.lisp index 83f48dd..c3a56d4 100644 --- a/examples/meshtastic/lisp/ui-vars.lisp +++ b/examples/meshtastic/lisp/ui-vars.lisp @@ -4,6 +4,7 @@ (:use :cl) (:export #:*busy* + #:*edit* #:*group* #:*loading* #:*main-view* @@ -18,6 +19,7 @@ (in-package :ui) (defparameter *busy* "busy") +(defparameter *edit* "edit") (defparameter *group* "group") (defparameter *loading* "loading") (defparameter *main-view* "main_view") diff --git a/examples/meshtastic/qml/ext/Messages.qml b/examples/meshtastic/qml/ext/Messages.qml index fd821ca..bb5b723 100644 --- a/examples/meshtastic/qml/ext/Messages.qml +++ b/examples/meshtastic/qml/ext/Messages.qml @@ -110,6 +110,7 @@ Rectangle { TextArea { id: edit + objectName: "edit" anchors.fill: parent textFormat: TextEdit.PlainText font.pixelSize: 18 diff --git a/examples/meshtastic/readme.md b/examples/meshtastic/readme.md index f3b227c..bf9fb1f 100644 --- a/examples/meshtastic/readme.md +++ b/examples/meshtastic/readme.md @@ -36,10 +36,12 @@ You will see a json output of all data sent/received. It simply uses the `print-json` convenience function from cl-protobufs. The message db uses **sqlite**, but in a lispy manner, storing basically just a -plist for every message. The reason I chose Qt instead of cl-sqlite is mobile: -Qt comes with its own version, which is pulled in automatially, so one doesn't -need to care about the OS limitations or indirect requirements. Additionally, -cffi (dependency of cl-sqlite) currently needs a small hack to work on mobile. +plist for every message. + +The reason I chose Qt qsqlite over cl-sqlite is mobile: Qt comes with its own +version, which is pulled in automatically, so one doesn't need to care about +the OS limitations or indirect requirements. Additionally, cffi (as a +dependency of cl-sqlite) currently needs a small hack to even work on mobile. @@ -67,7 +69,7 @@ ask for pairing/PIN during BLE ini. If your device doesn't have a display, use It may occur that the devices are sometimes not found. For me it worked again after unpairing the devices. Remember to unpair them from all computers/mobile -devices +devices. A generic bluetooth app like **nRF Connect** may help in order to see if the devices themselves work and are able to connect.