From 54d774e4ed82901402cab8e6d279df83dcc300d1 Mon Sep 17 00:00:00 2001 From: Myrlhyn <161041172+Myrlhyn@users.noreply.github.com> Date: Fri, 23 Feb 2024 15:06:21 +0100 Subject: [PATCH 01/74] Create Localizable.strings Translation to french - step 1 --- fr.lproj/Localizable.strings | 316 +++++++++++++++++++++++++++++++++++ 1 file changed, 316 insertions(+) create mode 100644 fr.lproj/Localizable.strings diff --git a/fr.lproj/Localizable.strings b/fr.lproj/Localizable.strings new file mode 100644 index 00000000..4556678e --- /dev/null +++ b/fr.lproj/Localizable.strings @@ -0,0 +1,316 @@ +/* + Localizable.strings + Meshtastic + + Copyright(c) Garth Vander Houwen on 12/12/22. + +*/ +"about"="À propos"; +"about.meshtastic"="À propos de Meshtastic"; +"admin"="Administrateur"; +"admin.log"="Journal des messages administrateur"; +"ago"="auparavant"; +"airtime"="Temps d'émission"; +"always.on"="En permanence"; +"ambient.lighting"="Lumière ambiante"; +"ambient.lighting.config"="Configuration de la lumière ambiante"; +"appsettings"="Réglages de l'application"; +"appsettings.provide.location"="Partager la position"; +"appsettings.smartposition"="Position intelligente"; +"are.you.sure"="Êtes-vous sûr ?"; +"ascii.capable"="ASCII Compatible"; +"available.radios"="Radios disponibles"; +"automatic.detection"="Détection automatique"; +"battery.level"="Niveau de batterie"; +"ble.name"="Nom du BLE"; +"ble.connection.timeout %d %@"="Connexion impossible après %d essais avec %@. Allez dans Réglages > Bluetooth et essayez de faire de faire > Oublier cet appareil."; +"ble.errorcode.6 %@"="%@ L'application se reconnectera automatiquement à la radio en favori dès qu'elle sera à nouveau visibile."; +"ble.errorcode.14 %@"="%@ Cette erreur ne peut généralement pas être corrigée sans aller dans Réglages > Bluetooth et faire > Oublier cet appareil, puis de reconnecter la radio."; +"ble.errorcode.pin %@"="%@ Merci d'essayer à nouveau en vérifiant bien le code PIN."; +"bluetooth"="Bluetooth"; +"bluetooth.off"="Le Bluetooth is arrêté"; +"bluetooth.config"="Configuration du Bluetooth"; +"bluetooth.mode.randompin"="Code PIN aléatoire"; +"bluetooth.mode.fixedpin"="Code PIN fixe"; +"bluetooth.mode.nopin"="Sans copde PIN (connexion directe)"; +"bluetooth.pairingmode"="Mode d'appairage"; +"bluetooth.pin.validation"="Le code pin BLE doit faire 6 chiffres."; +"bytes"="Octets"; +"cancel"="Annuler"; +"canned.messages"="Messages Canned"; +"canned.messages.config"="Configuration des messages Canned"; +"canned.messages.preset.manual"="Configuration manuelle"; +"canned.messages.preset.rakrotary"="Module d'encodage rotatif RAK"; +"canned.messages.preset.cardkb"="Clavier M5 Stack Card KB / RAK"; +"channel"="Canal"; +"channel.role.disabled"="Désactivé"; +"channel.role.primary"="Principal"; +"channel.role.secondary"="Secondaire"; +"channel.utilization"="Utilisation du canal"; +"channels"="Canaux"; +"clear.app.data"="Effacer les données de l'application"; +"clear.log"="Effacer"; +"close"="Fermer"; +"config.save.confirm"="After config values save the node will reboot."; +"communicating"="Communicating with device. ."; +"connected.radio"="Connected Radio"; +"connected"="Bluetooth Connected"; +"connecting"="Connecting . ."; +"contacts"="Contacts"; +"contacts %@"="Contacts (%@)"; +"copy"="Copy"; +"current"="Current"; +"default"="Default"; +"delete"="Delete"; +"detection.sensor"="Detection Sensor"; +"detection.sensor.config"="Detection Sensor Config"; +"detection.sensor.log"="Detection Sensor Log"; +"device"="Device"; +"device.config"="Device Config"; +"device.metrics.delete"="Delete all device metrics?"; +"device.metrics.log"="Device Metrics Log"; +"device.role.client"="App connected or stand alone messaging device."; +"device.role.clientmute"="Device that does not forward packets from other devices."; +"device.role.clienthidden"="Device that only broadcasts as needed for stealth or power savings."; +"device.role.tracker"="Broadcasts GPS position packets as priority."; +"device.role.lostandfound"="Broadcasts location as message to default channel regularly for to assist with device recovery."; +"device.role.sensor"="Broadcasts telemetry packets as priority."; +"device.role.tak"="Optimized for ATAK system communication, reduces routine broadcasts."; +"device.role.repeater"="Infrastructure node for extending network coverage by relaying messages with minimal overhead. Not visible in Nodes list."; +"device.role.router"="Infrastructure node for extending network coverage by relaying messages. Visible in Nodes list."; +"device.role.routerclient"="Combination of both ROUTER and CLIENT. Not for mobile devices."; +"direct.messages"="Direct Messages"; +"dismiss.keyboard"="Dismiss"; +"display"="Display"; +"display.config"="Display Config"; +"distance"="Distance"; +"disconnect"="Disconnect"; +"echo"="Echo"; +"email.address"="Email Address"; +"enabled"="Enabled"; +"encrypted"="Encrypted"; +"external.notification"="External Notification"; +"external.notification.config"="External Notification Config"; +"finish"="Finish"; +"firmware.version"="Firmware Version"; +"firmware.version.unsupported"="Unsupported Firmware Version Detected, unable to connect to device."; +"gas"="Gas"; +"gas.resistance"="Gas Resistance"; +"generate.qr.code"="Generate QR Code"; +"gpsformat.dec"="Decimal Degrees Format"; +"gpsformat.dms"="Degrees Minutes Seconds"; +"gpsformat.utm"="Universal Transverse Mercator"; +"gpsformat.mgrs"="Military Grid Reference System"; +"gpsformat.olc"="Open Location Code (aka Plus Codes)"; +"gpsformat.osgr"="Ordnance Survey Grid Reference"; +"gpsmode.disabled"="Disabled"; +"gpsmode.enabled"="Enabled"; +"gpsmode.notPresent"="Not Present"; +"heard"="Heard"; +"heard.last"="Last Heard"; +"hybrid"="Hybrid"; +"hybrid.flyover"="Hybrid Flyover"; +"include"="Include"; +"inputevent.none"="None"; +"inputevent.up"="Up"; +"inputevent.down"="Down"; +"inputevent.left"="Left"; +"inputevent.right"="Right"; +"inputevent.select"="Select"; +"inputevent.back"="Back"; +"inputevent.cancel"="Cancel"; +"interval.one.second"="One Second"; +"interval.two.seconds"="Two Seconds"; +"interval.three.seconds"="Three Seconds"; +"interval.four.seconds"="Four Seconds"; +"interval.five.seconds"="Five Seconds"; +"interval.ten.seconds"="Ten Seconds"; +"interval.fifteen.seconds"="Fifteen Seconds"; +"interval.twenty.seconds"="Twenty Seconds"; +"interval.twentyfive.seconds"="Twenty Five Seconds"; +"interval.thirty.seconds"="Thirty Seconds"; +"interval.fortyfive.seconds"="Forty Five Seconds"; +"interval.one.minute"="One Minute"; +"interval.two.minutes"="Two Minutes"; +"interval.five.minutes"="Five Minutes"; +"interval.ten.minutes"="Ten Minutes"; +"interval.fifteen.minutes"="Fifteen Minutes"; +"interval.thirty.minutes"="Thirty Minutes"; +"interval.one.hour"="One Hour"; +"interval.two.hours"="Two Hours"; +"interval.three.hours"="Three Hours"; +"interval.four.hours"="Four Hours"; +"interval.five.hours"="Five Hours"; +"interval.six.hours"="Six Hours"; +"interval.twelve.hours"="Twelve Hours"; +"interval.eighteen.hours"="Eighteen Hours"; +"interval.twentyfour.hours"="Twenty Four Hours"; +"interval.thirtysix.hours"="Thirty Six Hours"; +"interval.fortyeight.hours"="Forty Eight Hours"; +"interval.seventytwo.hours"="Seventy Two Hours"; +"keyboard.type"="Keyboard Type"; +"logging"="Logging"; +"lora"="LoRa"; +"lora.config"="LoRa Config"; +"map"="Mesh Map"; +"map.type"="Default Type"; +"map.centering"="Centering Mode"; +"map.tiles.delete"="Delete All Map Tiles"; +"map.recentering"="Automatic Re-centering"; +"map.use.legacy"="Use Legacy Mesh Map"; +"map.usertrackingmode"="User tracking mode"; +"map.usertrackingmode.follow"="Follow"; +"map.usertrackingmode.followwithheading"="Follow with heading"; +"map.usertrackingmode.none"="None"; +"mesh.live.activity"="Mesh Live Activity"; +"mesh.log"="Mesh Log"; +"mesh.log.ambientlighting.config %@"="Ambient Lighting module config received: %@"; +"mesh.log.bluetooth.config %@"="Bluetooth config received: %@"; +"mesh.log.cannedmessage.config %@"="Canned Message module config received: %@"; +"mesh.log.cannedmessages.messages.get %@"="Requested Canned Messages Module Messages for node: %@"; +"mesh.log.cannedmessages.messages.received %@"="Canned Messages Messages Received For: %@"; +"mesh.log.channel.sent %@ %d"="Sent a Channel for: %@ Channel Index %d"; +"mesh.log.channel.received %d %@"="Channel %d received from: %@"; +"mesh.log.device.config %@"="Device config received: %@"; +"mesh.log.display.config %@"="Display config received: %@"; +"mesh.log.devicemetadata %@"="Requesting Device Metadata for %@"; +"mesh.log.device.metadata.received %@"="Device Metadata received from: %@"; +"mesh.log.detectionsensor.config %@"="Detection Sensor module config received: %@"; +"mesh.log.externalnotification.config %@"="External Notification module config received: %@"; +"mesh.log.lora.config %@"="LoRa config received: %@"; +"mesh.log.lora.config.sent %@"="Sent a LoRa.Config for: %@"; +"mesh.log.mqtt.config %@"="MQTT module config received: %@"; +"mesh.log.myinfo %@"="MyInfo received: %@"; +"mesh.log.network.config %@"="Network config received: %@"; +"mesh.log.nodeinfo.received %@"="Node info received for: %@"; +"mesh.log.position.config %@"="Positon config received: %@"; +"mesh.log.position.received %@"="Position Packet received from node: %@"; +"mesh.log.rangetest.config %@"="Range Test module config received: %@"; +"mesh.log.ringtone.config %@"="RTTTL Ringtone config received: %@"; +"mesh.log.routing.message %@ %@"="Routing received for RequestID: %@ Ack Status: %@"; +"mesh.log.serial.config %@"="Serial module config received: %@"; +"mesh.log.sharelocation %@"="Sent a Position Packet from the Apple device GPS to node: %@"; +"mesh.log.storeforward.config %@"="Store & Forward module config received: %@"; +"mesh.log.telemetry.config %@"="Telemetry module config received: %@"; +"mesh.log.telemetry.received %@"="Telemetry received for: %@"; +"mesh.log.textmessage.received"="Message received from the text message app."; +"mesh.log.textmessage.send.failed %@"="Message Send Failed, not properly connected to %@"; +"mesh.log.textmessage.sent %@ %@ %@"="Sent message %@ from %@ to %@"; +"mesh.log.traceroute.received.direct %@"="Trace Route request sent to node: %@ was recieived directly."; +"mesh.log.traceroute.received.route %@"="Trace Route request returned: %@"; +"mesh.log.traceroute.sent %@"="Sent a Trace Route Request to node: %@"; +"mesh.log.wantconfig %@"="Issuing Want Config to %@"; +"mesh.log.waypoint.sent %@"="Sent a Waypoint Packet from: %@"; +"mesh.log.waypoint.received %@"="Waypoint Packet received from node: %@"; +"message"="Message"; +"message.details"="Message Details"; +"messages"="Messages"; +"mode"="Mode"; +"module.configuration"="Module Configuration"; +"mqtt"="MQTT"; +"mqtt.connect"="Connect to MQTT"; +"mqtt.config"="MQTT Config"; +"mqtt.clientproxy"="MQTT Client Proxy"; +"mqtt.disconnect"="Disconnect from MQTT"; +"mqtt.username"="Username"; +"name"="Name"; +"network"="Network"; +"network.config"="Network Config"; +"nodes"="Nodes"; +"nodes %@"="Nodes (%@)"; +"no.nodes"="No Meshtastic Nodes Found"; +"not.connected"="No device connected"; +"numbers.punctuation"="Numbers and Punctuation"; +"off"="Off"; +"offline"="Offline"; +"on.boot"="On Boot Only"; +"options"="Options"; +"password"="Password"; +"pause"="Pause"; +"phone.gps"="Phone GPS"; +"phone.gps.interval.description"="How frequently your phone will send your location to the device, location updates to the mesh are managed by the device."; +"position"="Position"; +"position.config"="Position Config"; +"preferred.radio"="Preferred Radio"; +"radio.configuration"="Radio Configuration"; +"range.test"="Range Test"; +"range.test.blocked"="Block Range Test"; +"range.test.config"="Range Test Config"; +"reply"="Reply"; +"reboot"="Reboot"; +"reboot.node"="Reboot node?"; +"received.ack"="Received Ack"; +"received.ack.real"="Recipient Ack"; +"resume"="Resume"; +"ringtone"="Ringtone"; +"ringtone.config"="Ringtone Config"; +"route.recorder"="Route Recorder"; +"routes"="Routes"; +"routing.acknowledged"="Acknowledged"; +"routing.noroute"="No Route"; +"routing.gotnak"="Received a negative acknowledgment"; +"routing.timeout"="Timeout"; +"routing.nointerface"="No Interface"; +"routing.maxretransmit"="Max Retransmission Reached"; +"routing.nochannel"="No Channel"; +"routing.toolarge"="The packet is too large"; +"routing.noresponse"="No Response"; +"routing.dutycyclelimit"="Regional Duty Cycle Limit Reached"; +"routing.badRequest"="Bad Request"; +"routing.notauthorized"="Not Authorized"; +"satellite"="Satellite"; +"satellite.flyover"="Satellite Flyover"; +"save"="Save"; +"save.config %@"="Save Config for %@"; +"serial"="Serial"; +"serial.config"="Serial Config"; +"serial.mode.default"="Default"; +"serial.mode.simple"="Simple"; +"serial.mode.proto"="Protobufs"; +"serial.mode.txtmsg"="Text Message"; +"serial.mode.nmea"="NMEA Positions"; +"settings"="Settings"; +"share.channels"="Share QR Code"; +"share.position"="Share Position"; +"subscribed"="Subscribed to mesh"; +"select.contact"="Select a Contact"; +"select.node"="Select a Node"; +"select.menu.item"="Select an item from the menu"; +"set.region"="Set LoRa Region"; +"standard"="Standard"; +"standard.muted"="Standard Muted"; +"start"="Start"; +"storeforward"="Store & Forward"; +"storeforward.config"="Store & Forward Config"; +"storeforward.heartbeat"="Send Heartbeat"; +"ssid"="SSID"; +"tapback"="Tapback Response"; +"tapback.heart"="Heart"; +"tapback.thumbsup"="Thumbs Up"; +"tapback.thumbsdown"="Thumbs Down"; +"tapback.haha"="HaHa"; +"tapback.exclamation"="Exclamation Mark"; +"tapback.question"="Question Mark"; +"tapback.poop"="Poop"; +"telemetry"="Telemetry (Sensors)"; +"telemetry.config"="Telemetry Config"; +"timeout"="Timeout"; +"timestamp"="Timestamp"; +"tip.bluetooth.connect.title"="Connected Radio"; +"tip.bluetooth.connect.message"="Shows information for the Lora radio connected via bluetooth. You can swipe left to disconnect the radio and long press to view stats or start the live activity."; +"tip.channels.create.title"="Manage Channels"; +"tip.channels.create.message"="Most data on your mesh is sent over the primary channel. You can set up secondary channels to create additional messaging groups secured by their own key. [Channel config tips](https://meshtastic.org/docs/configuration/tips/)"; +"tip.channels.share.title"="Sharing Meshtastic Channels"; +"tip.channels.share.message"="A Meshtastic QR code contains the LoRa config and channel values needed to communicate. Most mesh activity takes place on the required Primary channel. If you don't share your primary channel your first shared channel becomes the primary channel on the other network. Other channels are for private groups, each with its own key."; +"tip.messages.title"="Messages"; +"tip.messages.message"="You can send and receive channel (group chats) and direct messages. From any message you can long press to see available actions like copy, reply, tapback and delete as well as delivery details."; +"twitter"="Twitter"; +"unknown"="Unknown"; +"unknown.age"="Unknown Age"; +"unset"="Unset"; +"update.firmware"="Update Your Firmware"; +"update.interval"="Update Interval"; +"user"="User"; +"user.details"="User Details"; +"voltage"="Voltage"; +"waiting"="Waiting. . ."; From 6a92435323665897e0fe414c71f4746448917728 Mon Sep 17 00:00:00 2001 From: Myrlhyn <161041172+Myrlhyn@users.noreply.github.com> Date: Fri, 23 Feb 2024 15:20:24 +0100 Subject: [PATCH 02/74] Update Localizable.strings Translation to french, step 2 --- fr.lproj/Localizable.strings | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/fr.lproj/Localizable.strings b/fr.lproj/Localizable.strings index 4556678e..a4703f3d 100644 --- a/fr.lproj/Localizable.strings +++ b/fr.lproj/Localizable.strings @@ -51,22 +51,22 @@ "clear.app.data"="Effacer les données de l'application"; "clear.log"="Effacer"; "close"="Fermer"; -"config.save.confirm"="After config values save the node will reboot."; -"communicating"="Communicating with device. ."; -"connected.radio"="Connected Radio"; -"connected"="Bluetooth Connected"; -"connecting"="Connecting . ."; +"config.save.confirm"="Une fois la configuration sauvegardée, le noeud redémarrera."; +"communicating"="Communication avec l'appareil en cours. ."; +"connected.radio"="Radio connectée"; +"connected"="Bluetooth connecté"; +"connecting"="Connexion . ."; "contacts"="Contacts"; "contacts %@"="Contacts (%@)"; -"copy"="Copy"; -"current"="Current"; -"default"="Default"; -"delete"="Delete"; -"detection.sensor"="Detection Sensor"; -"detection.sensor.config"="Detection Sensor Config"; -"detection.sensor.log"="Detection Sensor Log"; -"device"="Device"; -"device.config"="Device Config"; +"copy"="Copier"; +"current"="Actuel"; +"default"="Par défaut"; +"delete"="Effacer"; +"detection.sensor"="Capteur de détection"; +"detection.sensor.config"="Configuration du capteur de détection"; +"detection.sensor.log"="Journal du capteur de détection"; +"device"="Appareil"; +"device.config"="Configuration de l'appareil"; "device.metrics.delete"="Delete all device metrics?"; "device.metrics.log"="Device Metrics Log"; "device.role.client"="App connected or stand alone messaging device."; From 982fd4e1f7e09e409c077b140b032763c1ebfe5f Mon Sep 17 00:00:00 2001 From: Myrlhyn <161041172+Myrlhyn@users.noreply.github.com> Date: Sun, 25 Feb 2024 17:56:10 +0100 Subject: [PATCH 03/74] Update Localizable.strings --- fr.lproj/Localizable.strings | 50 ++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/fr.lproj/Localizable.strings b/fr.lproj/Localizable.strings index a4703f3d..7b7c954d 100644 --- a/fr.lproj/Localizable.strings +++ b/fr.lproj/Localizable.strings @@ -67,33 +67,33 @@ "detection.sensor.log"="Journal du capteur de détection"; "device"="Appareil"; "device.config"="Configuration de l'appareil"; -"device.metrics.delete"="Delete all device metrics?"; -"device.metrics.log"="Device Metrics Log"; -"device.role.client"="App connected or stand alone messaging device."; -"device.role.clientmute"="Device that does not forward packets from other devices."; -"device.role.clienthidden"="Device that only broadcasts as needed for stealth or power savings."; -"device.role.tracker"="Broadcasts GPS position packets as priority."; -"device.role.lostandfound"="Broadcasts location as message to default channel regularly for to assist with device recovery."; -"device.role.sensor"="Broadcasts telemetry packets as priority."; -"device.role.tak"="Optimized for ATAK system communication, reduces routine broadcasts."; -"device.role.repeater"="Infrastructure node for extending network coverage by relaying messages with minimal overhead. Not visible in Nodes list."; -"device.role.router"="Infrastructure node for extending network coverage by relaying messages. Visible in Nodes list."; -"device.role.routerclient"="Combination of both ROUTER and CLIENT. Not for mobile devices."; -"direct.messages"="Direct Messages"; -"dismiss.keyboard"="Dismiss"; -"display"="Display"; -"display.config"="Display Config"; +"device.metrics.delete"="Effacer toutes les mesures de l’appareil?"; +"device.metrics.log"="Journal des mesures de l'appareil"; +"device.role.client"="Apploication connectée ou appareil de messagerie indépendant."; +"device.role.clientmute"="Appareil ne transmettant pas les paquets provenant d'autres appareils."; +"device.role.clienthidden"="Appareil ne diffusant que si nécessaire pour la discrétion et l'économie d'énergie."; +"device.role.tracker"="Transmet les paquets de positions GPS en priorité."; +"device.role.lostandfound"="Transmet régulièrement la position par message dans le canal par défaut pour vous aider à retrouver l'appareil."; +"device.role.sensor"="Transmet les paquets de télémétrie en priorité."; +"device.role.tak"="Optimisé pour le système de communication ATAK, diminue les émissions de routine."; +"device.role.repeater"="Noeud d'infrastructure qui étend la couverture du réseau en relayant les messages avec un minimum de surcharge. Invisible dans la liste des noeuds."; +"device.role.router"="Noeud d'infrastructure qui étend la couverture du réseau en relayant les messages. Visible dans la liste des noeuds."; +"device.role.routerclient"="Combinaison des modes ROUTER et CLIENT. Pas pour les appareils mobiles."; +"direct.messages"="Messages directs"; +"dismiss.keyboard"="Annuler"; +"display"="Écran"; +"display.config"="Configuration de l'écran"; "distance"="Distance"; -"disconnect"="Disconnect"; +"disconnect"="Déconnecter"; "echo"="Echo"; -"email.address"="Email Address"; -"enabled"="Enabled"; -"encrypted"="Encrypted"; -"external.notification"="External Notification"; -"external.notification.config"="External Notification Config"; -"finish"="Finish"; -"firmware.version"="Firmware Version"; -"firmware.version.unsupported"="Unsupported Firmware Version Detected, unable to connect to device."; +"email.address"="Adresse mail"; +"enabled"="Activé(e)"; +"encrypted"="Encrypté(e)"; +"external.notification"="Notification extérieure"; +"external.notification.config"="Configuration de la notification extérieure"; +"finish"="Terminer"; +"firmware.version"="Version du firmware"; +"firmware.version.unsupported"="Version non supportée du firmware détectée, impossible de se connecter à l'appareil."; "gas"="Gas"; "gas.resistance"="Gas Resistance"; "generate.qr.code"="Generate QR Code"; From 346eeb54c357b9c1a0f2410c6ead17d14fcba2d1 Mon Sep 17 00:00:00 2001 From: Myrlhyn <161041172+Myrlhyn@users.noreply.github.com> Date: Sun, 25 Feb 2024 20:17:52 +0100 Subject: [PATCH 04/74] Update Localizable.strings --- fr.lproj/Localizable.strings | 140 +++++++++++++++++------------------ 1 file changed, 70 insertions(+), 70 deletions(-) diff --git a/fr.lproj/Localizable.strings b/fr.lproj/Localizable.strings index 7b7c954d..38f2a646 100644 --- a/fr.lproj/Localizable.strings +++ b/fr.lproj/Localizable.strings @@ -85,85 +85,85 @@ "display.config"="Configuration de l'écran"; "distance"="Distance"; "disconnect"="Déconnecter"; -"echo"="Echo"; +"echo"="Écho"; "email.address"="Adresse mail"; -"enabled"="Activé(e)"; -"encrypted"="Encrypté(e)"; +"enabled"="Activé"; +"encrypted"="Encrypté"; "external.notification"="Notification extérieure"; "external.notification.config"="Configuration de la notification extérieure"; "finish"="Terminer"; "firmware.version"="Version du firmware"; "firmware.version.unsupported"="Version non supportée du firmware détectée, impossible de se connecter à l'appareil."; -"gas"="Gas"; -"gas.resistance"="Gas Resistance"; -"generate.qr.code"="Generate QR Code"; -"gpsformat.dec"="Decimal Degrees Format"; -"gpsformat.dms"="Degrees Minutes Seconds"; -"gpsformat.utm"="Universal Transverse Mercator"; +"gas"="Gaz"; +"gas.resistance"="Résistence du gaz"; +"generate.qr.code"="Générer un QR Code"; +"gpsformat.dec"="Format décimal pour les degrés"; +"gpsformat.dms"="Degrés Minutes Secondes"; +"gpsformat.utm"="Projection Mercator Transverse Universelle"; "gpsformat.mgrs"="Military Grid Reference System"; -"gpsformat.olc"="Open Location Code (aka Plus Codes)"; +"gpsformat.olc"="Open Location Code (alias Plus Codes)"; "gpsformat.osgr"="Ordnance Survey Grid Reference"; -"gpsmode.disabled"="Disabled"; -"gpsmode.enabled"="Enabled"; -"gpsmode.notPresent"="Not Present"; -"heard"="Heard"; -"heard.last"="Last Heard"; -"hybrid"="Hybrid"; -"hybrid.flyover"="Hybrid Flyover"; -"include"="Include"; -"inputevent.none"="None"; -"inputevent.up"="Up"; -"inputevent.down"="Down"; -"inputevent.left"="Left"; -"inputevent.right"="Right"; -"inputevent.select"="Select"; -"inputevent.back"="Back"; -"inputevent.cancel"="Cancel"; -"interval.one.second"="One Second"; -"interval.two.seconds"="Two Seconds"; -"interval.three.seconds"="Three Seconds"; -"interval.four.seconds"="Four Seconds"; -"interval.five.seconds"="Five Seconds"; -"interval.ten.seconds"="Ten Seconds"; -"interval.fifteen.seconds"="Fifteen Seconds"; -"interval.twenty.seconds"="Twenty Seconds"; -"interval.twentyfive.seconds"="Twenty Five Seconds"; -"interval.thirty.seconds"="Thirty Seconds"; -"interval.fortyfive.seconds"="Forty Five Seconds"; -"interval.one.minute"="One Minute"; -"interval.two.minutes"="Two Minutes"; -"interval.five.minutes"="Five Minutes"; -"interval.ten.minutes"="Ten Minutes"; -"interval.fifteen.minutes"="Fifteen Minutes"; -"interval.thirty.minutes"="Thirty Minutes"; -"interval.one.hour"="One Hour"; -"interval.two.hours"="Two Hours"; -"interval.three.hours"="Three Hours"; -"interval.four.hours"="Four Hours"; -"interval.five.hours"="Five Hours"; -"interval.six.hours"="Six Hours"; -"interval.twelve.hours"="Twelve Hours"; -"interval.eighteen.hours"="Eighteen Hours"; -"interval.twentyfour.hours"="Twenty Four Hours"; -"interval.thirtysix.hours"="Thirty Six Hours"; -"interval.fortyeight.hours"="Forty Eight Hours"; -"interval.seventytwo.hours"="Seventy Two Hours"; -"keyboard.type"="Keyboard Type"; -"logging"="Logging"; +"gpsmode.disabled"="Désactivé"; +"gpsmode.enabled"="Activé"; +"gpsmode.notPresent"="Absent"; +"heard"="Entendre"; +"heard.last"="Entendu pour la dernière fois"; +"hybrid"="Hybride"; +"hybrid.flyover"="Survol hybride"; +"include"="Inclure"; +"inputevent.none"="Aucun"; +"inputevent.up"="Haut"; +"inputevent.down"="Bas"; +"inputevent.left"="Gauche"; +"inputevent.right"="Droite"; +"inputevent.select"="Sélectionner"; +"inputevent.back"="Retour"; +"inputevent.cancel"="Annuler"; +"interval.one.second"="Une seconde"; +"interval.two.seconds"="Deux secondes"; +"interval.three.seconds"="Trois secondes"; +"interval.four.seconds"="Quatre secondes"; +"interval.five.seconds"="Cinq secondes"; +"interval.ten.seconds"="Dix secondes"; +"interval.fifteen.seconds"="Quinze secondes"; +"interval.twenty.seconds"="Vingr secondes"; +"interval.twentyfive.seconds"="Vignt cinq secondes"; +"interval.thirty.seconds"="Trente secondes"; +"interval.fortyfive.seconds"="Quanrante cinq secondes"; +"interval.one.minute"="Une minute"; +"interval.two.minutes"="Deux minutes"; +"interval.five.minutes"="Cinq minutes"; +"interval.ten.minutes"="Dix minutes"; +"interval.fifteen.minutes"="Quinze minutes"; +"interval.thirty.minutes"="Trente minutes"; +"interval.one.hour"="Une heure"; +"interval.two.hours"="Deux heures"; +"interval.three.hours"="Trois heures"; +"interval.four.hours"="Quatre heures"; +"interval.five.hours"="Cinq heures"; +"interval.six.hours"="Six heures"; +"interval.twelve.hours"="Douze heures"; +"interval.eighteen.hours"="Dix huit heures"; +"interval.twentyfour.hours"="Vingt quatre heures"; +"interval.thirtysix.hours"="Trente six heures"; +"interval.fortyeight.hours"="Quarante huit heures"; +"interval.seventytwo.hours"="Soixante douze heures"; +"keyboard.type"="Type de clavier"; +"logging"="Enregistrement"; "lora"="LoRa"; -"lora.config"="LoRa Config"; -"map"="Mesh Map"; -"map.type"="Default Type"; -"map.centering"="Centering Mode"; -"map.tiles.delete"="Delete All Map Tiles"; -"map.recentering"="Automatic Re-centering"; -"map.use.legacy"="Use Legacy Mesh Map"; -"map.usertrackingmode"="User tracking mode"; -"map.usertrackingmode.follow"="Follow"; -"map.usertrackingmode.followwithheading"="Follow with heading"; -"map.usertrackingmode.none"="None"; -"mesh.live.activity"="Mesh Live Activity"; -"mesh.log"="Mesh Log"; +"lora.config"="Configuration LoRa"; +"map"="Carte de maillage"; +"map.type"="Type par défaut"; +"map.centering"="Mode centré"; +"map.tiles.delete"="Supprimer toutes les tuiles de carte"; +"map.recentering"="Recentrage automatique"; +"map.use.legacy"="Utiliser l'ancienne génération de carte de maillage"; +"map.usertrackingmode"="Mode suivre l'utilisateur"; +"map.usertrackingmode.follow"="Suivre"; +"map.usertrackingmode.followwithheading"="Suivre avec le cap"; +"map.usertrackingmode.none"="Aucun"; +"mesh.live.activity"="Activité en direct du maillage"; +"mesh.log"="Journal du maillage"; "mesh.log.ambientlighting.config %@"="Ambient Lighting module config received: %@"; "mesh.log.bluetooth.config %@"="Bluetooth config received: %@"; "mesh.log.cannedmessage.config %@"="Canned Message module config received: %@"; From 6c927d36a0923d3a79e16d519a44a51359e99060 Mon Sep 17 00:00:00 2001 From: Myrlhyn <161041172+Myrlhyn@users.noreply.github.com> Date: Mon, 26 Feb 2024 14:21:10 +0100 Subject: [PATCH 05/74] Update Localizable.strings --- fr.lproj/Localizable.strings | 54 ++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/fr.lproj/Localizable.strings b/fr.lproj/Localizable.strings index 38f2a646..2f1742ef 100644 --- a/fr.lproj/Localizable.strings +++ b/fr.lproj/Localizable.strings @@ -37,8 +37,8 @@ "bluetooth.pin.validation"="Le code pin BLE doit faire 6 chiffres."; "bytes"="Octets"; "cancel"="Annuler"; -"canned.messages"="Messages Canned"; -"canned.messages.config"="Configuration des messages Canned"; +"canned.messages"="Messages préformatés"; +"canned.messages.config"="Configuration des messages préformatés"; "canned.messages.preset.manual"="Configuration manuelle"; "canned.messages.preset.rakrotary"="Module d'encodage rotatif RAK"; "canned.messages.preset.cardkb"="Clavier M5 Stack Card KB / RAK"; @@ -164,31 +164,31 @@ "map.usertrackingmode.none"="Aucun"; "mesh.live.activity"="Activité en direct du maillage"; "mesh.log"="Journal du maillage"; -"mesh.log.ambientlighting.config %@"="Ambient Lighting module config received: %@"; -"mesh.log.bluetooth.config %@"="Bluetooth config received: %@"; -"mesh.log.cannedmessage.config %@"="Canned Message module config received: %@"; -"mesh.log.cannedmessages.messages.get %@"="Requested Canned Messages Module Messages for node: %@"; -"mesh.log.cannedmessages.messages.received %@"="Canned Messages Messages Received For: %@"; -"mesh.log.channel.sent %@ %d"="Sent a Channel for: %@ Channel Index %d"; -"mesh.log.channel.received %d %@"="Channel %d received from: %@"; -"mesh.log.device.config %@"="Device config received: %@"; -"mesh.log.display.config %@"="Display config received: %@"; -"mesh.log.devicemetadata %@"="Requesting Device Metadata for %@"; -"mesh.log.device.metadata.received %@"="Device Metadata received from: %@"; -"mesh.log.detectionsensor.config %@"="Detection Sensor module config received: %@"; -"mesh.log.externalnotification.config %@"="External Notification module config received: %@"; -"mesh.log.lora.config %@"="LoRa config received: %@"; -"mesh.log.lora.config.sent %@"="Sent a LoRa.Config for: %@"; -"mesh.log.mqtt.config %@"="MQTT module config received: %@"; -"mesh.log.myinfo %@"="MyInfo received: %@"; -"mesh.log.network.config %@"="Network config received: %@"; -"mesh.log.nodeinfo.received %@"="Node info received for: %@"; -"mesh.log.position.config %@"="Positon config received: %@"; -"mesh.log.position.received %@"="Position Packet received from node: %@"; -"mesh.log.rangetest.config %@"="Range Test module config received: %@"; -"mesh.log.ringtone.config %@"="RTTTL Ringtone config received: %@"; -"mesh.log.routing.message %@ %@"="Routing received for RequestID: %@ Ack Status: %@"; -"mesh.log.serial.config %@"="Serial module config received: %@"; +"mesh.log.ambientlighting.config %@"="Configuration du module de lumière ambiante reçue : %@"; +"mesh.log.bluetooth.config %@"="Configuration du Bluetooth reçue : %@"; +"mesh.log.cannedmessage.config %@"="Configuration du module des messages préformatés reçue: %@"; +"mesh.log.cannedmessages.messages.get %@"="Messages du module des messages préformatés demandés pour le noeud : %@"; +"mesh.log.cannedmessages.messages.received %@"="Messages préformatés reçus pour : %@"; +"mesh.log.channel.sent %@ %d"="Canal envoyé pour : %@ Canal index %d"; +"mesh.log.channel.received %d %@"="Canal %d reçu de : %@"; +"mesh.log.device.config %@"="Configuration de l'appareil reçue : %@"; +"mesh.log.display.config %@"="Configuration de l'écran reçue : %@"; +"mesh.log.devicemetadata %@"="Demande des metadatas de l'appareil pour %@"; +"mesh.log.device.metadata.received %@"="Metadatas de l'appareil reçues de : %@"; +"mesh.log.detectionsensor.config %@"="Configuration du module de capteur de détection reçue : %@"; +"mesh.log.externalnotification.config %@"="Configuration du module de notification extérieure reçue : %@"; +"mesh.log.lora.config %@"="Configuration LoRa reçue : %@"; +"mesh.log.lora.config.sent %@"="Configuration LoRa envoyée pour : %@"; +"mesh.log.mqtt.config %@"="Configuration du module MQTT reçue : %@"; +"mesh.log.myinfo %@"="MesInfos reçues : %@"; +"mesh.log.network.config %@"="Configuration du réseau reçue : %@"; +"mesh.log.nodeinfo.received %@"="Information du noeud reçue pour : %@"; +"mesh.log.position.config %@"="Configuration de la position reçue : %@"; +"mesh.log.position.received %@"="Paquet de la position reçu du noeud : %@"; +"mesh.log.rangetest.config %@"="Configuration du module de test de la portée reçue : %@"; +"mesh.log.ringtone.config %@"="Configuration de la sonnerie RTTTL reçue : %@"; +"mesh.log.routing.message %@ %@"="Routage reçu pour la demande d'identité : %@ Status de l'accusé de réception : %@"; +"mesh.log.serial.config %@"="Configuration du moduel série reçue : %@"; "mesh.log.sharelocation %@"="Sent a Position Packet from the Apple device GPS to node: %@"; "mesh.log.storeforward.config %@"="Store & Forward module config received: %@"; "mesh.log.telemetry.config %@"="Telemetry module config received: %@"; From a488d4d831a6fe770eb4892acf8eac99a374b29b Mon Sep 17 00:00:00 2001 From: Myrlhyn <161041172+Myrlhyn@users.noreply.github.com> Date: Mon, 26 Feb 2024 14:41:06 +0100 Subject: [PATCH 06/74] Update Localizable.strings --- fr.lproj/Localizable.strings | 70 ++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/fr.lproj/Localizable.strings b/fr.lproj/Localizable.strings index 2f1742ef..9240b313 100644 --- a/fr.lproj/Localizable.strings +++ b/fr.lproj/Localizable.strings @@ -187,47 +187,47 @@ "mesh.log.position.received %@"="Paquet de la position reçu du noeud : %@"; "mesh.log.rangetest.config %@"="Configuration du module de test de la portée reçue : %@"; "mesh.log.ringtone.config %@"="Configuration de la sonnerie RTTTL reçue : %@"; -"mesh.log.routing.message %@ %@"="Routage reçu pour la demande d'identité : %@ Status de l'accusé de réception : %@"; -"mesh.log.serial.config %@"="Configuration du moduel série reçue : %@"; -"mesh.log.sharelocation %@"="Sent a Position Packet from the Apple device GPS to node: %@"; -"mesh.log.storeforward.config %@"="Store & Forward module config received: %@"; -"mesh.log.telemetry.config %@"="Telemetry module config received: %@"; -"mesh.log.telemetry.received %@"="Telemetry received for: %@"; -"mesh.log.textmessage.received"="Message received from the text message app."; -"mesh.log.textmessage.send.failed %@"="Message Send Failed, not properly connected to %@"; -"mesh.log.textmessage.sent %@ %@ %@"="Sent message %@ from %@ to %@"; -"mesh.log.traceroute.received.direct %@"="Trace Route request sent to node: %@ was recieived directly."; -"mesh.log.traceroute.received.route %@"="Trace Route request returned: %@"; -"mesh.log.traceroute.sent %@"="Sent a Trace Route Request to node: %@"; -"mesh.log.wantconfig %@"="Issuing Want Config to %@"; -"mesh.log.waypoint.sent %@"="Sent a Waypoint Packet from: %@"; -"mesh.log.waypoint.received %@"="Waypoint Packet received from node: %@"; +"mesh.log.routing.message %@ %@"="Routage reçu pour la demande numéro : %@ Status de l'accusé de réception : %@"; +"mesh.log.serial.config %@"="Configuration du module série reçue : %@"; +"mesh.log.sharelocation %@"="Paquet envoyé avec la position GPS de l'appareil Apple vers le noeud : %@"; +"mesh.log.storeforward.config %@"="Configuration du module de stockage et d'acheminement reçue : %@"; +"mesh.log.telemetry.config %@"="Configuration du module de télémetrie reçue : %@"; +"mesh.log.telemetry.received %@"="Télémetrie reçue pour : %@"; +"mesh.log.textmessage.received"="Message reçu depuis l'application de messagerie texte."; +"mesh.log.textmessage.send.failed %@"="Erreur d'envoi du message, mal connecté à %@"; +"mesh.log.textmessage.sent %@ %@ %@"="Envoi du message %@ de %@ à %@"; +"mesh.log.traceroute.received.direct %@"="La demande de Trace Route envoyée au noeud : %@ a été directement reçue."; +"mesh.log.traceroute.received.route %@"="La demande de Trace Route est revenue : %@"; +"mesh.log.traceroute.sent %@"="Envoi d'une demande de Trace Route au noeud : %@"; +"mesh.log.wantconfig %@"="Envoi d'un Want Config à %@"; +"mesh.log.waypoint.sent %@"="Paquet Waypoint envoyé depuis : %@"; +"mesh.log.waypoint.received %@"="Paquet Waypoint reçu du noeud : %@"; "message"="Message"; -"message.details"="Message Details"; +"message.details"="Détails du message"; "messages"="Messages"; "mode"="Mode"; -"module.configuration"="Module Configuration"; +"module.configuration"="Configuration du module"; "mqtt"="MQTT"; -"mqtt.connect"="Connect to MQTT"; -"mqtt.config"="MQTT Config"; -"mqtt.clientproxy"="MQTT Client Proxy"; -"mqtt.disconnect"="Disconnect from MQTT"; -"mqtt.username"="Username"; -"name"="Name"; -"network"="Network"; -"network.config"="Network Config"; -"nodes"="Nodes"; -"nodes %@"="Nodes (%@)"; -"no.nodes"="No Meshtastic Nodes Found"; -"not.connected"="No device connected"; -"numbers.punctuation"="Numbers and Punctuation"; -"off"="Off"; -"offline"="Offline"; -"on.boot"="On Boot Only"; +"mqtt.connect"="Connecter à MQTT"; +"mqtt.config"="Configuration MQTT"; +"mqtt.clientproxy"="Proxy client MQTT"; +"mqtt.disconnect"="Déconnecter MQTT"; +"mqtt.username"="Nom d'utilisateur"; +"name"="Nom"; +"network"="Réseau"; +"network.config"="Configuration du réseau"; +"nodes"="Noeuds"; +"nodes %@"="Noeuds (%@)"; +"no.nodes"="Aucun noeuds Meshtastic trouvés"; +"not.connected"="Aucun appareil connecté"; +"numbers.punctuation"="Nombres and Ponctuation"; +"off"="Éteint"; +"offline"="Hors ligne"; +"on.boot"="Uniquement au démarrage"; "options"="Options"; -"password"="Password"; +"password"="Mot de passe"; "pause"="Pause"; -"phone.gps"="Phone GPS"; +"phone.gps"="GPS du téléphone"; "phone.gps.interval.description"="How frequently your phone will send your location to the device, location updates to the mesh are managed by the device."; "position"="Position"; "position.config"="Position Config"; From e4f5a0778b85e6069ee22a6726becb1128946522 Mon Sep 17 00:00:00 2001 From: Myrlhyn <161041172+Myrlhyn@users.noreply.github.com> Date: Mon, 26 Feb 2024 21:24:37 +0100 Subject: [PATCH 07/74] Update Localizable.strings --- fr.lproj/Localizable.strings | 132 +++++++++++++++++------------------ 1 file changed, 66 insertions(+), 66 deletions(-) diff --git a/fr.lproj/Localizable.strings b/fr.lproj/Localizable.strings index 9240b313..e6dc0f4c 100644 --- a/fr.lproj/Localizable.strings +++ b/fr.lproj/Localizable.strings @@ -190,7 +190,7 @@ "mesh.log.routing.message %@ %@"="Routage reçu pour la demande numéro : %@ Status de l'accusé de réception : %@"; "mesh.log.serial.config %@"="Configuration du module série reçue : %@"; "mesh.log.sharelocation %@"="Paquet envoyé avec la position GPS de l'appareil Apple vers le noeud : %@"; -"mesh.log.storeforward.config %@"="Configuration du module de stockage et d'acheminement reçue : %@"; +"mesh.log.storeforward.config %@"="Configuration du module Stocker et Transmettre reçue : %@"; "mesh.log.telemetry.config %@"="Configuration du module de télémetrie reçue : %@"; "mesh.log.telemetry.received %@"="Télémetrie reçue pour : %@"; "mesh.log.textmessage.received"="Message reçu depuis l'application de messagerie texte."; @@ -218,7 +218,7 @@ "network.config"="Configuration du réseau"; "nodes"="Noeuds"; "nodes %@"="Noeuds (%@)"; -"no.nodes"="Aucun noeuds Meshtastic trouvés"; +"no.nodes"="Aucun noeud Meshtastic trouvé"; "not.connected"="Aucun appareil connecté"; "numbers.punctuation"="Nombres and Ponctuation"; "off"="Éteint"; @@ -228,78 +228,78 @@ "password"="Mot de passe"; "pause"="Pause"; "phone.gps"="GPS du téléphone"; -"phone.gps.interval.description"="How frequently your phone will send your location to the device, location updates to the mesh are managed by the device."; +"phone.gps.interval.description"="La fréquence à laquelle votre téléphone envoie votre position à l'appareil, les mises à jour de la position vers le maillage sont gérées par l'appareil."; "position"="Position"; -"position.config"="Position Config"; -"preferred.radio"="Preferred Radio"; -"radio.configuration"="Radio Configuration"; -"range.test"="Range Test"; -"range.test.blocked"="Block Range Test"; -"range.test.config"="Range Test Config"; -"reply"="Reply"; -"reboot"="Reboot"; -"reboot.node"="Reboot node?"; -"received.ack"="Received Ack"; -"received.ack.real"="Recipient Ack"; -"resume"="Resume"; -"ringtone"="Ringtone"; -"ringtone.config"="Ringtone Config"; -"route.recorder"="Route Recorder"; +"position.config"="Configuration de la position"; +"preferred.radio"="Radio favorie"; +"radio.configuration"="Configuration de la radio"; +"range.test"="Test de portée"; +"range.test.blocked"="Bloque le test de portée"; +"range.test.config"="Configuration du test de portée"; +"reply"="Répondre"; +"reboot"="Redémarrer"; +"reboot.node"="Redémarrer le noeud ?"; +"received.ack"="Accusé de réception reçu"; +"received.ack.real"="Accusé de réception du destinataire"; +"resume"="Reprendre"; +"ringtone"="Sonnerie"; +"ringtone.config"="Configuration de la sonnerie"; +"route.recorder"="Enregistreur de route"; "routes"="Routes"; -"routing.acknowledged"="Acknowledged"; -"routing.noroute"="No Route"; -"routing.gotnak"="Received a negative acknowledgment"; -"routing.timeout"="Timeout"; -"routing.nointerface"="No Interface"; -"routing.maxretransmit"="Max Retransmission Reached"; -"routing.nochannel"="No Channel"; -"routing.toolarge"="The packet is too large"; -"routing.noresponse"="No Response"; -"routing.dutycyclelimit"="Regional Duty Cycle Limit Reached"; -"routing.badRequest"="Bad Request"; -"routing.notauthorized"="Not Authorized"; +"routing.acknowledged"="Confirmé"; +"routing.noroute"="Pas de route"; +"routing.gotnak"="Accusé de réception négatif reçu"; +"routing.timeout"="Délai d'expiration"; +"routing.nointerface"="Pas d'interface"; +"routing.maxretransmit"="Nombre maximum de retransmissions atteint"; +"routing.nochannel"="Pas de canal"; +"routing.toolarge"="Le paquet est trop grand"; +"routing.noresponse"="Pas de réponse"; +"routing.dutycyclelimit"="Limite du cycle de service régional atteinte"; +"routing.badRequest"="Requête incorrecte"; +"routing.notauthorized"="Non autorisé"; "satellite"="Satellite"; -"satellite.flyover"="Satellite Flyover"; -"save"="Save"; -"save.config %@"="Save Config for %@"; -"serial"="Serial"; -"serial.config"="Serial Config"; -"serial.mode.default"="Default"; +"satellite.flyover"="Pont par satellite"; +"save"="Sauvegarder"; +"save.config %@"="Sauvegarder la configuration pour %@"; +"serial"="Série"; +"serial.config"="Configuration série"; +"serial.mode.default"="Défaut"; "serial.mode.simple"="Simple"; "serial.mode.proto"="Protobufs"; -"serial.mode.txtmsg"="Text Message"; -"serial.mode.nmea"="NMEA Positions"; -"settings"="Settings"; -"share.channels"="Share QR Code"; -"share.position"="Share Position"; -"subscribed"="Subscribed to mesh"; -"select.contact"="Select a Contact"; -"select.node"="Select a Node"; -"select.menu.item"="Select an item from the menu"; -"set.region"="Set LoRa Region"; +"serial.mode.txtmsg"="Message texte"; +"serial.mode.nmea"="Positions NMEA"; +"settings"="Réglages"; +"share.channels"="Partager le QR Code"; +"share.position"="Partager la position"; +"subscribed"="Abonné au maillage"; +"select.contact"="Sélectioner un contact"; +"select.node"="Sélectioner un noeud"; +"select.menu.item"="Sélectioner un item du menu"; +"set.region"="Définir la région LoRa"; "standard"="Standard"; -"standard.muted"="Standard Muted"; -"start"="Start"; -"storeforward"="Store & Forward"; -"storeforward.config"="Store & Forward Config"; -"storeforward.heartbeat"="Send Heartbeat"; +"standard.muted"="Standard en sourdine"; +"start"="Démarrer"; +"storeforward"="Stocker et Transmettre"; +"storeforward.config"="Configuration de Stocker et Transmettre"; +"storeforward.heartbeat"="Envoyer une impulsion"; "ssid"="SSID"; -"tapback"="Tapback Response"; -"tapback.heart"="Heart"; -"tapback.thumbsup"="Thumbs Up"; -"tapback.thumbsdown"="Thumbs Down"; +"tapback"="Réponse de Tapback"; +"tapback.heart"="Coeur"; +"tapback.thumbsup"="Pouce levé"; +"tapback.thumbsdown"="Pouce baissé"; "tapback.haha"="HaHa"; -"tapback.exclamation"="Exclamation Mark"; -"tapback.question"="Question Mark"; -"tapback.poop"="Poop"; -"telemetry"="Telemetry (Sensors)"; -"telemetry.config"="Telemetry Config"; -"timeout"="Timeout"; -"timestamp"="Timestamp"; -"tip.bluetooth.connect.title"="Connected Radio"; -"tip.bluetooth.connect.message"="Shows information for the Lora radio connected via bluetooth. You can swipe left to disconnect the radio and long press to view stats or start the live activity."; -"tip.channels.create.title"="Manage Channels"; -"tip.channels.create.message"="Most data on your mesh is sent over the primary channel. You can set up secondary channels to create additional messaging groups secured by their own key. [Channel config tips](https://meshtastic.org/docs/configuration/tips/)"; +"tapback.exclamation"="Point d'exclamation"; +"tapback.question"="Point d'interrogation"; +"tapback.poop"="Caca"; +"telemetry"="Télémetrie (Capteurs)"; +"telemetry.config"="Configuration de télémetrie"; +"timeout"="Délai d'expiration"; +"timestamp"="Horodatage"; +"tip.bluetooth.connect.title"="Radio connectée"; +"tip.bluetooth.connect.message"="Affiche les informations de la radio Lora connectée via le bluetooth. Vous pouvez faire un glissé vers la gauche pour déconnecter la radio et un appui long pour voir les statistiques ou démarrer l'activité en direct."; +"tip.channels.create.title"="Gérer les canaux"; +"tip.channels.create.message"="La pluspart des données de votre maillage sont envoyées sur le canal principal. Vous pouvez définir des canaux secondaires pour créer des groupes de messagerie additionnelle sécurisés avec leur propre clée. [Conseils de configuration du canal](https://meshtastic.org/docs/configuration/tips/)"; "tip.channels.share.title"="Sharing Meshtastic Channels"; "tip.channels.share.message"="A Meshtastic QR code contains the LoRa config and channel values needed to communicate. Most mesh activity takes place on the required Primary channel. If you don't share your primary channel your first shared channel becomes the primary channel on the other network. Other channels are for private groups, each with its own key."; "tip.messages.title"="Messages"; From 0377552ed962a5493ee2ab328e33f15f57db50f4 Mon Sep 17 00:00:00 2001 From: Myrlhyn <161041172+Myrlhyn@users.noreply.github.com> Date: Tue, 27 Feb 2024 09:02:00 +0100 Subject: [PATCH 08/74] Update Localizable.strings --- fr.lproj/Localizable.strings | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/fr.lproj/Localizable.strings b/fr.lproj/Localizable.strings index e6dc0f4c..c1a6b775 100644 --- a/fr.lproj/Localizable.strings +++ b/fr.lproj/Localizable.strings @@ -299,18 +299,18 @@ "tip.bluetooth.connect.title"="Radio connectée"; "tip.bluetooth.connect.message"="Affiche les informations de la radio Lora connectée via le bluetooth. Vous pouvez faire un glissé vers la gauche pour déconnecter la radio et un appui long pour voir les statistiques ou démarrer l'activité en direct."; "tip.channels.create.title"="Gérer les canaux"; -"tip.channels.create.message"="La pluspart des données de votre maillage sont envoyées sur le canal principal. Vous pouvez définir des canaux secondaires pour créer des groupes de messagerie additionnelle sécurisés avec leur propre clée. [Conseils de configuration du canal](https://meshtastic.org/docs/configuration/tips/)"; -"tip.channels.share.title"="Sharing Meshtastic Channels"; -"tip.channels.share.message"="A Meshtastic QR code contains the LoRa config and channel values needed to communicate. Most mesh activity takes place on the required Primary channel. If you don't share your primary channel your first shared channel becomes the primary channel on the other network. Other channels are for private groups, each with its own key."; +"tip.channels.create.message"="La pluspart des données de votre maillage sont envoyées sur le canal principal. Vous pouvez définir des canaux secondaires pour créer des groupes de messagerie additionnelle sécurisés avec leur propre clé. [Conseils de configuration du canal](https://meshtastic.org/docs/configuration/tips/)"; +"tip.channels.share.title"="Partage des canaux Meshtastic"; +"tip.channels.share.message"="Un code QR Meshtastic contient la configuration LoRa et les valeurs de canal nécessaires pour communiquer. La plupart des activités du maillage ont lieu sur le canal principal requis. Si vous ne partagez pas votre canal principal, votre premier canal partagé devient le canal principal de l’autre réseau. Les autres canaux sont pour les groupes privés, chacun avec sa propre clé."; "tip.messages.title"="Messages"; -"tip.messages.message"="You can send and receive channel (group chats) and direct messages. From any message you can long press to see available actions like copy, reply, tapback and delete as well as delivery details."; +"tip.messages.message"="Vous pouvez envoyer et recevoir des canaux (chats de groupe) et des messages directs. À partir de n’importe quel message, vous pouvez faire un appui long pour voir les actions possibles comme copier, répondre, tapback et supprimer ainsi que les détails de l'envoi."; "twitter"="Twitter"; -"unknown"="Unknown"; -"unknown.age"="Unknown Age"; -"unset"="Unset"; -"update.firmware"="Update Your Firmware"; -"update.interval"="Update Interval"; -"user"="User"; -"user.details"="User Details"; -"voltage"="Voltage"; -"waiting"="Waiting. . ."; +"unknown"="Inconnu"; +"unknown.age"="Age inconnu"; +"unset"="Désactivé"; +"update.firmware"="Mettre à jour votre Firmware"; +"update.interval"="Intervale de mise à jour"; +"user"="Utilisateur"; +"user.details"="Détails de l'utilisateur"; +"voltage"="Tension"; +"waiting"="En attente . . ."; From d8b4ffd5b97e37055c951d78b9fdd2b5b690610a Mon Sep 17 00:00:00 2001 From: Myrlhyn <161041172+Myrlhyn@users.noreply.github.com> Date: Tue, 27 Feb 2024 09:40:52 +0100 Subject: [PATCH 09/74] Update Localizable.strings Last review --- fr.lproj/Localizable.strings | 58 ++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/fr.lproj/Localizable.strings b/fr.lproj/Localizable.strings index c1a6b775..4a5ea20d 100644 --- a/fr.lproj/Localizable.strings +++ b/fr.lproj/Localizable.strings @@ -8,7 +8,7 @@ "about"="À propos"; "about.meshtastic"="À propos de Meshtastic"; "admin"="Administrateur"; -"admin.log"="Journal des messages administrateur"; +"admin.log"="Journal des messages d'administration"; "ago"="auparavant"; "airtime"="Temps d'émission"; "always.on"="En permanence"; @@ -24,17 +24,17 @@ "battery.level"="Niveau de batterie"; "ble.name"="Nom du BLE"; "ble.connection.timeout %d %@"="Connexion impossible après %d essais avec %@. Allez dans Réglages > Bluetooth et essayez de faire de faire > Oublier cet appareil."; -"ble.errorcode.6 %@"="%@ L'application se reconnectera automatiquement à la radio en favori dès qu'elle sera à nouveau visibile."; -"ble.errorcode.14 %@"="%@ Cette erreur ne peut généralement pas être corrigée sans aller dans Réglages > Bluetooth et faire > Oublier cet appareil, puis de reconnecter la radio."; +"ble.errorcode.6 %@"="%@ L'application se reconnectera automatiquement à la radio en favori dès qu'elle sera à nouveau disponible."; +"ble.errorcode.14 %@"="%@ Cette erreur ne peut généralement pas être corrigée sans aller dans Réglages > Bluetooth et faire > Oublier cet appareil, puis reconnecter la radio."; "ble.errorcode.pin %@"="%@ Merci d'essayer à nouveau en vérifiant bien le code PIN."; "bluetooth"="Bluetooth"; -"bluetooth.off"="Le Bluetooth is arrêté"; -"bluetooth.config"="Configuration du Bluetooth"; +"bluetooth.off"="Le Bluetooth est arrêté"; +"bluetooth.config"="Configuration Bluetooth"; "bluetooth.mode.randompin"="Code PIN aléatoire"; "bluetooth.mode.fixedpin"="Code PIN fixe"; -"bluetooth.mode.nopin"="Sans copde PIN (connexion directe)"; +"bluetooth.mode.nopin"="Sans code PIN (connexion directe)"; "bluetooth.pairingmode"="Mode d'appairage"; -"bluetooth.pin.validation"="Le code pin BLE doit faire 6 chiffres."; +"bluetooth.pin.validation"="Le code pin BLE doit avoir 6 chiffres."; "bytes"="Octets"; "cancel"="Annuler"; "canned.messages"="Messages préformatés"; @@ -69,7 +69,7 @@ "device.config"="Configuration de l'appareil"; "device.metrics.delete"="Effacer toutes les mesures de l’appareil?"; "device.metrics.log"="Journal des mesures de l'appareil"; -"device.role.client"="Apploication connectée ou appareil de messagerie indépendant."; +"device.role.client"="Application connectée ou appareil de messagerie autonome."; "device.role.clientmute"="Appareil ne transmettant pas les paquets provenant d'autres appareils."; "device.role.clienthidden"="Appareil ne diffusant que si nécessaire pour la discrétion et l'économie d'énergie."; "device.role.tracker"="Transmet les paquets de positions GPS en priorité."; @@ -106,10 +106,10 @@ "gpsmode.disabled"="Désactivé"; "gpsmode.enabled"="Activé"; "gpsmode.notPresent"="Absent"; -"heard"="Entendre"; -"heard.last"="Entendu pour la dernière fois"; +"heard"="Capté"; +"heard.last"="Capté pour la dernière fois"; "hybrid"="Hybride"; -"hybrid.flyover"="Survol hybride"; +"hybrid.flyover"="Flyover hybride"; "include"="Inclure"; "inputevent.none"="Aucun"; "inputevent.up"="Haut"; @@ -126,10 +126,10 @@ "interval.five.seconds"="Cinq secondes"; "interval.ten.seconds"="Dix secondes"; "interval.fifteen.seconds"="Quinze secondes"; -"interval.twenty.seconds"="Vingr secondes"; -"interval.twentyfive.seconds"="Vignt cinq secondes"; +"interval.twenty.seconds"="Vingt secondes"; +"interval.twentyfive.seconds"="Vingt cinq secondes"; "interval.thirty.seconds"="Trente secondes"; -"interval.fortyfive.seconds"="Quanrante cinq secondes"; +"interval.fortyfive.seconds"="Quarante cinq secondes"; "interval.one.minute"="Une minute"; "interval.two.minutes"="Deux minutes"; "interval.five.minutes"="Cinq minutes"; @@ -164,37 +164,37 @@ "map.usertrackingmode.none"="Aucun"; "mesh.live.activity"="Activité en direct du maillage"; "mesh.log"="Journal du maillage"; -"mesh.log.ambientlighting.config %@"="Configuration du module de lumière ambiante reçue : %@"; -"mesh.log.bluetooth.config %@"="Configuration du Bluetooth reçue : %@"; -"mesh.log.cannedmessage.config %@"="Configuration du module des messages préformatés reçue: %@"; -"mesh.log.cannedmessages.messages.get %@"="Messages du module des messages préformatés demandés pour le noeud : %@"; +"mesh.log.ambientlighting.config %@"="Configuration du module lumière ambiante reçue : %@"; +"mesh.log.bluetooth.config %@"="Configuration Bluetooth reçue : %@"; +"mesh.log.cannedmessage.config %@"="Configuration du module messages préformatés reçue : %@"; +"mesh.log.cannedmessages.messages.get %@"="Messages du module messages préformatés demandés pour le noeud : %@"; "mesh.log.cannedmessages.messages.received %@"="Messages préformatés reçus pour : %@"; "mesh.log.channel.sent %@ %d"="Canal envoyé pour : %@ Canal index %d"; "mesh.log.channel.received %d %@"="Canal %d reçu de : %@"; "mesh.log.device.config %@"="Configuration de l'appareil reçue : %@"; "mesh.log.display.config %@"="Configuration de l'écran reçue : %@"; -"mesh.log.devicemetadata %@"="Demande des metadatas de l'appareil pour %@"; +"mesh.log.devicemetadata %@"="Demande des metadatas de l'appareil à %@"; "mesh.log.device.metadata.received %@"="Metadatas de l'appareil reçues de : %@"; -"mesh.log.detectionsensor.config %@"="Configuration du module de capteur de détection reçue : %@"; -"mesh.log.externalnotification.config %@"="Configuration du module de notification extérieure reçue : %@"; +"mesh.log.detectionsensor.config %@"="Configuration du module capteur de détection reçue : %@"; +"mesh.log.externalnotification.config %@"="Configuration du module notification extérieure reçue : %@"; "mesh.log.lora.config %@"="Configuration LoRa reçue : %@"; -"mesh.log.lora.config.sent %@"="Configuration LoRa envoyée pour : %@"; +"mesh.log.lora.config.sent %@"="Configuration LoRa envoyée à : %@"; "mesh.log.mqtt.config %@"="Configuration du module MQTT reçue : %@"; "mesh.log.myinfo %@"="MesInfos reçues : %@"; "mesh.log.network.config %@"="Configuration du réseau reçue : %@"; "mesh.log.nodeinfo.received %@"="Information du noeud reçue pour : %@"; "mesh.log.position.config %@"="Configuration de la position reçue : %@"; "mesh.log.position.received %@"="Paquet de la position reçu du noeud : %@"; -"mesh.log.rangetest.config %@"="Configuration du module de test de la portée reçue : %@"; +"mesh.log.rangetest.config %@"="Configuration du module test deportée reçue : %@"; "mesh.log.ringtone.config %@"="Configuration de la sonnerie RTTTL reçue : %@"; "mesh.log.routing.message %@ %@"="Routage reçu pour la demande numéro : %@ Status de l'accusé de réception : %@"; "mesh.log.serial.config %@"="Configuration du module série reçue : %@"; "mesh.log.sharelocation %@"="Paquet envoyé avec la position GPS de l'appareil Apple vers le noeud : %@"; "mesh.log.storeforward.config %@"="Configuration du module Stocker et Transmettre reçue : %@"; -"mesh.log.telemetry.config %@"="Configuration du module de télémetrie reçue : %@"; +"mesh.log.telemetry.config %@"="Configuration du module télémetrie reçue : %@"; "mesh.log.telemetry.received %@"="Télémetrie reçue pour : %@"; "mesh.log.textmessage.received"="Message reçu depuis l'application de messagerie texte."; -"mesh.log.textmessage.send.failed %@"="Erreur d'envoi du message, mal connecté à %@"; +"mesh.log.textmessage.send.failed %@"="Erreur d'envoi du message, mauvaise connexion à %@"; "mesh.log.textmessage.sent %@ %@ %@"="Envoi du message %@ de %@ à %@"; "mesh.log.traceroute.received.direct %@"="La demande de Trace Route envoyée au noeud : %@ a été directement reçue."; "mesh.log.traceroute.received.route %@"="La demande de Trace Route est revenue : %@"; @@ -211,7 +211,7 @@ "mqtt.connect"="Connecter à MQTT"; "mqtt.config"="Configuration MQTT"; "mqtt.clientproxy"="Proxy client MQTT"; -"mqtt.disconnect"="Déconnecter MQTT"; +"mqtt.disconnect"="Déconnecter le MQTT"; "mqtt.username"="Nom d'utilisateur"; "name"="Nom"; "network"="Réseau"; @@ -234,7 +234,7 @@ "preferred.radio"="Radio favorie"; "radio.configuration"="Configuration de la radio"; "range.test"="Test de portée"; -"range.test.blocked"="Bloque le test de portée"; +"range.test.blocked"="Test de portée bloqué"; "range.test.config"="Configuration du test de portée"; "reply"="Répondre"; "reboot"="Redémarrer"; @@ -259,7 +259,7 @@ "routing.badRequest"="Requête incorrecte"; "routing.notauthorized"="Non autorisé"; "satellite"="Satellite"; -"satellite.flyover"="Pont par satellite"; +"satellite.flyover"="Flyover par satellite"; "save"="Sauvegarder"; "save.config %@"="Sauvegarder la configuration pour %@"; "serial"="Série"; @@ -303,7 +303,7 @@ "tip.channels.share.title"="Partage des canaux Meshtastic"; "tip.channels.share.message"="Un code QR Meshtastic contient la configuration LoRa et les valeurs de canal nécessaires pour communiquer. La plupart des activités du maillage ont lieu sur le canal principal requis. Si vous ne partagez pas votre canal principal, votre premier canal partagé devient le canal principal de l’autre réseau. Les autres canaux sont pour les groupes privés, chacun avec sa propre clé."; "tip.messages.title"="Messages"; -"tip.messages.message"="Vous pouvez envoyer et recevoir des canaux (chats de groupe) et des messages directs. À partir de n’importe quel message, vous pouvez faire un appui long pour voir les actions possibles comme copier, répondre, tapback et supprimer ainsi que les détails de l'envoi."; +"tip.messages.message"="Vous pouvez envoyer et recevoir des canaux (chats de groupe) et des messages directs. Depuis n’importe quel message, vous pouvez faire un appui long pour voir les actions possibles comme copier, répondre, tapback et supprimer ainsi que les détails de l'envoi."; "twitter"="Twitter"; "unknown"="Inconnu"; "unknown.age"="Age inconnu"; From 0dcdca5e23d1658ba3f55a9faa19275435026735 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Thu, 29 Feb 2024 21:26:17 -0800 Subject: [PATCH 10/74] Fix messaging bug, fix bug where node would not create user --- Meshtastic.xcodeproj/project.pbxproj | 8 +-- Meshtastic/Helpers/MeshPackets.swift | 2 +- .../contents | 4 +- Meshtastic/Persistence/UpdateCoreData.swift | 53 +++++++++++++------ 4 files changed, 44 insertions(+), 23 deletions(-) diff --git a/Meshtastic.xcodeproj/project.pbxproj b/Meshtastic.xcodeproj/project.pbxproj index d7a7997a..8b279cbd 100644 --- a/Meshtastic.xcodeproj/project.pbxproj +++ b/Meshtastic.xcodeproj/project.pbxproj @@ -1583,7 +1583,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 2.2.25; + MARKETING_VERSION = 2.2.26; PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient; PRODUCT_NAME = "$(TARGET_NAME)"; SUPPORTS_MACCATALYST = YES; @@ -1617,7 +1617,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 2.2.25; + MARKETING_VERSION = 2.2.26; PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient; PRODUCT_NAME = "$(TARGET_NAME)"; SUPPORTS_MACCATALYST = YES; @@ -1739,7 +1739,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 2.2.25; + MARKETING_VERSION = 2.2.26; PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient.Widgets; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -1772,7 +1772,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 2.2.25; + MARKETING_VERSION = 2.2.26; PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient.Widgets; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/Meshtastic/Helpers/MeshPackets.swift b/Meshtastic/Helpers/MeshPackets.swift index ad763b23..aeb39c3a 100644 --- a/Meshtastic/Helpers/MeshPackets.swift +++ b/Meshtastic/Helpers/MeshPackets.swift @@ -775,7 +775,7 @@ func telemetryPacket(packet: MeshPacket, connectedNode: Int64, context: NSManage func textMessageAppPacket(packet: MeshPacket, wantRangeTestPackets: Bool, connectedNode: Int64, storeForward: Bool = false, context: NSManagedObjectContext) { var messageText = String(bytes: packet.decoded.payload, encoding: .utf8) - if !wantRangeTestPackets && ((messageText?.starts(with: "seq ")) != nil) { + if !wantRangeTestPackets && (String(messageText ?? "").starts(with: "seq ")) { return } var storeForwardBroadcast = false diff --git a/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 28.xcdatamodel/contents b/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 28.xcdatamodel/contents index d3da3c8d..00f91752 100644 --- a/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 28.xcdatamodel/contents +++ b/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 28.xcdatamodel/contents @@ -1,5 +1,5 @@ - + @@ -249,7 +249,7 @@ - + diff --git a/Meshtastic/Persistence/UpdateCoreData.swift b/Meshtastic/Persistence/UpdateCoreData.swift index c6b290a5..341004f7 100644 --- a/Meshtastic/Persistence/UpdateCoreData.swift +++ b/Meshtastic/Persistence/UpdateCoreData.swift @@ -147,11 +147,23 @@ func upsertNodeInfoPacket (packet: MeshPacket, context: NSManagedObjectContext) newNode.channel = Int32(packet.channel) if let nodeInfoMessage = try? NodeInfo(serializedData: packet.decoded.payload) { newNode.channel = Int32(nodeInfoMessage.channel) - print(packet.channel) - print("Channel From Message\(nodeInfoMessage.channel)") } if let newUserMessage = try? User(serializedData: packet.decoded.payload) { - let newUser = UserEntity(context: context) + + if newUserMessage.id.isEmpty { + let newUser = UserEntity(context: context) + newUser.num = Int64(packet.from) + let userId = String(format:"%2X", packet.from) + newUser.userId = "!\(userId)" + let last4 = String(userId.suffix(4)) + newUser.longName = "Meshtastic \(last4)" + newUser.shortName = last4 + newUser.hwModel = "UNSET" + newNode.user = newUser + + } else { + + let newUser = UserEntity(context: context) newUser.userId = newUserMessage.id newUser.num = Int64(packet.from) newUser.longName = newUserMessage.longName @@ -159,6 +171,17 @@ func upsertNodeInfoPacket (packet: MeshPacket, context: NSManagedObjectContext) newUser.role = Int32(newUserMessage.role.rawValue) newUser.hwModel = String(describing: newUserMessage.hwModel).uppercased() newNode.user = newUser + } + } else { + let newUser = UserEntity(context: context) + newUser.num = Int64(packet.from) + let userId = String(format:"%2X", packet.from) + newUser.userId = "!\(userId)" + let last4 = String(userId.suffix(4)) + newUser.longName = "Meshtastic \(last4)" + newUser.shortName = last4 + newUser.hwModel = "UNSET" + newNode.user = newUser } if newNode.user == nil { @@ -177,7 +200,6 @@ func upsertNodeInfoPacket (packet: MeshPacket, context: NSManagedObjectContext) print("💥 Error Inserting New Core Data MyInfoEntity: \(nsError)") } newNode.myInfo = myInfoEntity - //newNode.objectWillChange.send() } else { // Update an existing node @@ -211,20 +233,19 @@ func upsertNodeInfoPacket (packet: MeshPacket, context: NSManagedObjectContext) fetchedNode[0].user!.shortName = nodeInfoMessage.user.shortName fetchedNode[0].user!.role = Int32(nodeInfoMessage.user.role.rawValue) fetchedNode[0].user!.hwModel = String(describing: nodeInfoMessage.user.hwModel).uppercased() - } else { - if (fetchedNode[0].user == nil) { - let newUser = UserEntity(context: context) - newUser.num = Int64(nodeInfoMessage.num) - let userId = String(format:"%2X", nodeInfoMessage.num) - newUser.userId = "!\(userId)" - let last4 = String(userId.suffix(4)) - newUser.longName = "Meshtastic \(last4)" - newUser.shortName = last4 - newUser.hwModel = "UNSET" - fetchedNode[0].user! = newUser - } } } + if (fetchedNode[0].user == nil) { + let newUser = UserEntity(context: context) + newUser.num = Int64(packet.from) + let userId = String(format:"%2X", packet.from) + newUser.userId = "!\(userId)" + let last4 = String(userId.suffix(4)) + newUser.longName = "Meshtastic \(last4)" + newUser.shortName = last4 + newUser.hwModel = "UNSET" + fetchedNode[0].user! = newUser + } do { try context.save() print("💾 Updated NodeInfo from Node Info App Packet For: \(fetchedNode[0].num)") From 78b902dae0b4634408ef1ceec8a315ea52ac741d Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sat, 2 Mar 2024 08:31:29 -0800 Subject: [PATCH 11/74] Update mesh logs to not spit out JSON Enhance node list search --- Meshtastic.xcodeproj/project.pbxproj | 12 +- Meshtastic/Helpers/BLEManager.swift | 27 +++-- .../contents | 55 +++++---- .../Views/Nodes/Helpers/NodeListItem.swift | 12 +- Meshtastic/Views/Nodes/NodeList.swift | 104 ++++++++++++------ Meshtastic/Views/Nodes/PaxCounterLog.swift | 4 +- 6 files changed, 130 insertions(+), 84 deletions(-) diff --git a/Meshtastic.xcodeproj/project.pbxproj b/Meshtastic.xcodeproj/project.pbxproj index 8b279cbd..156262d1 100644 --- a/Meshtastic.xcodeproj/project.pbxproj +++ b/Meshtastic.xcodeproj/project.pbxproj @@ -1583,7 +1583,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 2.2.26; + MARKETING_VERSION = 2.2.27; PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient; PRODUCT_NAME = "$(TARGET_NAME)"; SUPPORTS_MACCATALYST = YES; @@ -1617,7 +1617,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 2.2.26; + MARKETING_VERSION = 2.2.27; PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient; PRODUCT_NAME = "$(TARGET_NAME)"; SUPPORTS_MACCATALYST = YES; @@ -1727,7 +1727,7 @@ CODE_SIGN_ENTITLEMENTS = Widgets/WidgetsExtension.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 840; DEVELOPMENT_TEAM = GCH7VS5Y9R; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = Widgets/Info.plist; @@ -1739,7 +1739,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 2.2.26; + MARKETING_VERSION = 2.2.27; PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient.Widgets; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -1760,7 +1760,7 @@ CODE_SIGN_ENTITLEMENTS = Widgets/WidgetsExtension.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 840; DEVELOPMENT_TEAM = GCH7VS5Y9R; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = Widgets/Info.plist; @@ -1772,7 +1772,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 2.2.26; + MARKETING_VERSION = 2.2.27; PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient.Widgets; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/Meshtastic/Helpers/BLEManager.swift b/Meshtastic/Helpers/BLEManager.swift index a0e6af59..163e19a3 100644 --- a/Meshtastic/Helpers/BLEManager.swift +++ b/Meshtastic/Helpers/BLEManager.swift @@ -607,11 +607,14 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate case .adminApp: adminAppPacket(packet: decodedInfo.packet, context: context!) case .replyApp: - MeshLogger.log("🕸️ MESH PACKET received for Reply App UNHANDLED \((try? decodedInfo.packet.jsonString()) ?? "JSON Decode Failure")") + MeshLogger.log("🕸️ MESH PACKET received for Reply App handling as a text message") + textMessageAppPacket(packet: decodedInfo.packet, wantRangeTestPackets: wantRangeTestPackets, connectedNode: (self.connectedPeripheral != nil ? connectedPeripheral.num : 0), context: context!) case .ipTunnelApp: - MeshLogger.log("🕸️ MESH PACKET received for IP Tunnel App UNHANDLED \((try? decodedInfo.packet.jsonString()) ?? "JSON Decode Failure")") + //MeshLogger.log("🕸️ MESH PACKET received for IP Tunnel App UNHANDLED \((try? decodedInfo.packet.jsonString()) ?? "JSON Decode Failure")") + MeshLogger.log("🕸️ MESH PACKET received for IP Tunnel App UNHANDLED UNHANDLED") case .serialApp: - MeshLogger.log("🕸️ MESH PACKET received for Serial App UNHANDLED \((try? decodedInfo.packet.jsonString()) ?? "JSON Decode Failure")") + //MeshLogger.log("🕸️ MESH PACKET received for Serial App UNHANDLED \((try? decodedInfo.packet.jsonString()) ?? "JSON Decode Failure")") + MeshLogger.log("🕸️ MESH PACKET received for Serial App UNHANDLED UNHANDLED") case .storeForwardApp: if wantStoreAndForwardPackets { storeAndForwardPacket(packet: decodedInfo.packet, connectedNodeNum: (self.connectedPeripheral != nil ? connectedPeripheral.num : 0), context: context!) @@ -628,17 +631,23 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate case .telemetryApp: if !invalidVersion { telemetryPacket(packet: decodedInfo.packet, connectedNode: (self.connectedPeripheral != nil ? connectedPeripheral.num : 0), context: context!) } case .textMessageCompressedApp: - MeshLogger.log("🕸️ MESH PACKET received for Text Message Compressed App UNHANDLED \((try? decodedInfo.packet.jsonString()) ?? "JSON Decode Failure")") + //MeshLogger.log("🕸️ MESH PACKET received for Text Message Compressed App UNHANDLED \((try? decodedInfo.packet.jsonString()) ?? "JSON Decode Failure")") + MeshLogger.log("🕸️ MESH PACKET received for Text Message Compressed App UNHANDLED") case .zpsApp: - MeshLogger.log("🕸️ MESH PACKET received for ZPS App UNHANDLED \((try? decodedInfo.packet.jsonString()) ?? "JSON Decode Failure")") + // MeshLogger.log("🕸️ MESH PACKET received for Zero Positioning System App UNHANDLED \((try? decodedInfo.packet.jsonString()) ?? "JSON Decode Failure")") + MeshLogger.log("🕸️ MESH PACKET received for Zero Positioning System App UNHANDLED") case .privateApp: - MeshLogger.log("🕸️ MESH PACKET received for Private App UNHANDLED \((try? decodedInfo.packet.jsonString()) ?? "JSON Decode Failure")") + //MeshLogger.log("🕸️ MESH PACKET received for Private App UNHANDLED \((try? decodedInfo.packet.jsonString()) ?? "JSON Decode Failure")") + MeshLogger.log("🕸️ MESH PACKET received for Private App UNHANDLED UNHANDLED") case .atakForwarder: - MeshLogger.log("🕸️ MESH PACKET received for ATAK Forwarder App UNHANDLED \((try? decodedInfo.packet.jsonString()) ?? "JSON Decode Failure")") + //MeshLogger.log("🕸️ MESH PACKET received for ATAK Forwarder App UNHANDLED \((try? decodedInfo.packet.jsonString()) ?? "JSON Decode Failure")") + MeshLogger.log("🕸️ MESH PACKET received for ATAK Forwarder App UNHANDLED UNHANDLED") case .simulatorApp: - MeshLogger.log("🕸️ MESH PACKET received for Simulator App UNHANDLED \((try? decodedInfo.packet.jsonString()) ?? "JSON Decode Failure")") + //MeshLogger.log("🕸️ MESH PACKET received for Simulator App UNHANDLED \((try? decodedInfo.packet.jsonString()) ?? "JSON Decode Failure")") + MeshLogger.log("🕸️ MESH PACKET received for Simulator App UNHANDLED UNHANDLED") case .audioApp: - MeshLogger.log("🕸️ MESH PACKET received for Audio App UNHANDLED \((try? decodedInfo.packet.jsonString()) ?? "JSON Decode Failure")") + //MeshLogger.log("🕸️ MESH PACKET received for Audio App UNHANDLED \((try? decodedInfo.packet.jsonString()) ?? "JSON Decode Failure")") + MeshLogger.log("🕸️ MESH PACKET received for Audio App UNHANDLED UNHANDLED") case .tracerouteApp: if let routingMessage = try? RouteDiscovery(serializedData: decodedInfo.packet.decoded.payload) { let traceRoute = getTraceRoute(id: Int64(decodedInfo.packet.decoded.requestID), context: context!) diff --git a/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 28.xcdatamodel/contents b/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 28.xcdatamodel/contents index 00f91752..7c468a65 100644 --- a/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 28.xcdatamodel/contents +++ b/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 28.xcdatamodel/contents @@ -230,8 +230,7 @@ - - + @@ -239,31 +238,31 @@ - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + @@ -422,8 +421,8 @@ - - + + diff --git a/Meshtastic/Views/Nodes/Helpers/NodeListItem.swift b/Meshtastic/Views/Nodes/Helpers/NodeListItem.swift index 4dd1bf7c..053622ae 100644 --- a/Meshtastic/Views/Nodes/Helpers/NodeListItem.swift +++ b/Meshtastic/Views/Nodes/Helpers/NodeListItem.swift @@ -170,11 +170,13 @@ struct NodeListItem: View { .font(.callout) .frame(width: 30) } - if node.hasTraceRoutes { - Image(systemName: "signpost.right.and.left") - .symbolRenderingMode(.hierarchical) - .font(.callout) - .frame(width: 30) + if #available(iOS 17.0, macOS 14.0, *) { + if node.hasTraceRoutes { + Image(systemName: "signpost.right.and.left") + .symbolRenderingMode(.hierarchical) + .font(.callout) + .frame(width: 30) + } } } } diff --git a/Meshtastic/Views/Nodes/NodeList.swift b/Meshtastic/Views/Nodes/NodeList.swift index 48bfeb80..569b6651 100644 --- a/Meshtastic/Views/Nodes/NodeList.swift +++ b/Meshtastic/Views/Nodes/NodeList.swift @@ -7,6 +7,28 @@ import SwiftUI import CoreLocation +struct NodeSearchState { + var searchText = "" + var searchScope = SearchScopes.all + var predicate: NSPredicate = .init() + + enum SearchScopes: CaseIterable, Identifiable { + case all + case lora + case mqtt + + var id: Self { self } + + var title: LocalizedStringKey { + switch self { + case .all: return "All" + case .lora: return "LoRa" + case .mqtt: return "MQTT" + } + } + } +} + struct NodeList: View { @State private var columnVisibility = NavigationSplitViewVisibility.all @@ -15,18 +37,11 @@ struct NodeList: View { @State private var isPresentingClientHistorySentAlert = false @State private var isPresentingDeleteNodeAlert = false @State private var deleteNodeId: Int64 = 0 + @State private var searchState = NodeSearchState() @SceneStorage("selectedDetailView") var selectedDetailView: String? @State private var searchText = "" - var nodesQuery: Binding { - Binding { - searchText - } set: { newValue in - searchText = newValue - nodes.nsPredicate = newValue.isEmpty ? nil : NSPredicate(format: "user.longName CONTAINS[c] %@ OR user.shortName CONTAINS[c] %@", newValue, newValue) - } - } @Environment(\.managedObjectContext) var context @EnvironmentObject var bleManager: BLEManager @@ -37,8 +52,6 @@ struct NodeList: View { var nodes: FetchedResults - - var body: some View { NavigationSplitView(columnVisibility: $columnVisibility) { @@ -124,7 +137,12 @@ struct NodeList: View { Text("Any missed messages will be delivered again.") } } - .searchable(text: nodesQuery, prompt: "Find a node") + .searchable(text: $searchState.searchText, placement: nodes.count > 10 ? .navigationBarDrawer(displayMode: .always) : .automatic, prompt: "Find a node") + .searchScopes($searchState.searchScope) { + ForEach(NodeSearchState.SearchScopes.allCases) { scope in + Text(scope.title).tag(scope) + } + } .navigationTitle(String.localizedStringWithFormat("nodes %@".localized, String(nodes.count))) .listStyle(.plain) .confirmationDialog( @@ -195,33 +213,51 @@ struct NodeList: View { } .navigationSplitViewStyle(.balanced) -// .onChange(of: selectedNode) { _ in -// if selectedNode == nil { -// columnVisibility = .all -// } else { -// columnVisibility = .doubleColumn -// } -// } + .onChange(of: searchState.searchText) { _ in + runSearch() + } + .onChange(of: searchState.searchScope) { _ in + runSearch() + } .onAppear { if self.bleManager.context == nil { self.bleManager.context = context } } - -// } detail: { -// VStack { -// Button("Detail Only") { -// columnVisibility = .detailOnly -// } -// -// Button("Content and Detail") { -// columnVisibility = .doubleColumn -// } -// -// Button("Show All") { -// columnVisibility = .all -// } -// } -// } + } + + private func runSearch() { + /// Case Insensitive Search Text Predicates + var searchPredicates = ["user.userId", "user.hwModel", "user.longName", "user.shortName"].map { property in + return NSPredicate(format: "%K CONTAINS[c] %@", property, searchState.searchText) + } + /// Create a compound predicate using each text search preicate as an OR + let textSearchPredicate = NSCompoundPredicate(type: .or, subpredicates: searchPredicates) + + /// Set the predicate to nil if the search string is empty + if searchState.searchText.isEmpty { + nodes.nsPredicate = nil + return + } + + /// Add a predicate for the search scope if selected + if searchState.searchScope != .all { + + if searchState.searchScope == .lora { + let loraPredicate = NSPredicate(format: "viaMqtt == NO") + let scopePredicate = NSCompoundPredicate(type: .and, subpredicates: [loraPredicate]) + nodes.nsPredicate = NSCompoundPredicate(type: .and, subpredicates: [textSearchPredicate, scopePredicate]) + return + + } else if searchState.searchScope == .mqtt { + let mqttPredicate = NSPredicate(format: "viaMqtt == YES") + let scopePredicate = NSCompoundPredicate(type: .and, subpredicates: [mqttPredicate]) + nodes.nsPredicate = NSCompoundPredicate(type: .and, subpredicates: [textSearchPredicate, scopePredicate]) + return + } + } else { + /// Use the text search predicate + nodes.nsPredicate = textSearchPredicate + } } } diff --git a/Meshtastic/Views/Nodes/PaxCounterLog.swift b/Meshtastic/Views/Nodes/PaxCounterLog.swift index 3b04d662..b47ba1a1 100644 --- a/Meshtastic/Views/Nodes/PaxCounterLog.swift +++ b/Meshtastic/Views/Nodes/PaxCounterLog.swift @@ -75,8 +75,8 @@ struct PaxCounterLog: View { .chartXAxis(.automatic) .chartYScale(domain: 0...maxValue) .chartForegroundStyleScale([ - "paxcounter.ble": .blue, - "paxcounter.wifi": .orange, + "paxcounter.ble".localized: .blue, + "paxcounter.wifi".localized: .orange, "paxcounter.total".localized: .green ]) .chartLegend(position: .automatic, alignment: .bottom) From 1db42dbbcdaa89580888e76cb1d423c9d7d9109d Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sat, 2 Mar 2024 10:18:57 -0800 Subject: [PATCH 12/74] Add exchange position node list menu item, add improved search to the user list. --- Meshtastic/Helpers/BLEManager.swift | 3 - Meshtastic/Views/Messages/UserList.swift | 167 ++++++++++++----------- Meshtastic/Views/Nodes/NodeList.swift | 33 ++++- 3 files changed, 115 insertions(+), 88 deletions(-) diff --git a/Meshtastic/Helpers/BLEManager.swift b/Meshtastic/Helpers/BLEManager.swift index 163e19a3..cf663f10 100644 --- a/Meshtastic/Helpers/BLEManager.swift +++ b/Meshtastic/Helpers/BLEManager.swift @@ -1039,9 +1039,6 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate } catch { return false } - return false - - var meshPacket = MeshPacket() meshPacket.to = UInt32(destNum) diff --git a/Meshtastic/Views/Messages/UserList.swift b/Meshtastic/Views/Messages/UserList.swift index e4fa4b55..542e7650 100644 --- a/Meshtastic/Views/Messages/UserList.swift +++ b/Meshtastic/Views/Messages/UserList.swift @@ -17,12 +17,19 @@ struct UserList: View { @Environment(\.managedObjectContext) var context @EnvironmentObject var bleManager: BLEManager @State private var searchText = "" + var usersQuery: Binding { Binding { searchText } set: { newValue in searchText = newValue - users.nsPredicate = newValue.isEmpty ? nil : NSPredicate(format: "longName CONTAINS[c] %@ OR shortName CONTAINS[c] %@", newValue, newValue) + /// Case Insensitive Search Text Predicates + let searchPredicates = ["userId", "hwModel", "longName", "shortName"].map { property in + return NSPredicate(format: "%K CONTAINS[c] %@", property, searchText) + } + /// Create a compound predicate using each text search predicate as an OR + let textSearchPredicate = NSCompoundPredicate(type: .or, subpredicates: searchPredicates) + users.nsPredicate = newValue.isEmpty ? nil : textSearchPredicate } } @FetchRequest( @@ -48,94 +55,94 @@ struct UserList: View { let lastMessageDay = Calendar.current.dateComponents([.day], from: lastMessageTime).day ?? 0 let currentDay = Calendar.current.dateComponents([.day], from: Date()).day ?? 0 if user.num != bleManager.connectedPeripheral?.num ?? 0 { - NavigationLink(destination: UserMessageList(user: user)) { - ZStack { - Image(systemName: "circle.fill") - .opacity(user.unreadMessages > 0 ? 1 : 0) - .font(.system(size: 10)) - .foregroundColor(.accentColor) - .brightness(0.2) - } - - CircleText(text: user.shortName ?? "?", color: Color(UIColor(hex: UInt32(user.num)))) - - VStack(alignment: .leading){ - HStack{ - Text(user.longName ?? "unknown".localized) - .font(.headline) - Spacer() - if user.vip { - Image(systemName: "star.fill") - .foregroundColor(.yellow) + NavigationLink(destination: UserMessageList(user: user)) { + ZStack { + Image(systemName: "circle.fill") + .opacity(user.unreadMessages > 0 ? 1 : 0) + .font(.system(size: 10)) + .foregroundColor(.accentColor) + .brightness(0.2) + } + + CircleText(text: user.shortName ?? "?", color: Color(UIColor(hex: UInt32(user.num)))) + + VStack(alignment: .leading){ + HStack{ + Text(user.longName ?? "unknown".localized) + .font(.headline) + Spacer() + if user.vip { + Image(systemName: "star.fill") + .foregroundColor(.yellow) + } + if user.messageList.count > 0 { + if lastMessageDay == currentDay { + Text(lastMessageTime, style: .time ) + .font(.footnote) + .foregroundColor(.secondary) + } else if lastMessageDay == (currentDay - 1) { + Text("Yesterday") + .font(.footnote) + .foregroundColor(.secondary) + } else if lastMessageDay < (currentDay - 1) && lastMessageDay > (currentDay - 5) { + Text(lastMessageTime.formattedDate(format: dateFormatString)) + .font(.footnote) + .foregroundColor(.secondary) + } else if lastMessageDay < (currentDay - 1800) { + Text(lastMessageTime.formattedDate(format: dateFormatString)) + .font(.footnote) + .foregroundColor(.secondary) + } + } } + if user.messageList.count > 0 { - if lastMessageDay == currentDay { - Text(lastMessageTime, style: .time ) - .font(.footnote) - .foregroundColor(.secondary) - } else if lastMessageDay == (currentDay - 1) { - Text("Yesterday") - .font(.footnote) - .foregroundColor(.secondary) - } else if lastMessageDay < (currentDay - 1) && lastMessageDay > (currentDay - 5) { - Text(lastMessageTime.formattedDate(format: dateFormatString)) - .font(.footnote) - .foregroundColor(.secondary) - } else if lastMessageDay < (currentDay - 1800) { - Text(lastMessageTime.formattedDate(format: dateFormatString)) + HStack(alignment: .top) { + Text("\(mostRecent != nil ? mostRecent!.messagePayload! : " ")") .font(.footnote) .foregroundColor(.secondary) } } } - - if user.messageList.count > 0 { - HStack(alignment: .top) { - Text("\(mostRecent != nil ? mostRecent!.messagePayload! : " ")") - .font(.footnote) - .foregroundColor(.secondary) + } + .frame(height: 62) + .contextMenu { + Button { + user.vip = !user.vip + do { + try context.save() + } catch { + context.rollback() + print("💥 Save User VIP Error") + } + } label: { + Label(user.vip ? "Un-Favorite" : "Favorite", systemImage: user.vip ? "star.slash.fill" : "star.fill") + } + Button { + user.mute = !user.mute + do { + try context.save() + } catch { + context.rollback() + print("💥 Save User Mute Error") + } + } label: { + Label(user.mute ? "Show Alerts" : "Hide Alerts", systemImage: user.mute ? "bell" : "bell.slash") + } + if user.messageList.count > 0 { + Button(role: .destructive) { + isPresentingDeleteUserMessagesConfirm = true + userSelection = user + } label: { + Label("Delete Messages", systemImage: "trash") } } } - } - .frame(height: 62) - .contextMenu { - Button { - user.vip = !user.vip - do { - try context.save() - } catch { - context.rollback() - print("💥 Save User VIP Error") - } - } label: { - Label(user.vip ? "Un-Favorite" : "Favorite", systemImage: user.vip ? "star.slash.fill" : "star.fill") - } - Button { - user.mute = !user.mute - do { - try context.save() - } catch { - context.rollback() - print("💥 Save User Mute Error") - } - } label: { - Label(user.mute ? "Show Alerts" : "Hide Alerts", systemImage: user.mute ? "bell" : "bell.slash") - } - if user.messageList.count > 0 { - Button(role: .destructive) { - isPresentingDeleteUserMessagesConfirm = true - userSelection = user - } label: { - Label("Delete Messages", systemImage: "trash") - } - } - } - .confirmationDialog( - "This conversation will be deleted.", - isPresented: $isPresentingDeleteUserMessagesConfirm, - titleVisibility: .visible - ) { + .confirmationDialog( + "This conversation will be deleted.", + isPresented: $isPresentingDeleteUserMessagesConfirm, + titleVisibility: .visible + ) { Button(role: .destructive) { deleteUserMessages(user: userSelection!, context: context) context.refresh(node!.user!, mergeChanges: true) @@ -149,7 +156,7 @@ struct UserList: View { } .listStyle(.plain) .navigationTitle(String.localizedStringWithFormat("contacts %@".localized, String(users.count == 0 ? 0 : users.count - 1))) - .searchable(text: usersQuery, prompt: "Find a contact") + .searchable(text: usersQuery, placement: users.count > 10 ? .navigationBarDrawer(displayMode: .always) : .automatic, prompt: "Find a contact") } } } diff --git a/Meshtastic/Views/Nodes/NodeList.swift b/Meshtastic/Views/Nodes/NodeList.swift index 569b6651..122f8f10 100644 --- a/Meshtastic/Views/Nodes/NodeList.swift +++ b/Meshtastic/Views/Nodes/NodeList.swift @@ -36,6 +36,7 @@ struct NodeList: View { @State private var isPresentingTraceRouteSentAlert = false @State private var isPresentingClientHistorySentAlert = false @State private var isPresentingDeleteNodeAlert = false + @State private var isPresentingPositionSentAlert = false @State private var deleteNodeId: Int64 = 0 @State private var searchState = NodeSearchState() @@ -89,7 +90,21 @@ struct NodeList: View { } label: { Label(node.user!.mute ? "Show Alerts" : "Hide Alerts", systemImage: node.user!.mute ? "bell" : "bell.slash") } - if connectedNodeNum != node.num { + if bleManager.connectedPeripheral != nil { + Button { + let positionSent = bleManager.sendPosition( + channel: node.channel, + destNum: node.num, + wantResponse: true + ) + if positionSent { + isPresentingPositionSentAlert = true + } + } label: { + Label("Exchange Positions", systemImage: "arrow.triangle.2.circlepath") + } + } + if bleManager.connectedPeripheral != nil && connectedNodeNum != node.num { Button { let success = bleManager.sendTraceRouteRequest(destNum: node.user?.num ?? 0, wantResponse: true) if success { @@ -120,6 +135,14 @@ struct NodeList: View { } } } + .alert( + "Position Sent", + isPresented: $isPresentingPositionSentAlert + ) { + Button("OK", role: .cancel) { } + } message: { + Text("Your position has been sent with a request for a response with their position.") + } .alert( "Trace Route Sent", isPresented: $isPresentingTraceRouteSentAlert @@ -214,10 +237,10 @@ struct NodeList: View { } .navigationSplitViewStyle(.balanced) .onChange(of: searchState.searchText) { _ in - runSearch() + searchNodeList() } .onChange(of: searchState.searchScope) { _ in - runSearch() + searchNodeList() } .onAppear { if self.bleManager.context == nil { @@ -226,9 +249,9 @@ struct NodeList: View { } } - private func runSearch() { + private func searchNodeList() { /// Case Insensitive Search Text Predicates - var searchPredicates = ["user.userId", "user.hwModel", "user.longName", "user.shortName"].map { property in + let searchPredicates = ["user.userId", "user.hwModel", "user.longName", "user.shortName"].map { property in return NSPredicate(format: "%K CONTAINS[c] %@", property, searchState.searchText) } /// Create a compound predicate using each text search preicate as an OR From b22ca2db81dc24851dc187dad1345663ccea3790 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sat, 2 Mar 2024 16:38:59 -0800 Subject: [PATCH 13/74] =?UTF-8?q?Hops=20away!=20=F0=9F=90=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Meshtastic.xcodeproj/project.pbxproj | 4 +- Meshtastic/Helpers/MeshPackets.swift | 2 +- .../Meshtastic.xcdatamodeld/.xccurrentversion | 2 +- .../contents | 3 +- .../contents | 449 ++++++++++++++++++ .../Views/Nodes/Helpers/NodeListItem.swift | 17 +- 6 files changed, 470 insertions(+), 7 deletions(-) create mode 100644 Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 29.xcdatamodel/contents diff --git a/Meshtastic.xcodeproj/project.pbxproj b/Meshtastic.xcodeproj/project.pbxproj index 156262d1..8e1b5c2b 100644 --- a/Meshtastic.xcodeproj/project.pbxproj +++ b/Meshtastic.xcodeproj/project.pbxproj @@ -294,6 +294,7 @@ DD3501882852FC3B000FC853 /* Settings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Settings.swift; sourceTree = ""; }; DD3619132B1EE20700C41C8C /* MeshtasticDataModelV21.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = MeshtasticDataModelV21.xcdatamodel; sourceTree = ""; }; DD3619142B1EF9F900C41C8C /* LocationsHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationsHandler.swift; sourceTree = ""; }; + DD398EBD2B93F640002B4C51 /* MeshtasticDataModelV 29.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "MeshtasticDataModelV 29.xcdatamodel"; sourceTree = ""; }; DD3CC6B428E33FD100FA9159 /* ShareChannels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareChannels.swift; sourceTree = ""; }; DD3CC6BB28E366DF00FA9159 /* MeshtasticDataModel.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = MeshtasticDataModel.xcdatamodel; sourceTree = ""; }; DD3CC6BD28E4CD9800FA9159 /* BatteryGauge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BatteryGauge.swift; sourceTree = ""; }; @@ -1883,6 +1884,7 @@ DD3CC6BA28E366DF00FA9159 /* Meshtastic.xcdatamodeld */ = { isa = XCVersionGroup; children = ( + DD398EBD2B93F640002B4C51 /* MeshtasticDataModelV 29.xcdatamodel */, DD0E20FF2B892E1300F2D100 /* MeshtasticDataModelV 28.xcdatamodel */, D93069062B81D8900066FBC8 /* MeshtasticDataModelV 27.xcdatamodel */, DD05296F2B77F454008E44CD /* MeshtasticDataModelV 26.xcdatamodel */, @@ -1912,7 +1914,7 @@ DD5D0A9A2931AD6B00F7EA61 /* MeshtasticDataModelV2.xcdatamodel */, DD3CC6BB28E366DF00FA9159 /* MeshtasticDataModel.xcdatamodel */, ); - currentVersion = DD0E20FF2B892E1300F2D100 /* MeshtasticDataModelV 28.xcdatamodel */; + currentVersion = DD398EBD2B93F640002B4C51 /* MeshtasticDataModelV 29.xcdatamodel */; name = Meshtastic.xcdatamodeld; path = Meshtastic/Meshtastic.xcdatamodeld; sourceTree = ""; diff --git a/Meshtastic/Helpers/MeshPackets.swift b/Meshtastic/Helpers/MeshPackets.swift index aeb39c3a..c02835e7 100644 --- a/Meshtastic/Helpers/MeshPackets.swift +++ b/Meshtastic/Helpers/MeshPackets.swift @@ -775,7 +775,7 @@ func telemetryPacket(packet: MeshPacket, connectedNode: Int64, context: NSManage func textMessageAppPacket(packet: MeshPacket, wantRangeTestPackets: Bool, connectedNode: Int64, storeForward: Bool = false, context: NSManagedObjectContext) { var messageText = String(bytes: packet.decoded.payload, encoding: .utf8) - if !wantRangeTestPackets && (String(messageText ?? "").starts(with: "seq ")) { + if !wantRangeTestPackets && (String(messageText ?? "seq ").starts(with: "seq ")) { return } var storeForwardBroadcast = false diff --git a/Meshtastic/Meshtastic.xcdatamodeld/.xccurrentversion b/Meshtastic/Meshtastic.xcdatamodeld/.xccurrentversion index 37d79244..a647b881 100644 --- a/Meshtastic/Meshtastic.xcdatamodeld/.xccurrentversion +++ b/Meshtastic/Meshtastic.xcdatamodeld/.xccurrentversion @@ -3,6 +3,6 @@ _XCCurrentVersionName - MeshtasticDataModelV 28.xcdatamodel + MeshtasticDataModelV 29.xcdatamodel diff --git a/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 28.xcdatamodel/contents b/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 28.xcdatamodel/contents index 7c468a65..348b7fea 100644 --- a/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 28.xcdatamodel/contents +++ b/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 28.xcdatamodel/contents @@ -230,7 +230,8 @@ - + + diff --git a/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 29.xcdatamodel/contents b/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 29.xcdatamodel/contents new file mode 100644 index 00000000..aed0e3e0 --- /dev/null +++ b/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 29.xcdatamodel/contents @@ -0,0 +1,449 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Meshtastic/Views/Nodes/Helpers/NodeListItem.swift b/Meshtastic/Views/Nodes/Helpers/NodeListItem.swift index 053622ae..67922046 100644 --- a/Meshtastic/Views/Nodes/Helpers/NodeListItem.swift +++ b/Meshtastic/Views/Nodes/Helpers/NodeListItem.swift @@ -23,6 +23,16 @@ struct NodeListItem: View { VStack(alignment: .leading) { CircleText(text: node.user?.shortName ?? "?", color: Color(UIColor(hex: UInt32(node.num))), circleSize: 70) .padding(.trailing, 5) + if node.hopsAway == 0 { + HStack { + Image(systemName: "hare") + .font(.callout) + .symbolRenderingMode(.hierarchical) + Image(systemName: "\(node.hopsAway).square") + .font(.title2) + .symbolRenderingMode(.hierarchical) + } + } BatteryLevelCompact(node: node, font: .caption, iconFont: .callout, color: .accentColor) .padding(.trailing, 5) } @@ -118,6 +128,7 @@ struct NodeListItem: View { } } HStack { + if node.channel > 0 { Image(systemName: "fibrechannel") .font(.callout) @@ -180,12 +191,12 @@ struct NodeListItem: View { } } } - if !connected { - HStack { + if !node.viaMqtt && connectedNode != node.num { + HStack (alignment: .bottom) { let preset = ModemPresets(rawValue: Int(modemPreset)) LoRaSignalStrengthMeter(snr: node.snr, rssi: node.rssi, preset: preset ?? ModemPresets.longFast, compact: true) - } + .padding(.top) } } .frame(maxWidth: .infinity, alignment: .leading) From 2ba208fa8ebb8fd28f3896070b024d1f8fa40af5 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sat, 9 Mar 2024 20:07:12 -0800 Subject: [PATCH 14/74] Bump version and protos --- Meshtastic.xcodeproj/project.pbxproj | 8 +- Meshtastic/Persistence/UpdateCoreData.swift | 2 + .../Protobufs/meshtastic/deviceonly.pb.swift | 30 +++ Meshtastic/Protobufs/meshtastic/mesh.pb.swift | 229 +++++++++++++----- .../Protobufs/meshtastic/portnums.pb.swift | 10 +- .../Protobufs/meshtastic/telemetry.pb.swift | 8 + Meshtastic/Views/Messages/UserList.swift | 1 + .../Views/Nodes/Helpers/NodeListItem.swift | 47 ++-- Meshtastic/Views/Nodes/MeshMap.swift | 1 + Meshtastic/Views/Nodes/NodeList.swift | 1 + Meshtastic/Views/Nodes/PaxCounterLog.swift | 10 +- Meshtastic/Views/Settings/Channels.swift | 2 +- protobufs | 2 +- 13 files changed, 250 insertions(+), 101 deletions(-) diff --git a/Meshtastic.xcodeproj/project.pbxproj b/Meshtastic.xcodeproj/project.pbxproj index 8e1b5c2b..4cd9deb0 100644 --- a/Meshtastic.xcodeproj/project.pbxproj +++ b/Meshtastic.xcodeproj/project.pbxproj @@ -1584,7 +1584,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 2.2.27; + MARKETING_VERSION = 2.3.0; PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient; PRODUCT_NAME = "$(TARGET_NAME)"; SUPPORTS_MACCATALYST = YES; @@ -1618,7 +1618,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 2.2.27; + MARKETING_VERSION = 2.3.0; PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient; PRODUCT_NAME = "$(TARGET_NAME)"; SUPPORTS_MACCATALYST = YES; @@ -1740,7 +1740,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 2.2.27; + MARKETING_VERSION = 2.3.0; PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient.Widgets; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -1773,7 +1773,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 2.2.27; + MARKETING_VERSION = 2.3.0; PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient.Widgets; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/Meshtastic/Persistence/UpdateCoreData.swift b/Meshtastic/Persistence/UpdateCoreData.swift index 341004f7..cdd0d91e 100644 --- a/Meshtastic/Persistence/UpdateCoreData.swift +++ b/Meshtastic/Persistence/UpdateCoreData.swift @@ -147,6 +147,7 @@ func upsertNodeInfoPacket (packet: MeshPacket, context: NSManagedObjectContext) newNode.channel = Int32(packet.channel) if let nodeInfoMessage = try? NodeInfo(serializedData: packet.decoded.payload) { newNode.channel = Int32(nodeInfoMessage.channel) + newNode.hopsAway = Int32(truncatingIfNeeded: nodeInfoMessage.hopsAway) } if let newUserMessage = try? User(serializedData: packet.decoded.payload) { @@ -215,6 +216,7 @@ func upsertNodeInfoPacket (packet: MeshPacket, context: NSManagedObjectContext) if let nodeInfoMessage = try? NodeInfo(serializedData: packet.decoded.payload) { fetchedNode[0].channel = Int32(nodeInfoMessage.channel) + fetchedNode[0].hopsAway = Int32(truncatingIfNeeded: nodeInfoMessage.hopsAway) if nodeInfoMessage.hasDeviceMetrics { let telemetry = TelemetryEntity(context: context) telemetry.batteryLevel = Int32(nodeInfoMessage.deviceMetrics.batteryLevel) diff --git a/Meshtastic/Protobufs/meshtastic/deviceonly.pb.swift b/Meshtastic/Protobufs/meshtastic/deviceonly.pb.swift index 821b9370..048c99aa 100644 --- a/Meshtastic/Protobufs/meshtastic/deviceonly.pb.swift +++ b/Meshtastic/Protobufs/meshtastic/deviceonly.pb.swift @@ -254,6 +254,20 @@ struct NodeInfoLite { set {_uniqueStorage()._channel = newValue} } + /// + /// True if we witnessed the node over MQTT instead of LoRA transport + var viaMqtt: Bool { + get {return _storage._viaMqtt} + set {_uniqueStorage()._viaMqtt = newValue} + } + + /// + /// Number of hops away from us this node is (0 if adjacent) + var hopsAway: UInt32 { + get {return _storage._hopsAway} + set {_uniqueStorage()._hopsAway = newValue} + } + var unknownFields = SwiftProtobuf.UnknownStorage() init() {} @@ -583,6 +597,8 @@ extension NodeInfoLite: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat 5: .standard(proto: "last_heard"), 6: .standard(proto: "device_metrics"), 7: .same(proto: "channel"), + 8: .standard(proto: "via_mqtt"), + 9: .standard(proto: "hops_away"), ] fileprivate class _StorageClass { @@ -593,6 +609,8 @@ extension NodeInfoLite: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat var _lastHeard: UInt32 = 0 var _deviceMetrics: DeviceMetrics? = nil var _channel: UInt32 = 0 + var _viaMqtt: Bool = false + var _hopsAway: UInt32 = 0 static let defaultInstance = _StorageClass() @@ -606,6 +624,8 @@ extension NodeInfoLite: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat _lastHeard = source._lastHeard _deviceMetrics = source._deviceMetrics _channel = source._channel + _viaMqtt = source._viaMqtt + _hopsAway = source._hopsAway } } @@ -631,6 +651,8 @@ extension NodeInfoLite: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat case 5: try { try decoder.decodeSingularFixed32Field(value: &_storage._lastHeard) }() case 6: try { try decoder.decodeSingularMessageField(value: &_storage._deviceMetrics) }() case 7: try { try decoder.decodeSingularUInt32Field(value: &_storage._channel) }() + case 8: try { try decoder.decodeSingularBoolField(value: &_storage._viaMqtt) }() + case 9: try { try decoder.decodeSingularUInt32Field(value: &_storage._hopsAway) }() default: break } } @@ -664,6 +686,12 @@ extension NodeInfoLite: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat if _storage._channel != 0 { try visitor.visitSingularUInt32Field(value: _storage._channel, fieldNumber: 7) } + if _storage._viaMqtt != false { + try visitor.visitSingularBoolField(value: _storage._viaMqtt, fieldNumber: 8) + } + if _storage._hopsAway != 0 { + try visitor.visitSingularUInt32Field(value: _storage._hopsAway, fieldNumber: 9) + } } try unknownFields.traverse(visitor: &visitor) } @@ -680,6 +708,8 @@ extension NodeInfoLite: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat if _storage._lastHeard != rhs_storage._lastHeard {return false} if _storage._deviceMetrics != rhs_storage._deviceMetrics {return false} if _storage._channel != rhs_storage._channel {return false} + if _storage._viaMqtt != rhs_storage._viaMqtt {return false} + if _storage._hopsAway != rhs_storage._hopsAway {return false} return true } if !storagesAreEqual {return false} diff --git a/Meshtastic/Protobufs/meshtastic/mesh.pb.swift b/Meshtastic/Protobufs/meshtastic/mesh.pb.swift index caa1f1bc..bdc8da97 100644 --- a/Meshtastic/Protobufs/meshtastic/mesh.pb.swift +++ b/Meshtastic/Protobufs/meshtastic/mesh.pb.swift @@ -1434,8 +1434,7 @@ struct MeshPacket { } /// - /// The (immediatSee Priority description for more details.y should be fixed32 instead, this encoding only - /// hurts the ble link though. + /// The (immediate) destination for this packet var to: UInt32 { get {return _storage._to} set {_uniqueStorage()._to = newValue} @@ -1566,6 +1565,14 @@ struct MeshPacket { set {_uniqueStorage()._viaMqtt = newValue} } + /// + /// Hop limit with which the original packet started. Sent via LoRa using three bits in the unencrypted header. + /// When receiving a packet, the difference between hop_start and hop_limit gives how many hops it traveled. + var hopStart: UInt32 { + get {return _storage._hopStart} + set {_uniqueStorage()._hopStart = newValue} + } + var unknownFields = SwiftProtobuf.UnknownStorage() enum OneOf_PayloadVariant: Equatable { @@ -1779,62 +1786,86 @@ struct NodeInfo { /// /// The node number - var num: UInt32 = 0 + var num: UInt32 { + get {return _storage._num} + set {_uniqueStorage()._num = newValue} + } /// /// The user info for this node var user: User { - get {return _user ?? User()} - set {_user = newValue} + get {return _storage._user ?? User()} + set {_uniqueStorage()._user = newValue} } /// Returns true if `user` has been explicitly set. - var hasUser: Bool {return self._user != nil} + var hasUser: Bool {return _storage._user != nil} /// Clears the value of `user`. Subsequent reads from it will return its default value. - mutating func clearUser() {self._user = nil} + mutating func clearUser() {_uniqueStorage()._user = nil} /// /// This position data. Note: before 1.2.14 we would also store the last time we've heard from this node in position.time, that is no longer true. /// Position.time now indicates the last time we received a POSITION from that node. var position: Position { - get {return _position ?? Position()} - set {_position = newValue} + get {return _storage._position ?? Position()} + set {_uniqueStorage()._position = newValue} } /// Returns true if `position` has been explicitly set. - var hasPosition: Bool {return self._position != nil} + var hasPosition: Bool {return _storage._position != nil} /// Clears the value of `position`. Subsequent reads from it will return its default value. - mutating func clearPosition() {self._position = nil} + mutating func clearPosition() {_uniqueStorage()._position = nil} /// /// Returns the Signal-to-noise ratio (SNR) of the last received message, /// as measured by the receiver. Return SNR of the last received message in dB - var snr: Float = 0 + var snr: Float { + get {return _storage._snr} + set {_uniqueStorage()._snr = newValue} + } /// /// Set to indicate the last time we received a packet from this node - var lastHeard: UInt32 = 0 + var lastHeard: UInt32 { + get {return _storage._lastHeard} + set {_uniqueStorage()._lastHeard = newValue} + } /// /// The latest device metrics for the node. var deviceMetrics: DeviceMetrics { - get {return _deviceMetrics ?? DeviceMetrics()} - set {_deviceMetrics = newValue} + get {return _storage._deviceMetrics ?? DeviceMetrics()} + set {_uniqueStorage()._deviceMetrics = newValue} } /// Returns true if `deviceMetrics` has been explicitly set. - var hasDeviceMetrics: Bool {return self._deviceMetrics != nil} + var hasDeviceMetrics: Bool {return _storage._deviceMetrics != nil} /// Clears the value of `deviceMetrics`. Subsequent reads from it will return its default value. - mutating func clearDeviceMetrics() {self._deviceMetrics = nil} + mutating func clearDeviceMetrics() {_uniqueStorage()._deviceMetrics = nil} /// /// local channel index we heard that node on. Only populated if its not the default channel. - var channel: UInt32 = 0 + var channel: UInt32 { + get {return _storage._channel} + set {_uniqueStorage()._channel = newValue} + } + + /// + /// True if we witnessed the node over MQTT instead of LoRA transport + var viaMqtt: Bool { + get {return _storage._viaMqtt} + set {_uniqueStorage()._viaMqtt = newValue} + } + + /// + /// Number of hops away from us this node is (0 if adjacent) + var hopsAway: UInt32 { + get {return _storage._hopsAway} + set {_uniqueStorage()._hopsAway = newValue} + } var unknownFields = SwiftProtobuf.UnknownStorage() init() {} - fileprivate var _user: User? = nil - fileprivate var _position: Position? = nil - fileprivate var _deviceMetrics: DeviceMetrics? = nil + fileprivate var _storage = _StorageClass.defaultInstance } /// @@ -3369,6 +3400,7 @@ extension MeshPacket: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementatio 12: .standard(proto: "rx_rssi"), 13: .same(proto: "delayed"), 14: .standard(proto: "via_mqtt"), + 15: .standard(proto: "hop_start"), ] fileprivate class _StorageClass { @@ -3385,6 +3417,7 @@ extension MeshPacket: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementatio var _rxRssi: Int32 = 0 var _delayed: MeshPacket.Delayed = .noDelay var _viaMqtt: Bool = false + var _hopStart: UInt32 = 0 static let defaultInstance = _StorageClass() @@ -3404,6 +3437,7 @@ extension MeshPacket: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementatio _rxRssi = source._rxRssi _delayed = source._delayed _viaMqtt = source._viaMqtt + _hopStart = source._hopStart } } @@ -3455,6 +3489,7 @@ extension MeshPacket: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementatio case 12: try { try decoder.decodeSingularInt32Field(value: &_storage._rxRssi) }() case 13: try { try decoder.decodeSingularEnumField(value: &_storage._delayed) }() case 14: try { try decoder.decodeSingularBoolField(value: &_storage._viaMqtt) }() + case 15: try { try decoder.decodeSingularUInt32Field(value: &_storage._hopStart) }() default: break } } @@ -3514,6 +3549,9 @@ extension MeshPacket: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementatio if _storage._viaMqtt != false { try visitor.visitSingularBoolField(value: _storage._viaMqtt, fieldNumber: 14) } + if _storage._hopStart != 0 { + try visitor.visitSingularUInt32Field(value: _storage._hopStart, fieldNumber: 15) + } } try unknownFields.traverse(visitor: &visitor) } @@ -3536,6 +3574,7 @@ extension MeshPacket: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementatio if _storage._rxRssi != rhs_storage._rxRssi {return false} if _storage._delayed != rhs_storage._delayed {return false} if _storage._viaMqtt != rhs_storage._viaMqtt {return false} + if _storage._hopStart != rhs_storage._hopStart {return false} return true } if !storagesAreEqual {return false} @@ -3575,63 +3614,123 @@ extension NodeInfo: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationB 5: .standard(proto: "last_heard"), 6: .standard(proto: "device_metrics"), 7: .same(proto: "channel"), + 8: .standard(proto: "via_mqtt"), + 9: .standard(proto: "hops_away"), ] + fileprivate class _StorageClass { + var _num: UInt32 = 0 + var _user: User? = nil + var _position: Position? = nil + var _snr: Float = 0 + var _lastHeard: UInt32 = 0 + var _deviceMetrics: DeviceMetrics? = nil + var _channel: UInt32 = 0 + var _viaMqtt: Bool = false + var _hopsAway: UInt32 = 0 + + static let defaultInstance = _StorageClass() + + private init() {} + + init(copying source: _StorageClass) { + _num = source._num + _user = source._user + _position = source._position + _snr = source._snr + _lastHeard = source._lastHeard + _deviceMetrics = source._deviceMetrics + _channel = source._channel + _viaMqtt = source._viaMqtt + _hopsAway = source._hopsAway + } + } + + fileprivate mutating func _uniqueStorage() -> _StorageClass { + if !isKnownUniquelyReferenced(&_storage) { + _storage = _StorageClass(copying: _storage) + } + return _storage + } + mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularUInt32Field(value: &self.num) }() - case 2: try { try decoder.decodeSingularMessageField(value: &self._user) }() - case 3: try { try decoder.decodeSingularMessageField(value: &self._position) }() - case 4: try { try decoder.decodeSingularFloatField(value: &self.snr) }() - case 5: try { try decoder.decodeSingularFixed32Field(value: &self.lastHeard) }() - case 6: try { try decoder.decodeSingularMessageField(value: &self._deviceMetrics) }() - case 7: try { try decoder.decodeSingularUInt32Field(value: &self.channel) }() - default: break + _ = _uniqueStorage() + try withExtendedLifetime(_storage) { (_storage: _StorageClass) in + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularUInt32Field(value: &_storage._num) }() + case 2: try { try decoder.decodeSingularMessageField(value: &_storage._user) }() + case 3: try { try decoder.decodeSingularMessageField(value: &_storage._position) }() + case 4: try { try decoder.decodeSingularFloatField(value: &_storage._snr) }() + case 5: try { try decoder.decodeSingularFixed32Field(value: &_storage._lastHeard) }() + case 6: try { try decoder.decodeSingularMessageField(value: &_storage._deviceMetrics) }() + case 7: try { try decoder.decodeSingularUInt32Field(value: &_storage._channel) }() + case 8: try { try decoder.decodeSingularBoolField(value: &_storage._viaMqtt) }() + case 9: try { try decoder.decodeSingularUInt32Field(value: &_storage._hopsAway) }() + default: break + } } } } func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - if self.num != 0 { - try visitor.visitSingularUInt32Field(value: self.num, fieldNumber: 1) - } - try { if let v = self._user { - try visitor.visitSingularMessageField(value: v, fieldNumber: 2) - } }() - try { if let v = self._position { - try visitor.visitSingularMessageField(value: v, fieldNumber: 3) - } }() - if self.snr != 0 { - try visitor.visitSingularFloatField(value: self.snr, fieldNumber: 4) - } - if self.lastHeard != 0 { - try visitor.visitSingularFixed32Field(value: self.lastHeard, fieldNumber: 5) - } - try { if let v = self._deviceMetrics { - try visitor.visitSingularMessageField(value: v, fieldNumber: 6) - } }() - if self.channel != 0 { - try visitor.visitSingularUInt32Field(value: self.channel, fieldNumber: 7) + try withExtendedLifetime(_storage) { (_storage: _StorageClass) in + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + if _storage._num != 0 { + try visitor.visitSingularUInt32Field(value: _storage._num, fieldNumber: 1) + } + try { if let v = _storage._user { + try visitor.visitSingularMessageField(value: v, fieldNumber: 2) + } }() + try { if let v = _storage._position { + try visitor.visitSingularMessageField(value: v, fieldNumber: 3) + } }() + if _storage._snr != 0 { + try visitor.visitSingularFloatField(value: _storage._snr, fieldNumber: 4) + } + if _storage._lastHeard != 0 { + try visitor.visitSingularFixed32Field(value: _storage._lastHeard, fieldNumber: 5) + } + try { if let v = _storage._deviceMetrics { + try visitor.visitSingularMessageField(value: v, fieldNumber: 6) + } }() + if _storage._channel != 0 { + try visitor.visitSingularUInt32Field(value: _storage._channel, fieldNumber: 7) + } + if _storage._viaMqtt != false { + try visitor.visitSingularBoolField(value: _storage._viaMqtt, fieldNumber: 8) + } + if _storage._hopsAway != 0 { + try visitor.visitSingularUInt32Field(value: _storage._hopsAway, fieldNumber: 9) + } } try unknownFields.traverse(visitor: &visitor) } static func ==(lhs: NodeInfo, rhs: NodeInfo) -> Bool { - if lhs.num != rhs.num {return false} - if lhs._user != rhs._user {return false} - if lhs._position != rhs._position {return false} - if lhs.snr != rhs.snr {return false} - if lhs.lastHeard != rhs.lastHeard {return false} - if lhs._deviceMetrics != rhs._deviceMetrics {return false} - if lhs.channel != rhs.channel {return false} + if lhs._storage !== rhs._storage { + let storagesAreEqual: Bool = withExtendedLifetime((lhs._storage, rhs._storage)) { (_args: (_StorageClass, _StorageClass)) in + let _storage = _args.0 + let rhs_storage = _args.1 + if _storage._num != rhs_storage._num {return false} + if _storage._user != rhs_storage._user {return false} + if _storage._position != rhs_storage._position {return false} + if _storage._snr != rhs_storage._snr {return false} + if _storage._lastHeard != rhs_storage._lastHeard {return false} + if _storage._deviceMetrics != rhs_storage._deviceMetrics {return false} + if _storage._channel != rhs_storage._channel {return false} + if _storage._viaMqtt != rhs_storage._viaMqtt {return false} + if _storage._hopsAway != rhs_storage._hopsAway {return false} + return true + } + if !storagesAreEqual {return false} + } if lhs.unknownFields != rhs.unknownFields {return false} return true } diff --git a/Meshtastic/Protobufs/meshtastic/portnums.pb.swift b/Meshtastic/Protobufs/meshtastic/portnums.pb.swift index ea5ce5bd..937ff635 100644 --- a/Meshtastic/Protobufs/meshtastic/portnums.pb.swift +++ b/Meshtastic/Protobufs/meshtastic/portnums.pb.swift @@ -58,25 +58,25 @@ enum PortNum: SwiftProtobuf.Enum { /// /// The built-in position messaging app. - /// Payload is a [Position](/docs/developers/protobufs/api#position) message + /// Payload is a Position message. /// ENCODING: Protobuf case positionApp // = 3 /// /// The built-in user info app. - /// Payload is a [User](/docs/developers/protobufs/api#user) message + /// Payload is a User message. /// ENCODING: Protobuf case nodeinfoApp // = 4 /// /// Protocol control packets for mesh protocol use. - /// Payload is a [Routing](/docs/developers/protobufs/api#routing) message + /// Payload is a Routing message. /// ENCODING: Protobuf case routingApp // = 5 /// /// Admin control packets. - /// Payload is a [AdminMessage](/docs/developers/protobufs/api#adminmessage) message + /// Payload is a AdminMessage message. /// ENCODING: Protobuf case adminApp // = 6 @@ -90,7 +90,7 @@ enum PortNum: SwiftProtobuf.Enum { /// /// Waypoint payloads. - /// Payload is a [Waypoint](/docs/developers/protobufs/api#waypoint) message + /// Payload is a Waypoint message. /// ENCODING: Protobuf case waypointApp // = 8 diff --git a/Meshtastic/Protobufs/meshtastic/telemetry.pb.swift b/Meshtastic/Protobufs/meshtastic/telemetry.pb.swift index debcff60..72d378bc 100644 --- a/Meshtastic/Protobufs/meshtastic/telemetry.pb.swift +++ b/Meshtastic/Protobufs/meshtastic/telemetry.pb.swift @@ -84,6 +84,10 @@ enum TelemetrySensorType: SwiftProtobuf.Enum { /// /// INA3221 3 Channel Voltage / Current Sensor case ina3221 // = 14 + + /// + /// BMP085/BMP180 High accuracy temperature and pressure (older Version of BMP280) + case bmp085 // = 15 case UNRECOGNIZED(Int) init() { @@ -107,6 +111,7 @@ enum TelemetrySensorType: SwiftProtobuf.Enum { case 12: self = .sht31 case 13: self = .pmsa003I case 14: self = .ina3221 + case 15: self = .bmp085 default: self = .UNRECOGNIZED(rawValue) } } @@ -128,6 +133,7 @@ enum TelemetrySensorType: SwiftProtobuf.Enum { case .sht31: return 12 case .pmsa003I: return 13 case .ina3221: return 14 + case .bmp085: return 15 case .UNRECOGNIZED(let i): return i } } @@ -154,6 +160,7 @@ extension TelemetrySensorType: CaseIterable { .sht31, .pmsa003I, .ina3221, + .bmp085, ] } @@ -450,6 +457,7 @@ extension TelemetrySensorType: SwiftProtobuf._ProtoNameProviding { 12: .same(proto: "SHT31"), 13: .same(proto: "PMSA003I"), 14: .same(proto: "INA3221"), + 15: .same(proto: "BMP085"), ] } diff --git a/Meshtastic/Views/Messages/UserList.swift b/Meshtastic/Views/Messages/UserList.swift index 542e7650..6b4ded5f 100644 --- a/Meshtastic/Views/Messages/UserList.swift +++ b/Meshtastic/Views/Messages/UserList.swift @@ -157,6 +157,7 @@ struct UserList: View { .listStyle(.plain) .navigationTitle(String.localizedStringWithFormat("contacts %@".localized, String(users.count == 0 ? 0 : users.count - 1))) .searchable(text: usersQuery, placement: users.count > 10 ? .navigationBarDrawer(displayMode: .always) : .automatic, prompt: "Find a contact") + .disableAutocorrection(true) } } } diff --git a/Meshtastic/Views/Nodes/Helpers/NodeListItem.swift b/Meshtastic/Views/Nodes/Helpers/NodeListItem.swift index 67922046..b309c925 100644 --- a/Meshtastic/Views/Nodes/Helpers/NodeListItem.swift +++ b/Meshtastic/Views/Nodes/Helpers/NodeListItem.swift @@ -21,18 +21,9 @@ struct NodeListItem: View { LazyVStack(alignment: .leading) { HStack { VStack(alignment: .leading) { + CircleText(text: node.user?.shortName ?? "?", color: Color(UIColor(hex: UInt32(node.num))), circleSize: 70) .padding(.trailing, 5) - if node.hopsAway == 0 { - HStack { - Image(systemName: "hare") - .font(.callout) - .symbolRenderingMode(.hierarchical) - Image(systemName: "\(node.hopsAway).square") - .font(.title2) - .symbolRenderingMode(.hierarchical) - } - } BatteryLevelCompact(node: node, font: .caption, iconFont: .callout, color: .accentColor) .padding(.trailing, 5) } @@ -128,26 +119,42 @@ struct NodeListItem: View { } } HStack { - - if node.channel > 0 { - Image(systemName: "fibrechannel") - .font(.callout) - .symbolRenderingMode(.hierarchical) - .frame(width: 30) - Text("Channel: \(node.channel)") - .foregroundColor(.gray) - .font(UIDevice.current.userInterfaceIdiom == .phone ? .callout : .caption) + if node.channel >= 0 { + HStack { + Image(systemName: "\(node.channel).circle.fill") + .font(.title2) + .symbolRenderingMode(.hierarchical) + .frame(width: 30) + .foregroundColor(.accentColor) + Text("Channel") + .foregroundColor(.gray) + .font(UIDevice.current.userInterfaceIdiom == .phone ? .callout : .caption) + } } + if node.viaMqtt && connectedNode != node.num { Image(systemName: "network") .symbolRenderingMode(.hierarchical) .font(.callout) .frame(width: 30) - Text("Via MQTT") + Text("MQTT") .foregroundColor(.gray) .font(UIDevice.current.userInterfaceIdiom == .phone ? .callout : .caption) } } + if node.hopsAway > 0 { + HStack { + Image(systemName: "hare") + .font(.callout) + .symbolRenderingMode(.hierarchical) + Text("Hops Away:") + .foregroundColor(.gray) + .font(UIDevice.current.userInterfaceIdiom == .phone ? .callout : .caption) + Image(systemName: "\(node.hopsAway).square") + .font(.title2) + .symbolRenderingMode(.hierarchical) + } + } if node.hasPositions || node.hasEnvironmentMetrics || node.hasDetectionSensorMetrics || node.hasTraceRoutes { HStack { Image(systemName: "scroll") diff --git a/Meshtastic/Views/Nodes/MeshMap.swift b/Meshtastic/Views/Nodes/MeshMap.swift index 1859993a..4394efce 100644 --- a/Meshtastic/Views/Nodes/MeshMap.swift +++ b/Meshtastic/Views/Nodes/MeshMap.swift @@ -123,6 +123,7 @@ struct MeshMap: View { if radius > 0.0 { MapCircle(center: position.coordinate, radius: radius) .foregroundStyle(Color(nodeColor).opacity(0.25)) + .stroke(.white, lineWidth: 2) } } /// Routes diff --git a/Meshtastic/Views/Nodes/NodeList.swift b/Meshtastic/Views/Nodes/NodeList.swift index 122f8f10..8d446b18 100644 --- a/Meshtastic/Views/Nodes/NodeList.swift +++ b/Meshtastic/Views/Nodes/NodeList.swift @@ -161,6 +161,7 @@ struct NodeList: View { } } .searchable(text: $searchState.searchText, placement: nodes.count > 10 ? .navigationBarDrawer(displayMode: .always) : .automatic, prompt: "Find a node") + .disableAutocorrection(true) .searchScopes($searchState.searchScope) { ForEach(NodeSearchState.SearchScopes.allCases) { scope in Text(scope.title).tag(scope) diff --git a/Meshtastic/Views/Nodes/PaxCounterLog.swift b/Meshtastic/Views/Nodes/PaxCounterLog.swift index b47ba1a1..df85fc01 100644 --- a/Meshtastic/Views/Nodes/PaxCounterLog.swift +++ b/Meshtastic/Views/Nodes/PaxCounterLog.swift @@ -111,11 +111,11 @@ struct PaxCounterLog: View { } else { ScrollView { let columns = [ - GridItem(.flexible(minimum: 20, maximum: 55), spacing: 0.1), - GridItem(.flexible(minimum: 20, maximum: 55), spacing: 0.1), - GridItem(.flexible(minimum: 20, maximum: 55), spacing: 0.1), - GridItem(.flexible(minimum: 60, maximum: 100), spacing: 0.1), - GridItem(.flexible(minimum: 130, maximum: 200), spacing: 0.1) + GridItem(.flexible(minimum: 20, maximum: 50), spacing: 0.1), + GridItem(.flexible(minimum: 20, maximum: 50), spacing: 0.1), + GridItem(.flexible(minimum: 20, maximum: 50), spacing: 0.1), + GridItem(.flexible(minimum: 60, maximum: 140), spacing: 0.1), + GridItem(.flexible(minimum: 100, maximum: 160), spacing: 0.1) ] LazyVGrid(columns: columns, alignment: .leading, spacing: 1) { GridRow { diff --git a/Meshtastic/Views/Settings/Channels.swift b/Meshtastic/Views/Settings/Channels.swift index ea91d13b..0f5cc6e5 100644 --- a/Meshtastic/Views/Settings/Channels.swift +++ b/Meshtastic/Views/Settings/Channels.swift @@ -268,7 +268,7 @@ struct Channels: View { if !preciseLocation { VStack(alignment: .leading) { - Label("Reduce Precision", systemImage: "location.viewfinder") + Label("Approximate Location", systemImage: "location.slash.circle.fill") Slider( value: $positionPrecision, in: 11...16, diff --git a/protobufs b/protobufs index 52415835..5a97acb1 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 5241583565ccbbb4986180bf4c6eb7f8a0dec285 +Subproject commit 5a97acb17543a10e114675a205e3274a83e721af From 7ecba4cabe0e03a655ce0817cacfad6ec5244e69 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sat, 9 Mar 2024 20:56:40 -0800 Subject: [PATCH 15/74] Disable debug log and serial output if managed mode is on --- Meshtastic/Views/Settings/Config/DeviceConfig.swift | 4 ++++ Meshtastic/Views/Settings/Settings.swift | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Meshtastic/Views/Settings/Config/DeviceConfig.swift b/Meshtastic/Views/Settings/Config/DeviceConfig.swift index 63ebf59b..6e190609 100644 --- a/Meshtastic/Views/Settings/Config/DeviceConfig.swift +++ b/Meshtastic/Views/Settings/Config/DeviceConfig.swift @@ -179,6 +179,10 @@ struct DeviceConfig: View { dc.nodeInfoBroadcastSecs = UInt32(nodeInfoBroadcastSecs) dc.doubleTapAsButtonPress = doubleTapAsButtonPress dc.isManaged = isManaged + if isManaged { + serialEnabled = false + debugLogEnabled = false + } let adminMessageId = bleManager.saveDeviceConfig(config: dc, fromUser: connectedNode!.user!, toUser: node!.user!, adminIndex: connectedNode?.myInfo?.adminIndex ?? 0) if adminMessageId > 0 { // Should show a saved successfully alert once I know that to be true diff --git a/Meshtastic/Views/Settings/Settings.swift b/Meshtastic/Views/Settings/Settings.swift index 88ffbf40..b98893e9 100644 --- a/Meshtastic/Views/Settings/Settings.swift +++ b/Meshtastic/Views/Settings/Settings.swift @@ -144,7 +144,7 @@ struct Settings: View { Text("Your region has a \(rc?.dutyCycle ?? 0)% hourly duty cycle, your radio will stop sending packets when it reaches the hourly limit.") .foregroundColor(.orange) .font(.caption) - Text("Limit all periodic broadcasts intervals especially telemetry and position. If you need to increase hops, do it on nodes at the edges, not the ones in the middle. MQTT is not advised when you are duty cycle restricted because the gateway node is then doing all the work.") + Text("Limit all periodic broadcast intervals especially telemetry and position. If you need to increase hops, do it on nodes at the edges, not the ones in the middle. MQTT is not advised when you are duty cycle restricted because the gateway node is then doing all the work.") .font(.caption2) .foregroundColor(.gray) } From 08de61ee71b591026e294ad12c9c19a555223018 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sat, 9 Mar 2024 23:37:00 -0800 Subject: [PATCH 16/74] Node list updates --- Meshtastic/Extensions/UserDefaults.swift | 9 +++++++++ .../Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift | 1 + Meshtastic/Views/Nodes/Helpers/NodeInfoItem.swift | 5 +++-- Meshtastic/Views/Nodes/Helpers/NodeListItem.swift | 10 +--------- Meshtastic/Views/Nodes/NodeList.swift | 3 +-- Meshtastic/Views/Settings/Config/LoRaConfig.swift | 3 +++ 6 files changed, 18 insertions(+), 13 deletions(-) diff --git a/Meshtastic/Extensions/UserDefaults.swift b/Meshtastic/Extensions/UserDefaults.swift index b1b1785b..1963ed4f 100644 --- a/Meshtastic/Extensions/UserDefaults.swift +++ b/Meshtastic/Extensions/UserDefaults.swift @@ -27,6 +27,7 @@ extension UserDefaults { case enableDetectionNotifications case detectionSensorRole case enableSmartPosition + case modemPreset } func reset() { @@ -202,4 +203,12 @@ extension UserDefaults { UserDefaults.standard.set(newValue, forKey: "enableSmartPosition") } } + static var modemPreset: Int { + get { + UserDefaults.standard.integer(forKey: "modemPreset") + } + set { + UserDefaults.standard.set(newValue, forKey: "modemPreset") + } + } } diff --git a/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift b/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift index 1ce1c603..3511cfdb 100644 --- a/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift +++ b/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift @@ -107,6 +107,7 @@ struct NodeMapSwiftUI: View { if radius > 0.0 { MapCircle(center: position.coordinate, radius: radius) .foregroundStyle(Color(nodeColor).opacity(0.25)) + .stroke(.white, lineWidth: 2) } } Annotation(position.latest ? node.user?.shortName ?? "?": "", coordinate: position.coordinate) { diff --git a/Meshtastic/Views/Nodes/Helpers/NodeInfoItem.swift b/Meshtastic/Views/Nodes/Helpers/NodeInfoItem.swift index fb3ce8e4..0b381b9c 100644 --- a/Meshtastic/Views/Nodes/Helpers/NodeInfoItem.swift +++ b/Meshtastic/Views/Nodes/Helpers/NodeInfoItem.swift @@ -12,6 +12,7 @@ import MapKit struct NodeInfoItem: View { @ObservedObject var node: NodeInfoEntity + var modemPreset: ModemPresets = ModemPresets(rawValue: UserDefaults.modemPreset) ?? ModemPresets.longFast var body: some View { @@ -37,11 +38,11 @@ struct NodeInfoItem: View { if node.snr != 0 && !node.viaMqtt { Divider() VStack(alignment: .center) { - let signalStrength = getLoRaSignalStrength(snr: node.snr, rssi: node.rssi, preset: ModemPresets.longModerate) + let signalStrength = getLoRaSignalStrength(snr: node.snr, rssi: node.rssi, preset: modemPreset) LoRaSignalStrengthIndicator(signalStrength: signalStrength) Text("Signal \(signalStrength.description)").font(.footnote) Text("SNR \(String(format: "%.2f", node.snr))dB") - .foregroundColor(getSnrColor(snr: node.snr, preset: ModemPresets.longModerate)) + .foregroundColor(getSnrColor(snr: node.snr, preset: modemPreset)) .font(.caption2) Text("RSSI \(node.rssi)dB") .foregroundColor(getRssiColor(rssi: node.rssi)) diff --git a/Meshtastic/Views/Nodes/Helpers/NodeListItem.swift b/Meshtastic/Views/Nodes/Helpers/NodeListItem.swift index b309c925..4ffdffca 100644 --- a/Meshtastic/Views/Nodes/Helpers/NodeListItem.swift +++ b/Meshtastic/Views/Nodes/Helpers/NodeListItem.swift @@ -13,7 +13,6 @@ struct NodeListItem: View { @ObservedObject var node: NodeInfoEntity var connected: Bool var connectedNode: Int64 - var modemPreset: Int var body: some View { @@ -119,7 +118,7 @@ struct NodeListItem: View { } } HStack { - if node.channel >= 0 { + if node.channel > 0 { HStack { Image(systemName: "\(node.channel).circle.fill") .font(.title2) @@ -198,13 +197,6 @@ struct NodeListItem: View { } } } - if !node.viaMqtt && connectedNode != node.num { - HStack (alignment: .bottom) { - let preset = ModemPresets(rawValue: Int(modemPreset)) - LoRaSignalStrengthMeter(snr: node.snr, rssi: node.rssi, preset: preset ?? ModemPresets.longFast, compact: true) - } - .padding(.top) - } } .frame(maxWidth: .infinity, alignment: .leading) } diff --git a/Meshtastic/Views/Nodes/NodeList.swift b/Meshtastic/Views/Nodes/NodeList.swift index 8d446b18..56edacbb 100644 --- a/Meshtastic/Views/Nodes/NodeList.swift +++ b/Meshtastic/Views/Nodes/NodeList.swift @@ -62,8 +62,7 @@ struct NodeList: View { NodeListItem(node: node, connected: bleManager.connectedPeripheral != nil && bleManager.connectedPeripheral?.num ?? -1 == node.num, - connectedNode: (bleManager.connectedPeripheral != nil ? bleManager.connectedPeripheral?.num ?? -1 : -1), - modemPreset: Int(connectedNode?.loRaConfig?.modemPreset ?? 0)) + connectedNode: (bleManager.connectedPeripheral != nil ? bleManager.connectedPeripheral?.num ?? -1 : -1)) .contextMenu { if node.user != nil { Button { diff --git a/Meshtastic/Views/Settings/Config/LoRaConfig.swift b/Meshtastic/Views/Settings/Config/LoRaConfig.swift index eace3897..3ca281c2 100644 --- a/Meshtastic/Views/Settings/Config/LoRaConfig.swift +++ b/Meshtastic/Views/Settings/Config/LoRaConfig.swift @@ -205,6 +205,9 @@ struct LoRaConfig: View { lc.sx126XRxBoostedGain = rxBoostedGain lc.overrideFrequency = overrideFrequency lc.ignoreMqtt = ignoreMqtt + if connectedNode?.num ?? -1 == node?.user?.num ?? 0 { + UserDefaults.modemPreset = modemPreset + } let adminMessageId = bleManager.saveLoRaConfig(config: lc, fromUser: connectedNode!.user!, toUser: node!.user!, adminIndex: connectedNode?.myInfo?.adminIndex ?? 0) if adminMessageId > 0 { // Should show a saved successfully alert once I know that to be true From 989b6c41e52ebaffa71585e29ab092259c1430a0 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sun, 10 Mar 2024 00:25:02 -0800 Subject: [PATCH 17/74] Add 1 byte key to channel validation. --- Meshtastic/Views/Settings/Channels.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Meshtastic/Views/Settings/Channels.swift b/Meshtastic/Views/Settings/Channels.swift index 0f5cc6e5..db9c9a03 100644 --- a/Meshtastic/Views/Settings/Channels.swift +++ b/Meshtastic/Views/Settings/Channels.swift @@ -68,6 +68,8 @@ struct Channels: View { channelKeySize = 0 } else if channelKey == "AQ==" { channelKeySize = -1 + } else if channelKey.count == 4 { + channelKeySize = 1 } else if channelKey.count == 24 { channelKeySize = 16 } else if channelKey.count == 32 { @@ -303,7 +305,7 @@ struct Channels: View { } .onAppear { let tempKey = Data(base64Encoded: channelKey) ?? Data() - if tempKey.count == channelKeySize || channelKeySize == -1{ + if tempKey.count == channelKeySize || channelKeySize == -1 { hasValidKey = true } else { From 4fd8efe4b31dbe8f66966f113838ee6a29a8da5b Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sun, 10 Mar 2024 00:34:21 -0800 Subject: [PATCH 18/74] Disasble auto correct on node and user lists --- Meshtastic/Views/Messages/UserList.swift | 2 +- Meshtastic/Views/Nodes/NodeList.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Meshtastic/Views/Messages/UserList.swift b/Meshtastic/Views/Messages/UserList.swift index 6b4ded5f..deab7b0d 100644 --- a/Meshtastic/Views/Messages/UserList.swift +++ b/Meshtastic/Views/Messages/UserList.swift @@ -157,7 +157,7 @@ struct UserList: View { .listStyle(.plain) .navigationTitle(String.localizedStringWithFormat("contacts %@".localized, String(users.count == 0 ? 0 : users.count - 1))) .searchable(text: usersQuery, placement: users.count > 10 ? .navigationBarDrawer(displayMode: .always) : .automatic, prompt: "Find a contact") - .disableAutocorrection(true) + .disableAutocorrection(true) } } } diff --git a/Meshtastic/Views/Nodes/NodeList.swift b/Meshtastic/Views/Nodes/NodeList.swift index 56edacbb..4ae2d1ac 100644 --- a/Meshtastic/Views/Nodes/NodeList.swift +++ b/Meshtastic/Views/Nodes/NodeList.swift @@ -160,7 +160,7 @@ struct NodeList: View { } } .searchable(text: $searchState.searchText, placement: nodes.count > 10 ? .navigationBarDrawer(displayMode: .always) : .automatic, prompt: "Find a node") - .disableAutocorrection(true) + .disableAutocorrection(true) .searchScopes($searchState.searchScope) { ForEach(NodeSearchState.SearchScopes.allCases) { scope in Text(scope.title).tag(scope) From 93ac03959b65e08c80bd8aa03678f28008f0a7c8 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sun, 10 Mar 2024 03:30:11 -0700 Subject: [PATCH 19/74] Add mqtt to postion popover --- Meshtastic.xcodeproj/project.pbxproj | 8 ++++---- .../Nodes/Helpers/Map/PositionPopover.swift | 18 +++++++++++++++--- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Meshtastic.xcodeproj/project.pbxproj b/Meshtastic.xcodeproj/project.pbxproj index 4cd9deb0..e54ac7fc 100644 --- a/Meshtastic.xcodeproj/project.pbxproj +++ b/Meshtastic.xcodeproj/project.pbxproj @@ -1572,7 +1572,7 @@ CODE_SIGN_ENTITLEMENTS = Meshtastic/Meshtastic.entitlements; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 841; DEVELOPMENT_ASSET_PATHS = "\"Meshtastic/Preview Content\""; DEVELOPMENT_TEAM = GCH7VS5Y9R; ENABLE_PREVIEWS = YES; @@ -1606,7 +1606,7 @@ CODE_SIGN_ENTITLEMENTS = Meshtastic/Meshtastic.entitlements; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 841; DEVELOPMENT_ASSET_PATHS = "\"Meshtastic/Preview Content\""; DEVELOPMENT_TEAM = GCH7VS5Y9R; ENABLE_PREVIEWS = YES; @@ -1728,7 +1728,7 @@ CODE_SIGN_ENTITLEMENTS = Widgets/WidgetsExtension.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 840; + CURRENT_PROJECT_VERSION = 841; DEVELOPMENT_TEAM = GCH7VS5Y9R; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = Widgets/Info.plist; @@ -1761,7 +1761,7 @@ CODE_SIGN_ENTITLEMENTS = Widgets/WidgetsExtension.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 840; + CURRENT_PROJECT_VERSION = 841; DEVELOPMENT_TEAM = GCH7VS5Y9R; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = Widgets/Info.plist; diff --git a/Meshtastic/Views/Nodes/Helpers/Map/PositionPopover.swift b/Meshtastic/Views/Nodes/Helpers/Map/PositionPopover.swift index 9b062da4..b5fc9fd8 100644 --- a/Meshtastic/Views/Nodes/Helpers/Map/PositionPopover.swift +++ b/Meshtastic/Views/Nodes/Helpers/Map/PositionPopover.swift @@ -130,6 +130,19 @@ struct PositionPopover: View { .frame(width: 35) } .padding(.bottom, 5) + if position.nodePosition?.viaMqtt ?? false { + + Label { + let heading = Measurement(value: degrees.degrees, unit: UnitAngle.degrees) + Text("MQTT") + } icon: { + Image(systemName: "network") + .symbolRenderingMode(.hierarchical) + .frame(width: 35) + .rotationEffect(degrees) + } + .padding(.bottom, 5) + } if let lastLocation = locationsHandler.locationsArray.last { /// Distance if lastLocation.distance(from: CLLocation(latitude: LocationsHandler.DefaultLocation.latitude, longitude: LocationsHandler.DefaultLocation.longitude)) > 0.0 { @@ -181,8 +194,7 @@ struct PositionPopover: View { } BatteryGauge(node: position.nodePosition!) } - let mpInt = Int(position.nodePosition?.loRaConfig?.modemPreset ?? 0) - LoRaSignalStrengthMeter(snr: position.nodePosition?.snr ?? 0.0, rssi: position.nodePosition?.rssi ?? 0, preset: ModemPresets(rawValue: mpInt) ?? ModemPresets.longFast, compact: false) + LoRaSignalStrengthMeter(snr: position.nodePosition?.snr ?? 0.0, rssi: position.nodePosition?.rssi ?? 0, preset: ModemPresets(rawValue: UserDefaults.modemPreset) ?? ModemPresets.longFast, compact: false) Spacer() } } @@ -202,7 +214,7 @@ struct PositionPopover: View { #endif } } - .presentationDetents([.fraction(0.45), .fraction(0.55), .fraction(0.65)]) + .presentationDetents([.fraction(0.55), .fraction(0.65), .fraction(0.75)]) .presentationDragIndicator(.visible) } } From 8a8cd6938300275a190cbefc7cd29e154ae1fcd4 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sun, 10 Mar 2024 15:16:18 -0700 Subject: [PATCH 20/74] Client proxy manage topic update, don't show exchange positons for the connected node --- Meshtastic/Helpers/Mqtt/MqttClientProxyManager.swift | 4 ++-- Meshtastic/Views/Nodes/NodeList.swift | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Meshtastic/Helpers/Mqtt/MqttClientProxyManager.swift b/Meshtastic/Helpers/Mqtt/MqttClientProxyManager.swift index 1196e1b5..ce3bcf49 100644 --- a/Meshtastic/Helpers/Mqtt/MqttClientProxyManager.swift +++ b/Meshtastic/Helpers/Mqtt/MqttClientProxyManager.swift @@ -21,7 +21,7 @@ class MqttClientProxyManager { private static let defaultKeepAliveInterval: Int32 = 60 weak var delegate: MqttClientProxyManagerDelegate? var mqttClientProxy: CocoaMQTT? - var topic = "msh/2/c" + var topic = "msh/2/e" var debugLog = false func connectFromConfigSettings(node: NodeInfoEntity) { let defaultServerAddress = "mqtt.meshtastic.org" @@ -41,7 +41,7 @@ class MqttClientProxyManager { let username = node.mqttConfig?.username let password = node.mqttConfig?.password let root = node.mqttConfig?.root?.count ?? 0 > 0 ? node.mqttConfig?.root : "msh" - let prefix = root! + "/2/c" + let prefix = root! + "/2/e" topic = prefix + "/#" let qos = CocoaMQTTQoS(rawValue: UInt8(1))! connect(host: host, port: port, useSsl: useSsl, username: username, password: password, topic: topic, qos: qos, cleanSession: true) diff --git a/Meshtastic/Views/Nodes/NodeList.swift b/Meshtastic/Views/Nodes/NodeList.swift index 4ae2d1ac..81ae069f 100644 --- a/Meshtastic/Views/Nodes/NodeList.swift +++ b/Meshtastic/Views/Nodes/NodeList.swift @@ -89,7 +89,7 @@ struct NodeList: View { } label: { Label(node.user!.mute ? "Show Alerts" : "Hide Alerts", systemImage: node.user!.mute ? "bell" : "bell.slash") } - if bleManager.connectedPeripheral != nil { + if bleManager.connectedPeripheral != nil && node.num != connectedNodeNum { Button { let positionSent = bleManager.sendPosition( channel: node.channel, From 61a98a09b9498dd8811df2cc20dcb9fef1e5bbeb Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sun, 10 Mar 2024 20:17:54 -0700 Subject: [PATCH 21/74] Handle topic change keep less positions in memory --- Meshtastic.xcodeproj/project.pbxproj | 4 +- Meshtastic/Extensions/UserDefaults.swift | 9 ++++ Meshtastic/Helpers/BLEManager.swift | 1 + Meshtastic/Helpers/LocationsHandler.swift | 44 +++++++++---------- .../Helpers/Mqtt/MqttClientProxyManager.swift | 9 ++-- Meshtastic/Views/Settings/AppSettings.swift | 6 +++ Meshtastic/Views/Settings/Firmware.swift | 2 +- 7 files changed, 47 insertions(+), 28 deletions(-) diff --git a/Meshtastic.xcodeproj/project.pbxproj b/Meshtastic.xcodeproj/project.pbxproj index e54ac7fc..6cf4d0e2 100644 --- a/Meshtastic.xcodeproj/project.pbxproj +++ b/Meshtastic.xcodeproj/project.pbxproj @@ -1572,7 +1572,7 @@ CODE_SIGN_ENTITLEMENTS = Meshtastic/Meshtastic.entitlements; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 841; + CURRENT_PROJECT_VERSION = 842; DEVELOPMENT_ASSET_PATHS = "\"Meshtastic/Preview Content\""; DEVELOPMENT_TEAM = GCH7VS5Y9R; ENABLE_PREVIEWS = YES; @@ -1606,7 +1606,7 @@ CODE_SIGN_ENTITLEMENTS = Meshtastic/Meshtastic.entitlements; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 841; + CURRENT_PROJECT_VERSION = 842; DEVELOPMENT_ASSET_PATHS = "\"Meshtastic/Preview Content\""; DEVELOPMENT_TEAM = GCH7VS5Y9R; ENABLE_PREVIEWS = YES; diff --git a/Meshtastic/Extensions/UserDefaults.swift b/Meshtastic/Extensions/UserDefaults.swift index 1963ed4f..39cc9b89 100644 --- a/Meshtastic/Extensions/UserDefaults.swift +++ b/Meshtastic/Extensions/UserDefaults.swift @@ -28,6 +28,7 @@ extension UserDefaults { case detectionSensorRole case enableSmartPosition case modemPreset + case firmwareVersion } func reset() { @@ -211,4 +212,12 @@ extension UserDefaults { UserDefaults.standard.set(newValue, forKey: "modemPreset") } } + static var firmwareVersion: String { + get { + UserDefaults.standard.string(forKey: "firmwareVersion") ?? "0.0.0" + } + set { + UserDefaults.standard.set(newValue, forKey: "firmwareVersion") + } + } } diff --git a/Meshtastic/Helpers/BLEManager.swift b/Meshtastic/Helpers/BLEManager.swift index cf663f10..5d85d325 100644 --- a/Meshtastic/Helpers/BLEManager.swift +++ b/Meshtastic/Helpers/BLEManager.swift @@ -582,6 +582,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate nowKnown = true connectedVersion = String(version.dropLast()) appState.firmwareVersion = connectedVersion + UserDefaults.firmwareVersion = connectedVersion } let supportedVersion = connectedVersion == "0.0.0" || self.minimumVersion.compare(connectedVersion, options: .numeric) == .orderedAscending || minimumVersion.compare(connectedVersion, options: .numeric) == .orderedSame if !supportedVersion { diff --git a/Meshtastic/Helpers/LocationsHandler.swift b/Meshtastic/Helpers/LocationsHandler.swift index 82714d62..6ec44b90 100644 --- a/Meshtastic/Helpers/LocationsHandler.swift +++ b/Meshtastic/Helpers/LocationsHandler.swift @@ -60,14 +60,10 @@ import CoreLocation self.isStationary = update.isStationary var locationAdded: Bool - if enableSmartPosition { - locationAdded = addLocation(loc) - //print("Added Location \(self.count): \(loc)") - } else { - locationsArray.append(loc) - locationAdded = true - } - if locationAdded { + locationAdded = addLocation(loc, smartPostion: enableSmartPosition) + if !isRecording && locationAdded { + self.count = 1 + } else if locationAdded && isRecording { self.count += 1 } } @@ -84,19 +80,21 @@ import CoreLocation self.updatesStarted = false } - func addLocation(_ location: CLLocation) -> Bool { - let age = -location.timestamp.timeIntervalSinceNow - if age > 10 { - print("Bad Location \(self.count): Too Old \(age) seconds ago \(location)") - return false - } - if location.horizontalAccuracy < 0 { - print("Bad Location \(self.count): Horizontal Accuracy: \(location.horizontalAccuracy) \(location)") - return false - } - if location.horizontalAccuracy > 25 { - print("Bad Location \(self.count): Horizontal Accuracy: \(location.horizontalAccuracy) \(location)") - return false + func addLocation(_ location: CLLocation, smartPostion: Bool) -> Bool { + if smartPostion { + let age = -location.timestamp.timeIntervalSinceNow + if age > 10 { + print("Bad Location \(self.count): Too Old \(age) seconds ago \(location)") + return false + } + if location.horizontalAccuracy < 0 { + print("Bad Location \(self.count): Horizontal Accuracy: \(location.horizontalAccuracy) \(location)") + return false + } + if location.horizontalAccuracy > 25 { + print("Bad Location \(self.count): Horizontal Accuracy: \(location.horizontalAccuracy) \(location)") + return false + } } if isRecording { if let lastLocation = locationsArray.last { @@ -107,8 +105,10 @@ import CoreLocation elevationGain += gain } } + locationsArray.append(location) + } else { + locationsArray = [location] } - locationsArray.append(location) return true } diff --git a/Meshtastic/Helpers/Mqtt/MqttClientProxyManager.swift b/Meshtastic/Helpers/Mqtt/MqttClientProxyManager.swift index ce3bcf49..5a1a33d4 100644 --- a/Meshtastic/Helpers/Mqtt/MqttClientProxyManager.swift +++ b/Meshtastic/Helpers/Mqtt/MqttClientProxyManager.swift @@ -21,7 +21,7 @@ class MqttClientProxyManager { private static let defaultKeepAliveInterval: Int32 = 60 weak var delegate: MqttClientProxyManagerDelegate? var mqttClientProxy: CocoaMQTT? - var topic = "msh/2/e" + var topic = "msh" var debugLog = false func connectFromConfigSettings(node: NodeInfoEntity) { let defaultServerAddress = "mqtt.meshtastic.org" @@ -36,13 +36,16 @@ class MqttClientProxyManager { defaultServerPort = Int(fullHost.components(separatedBy: ":")[1]) ?? (useSsl ? 8883 : 1883) } } + let minimumVersion = "2.3.0" + let latestVersion = minimumVersion.compare(UserDefaults.firmwareVersion, options: .numeric) == .orderedSame + if let host = host { let port = defaultServerPort let username = node.mqttConfig?.username let password = node.mqttConfig?.password let root = node.mqttConfig?.root?.count ?? 0 > 0 ? node.mqttConfig?.root : "msh" - let prefix = root! + "/2/e" - topic = prefix + "/#" + let prefix = root! + topic = prefix + (latestVersion ? "/2/e" : "/2/c") + "/#" let qos = CocoaMQTTQoS(rawValue: UInt8(1))! connect(host: host, port: port, useSsl: useSsl, username: username, password: password, topic: topic, qos: qos, cleanSession: true) } diff --git a/Meshtastic/Views/Settings/AppSettings.swift b/Meshtastic/Views/Settings/AppSettings.swift index 9e559b62..cd9ef8f4 100644 --- a/Meshtastic/Views/Settings/AppSettings.swift +++ b/Meshtastic/Views/Settings/AppSettings.swift @@ -24,9 +24,15 @@ struct AppSettings: View { Label("appsettings.provide.location", systemImage: "location.circle.fill") } .toggleStyle(SwitchToggleStyle(tint: .accentColor)) + Text("Use your phone's gps to provide a location to your node. Must have location access and precise location enabled for Meshtastic in Settings.") + .font(.caption2) + .foregroundColor(.gray) if provideLocation { Toggle(isOn: $enableSmartPosition) { Label("appsettings.smartposition", systemImage: "brain") + Text("Will only send a position to the phone if it is recent and of high horizontal accuracy.") + .font(.caption2) + .foregroundColor(.gray) } .toggleStyle(SwitchToggleStyle(tint: .accentColor)) VStack { diff --git a/Meshtastic/Views/Settings/Firmware.swift b/Meshtastic/Views/Settings/Firmware.swift index 21aa3b82..98b29957 100644 --- a/Meshtastic/Views/Settings/Firmware.swift +++ b/Meshtastic/Views/Settings/Firmware.swift @@ -12,7 +12,7 @@ struct Firmware: View { @Environment(\.managedObjectContext) var context @EnvironmentObject var bleManager: BLEManager var node: NodeInfoEntity? - @State var minimumVersion = "2.2.21" + @State var minimumVersion = "2.3.0" @State var version = "" @State private var currentDevice: DeviceHardware? @State private var latestStable: FirmwareRelease? From c36832586c3b372b4e62502aebe0e7c1d4fa7f7f Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sun, 10 Mar 2024 22:14:46 -0700 Subject: [PATCH 22/74] Scoll to dismiss keyboard for the two searchable lists --- Meshtastic/Views/Messages/UserList.swift | 1 + Meshtastic/Views/Nodes/NodeList.swift | 1 + 2 files changed, 2 insertions(+) diff --git a/Meshtastic/Views/Messages/UserList.swift b/Meshtastic/Views/Messages/UserList.swift index deab7b0d..978e8c08 100644 --- a/Meshtastic/Views/Messages/UserList.swift +++ b/Meshtastic/Views/Messages/UserList.swift @@ -158,6 +158,7 @@ struct UserList: View { .navigationTitle(String.localizedStringWithFormat("contacts %@".localized, String(users.count == 0 ? 0 : users.count - 1))) .searchable(text: usersQuery, placement: users.count > 10 ? .navigationBarDrawer(displayMode: .always) : .automatic, prompt: "Find a contact") .disableAutocorrection(true) + .scrollDismissesKeyboard(.immediately) } } } diff --git a/Meshtastic/Views/Nodes/NodeList.swift b/Meshtastic/Views/Nodes/NodeList.swift index 81ae069f..c2532ad7 100644 --- a/Meshtastic/Views/Nodes/NodeList.swift +++ b/Meshtastic/Views/Nodes/NodeList.swift @@ -161,6 +161,7 @@ struct NodeList: View { } .searchable(text: $searchState.searchText, placement: nodes.count > 10 ? .navigationBarDrawer(displayMode: .always) : .automatic, prompt: "Find a node") .disableAutocorrection(true) + .scrollDismissesKeyboard(.immediately) .searchScopes($searchState.searchScope) { ForEach(NodeSearchState.SearchScopes.allCases) { scope in Text(scope.title).tag(scope) From 35f99173ba549d94cbb35535eecbd886bbe01630 Mon Sep 17 00:00:00 2001 From: Wolfgang Nagele Date: Mon, 11 Mar 2024 21:41:44 +0100 Subject: [PATCH 23/74] Device metrics chart improvements --- Meshtastic/Views/Nodes/DeviceMetricsLog.swift | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/Meshtastic/Views/Nodes/DeviceMetricsLog.swift b/Meshtastic/Views/Nodes/DeviceMetricsLog.swift index e1e87b6a..269b3020 100644 --- a/Meshtastic/Views/Nodes/DeviceMetricsLog.swift +++ b/Meshtastic/Views/Nodes/DeviceMetricsLog.swift @@ -34,22 +34,25 @@ struct DeviceMetricsLog: View { Chart { ForEach(chartData, id: \.self) { point in - Plot { - LineMark( - x: .value("x", point.time!), - y: .value("y", point.batteryLevel) - ) + if point.batteryLevel != 101 { // Filter out magic charging value + Plot { + LineMark( + x: .value("x", point.time!), + y: .value("y", point.batteryLevel) + ) + } + .accessibilityLabel("Line Series") + .accessibilityValue("X: \(point.time!), Y: \(point.batteryLevel)") + .foregroundStyle(batteryChartColor) + .interpolationMethod(.linear) } - .accessibilityLabel("Line Series") - .accessibilityValue("X: \(point.time!), Y: \(point.batteryLevel)") - .foregroundStyle(batteryChartColor) - .interpolationMethod(.cardinal) Plot { PointMark( x: .value("x", point.time!), y: .value("y", point.channelUtilization) ) + .symbolSize(25) } .accessibilityLabel("Line Series") .accessibilityValue("X: \(point.time!), Y: \(point.channelUtilization)") @@ -64,6 +67,7 @@ struct DeviceMetricsLog: View { x: .value("x", point.time!), y: .value("y", point.airUtilTx) ) + .symbolSize(25) } .accessibilityLabel("Line Series") .accessibilityValue("X: \(point.time!), Y: \(point.airUtilTx)") From 50add85292423c48aa4ed092a8ff7f4e2bd12d5a Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Wed, 13 Mar 2024 05:52:31 -0700 Subject: [PATCH 24/74] Tighten up node list Add m to dBm on lora config New reverse geocoded nearby mqtt topics --- Meshtastic.xcodeproj/project.pbxproj | 4 +- Meshtastic/Views/Bluetooth/Connect.swift | 2 +- .../Views/Nodes/Helpers/NodeListItem.swift | 4 +- .../Views/Settings/Config/LoRaConfig.swift | 2 +- .../Settings/Config/Module/MQTTConfig.swift | 81 +++++++++++++++++-- 5 files changed, 80 insertions(+), 13 deletions(-) diff --git a/Meshtastic.xcodeproj/project.pbxproj b/Meshtastic.xcodeproj/project.pbxproj index 6cf4d0e2..a0beff25 100644 --- a/Meshtastic.xcodeproj/project.pbxproj +++ b/Meshtastic.xcodeproj/project.pbxproj @@ -1572,7 +1572,7 @@ CODE_SIGN_ENTITLEMENTS = Meshtastic/Meshtastic.entitlements; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 842; + CURRENT_PROJECT_VERSION = 843; DEVELOPMENT_ASSET_PATHS = "\"Meshtastic/Preview Content\""; DEVELOPMENT_TEAM = GCH7VS5Y9R; ENABLE_PREVIEWS = YES; @@ -1606,7 +1606,7 @@ CODE_SIGN_ENTITLEMENTS = Meshtastic/Meshtastic.entitlements; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 842; + CURRENT_PROJECT_VERSION = 843; DEVELOPMENT_ASSET_PATHS = "\"Meshtastic/Preview Content\""; DEVELOPMENT_TEAM = GCH7VS5Y9R; ENABLE_PREVIEWS = YES; diff --git a/Meshtastic/Views/Bluetooth/Connect.swift b/Meshtastic/Views/Bluetooth/Connect.swift index abf933a6..8fcc31cb 100644 --- a/Meshtastic/Views/Bluetooth/Connect.swift +++ b/Meshtastic/Views/Bluetooth/Connect.swift @@ -209,7 +209,7 @@ struct Connect: View { }.padding([.bottom, .top]) } } - .confirmationDialog("Connecting to a new radio will clear all local app data on the phone and will reset all app settings.", isPresented: $presentingSwitchPreferredPeripheral, titleVisibility: .visible) { + .confirmationDialog("Connecting to a new radio will clear all local app data on the phone and will reset all app specific settings.", isPresented: $presentingSwitchPreferredPeripheral, titleVisibility: .visible) { Button("Connect to new radio?", role: .destructive) { UserDefaults.preferredPeripheralId = selectedPeripherialId diff --git a/Meshtastic/Views/Nodes/Helpers/NodeListItem.swift b/Meshtastic/Views/Nodes/Helpers/NodeListItem.swift index 4ffdffca..871c54af 100644 --- a/Meshtastic/Views/Nodes/Helpers/NodeListItem.swift +++ b/Meshtastic/Views/Nodes/Helpers/NodeListItem.swift @@ -202,6 +202,8 @@ struct NodeListItem: View { } } } - .padding([.top, .bottom]) + .padding(.top, 4) + .padding(.bottom, 4) + //.padding([.top, .bottom]) } } diff --git a/Meshtastic/Views/Settings/Config/LoRaConfig.swift b/Meshtastic/Views/Settings/Config/LoRaConfig.swift index 3ca281c2..e9a0f352 100644 --- a/Meshtastic/Views/Settings/Config/LoRaConfig.swift +++ b/Meshtastic/Views/Settings/Config/LoRaConfig.swift @@ -181,7 +181,7 @@ struct LoRaConfig: View { HStack { Image(systemName: "antenna.radiowaves.left.and.right") .foregroundColor(.accentColor) - Stepper("\(txPower)db Transmit Power", value: $txPower, in: 1...30, step: 1) + Stepper("\(txPower)dBm Transmit Power", value: $txPower, in: 1...30, step: 1) .padding(5) } } diff --git a/Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift b/Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift index 8136e865..2ce168ac 100644 --- a/Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift +++ b/Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift @@ -5,6 +5,7 @@ // Copyright (c) Garth Vander Houwen 9/4/22. // import SwiftUI +import CoreLocation struct MQTTConfig: View { @@ -23,9 +24,9 @@ struct MQTTConfig: View { @State var jsonEnabled = false @State var tlsEnabled = true @State var root = "msh" + @State var selectedTopic = "" @State var mqttConnected: Bool = false - - + @State var nearbyTopics = [String]() var body: some View { VStack { @@ -51,7 +52,7 @@ struct MQTTConfig: View { Toggle(isOn: $proxyToClientEnabled) { Label("mqtt.clientproxy", systemImage: "iphone.radiowaves.left.and.right") - Text("If both MQTT and the client proxy are enabled your mobile device will utilize an available network connection to connect to the specified MQTT server.") + Text("Utilizes the network connection on your phone to connect to MQTT.") } .toggleStyle(SwitchToggleStyle(tint: .accentColor)) @@ -69,7 +70,7 @@ struct MQTTConfig: View { Toggle(isOn: $jsonEnabled) { Label("JSON Enabled", systemImage: "ellipsis.curlybraces") - Text("JSON mode is a limited, unencrypted MQTT output that can crash your node it should not be enabled unless you are locally integrating with home assistant") + Text("JSON mode is a limited, unencrypted MQTT output for locally integrating with home assistant") } .toggleStyle(SwitchToggleStyle(tint: .accentColor)) @@ -80,7 +81,7 @@ struct MQTTConfig: View { .toggleStyle(SwitchToggleStyle(tint: .accentColor)) } - Section(header: Text("Custom Server")) { + Section(header: Text("Server")) { HStack { Label("Address", systemImage: "server.rack") TextField("Server Address", text: $address) @@ -157,6 +158,7 @@ struct MQTTConfig: View { } .keyboardType(.default) .scrollDismissesKeyboard(.interactively) + .listRowSeparator(/*@START_MENU_TOKEN@*/.visible/*@END_MENU_TOKEN@*/) HStack { Label("Root Topic", systemImage: "tree") TextField("Root Topic", text: $root) @@ -164,8 +166,8 @@ struct MQTTConfig: View { .onChange(of: root, perform: { _ in let totalBytes = root.utf8.count // Only mess with the value if it is too big - if totalBytes > 14 { - let firstNBytes = Data(root.utf8.prefix(14)) + if totalBytes > 15 { + let firstNBytes = Data(root.utf8.prefix(15)) if let maxBytesString = String(data: firstNBytes, encoding: String.Encoding.utf8) { // Set the shortName back to the last place where it was the right size root = maxBytesString @@ -177,9 +179,23 @@ struct MQTTConfig: View { .keyboardType(.asciiCapable) .scrollDismissesKeyboard(.interactively) .disableAutocorrection(true) - Text("The root topic to use for MQTT messages. Default is \"msh\". This is useful if you want to use a single MQTT server for multiple meshtastic networks and separate them via ACLs") + .listRowSeparator(.hidden) + Text("The root topic to use for MQTT.") .foregroundColor(.gray) .font(.callout) + + if nearbyTopics.count > 0 { + Picker("Nearby Topics", selection: $selectedTopic ) { + ForEach(nearbyTopics, id: \.self) { nt in + Text(nt) + } + } + .pickerStyle(InlinePickerStyle()) + .listRowSeparator(.hidden) + Text("If the default region topic is too busy you can choose a more local topic.") + .foregroundColor(.gray) + .font(.callout) + } } Text("You can set uplink and downlink for each channel.") .font(.callout) @@ -249,6 +265,9 @@ struct MQTTConfig: View { if newRoot != node!.mqttConfig!.root { hasChanges = true } } } + .onChange(of: selectedTopic) { newSelectedTopic in + root = newSelectedTopic + } .onChange(of: enabled) { newEnabled in if node != nil && node?.mqttConfig != nil { if newEnabled != node!.mqttConfig!.enabled { hasChanges = true } @@ -290,6 +309,52 @@ struct MQTTConfig: View { } } func setMqttValues() { + + if #available(iOS 17.0, macOS 14.0, *) { + + nearbyTopics = [] + let geocoder = CLGeocoder() + if LocationsHandler.shared.locationsArray.count > 0 { + geocoder.reverseGeocodeLocation(LocationsHandler.shared.locationsArray.first!, completionHandler: {(placemarks, error) -> Void in + if error != nil { + print("Failed to reverse geocode location") + return + } + + if let placemarks = placemarks, let placemark = placemarks.first { + + /// Country Topic unless you are US + if placemark.isoCountryCode ?? "unknown" != "US" { + let countryTopic = root + "/" + (placemark.isoCountryCode ?? "") + if !countryTopic.isEmpty { + nearbyTopics.append(countryTopic) + } + } + let stateTopic = root + "/" + (placemark.administrativeArea ?? "") + if !stateTopic.isEmpty { + nearbyTopics.append(stateTopic) + } + let countyTopic = root + "/" + (placemark.subAdministrativeArea?.lowercased().replacingOccurrences(of: " ", with: "") ?? "") + if !countyTopic.isEmpty { + nearbyTopics.append(countyTopic) + } + let cityTopic = root + "/" + (placemark.locality?.lowercased().replacingOccurrences(of: " ", with: "") ?? "") + if !cityTopic.isEmpty { + nearbyTopics.append(cityTopic) + } + let neightborhoodTopic = root + "/" + (placemark.subLocality?.lowercased().replacingOccurrences(of: " ", with: "") ?? "") + if !neightborhoodTopic.isEmpty { + nearbyTopics.append(neightborhoodTopic) + } + + } + else + { + print("No Location") + } + }) + } + } self.enabled = (node?.mqttConfig?.enabled ?? false) self.proxyToClientEnabled = (node?.mqttConfig?.proxyToClientEnabled ?? false) self.address = node?.mqttConfig?.address ?? "" From 387e594d45d09faace04ba26d95b51db5493d4c8 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Wed, 13 Mar 2024 05:53:45 -0700 Subject: [PATCH 25/74] Bump version --- Meshtastic.xcodeproj/project.pbxproj | 16 ++++++++-------- .../Views/Nodes/Helpers/NodeListItem.swift | 1 - 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Meshtastic.xcodeproj/project.pbxproj b/Meshtastic.xcodeproj/project.pbxproj index a0beff25..2bb892bb 100644 --- a/Meshtastic.xcodeproj/project.pbxproj +++ b/Meshtastic.xcodeproj/project.pbxproj @@ -1572,7 +1572,7 @@ CODE_SIGN_ENTITLEMENTS = Meshtastic/Meshtastic.entitlements; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 843; + CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_ASSET_PATHS = "\"Meshtastic/Preview Content\""; DEVELOPMENT_TEAM = GCH7VS5Y9R; ENABLE_PREVIEWS = YES; @@ -1584,7 +1584,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 2.3.0; + MARKETING_VERSION = 2.3.1; PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient; PRODUCT_NAME = "$(TARGET_NAME)"; SUPPORTS_MACCATALYST = YES; @@ -1606,7 +1606,7 @@ CODE_SIGN_ENTITLEMENTS = Meshtastic/Meshtastic.entitlements; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 843; + CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_ASSET_PATHS = "\"Meshtastic/Preview Content\""; DEVELOPMENT_TEAM = GCH7VS5Y9R; ENABLE_PREVIEWS = YES; @@ -1618,7 +1618,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 2.3.0; + MARKETING_VERSION = 2.3.1; PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient; PRODUCT_NAME = "$(TARGET_NAME)"; SUPPORTS_MACCATALYST = YES; @@ -1728,7 +1728,7 @@ CODE_SIGN_ENTITLEMENTS = Widgets/WidgetsExtension.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 841; + CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = GCH7VS5Y9R; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = Widgets/Info.plist; @@ -1740,7 +1740,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 2.3.0; + MARKETING_VERSION = 2.3.1; PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient.Widgets; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -1761,7 +1761,7 @@ CODE_SIGN_ENTITLEMENTS = Widgets/WidgetsExtension.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 841; + CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = GCH7VS5Y9R; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = Widgets/Info.plist; @@ -1773,7 +1773,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 2.3.0; + MARKETING_VERSION = 2.3.1; PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient.Widgets; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/Meshtastic/Views/Nodes/Helpers/NodeListItem.swift b/Meshtastic/Views/Nodes/Helpers/NodeListItem.swift index 871c54af..c880d27b 100644 --- a/Meshtastic/Views/Nodes/Helpers/NodeListItem.swift +++ b/Meshtastic/Views/Nodes/Helpers/NodeListItem.swift @@ -204,6 +204,5 @@ struct NodeListItem: View { } .padding(.top, 4) .padding(.bottom, 4) - //.padding([.top, .bottom]) } } From 5d7693b40d19290247e537122872fa0ca0f1b34b Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Wed, 13 Mar 2024 20:47:18 -0700 Subject: [PATCH 26/74] New mqtt root size --- .../Protobufs/meshtastic/clientonly.pb.swift | 33 ++++ .../meshtastic/module_config.pb.swift | 92 ++++++++++ Meshtastic/Protobufs/meshtastic/mqtt.pb.swift | 171 ++++++++++++++++++ .../Protobufs/meshtastic/portnums.pb.swift | 8 + Meshtastic/Views/Nodes/DeviceMetricsLog.swift | 2 +- .../Settings/Config/Module/MQTTConfig.swift | 4 +- protobufs | 2 +- 7 files changed, 308 insertions(+), 4 deletions(-) diff --git a/Meshtastic/Protobufs/meshtastic/clientonly.pb.swift b/Meshtastic/Protobufs/meshtastic/clientonly.pb.swift index 050c719d..64fd71c0 100644 --- a/Meshtastic/Protobufs/meshtastic/clientonly.pb.swift +++ b/Meshtastic/Protobufs/meshtastic/clientonly.pb.swift @@ -94,8 +94,22 @@ struct DeviceProfile { fileprivate var _moduleConfig: LocalModuleConfig? = nil } +/// +/// A heartbeat message is sent by a node to indicate that it is still alive. +/// This is currently only needed to keep serial connections alive. +struct Heartbeat { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + #if swift(>=5.5) && canImport(_Concurrency) extension DeviceProfile: @unchecked Sendable {} +extension Heartbeat: @unchecked Sendable {} #endif // swift(>=5.5) && canImport(_Concurrency) // MARK: - Code below here is support for the SwiftProtobuf runtime. @@ -161,3 +175,22 @@ extension DeviceProfile: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementa return true } } + +extension Heartbeat: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".Heartbeat" + static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() { + } + } + + func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Heartbeat, rhs: Heartbeat) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/Meshtastic/Protobufs/meshtastic/module_config.pb.swift b/Meshtastic/Protobufs/meshtastic/module_config.pb.swift index 3aee0200..b688479b 100644 --- a/Meshtastic/Protobufs/meshtastic/module_config.pb.swift +++ b/Meshtastic/Protobufs/meshtastic/module_config.pb.swift @@ -376,6 +376,43 @@ struct ModuleConfig { /// If true, we can use the connected phone / client to proxy messages to MQTT instead of a direct connection var proxyToClientEnabled: Bool = false + /// + /// If true, we will periodically report unencrypted information about our node to a map via MQTT + var mapReportingEnabled: Bool = false + + /// + /// Settings for reporting information about our node to a map via MQTT + var mapReportSettings: ModuleConfig.MapReportSettings { + get {return _mapReportSettings ?? ModuleConfig.MapReportSettings()} + set {_mapReportSettings = newValue} + } + /// Returns true if `mapReportSettings` has been explicitly set. + var hasMapReportSettings: Bool {return self._mapReportSettings != nil} + /// Clears the value of `mapReportSettings`. Subsequent reads from it will return its default value. + mutating func clearMapReportSettings() {self._mapReportSettings = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _mapReportSettings: ModuleConfig.MapReportSettings? = nil + } + + /// + /// Settings for reporting unencrypted information about our node to a map via MQTT + struct MapReportSettings { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// + /// How often we should report our info to the map (in seconds) + var publishIntervalSecs: UInt32 = 0 + + /// + /// Bits of precision for the location sent (default of 32 is full precision). + var positionPrecision: UInt32 = 0 + var unknownFields = SwiftProtobuf.UnknownStorage() init() {} @@ -1207,6 +1244,7 @@ extension RemoteHardwarePinType: @unchecked Sendable {} extension ModuleConfig: @unchecked Sendable {} extension ModuleConfig.OneOf_PayloadVariant: @unchecked Sendable {} extension ModuleConfig.MQTTConfig: @unchecked Sendable {} +extension ModuleConfig.MapReportSettings: @unchecked Sendable {} extension ModuleConfig.RemoteHardwareConfig: @unchecked Sendable {} extension ModuleConfig.NeighborInfoConfig: @unchecked Sendable {} extension ModuleConfig.DetectionSensorConfig: @unchecked Sendable {} @@ -1518,6 +1556,8 @@ extension ModuleConfig.MQTTConfig: SwiftProtobuf.Message, SwiftProtobuf._Message 7: .standard(proto: "tls_enabled"), 8: .same(proto: "root"), 9: .standard(proto: "proxy_to_client_enabled"), + 10: .standard(proto: "map_reporting_enabled"), + 11: .standard(proto: "map_report_settings"), ] mutating func decodeMessage(decoder: inout D) throws { @@ -1535,12 +1575,18 @@ extension ModuleConfig.MQTTConfig: SwiftProtobuf.Message, SwiftProtobuf._Message case 7: try { try decoder.decodeSingularBoolField(value: &self.tlsEnabled) }() case 8: try { try decoder.decodeSingularStringField(value: &self.root) }() case 9: try { try decoder.decodeSingularBoolField(value: &self.proxyToClientEnabled) }() + case 10: try { try decoder.decodeSingularBoolField(value: &self.mapReportingEnabled) }() + case 11: try { try decoder.decodeSingularMessageField(value: &self._mapReportSettings) }() default: break } } } func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 if self.enabled != false { try visitor.visitSingularBoolField(value: self.enabled, fieldNumber: 1) } @@ -1568,6 +1614,12 @@ extension ModuleConfig.MQTTConfig: SwiftProtobuf.Message, SwiftProtobuf._Message if self.proxyToClientEnabled != false { try visitor.visitSingularBoolField(value: self.proxyToClientEnabled, fieldNumber: 9) } + if self.mapReportingEnabled != false { + try visitor.visitSingularBoolField(value: self.mapReportingEnabled, fieldNumber: 10) + } + try { if let v = self._mapReportSettings { + try visitor.visitSingularMessageField(value: v, fieldNumber: 11) + } }() try unknownFields.traverse(visitor: &visitor) } @@ -1581,6 +1633,46 @@ extension ModuleConfig.MQTTConfig: SwiftProtobuf.Message, SwiftProtobuf._Message if lhs.tlsEnabled != rhs.tlsEnabled {return false} if lhs.root != rhs.root {return false} if lhs.proxyToClientEnabled != rhs.proxyToClientEnabled {return false} + if lhs.mapReportingEnabled != rhs.mapReportingEnabled {return false} + if lhs._mapReportSettings != rhs._mapReportSettings {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension ModuleConfig.MapReportSettings: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = ModuleConfig.protoMessageName + ".MapReportSettings" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "publish_interval_secs"), + 2: .standard(proto: "position_precision"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularUInt32Field(value: &self.publishIntervalSecs) }() + case 2: try { try decoder.decodeSingularUInt32Field(value: &self.positionPrecision) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if self.publishIntervalSecs != 0 { + try visitor.visitSingularUInt32Field(value: self.publishIntervalSecs, fieldNumber: 1) + } + if self.positionPrecision != 0 { + try visitor.visitSingularUInt32Field(value: self.positionPrecision, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: ModuleConfig.MapReportSettings, rhs: ModuleConfig.MapReportSettings) -> Bool { + if lhs.publishIntervalSecs != rhs.publishIntervalSecs {return false} + if lhs.positionPrecision != rhs.positionPrecision {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } diff --git a/Meshtastic/Protobufs/meshtastic/mqtt.pb.swift b/Meshtastic/Protobufs/meshtastic/mqtt.pb.swift index 73fe4c30..43000bd1 100644 --- a/Meshtastic/Protobufs/meshtastic/mqtt.pb.swift +++ b/Meshtastic/Protobufs/meshtastic/mqtt.pb.swift @@ -55,8 +55,75 @@ struct ServiceEnvelope { fileprivate var _packet: MeshPacket? = nil } +/// +/// Information about a node intended to be reported unencrypted to a map using MQTT. +struct MapReport { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// + /// A full name for this user, i.e. "Kevin Hester" + var longName: String = String() + + /// + /// A VERY short name, ideally two characters. + /// Suitable for a tiny OLED screen + var shortName: String = String() + + /// + /// Role of the node that applies specific settings for a particular use-case + var role: Config.DeviceConfig.Role = .client + + /// + /// Hardware model of the node, i.e. T-Beam, Heltec V3, etc... + var hwModel: HardwareModel = .unset + + /// + /// Device firmware version string + var firmwareVersion: String = String() + + /// + /// The region code for the radio (US, CN, EU433, etc...) + var region: Config.LoRaConfig.RegionCode = .unset + + /// + /// Modem preset used by the radio (LongFast, MediumSlow, etc...) + var modemPreset: Config.LoRaConfig.ModemPreset = .longFast + + /// + /// Whether the node has a channel with default PSK and name (LongFast, MediumSlow, etc...) + /// and it uses the default frequency slot given the region and modem preset. + var hasDefaultChannel_p: Bool = false + + /// + /// Latitude: multiply by 1e-7 to get degrees in floating point + var latitudeI: Int32 = 0 + + /// + /// Longitude: multiply by 1e-7 to get degrees in floating point + var longitudeI: Int32 = 0 + + /// + /// Altitude in meters above MSL + var altitude: Int32 = 0 + + /// + /// Indicates the bits of precision for latitude and longitude set by the sending node + var positionPrecision: UInt32 = 0 + + /// + /// Number of online nodes (heard in the last 2 hours) this node has in its list that were received locally (not via MQTT) + var numOnlineLocalNodes: UInt32 = 0 + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + #if swift(>=5.5) && canImport(_Concurrency) extension ServiceEnvelope: @unchecked Sendable {} +extension MapReport: @unchecked Sendable {} #endif // swift(>=5.5) && canImport(_Concurrency) // MARK: - Code below here is support for the SwiftProtobuf runtime. @@ -110,3 +177,107 @@ extension ServiceEnvelope: SwiftProtobuf.Message, SwiftProtobuf._MessageImplemen return true } } + +extension MapReport: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".MapReport" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "long_name"), + 2: .standard(proto: "short_name"), + 3: .same(proto: "role"), + 4: .standard(proto: "hw_model"), + 5: .standard(proto: "firmware_version"), + 6: .same(proto: "region"), + 7: .standard(proto: "modem_preset"), + 8: .standard(proto: "has_default_channel"), + 9: .standard(proto: "latitude_i"), + 10: .standard(proto: "longitude_i"), + 11: .same(proto: "altitude"), + 12: .standard(proto: "position_precision"), + 13: .standard(proto: "num_online_local_nodes"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.longName) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.shortName) }() + case 3: try { try decoder.decodeSingularEnumField(value: &self.role) }() + case 4: try { try decoder.decodeSingularEnumField(value: &self.hwModel) }() + case 5: try { try decoder.decodeSingularStringField(value: &self.firmwareVersion) }() + case 6: try { try decoder.decodeSingularEnumField(value: &self.region) }() + case 7: try { try decoder.decodeSingularEnumField(value: &self.modemPreset) }() + case 8: try { try decoder.decodeSingularBoolField(value: &self.hasDefaultChannel_p) }() + case 9: try { try decoder.decodeSingularSFixed32Field(value: &self.latitudeI) }() + case 10: try { try decoder.decodeSingularSFixed32Field(value: &self.longitudeI) }() + case 11: try { try decoder.decodeSingularInt32Field(value: &self.altitude) }() + case 12: try { try decoder.decodeSingularUInt32Field(value: &self.positionPrecision) }() + case 13: try { try decoder.decodeSingularUInt32Field(value: &self.numOnlineLocalNodes) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if !self.longName.isEmpty { + try visitor.visitSingularStringField(value: self.longName, fieldNumber: 1) + } + if !self.shortName.isEmpty { + try visitor.visitSingularStringField(value: self.shortName, fieldNumber: 2) + } + if self.role != .client { + try visitor.visitSingularEnumField(value: self.role, fieldNumber: 3) + } + if self.hwModel != .unset { + try visitor.visitSingularEnumField(value: self.hwModel, fieldNumber: 4) + } + if !self.firmwareVersion.isEmpty { + try visitor.visitSingularStringField(value: self.firmwareVersion, fieldNumber: 5) + } + if self.region != .unset { + try visitor.visitSingularEnumField(value: self.region, fieldNumber: 6) + } + if self.modemPreset != .longFast { + try visitor.visitSingularEnumField(value: self.modemPreset, fieldNumber: 7) + } + if self.hasDefaultChannel_p != false { + try visitor.visitSingularBoolField(value: self.hasDefaultChannel_p, fieldNumber: 8) + } + if self.latitudeI != 0 { + try visitor.visitSingularSFixed32Field(value: self.latitudeI, fieldNumber: 9) + } + if self.longitudeI != 0 { + try visitor.visitSingularSFixed32Field(value: self.longitudeI, fieldNumber: 10) + } + if self.altitude != 0 { + try visitor.visitSingularInt32Field(value: self.altitude, fieldNumber: 11) + } + if self.positionPrecision != 0 { + try visitor.visitSingularUInt32Field(value: self.positionPrecision, fieldNumber: 12) + } + if self.numOnlineLocalNodes != 0 { + try visitor.visitSingularUInt32Field(value: self.numOnlineLocalNodes, fieldNumber: 13) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: MapReport, rhs: MapReport) -> Bool { + if lhs.longName != rhs.longName {return false} + if lhs.shortName != rhs.shortName {return false} + if lhs.role != rhs.role {return false} + if lhs.hwModel != rhs.hwModel {return false} + if lhs.firmwareVersion != rhs.firmwareVersion {return false} + if lhs.region != rhs.region {return false} + if lhs.modemPreset != rhs.modemPreset {return false} + if lhs.hasDefaultChannel_p != rhs.hasDefaultChannel_p {return false} + if lhs.latitudeI != rhs.latitudeI {return false} + if lhs.longitudeI != rhs.longitudeI {return false} + if lhs.altitude != rhs.altitude {return false} + if lhs.positionPrecision != rhs.positionPrecision {return false} + if lhs.numOnlineLocalNodes != rhs.numOnlineLocalNodes {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/Meshtastic/Protobufs/meshtastic/portnums.pb.swift b/Meshtastic/Protobufs/meshtastic/portnums.pb.swift index 937ff635..c8948d7d 100644 --- a/Meshtastic/Protobufs/meshtastic/portnums.pb.swift +++ b/Meshtastic/Protobufs/meshtastic/portnums.pb.swift @@ -181,6 +181,10 @@ enum PortNum: SwiftProtobuf.Enum { /// Portnum for payloads from the official Meshtastic ATAK plugin case atakPlugin // = 72 + /// + /// Provides unencrypted information about a node for consumption by a map via MQTT + case mapReportApp // = 73 + /// /// Private applications should use portnums >= 256. /// To simplify initial development and testing you can use "PRIVATE_APP" @@ -226,6 +230,7 @@ enum PortNum: SwiftProtobuf.Enum { case 70: self = .tracerouteApp case 71: self = .neighborinfoApp case 72: self = .atakPlugin + case 73: self = .mapReportApp case 256: self = .privateApp case 257: self = .atakForwarder case 511: self = .max @@ -258,6 +263,7 @@ enum PortNum: SwiftProtobuf.Enum { case .tracerouteApp: return 70 case .neighborinfoApp: return 71 case .atakPlugin: return 72 + case .mapReportApp: return 73 case .privateApp: return 256 case .atakForwarder: return 257 case .max: return 511 @@ -295,6 +301,7 @@ extension PortNum: CaseIterable { .tracerouteApp, .neighborinfoApp, .atakPlugin, + .mapReportApp, .privateApp, .atakForwarder, .max, @@ -334,6 +341,7 @@ extension PortNum: SwiftProtobuf._ProtoNameProviding { 70: .same(proto: "TRACEROUTE_APP"), 71: .same(proto: "NEIGHBORINFO_APP"), 72: .same(proto: "ATAK_PLUGIN"), + 73: .same(proto: "MAP_REPORT_APP"), 256: .same(proto: "PRIVATE_APP"), 257: .same(proto: "ATAK_FORWARDER"), 511: .same(proto: "MAX"), diff --git a/Meshtastic/Views/Nodes/DeviceMetricsLog.swift b/Meshtastic/Views/Nodes/DeviceMetricsLog.swift index e1e87b6a..38ce2e1b 100644 --- a/Meshtastic/Views/Nodes/DeviceMetricsLog.swift +++ b/Meshtastic/Views/Nodes/DeviceMetricsLog.swift @@ -43,7 +43,7 @@ struct DeviceMetricsLog: View { .accessibilityLabel("Line Series") .accessibilityValue("X: \(point.time!), Y: \(point.batteryLevel)") .foregroundStyle(batteryChartColor) - .interpolationMethod(.cardinal) + .interpolationMethod(.linear) Plot { PointMark( diff --git a/Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift b/Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift index 2ce168ac..97a7225a 100644 --- a/Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift +++ b/Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift @@ -166,8 +166,8 @@ struct MQTTConfig: View { .onChange(of: root, perform: { _ in let totalBytes = root.utf8.count // Only mess with the value if it is too big - if totalBytes > 15 { - let firstNBytes = Data(root.utf8.prefix(15)) + if totalBytes > 30 { + let firstNBytes = Data(root.utf8.prefix(30)) if let maxBytesString = String(data: firstNBytes, encoding: String.Encoding.utf8) { // Set the shortName back to the last place where it was the right size root = maxBytesString diff --git a/protobufs b/protobufs index 5a97acb1..7e3ee8cd 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 5a97acb17543a10e114675a205e3274a83e721af +Subproject commit 7e3ee8cd96740910d0611433cb9a05a7a692568c From d84f2ad91a63b135df9e2ff52072b0579567fafb Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Thu, 14 Mar 2024 00:04:35 -0700 Subject: [PATCH 27/74] Add power telemetry config. --- Meshtastic.xcodeproj/project.pbxproj | 4 +- Meshtastic/Helpers/BLEManager.swift | 3 + .../Meshtastic.xcdatamodeld/.xccurrentversion | 2 +- .../contents | 452 ++++++++++++++++++ Meshtastic/Persistence/UpdateCoreData.swift | 6 + .../Config/Module/TelemetryConfig.swift | 57 ++- 6 files changed, 520 insertions(+), 4 deletions(-) create mode 100644 Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 30.xcdatamodel/contents diff --git a/Meshtastic.xcodeproj/project.pbxproj b/Meshtastic.xcodeproj/project.pbxproj index 2bb892bb..4dac1356 100644 --- a/Meshtastic.xcodeproj/project.pbxproj +++ b/Meshtastic.xcodeproj/project.pbxproj @@ -370,6 +370,7 @@ DD97E96528EFD9820056DDA4 /* MeshtasticLogo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MeshtasticLogo.swift; sourceTree = ""; }; DD97E96728EFE9A00056DDA4 /* About.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = About.swift; sourceTree = ""; }; DD994B68295F88B60013760A /* IntervalEnums.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IntervalEnums.swift; sourceTree = ""; }; + DD9A1A912BA2D2D3001E602E /* MeshtasticDataModelV 30.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "MeshtasticDataModelV 30.xcdatamodel"; sourceTree = ""; }; DDA0B6B1294CDC55001356EC /* Channels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Channels.swift; sourceTree = ""; }; DDA1C48D28DB49D3009933EC /* ChannelRoles.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChannelRoles.swift; sourceTree = ""; }; DDA6B2E828419CF2003E8C16 /* MeshPackets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MeshPackets.swift; sourceTree = ""; }; @@ -1884,6 +1885,7 @@ DD3CC6BA28E366DF00FA9159 /* Meshtastic.xcdatamodeld */ = { isa = XCVersionGroup; children = ( + DD9A1A912BA2D2D3001E602E /* MeshtasticDataModelV 30.xcdatamodel */, DD398EBD2B93F640002B4C51 /* MeshtasticDataModelV 29.xcdatamodel */, DD0E20FF2B892E1300F2D100 /* MeshtasticDataModelV 28.xcdatamodel */, D93069062B81D8900066FBC8 /* MeshtasticDataModelV 27.xcdatamodel */, @@ -1914,7 +1916,7 @@ DD5D0A9A2931AD6B00F7EA61 /* MeshtasticDataModelV2.xcdatamodel */, DD3CC6BB28E366DF00FA9159 /* MeshtasticDataModel.xcdatamodel */, ); - currentVersion = DD398EBD2B93F640002B4C51 /* MeshtasticDataModelV 29.xcdatamodel */; + currentVersion = DD9A1A912BA2D2D3001E602E /* MeshtasticDataModelV 30.xcdatamodel */; name = Meshtastic.xcdatamodeld; path = Meshtastic/Meshtastic.xcdatamodeld; sourceTree = ""; diff --git a/Meshtastic/Helpers/BLEManager.swift b/Meshtastic/Helpers/BLEManager.swift index 5d85d325..980e2870 100644 --- a/Meshtastic/Helpers/BLEManager.swift +++ b/Meshtastic/Helpers/BLEManager.swift @@ -710,12 +710,15 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate } case .paxcounterApp: paxCounterPacket(packet: decodedInfo.packet, context: context!) + case .mapReportApp: + MeshLogger.log("🕸️ MESH PACKET received for Map Report App UNHANDLED\(try! decodedInfo.packet.jsonString())") case .UNRECOGNIZED: MeshLogger.log("🕸️ MESH PACKET received for Other App UNHANDLED \(try! decodedInfo.packet.jsonString())") case .max: print("MAX PORT NUM OF 511") case .atakPlugin: MeshLogger.log("🕸️ MESH PACKET received for ATAK Plugin App UNHANDLED \((try? decodedInfo.packet.jsonString()) ?? "JSON Decode Failure")") + } if decodedInfo.configCompleteID != 0 && decodedInfo.configCompleteID == configNonce { diff --git a/Meshtastic/Meshtastic.xcdatamodeld/.xccurrentversion b/Meshtastic/Meshtastic.xcdatamodeld/.xccurrentversion index a647b881..e8a31698 100644 --- a/Meshtastic/Meshtastic.xcdatamodeld/.xccurrentversion +++ b/Meshtastic/Meshtastic.xcdatamodeld/.xccurrentversion @@ -3,6 +3,6 @@ _XCCurrentVersionName - MeshtasticDataModelV 29.xcdatamodel + MeshtasticDataModelV 30.xcdatamodel diff --git a/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 30.xcdatamodel/contents b/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 30.xcdatamodel/contents new file mode 100644 index 00000000..733896d1 --- /dev/null +++ b/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 30.xcdatamodel/contents @@ -0,0 +1,452 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Meshtastic/Persistence/UpdateCoreData.swift b/Meshtastic/Persistence/UpdateCoreData.swift index cdd0d91e..ee6ceac7 100644 --- a/Meshtastic/Persistence/UpdateCoreData.swift +++ b/Meshtastic/Persistence/UpdateCoreData.swift @@ -1317,6 +1317,9 @@ func upsertTelemetryModuleConfigPacket(config: Meshtastic.ModuleConfig.Telemetry newTelemetryConfig.environmentMeasurementEnabled = config.environmentMeasurementEnabled newTelemetryConfig.environmentScreenEnabled = config.environmentScreenEnabled newTelemetryConfig.environmentDisplayFahrenheit = config.environmentDisplayFahrenheit + newTelemetryConfig.powerMeasurementEnabled = config.powerMeasurementEnabled + newTelemetryConfig.powerUpdateInterval = Int32(config.powerUpdateInterval) + newTelemetryConfig.powerScreenEnabled = config.powerScreenEnabled fetchedNode[0].telemetryConfig = newTelemetryConfig } else { @@ -1325,6 +1328,9 @@ func upsertTelemetryModuleConfigPacket(config: Meshtastic.ModuleConfig.Telemetry fetchedNode[0].telemetryConfig?.environmentMeasurementEnabled = config.environmentMeasurementEnabled fetchedNode[0].telemetryConfig?.environmentScreenEnabled = config.environmentScreenEnabled fetchedNode[0].telemetryConfig?.environmentDisplayFahrenheit = config.environmentDisplayFahrenheit + fetchedNode[0].telemetryConfig?.powerMeasurementEnabled = config.powerMeasurementEnabled + fetchedNode[0].telemetryConfig?.powerUpdateInterval = Int32(config.powerUpdateInterval) + fetchedNode[0].telemetryConfig?.powerScreenEnabled = config.powerScreenEnabled } do { diff --git a/Meshtastic/Views/Settings/Config/Module/TelemetryConfig.swift b/Meshtastic/Views/Settings/Config/Module/TelemetryConfig.swift index c90be6da..48cb9b26 100644 --- a/Meshtastic/Views/Settings/Config/Module/TelemetryConfig.swift +++ b/Meshtastic/Views/Settings/Config/Module/TelemetryConfig.swift @@ -21,6 +21,10 @@ struct TelemetryConfig: View { @State var environmentMeasurementEnabled = false @State var environmentScreenEnabled = false @State var environmentDisplayFahrenheit = false + @State var powerMeasurementEnabled = false + @State var powerUpdateInterval = 0 + @State var powerScreenEnabled = false + var body: some View { VStack { @@ -30,7 +34,9 @@ struct TelemetryConfig: View { Section(header: Text("update.interval")) { Picker("Device Metrics", selection: $deviceUpdateInterval ) { ForEach(UpdateIntervals.allCases) { ui in - Text(ui.description) + if ui.rawValue >= 900 { + Text(ui.description) + } } } .pickerStyle(DefaultPickerStyle()) @@ -41,7 +47,9 @@ struct TelemetryConfig: View { .listRowSeparator(.visible) Picker("Sensor Metrics", selection: $environmentUpdateInterval ) { ForEach(UpdateIntervals.allCases) { ui in - Text(ui.description) + if ui.rawValue >= 900 { + Text(ui.description) + } } } .pickerStyle(DefaultPickerStyle()) @@ -67,6 +75,30 @@ struct TelemetryConfig: View { } .toggleStyle(SwitchToggleStyle(tint: .accentColor)) } + Section(header: Text("Power Options")) { + Toggle(isOn: $powerMeasurementEnabled) { + Label("enabled", systemImage: "bolt") + } + .toggleStyle(SwitchToggleStyle(tint: .accentColor)) + .listRowSeparator(.visible) + Picker("Power Metrics", selection: $powerUpdateInterval ) { + ForEach(UpdateIntervals.allCases) { ui in + if ui.rawValue >= 900 { + Text(ui.description) + } + } + } + .pickerStyle(DefaultPickerStyle()) + .listRowSeparator(.hidden) + Text("How often power metrics are sent out over the mesh. Default is 15 minutes.") + .foregroundColor(.gray) + .font(.callout) + .listRowSeparator(.visible) + Toggle(isOn: $powerScreenEnabled) { + Label("Power Screen", systemImage: "tv") + } + .toggleStyle(SwitchToggleStyle(tint: .accentColor)) + } } .disabled(self.bleManager.connectedPeripheral == nil || node?.telemetryConfig == nil) @@ -79,6 +111,9 @@ struct TelemetryConfig: View { tc.environmentMeasurementEnabled = environmentMeasurementEnabled tc.environmentScreenEnabled = environmentScreenEnabled tc.environmentDisplayFahrenheit = environmentDisplayFahrenheit + tc.powerMeasurementEnabled = powerMeasurementEnabled + tc.powerUpdateInterval = UInt32(powerUpdateInterval) + tc.powerScreenEnabled = powerScreenEnabled let adminMessageId = bleManager.saveTelemetryModuleConfig(config: tc, fromUser: connectedNode!.user!, toUser: node!.user!, adminIndex: connectedNode?.myInfo?.adminIndex ?? 0) if adminMessageId > 0 { // Should show a saved successfully alert once I know that to be true @@ -132,6 +167,21 @@ struct TelemetryConfig: View { if newEnvDisplayF != node!.telemetryConfig!.environmentDisplayFahrenheit { hasChanges = true } } } + .onChange(of: powerMeasurementEnabled) { newPowerMeasurementEnabled in + if node != nil && node?.telemetryConfig != nil { + if newPowerMeasurementEnabled != node!.telemetryConfig!.powerMeasurementEnabled { hasChanges = true } + } + } + .onChange(of: powerUpdateInterval) { newPowerUpdateInterval in + if node != nil && node?.telemetryConfig != nil { + if newPowerUpdateInterval != node!.telemetryConfig!.powerUpdateInterval { hasChanges = true } + } + } + .onChange(of: powerScreenEnabled) { newPowerScreenEnabled in + if node != nil && node?.telemetryConfig != nil { + if newPowerScreenEnabled != node!.telemetryConfig!.powerScreenEnabled { hasChanges = true } + } + } } } func setTelemetryValues() { @@ -140,6 +190,9 @@ struct TelemetryConfig: View { self.environmentMeasurementEnabled = node?.telemetryConfig?.environmentMeasurementEnabled ?? false self.environmentScreenEnabled = node?.telemetryConfig?.environmentScreenEnabled ?? false self.environmentDisplayFahrenheit = node?.telemetryConfig?.environmentDisplayFahrenheit ?? false + self.powerMeasurementEnabled = node?.telemetryConfig?.powerMeasurementEnabled ?? false + self.powerUpdateInterval = Int(node?.telemetryConfig?.powerUpdateInterval ?? 0) + self.powerScreenEnabled = node?.telemetryConfig?.powerScreenEnabled ?? false self.hasChanges = false } } From 676662bb4f9a19c1e7c6d0896b9ab47d7bdec06b Mon Sep 17 00:00:00 2001 From: Wolfgang Nagele Date: Thu, 14 Mar 2024 20:37:27 +0100 Subject: [PATCH 28/74] Drop filtering of 101% --- Meshtastic/Views/Nodes/DeviceMetricsLog.swift | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/Meshtastic/Views/Nodes/DeviceMetricsLog.swift b/Meshtastic/Views/Nodes/DeviceMetricsLog.swift index 269b3020..2c5fe248 100644 --- a/Meshtastic/Views/Nodes/DeviceMetricsLog.swift +++ b/Meshtastic/Views/Nodes/DeviceMetricsLog.swift @@ -34,18 +34,16 @@ struct DeviceMetricsLog: View { Chart { ForEach(chartData, id: \.self) { point in - if point.batteryLevel != 101 { // Filter out magic charging value - Plot { - LineMark( - x: .value("x", point.time!), - y: .value("y", point.batteryLevel) - ) - } - .accessibilityLabel("Line Series") - .accessibilityValue("X: \(point.time!), Y: \(point.batteryLevel)") - .foregroundStyle(batteryChartColor) - .interpolationMethod(.linear) + Plot { + LineMark( + x: .value("x", point.time!), + y: .value("y", point.batteryLevel) + ) } + .accessibilityLabel("Line Series") + .accessibilityValue("X: \(point.time!), Y: \(point.batteryLevel)") + .foregroundStyle(batteryChartColor) + .interpolationMethod(.linear) Plot { PointMark( From d5f5d7036411410635e29a9483cefb12524fea8d Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Thu, 14 Mar 2024 18:58:05 -0700 Subject: [PATCH 29/74] Start work to fix the broken node map view Tidy up suggested mqtt topics --- Meshtastic/Enums/LoraConfigEnums.swift | 42 +++- .../Nodes/Helpers/Map/NodeMapSwiftUI.swift | 198 +++++++++--------- .../Settings/Config/Module/MQTTConfig.swift | 20 +- .../Config/Module/TelemetryConfig.swift | 6 +- 4 files changed, 151 insertions(+), 115 deletions(-) diff --git a/Meshtastic/Enums/LoraConfigEnums.swift b/Meshtastic/Enums/LoraConfigEnums.swift index 53084e54..781661c6 100644 --- a/Meshtastic/Enums/LoraConfigEnums.swift +++ b/Meshtastic/Enums/LoraConfigEnums.swift @@ -28,7 +28,47 @@ enum RegionCodes: Int, CaseIterable, Identifiable { case my_919 = 17 case sg_923 = 18 case lora24 = 13 - + var topic: String { + switch self { + case .unset: + "UNSET" + case .us: + "US" + case .eu433: + "EU_433" + case .eu868: + "EU_868" + case .cn: + "CN" + case .jp: + "JP" + case .anz: + "ANZ" + case .kr: + "KR" + case .tw: + "TW" + case .ru: + "RU" + case .in: + "IN" + case .nz865: + "NZ_865" + case .th: + "TH" + case .ua433: + "UA_433" + case .ua868: + "UA_868" + case .my_433: + "MY_433" + case .my_919: + "MY_919" + case .sg_923: + "SG_923" + case .lora24: + "LORA_24" + } } var id: Int { self.rawValue } var description: String { switch self { diff --git a/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift b/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift index 3511cfdb..91ca6db4 100644 --- a/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift +++ b/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift @@ -10,7 +10,6 @@ import CoreLocation #if canImport(MapKit) import MapKit #endif -import WeatherKit @available(iOS 17.0, macOS 14.0, *) struct NodeMapSwiftUI: View { @@ -60,6 +59,15 @@ struct NodeMapSwiftUI: View { Map(position: $position, bounds: MapCameraBounds(minimumDistance: 1, maximumDistance: .infinity), scope: mapScope) { /// Node Color from node.num let nodeColor = UIColor(hex: UInt32(node.num)) + /// Convex Hull + if showConvexHull { + if lineCoords.count > 0 { + let hull = lineCoords.getConvexHull() + MapPolygon(coordinates: hull) + .stroke(Color(nodeColor.darker()), lineWidth: 3) + .foregroundStyle(Color(nodeColor).opacity(0.4)) + } + } /// Route Lines if showRouteLines { let gradient = LinearGradient( @@ -73,114 +81,96 @@ struct NodeMapSwiftUI: View { MapPolyline(coordinates: lineCoords) .stroke(gradient, style: dashed) } - /// Convex Hull - if showConvexHull { - if lineCoords.count > 0 { - let hull = lineCoords.getConvexHull() - MapPolygon(coordinates: hull) - .stroke(Color(nodeColor.darker()), lineWidth: 3) - .foregroundStyle(Color(nodeColor).opacity(0.4)) - } - } - - /// Waypoint Annotations - if waypoints.count > 0 && showWaypoints { - ForEach(Array(waypoints), id: \.id) { waypoint in - Annotation(waypoint.name ?? "?", coordinate: waypoint.coordinate) { - LazyVStack { - CircleText(text: String(UnicodeScalar(Int(waypoint.icon)) ?? "📍"), color: Color.orange, circleSize: 35) - .onTapGesture(coordinateSpace: .named("nodemap")) { location in - selectedWaypoint = (selectedWaypoint == waypoint ? nil : waypoint) - } - } - } - } - } + + + /// Node Annotations ForEach(positionArray, id: \.id) { position in let pf = PositionFlags(rawValue: Int(position.nodePosition?.metadata?.positionFlags ?? 771)) let headingDegrees = Angle.degrees(Double(position.heading)) - /// Reduced Precision Map Circle - if position.latest && 11...16 ~= position.precisionBits { - let pp = PositionPrecision(rawValue: Int(position.precisionBits)) - let radius : CLLocationDistance = pp?.precisionMeters ?? 0 - if radius > 0.0 { - MapCircle(center: position.coordinate, radius: radius) - .foregroundStyle(Color(nodeColor).opacity(0.25)) - .stroke(.white, lineWidth: 2) +// /// Reduced Precision Map Circle +// if position.latest && 11...16 ~= position.precisionBits { +// let pp = PositionPrecision(rawValue: Int(position.precisionBits)) +// let radius : CLLocationDistance = pp?.precisionMeters ?? 0 +// if radius > 0.0 { +// MapCircle(center: position.coordinate, radius: radius) +// .foregroundStyle(Color(nodeColor).opacity(0.25)) +// .stroke(.white, lineWidth: 2) +// } +// } +// Annotation(position.latest ? node.user?.shortName ?? "?": "", coordinate: position.coordinate) { +// LazyVStack { +// if position.latest { +// ZStack { +// Circle() +// .fill(Color(nodeColor.lighter()).opacity(0.4).shadow(.drop(color: Color(nodeColor).isLight() ? .black : .white, radius: 5))) +// .foregroundStyle(Color(nodeColor.lighter()).opacity(0.3)) +// .frame(width: 50, height: 50) +// if pf.contains(.Heading) { +// Image(systemName: pf.contains(.Speed) && position.speed > 1 ? "location.north" : "octagon") +// .symbolEffect(.pulse.byLayer) +// .padding(5) +// .foregroundStyle(Color(nodeColor).isLight() ? .black : .white) +// .background(Color(nodeColor.darker())) +// .clipShape(Circle()) +// .rotationEffect(headingDegrees) +// .onTapGesture { +// selectedPosition = (selectedPosition == position ? nil : position) +// } +// .popover(item: $selectedPosition) { selection in +// PositionPopover(position: selection) +// .padding() +// .opacity(0.8) +// .presentationCompactAdaptation(.popover) +// } +// +// } else { +// Image(systemName: "flipphone") +// .symbolEffect(.pulse.byLayer) +// .padding(5) +// .foregroundStyle(Color(nodeColor).isLight() ? .black : .white) +// .background(Color(UIColor(hex: UInt32(node.num)).darker())) +// .clipShape(Circle()) +// .onTapGesture { +// selectedPosition = (selectedPosition == position ? nil : position) +// } +// .popover(item: $selectedPosition) { selection in +// PositionPopover(position: selection) +// .padding() +// .opacity(0.8) +// .presentationCompactAdaptation(.popover) +// } +// +// } +// } +// } else { +// if showNodeHistory { +// if pf.contains(.Heading) { +// Image(systemName: "location.north.circle") +// .resizable() +// .scaledToFit() +// .foregroundStyle(Color(UIColor(hex: UInt32(node.num))).isLight() ? .black : .white) +// .background(Color(UIColor(hex: UInt32(node.num)))) +// .clipShape(Circle()) +// .rotationEffect(headingDegrees) +// .frame(width: 16, height: 16) +// +// } else { +// Circle() +// .fill(Color(UIColor(hex: UInt32(node.num)))) +// .strokeBorder(Color(UIColor(hex: UInt32(node.num))).isLight() ? .black : .white ,lineWidth: 2) +// .frame(width: 12, height: 12) +// } +// } +// } + + } - } - Annotation(position.latest ? node.user?.shortName ?? "?": "", coordinate: position.coordinate) { - LazyVStack { - if position.latest { - ZStack { - Circle() - .fill(Color(nodeColor.lighter()).opacity(0.4).shadow(.drop(color: Color(nodeColor).isLight() ? .black : .white, radius: 5))) - .foregroundStyle(Color(nodeColor.lighter()).opacity(0.3)) - .frame(width: 50, height: 50) - if pf.contains(.Heading) { - Image(systemName: pf.contains(.Speed) && position.speed > 1 ? "location.north" : "octagon") - .symbolEffect(.pulse.byLayer) - .padding(5) - .foregroundStyle(Color(nodeColor).isLight() ? .black : .white) - .background(Color(nodeColor.darker())) - .clipShape(Circle()) - .rotationEffect(headingDegrees) - .onTapGesture { - selectedPosition = (selectedPosition == position ? nil : position) - } - .popover(item: $selectedPosition) { selection in - PositionPopover(position: selection) - .padding() - .opacity(0.8) - .presentationCompactAdaptation(.popover) - } - - } else { - Image(systemName: "flipphone") - .symbolEffect(.pulse.byLayer) - .padding(5) - .foregroundStyle(Color(nodeColor).isLight() ? .black : .white) - .background(Color(UIColor(hex: UInt32(node.num)).darker())) - .clipShape(Circle()) - .onTapGesture { - selectedPosition = (selectedPosition == position ? nil : position) - } - .popover(item: $selectedPosition) { selection in - PositionPopover(position: selection) - .padding() - .opacity(0.8) - .presentationCompactAdaptation(.popover) - } - - } - } - } else { - if showNodeHistory { - if pf.contains(.Heading) { - Image(systemName: "location.north.circle") - .resizable() - .scaledToFit() - .foregroundStyle(Color(UIColor(hex: UInt32(node.num))).isLight() ? .black : .white) - .background(Color(UIColor(hex: UInt32(node.num)))) - .clipShape(Circle()) - .rotationEffect(headingDegrees) - .frame(width: 16, height: 16) - - } else { - Circle() - .fill(Color(UIColor(hex: UInt32(node.num)))) - .strokeBorder(Color(UIColor(hex: UInt32(node.num))).isLight() ? .black : .white ,lineWidth: 2) - .frame(width: 12, height: 12) - } - } - } - } - } - .tag(position.time) - .annotationTitles(.automatic) - .annotationSubtitles(.automatic) - } +// } +// .tag(position.time) +// .annotationTitles(.automatic) +// .annotationSubtitles(.automatic) +// } } .mapScope(mapScope) .mapStyle(mapStyle) diff --git a/Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift b/Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift index 97a7225a..3d228ad3 100644 --- a/Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift +++ b/Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift @@ -26,7 +26,9 @@ struct MQTTConfig: View { @State var root = "msh" @State var selectedTopic = "" @State var mqttConnected: Bool = false + @State var defaultTopic = "msh/US" @State var nearbyTopics = [String]() + let locale = Locale.current var body: some View { VStack { @@ -315,6 +317,8 @@ struct MQTTConfig: View { nearbyTopics = [] let geocoder = CLGeocoder() if LocationsHandler.shared.locationsArray.count > 0 { + let region = RegionCodes(rawValue: Int(node?.loRaConfig?.regionCode ?? 0))?.topic + defaultTopic = "msh/" + (region ?? "UNSET") geocoder.reverseGeocodeLocation(LocationsHandler.shared.locationsArray.first!, completionHandler: {(placemarks, error) -> Void in if error != nil { print("Failed to reverse geocode location") @@ -322,27 +326,29 @@ struct MQTTConfig: View { } if let placemarks = placemarks, let placemark = placemarks.first { - + let cc = locale.region?.identifier ?? "UNK" /// Country Topic unless you are US - if placemark.isoCountryCode ?? "unknown" != "US" { - let countryTopic = root + "/" + (placemark.isoCountryCode ?? "") + if placemark.isoCountryCode ?? "unknown" != cc { + let countryTopic = defaultTopic + "/" + (placemark.isoCountryCode ?? "") if !countryTopic.isEmpty { nearbyTopics.append(countryTopic) } } - let stateTopic = root + "/" + (placemark.administrativeArea ?? "") + let stateTopic = defaultTopic + "/" + (placemark.administrativeArea ?? "") if !stateTopic.isEmpty { nearbyTopics.append(stateTopic) } - let countyTopic = root + "/" + (placemark.subAdministrativeArea?.lowercased().replacingOccurrences(of: " ", with: "") ?? "") + let countyTopic = defaultTopic + "/" + (placemark.subAdministrativeArea?.lowercased().replacingOccurrences(of: " ", with: "") ?? "") if !countyTopic.isEmpty { nearbyTopics.append(countyTopic) } - let cityTopic = root + "/" + (placemark.locality?.lowercased().replacingOccurrences(of: " ", with: "") ?? "") + let cityTopic = defaultTopic + "/" + (placemark.locality?.lowercased().replacingOccurrences(of: " ", with: "") ?? "") if !cityTopic.isEmpty { nearbyTopics.append(cityTopic) } - let neightborhoodTopic = root + "/" + (placemark.subLocality?.lowercased().replacingOccurrences(of: " ", with: "") ?? "") + let neightborhoodTopic = defaultTopic + "/" + (placemark.subLocality?.lowercased() + .replacingOccurrences(of: " ", with: "") + .replacingOccurrences(of: "'", with: "") ?? "") if !neightborhoodTopic.isEmpty { nearbyTopics.append(neightborhoodTopic) } diff --git a/Meshtastic/Views/Settings/Config/Module/TelemetryConfig.swift b/Meshtastic/Views/Settings/Config/Module/TelemetryConfig.swift index 48cb9b26..7483118b 100644 --- a/Meshtastic/Views/Settings/Config/Module/TelemetryConfig.swift +++ b/Meshtastic/Views/Settings/Config/Module/TelemetryConfig.swift @@ -185,13 +185,13 @@ struct TelemetryConfig: View { } } func setTelemetryValues() { - self.deviceUpdateInterval = Int(node?.telemetryConfig?.deviceUpdateInterval ?? 0) - self.environmentUpdateInterval = Int(node?.telemetryConfig?.environmentUpdateInterval ?? 0) + self.deviceUpdateInterval = Int(node?.telemetryConfig?.deviceUpdateInterval ?? 900) + self.environmentUpdateInterval = Int(node?.telemetryConfig?.environmentUpdateInterval ?? 900) self.environmentMeasurementEnabled = node?.telemetryConfig?.environmentMeasurementEnabled ?? false self.environmentScreenEnabled = node?.telemetryConfig?.environmentScreenEnabled ?? false self.environmentDisplayFahrenheit = node?.telemetryConfig?.environmentDisplayFahrenheit ?? false self.powerMeasurementEnabled = node?.telemetryConfig?.powerMeasurementEnabled ?? false - self.powerUpdateInterval = Int(node?.telemetryConfig?.powerUpdateInterval ?? 0) + self.powerUpdateInterval = Int(node?.telemetryConfig?.powerUpdateInterval ?? 900) self.powerScreenEnabled = node?.telemetryConfig?.powerScreenEnabled ?? false self.hasChanges = false } From 550add228c33fc33751151d81f90a7693aaa1b93 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Thu, 14 Mar 2024 23:05:05 -0700 Subject: [PATCH 30/74] Move node map into map content view Dont change channel for node infos directed at other nodes --- Meshtastic.xcodeproj/project.pbxproj | 4 + Meshtastic/Persistence/UpdateCoreData.swift | 9 +- .../Nodes/Helpers/Map/NodeMapContent.swift | 166 ++++++++++++++++++ .../Nodes/Helpers/Map/NodeMapSwiftUI.swift | 115 +----------- 4 files changed, 177 insertions(+), 117 deletions(-) create mode 100644 Meshtastic/Views/Nodes/Helpers/Map/NodeMapContent.swift diff --git a/Meshtastic.xcodeproj/project.pbxproj b/Meshtastic.xcodeproj/project.pbxproj index 4dac1356..6ae7e268 100644 --- a/Meshtastic.xcodeproj/project.pbxproj +++ b/Meshtastic.xcodeproj/project.pbxproj @@ -110,6 +110,7 @@ DD8ED9C8289CE4B900B3B0AB /* RoutingError.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD8ED9C7289CE4B900B3B0AB /* RoutingError.swift */; }; DD90860E26F69BAE00DC5189 /* NodeMap.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD90860D26F69BAE00DC5189 /* NodeMap.swift */; }; DD913639270DFF4C00D7ACF3 /* LocalNotificationManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD913638270DFF4C00D7ACF3 /* LocalNotificationManager.swift */; }; + DD93800B2BA3F968008BEC06 /* NodeMapContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD93800A2BA3F968008BEC06 /* NodeMapContent.swift */; }; DD94B7402ACCE3BE00DCD1D1 /* MapSettingsForm.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD94B73F2ACCE3BE00DCD1D1 /* MapSettingsForm.swift */; }; DD964FBD296E6B01007C176F /* EmojiOnlyTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD964FBC296E6B01007C176F /* EmojiOnlyTextField.swift */; }; DD964FBF296E76EF007C176F /* WaypointFormMapKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD964FBE296E76EF007C176F /* WaypointFormMapKit.swift */; }; @@ -360,6 +361,7 @@ DD90860A26F645B700DC5189 /* Meshtastic.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Meshtastic.entitlements; sourceTree = ""; }; DD90860D26F69BAE00DC5189 /* NodeMap.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NodeMap.swift; sourceTree = ""; }; DD913638270DFF4C00D7ACF3 /* LocalNotificationManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalNotificationManager.swift; sourceTree = ""; }; + DD93800A2BA3F968008BEC06 /* NodeMapContent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NodeMapContent.swift; sourceTree = ""; }; DD94B73F2ACCE3BE00DCD1D1 /* MapSettingsForm.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapSettingsForm.swift; sourceTree = ""; }; DD964FBC296E6B01007C176F /* EmojiOnlyTextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiOnlyTextField.swift; sourceTree = ""; }; DD964FBE296E76EF007C176F /* WaypointFormMapKit.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WaypointFormMapKit.swift; sourceTree = ""; }; @@ -748,6 +750,7 @@ DDAD49EB2AFAE82500B4425D /* Map */ = { isa = PBXGroup; children = ( + DD93800A2BA3F968008BEC06 /* NodeMapContent.swift */, DD94B73F2ACCE3BE00DCD1D1 /* MapSettingsForm.swift */, DDB6CCFA2AAF805100945AF6 /* NodeMapSwiftUI.swift */, DD13AA482AB73BF400BA0C98 /* PositionPopover.swift */, @@ -1365,6 +1368,7 @@ DD5E5205298EE33B00D21B61 /* mesh.pb.swift in Sources */, DDF6B2482A9AEBF500BA6931 /* StoreForwardConfig.swift in Sources */, DD8169F9271F1A6100F4AB02 /* MeshLogger.swift in Sources */, + DD93800B2BA3F968008BEC06 /* NodeMapContent.swift in Sources */, DD41582A28585C32009B0E59 /* RangeTestConfig.swift in Sources */, DD1925B728CDA5A400720036 /* CannedMessagesConfigEnums.swift in Sources */, DDDB444429F8A8DD00EE2349 /* Float.swift in Sources */, diff --git a/Meshtastic/Persistence/UpdateCoreData.swift b/Meshtastic/Persistence/UpdateCoreData.swift index ee6ceac7..121cab33 100644 --- a/Meshtastic/Persistence/UpdateCoreData.swift +++ b/Meshtastic/Persistence/UpdateCoreData.swift @@ -144,9 +144,10 @@ func upsertNodeInfoPacket (packet: MeshPacket, context: NSManagedObjectContext) newNode.snr = packet.rxSnr newNode.rssi = packet.rxRssi newNode.viaMqtt = packet.viaMqtt - newNode.channel = Int32(packet.channel) + if packet.to == 4294967295 || packet.to == UserDefaults.preferredPeripheralNum { + newNode.channel = Int32(packet.channel) + } if let nodeInfoMessage = try? NodeInfo(serializedData: packet.decoded.payload) { - newNode.channel = Int32(nodeInfoMessage.channel) newNode.hopsAway = Int32(truncatingIfNeeded: nodeInfoMessage.hopsAway) } if let newUserMessage = try? User(serializedData: packet.decoded.payload) { @@ -212,7 +213,9 @@ func upsertNodeInfoPacket (packet: MeshPacket, context: NSManagedObjectContext) fetchedNode[0].snr = packet.rxSnr fetchedNode[0].rssi = packet.rxRssi fetchedNode[0].viaMqtt = packet.viaMqtt - fetchedNode[0].channel = Int32(packet.channel) + if packet.to == 4294967295 || packet.to == UserDefaults.preferredPeripheralNum { + fetchedNode[0].channel = Int32(packet.channel) + } if let nodeInfoMessage = try? NodeInfo(serializedData: packet.decoded.payload) { fetchedNode[0].channel = Int32(nodeInfoMessage.channel) diff --git a/Meshtastic/Views/Nodes/Helpers/Map/NodeMapContent.swift b/Meshtastic/Views/Nodes/Helpers/Map/NodeMapContent.swift new file mode 100644 index 00000000..2c15e9de --- /dev/null +++ b/Meshtastic/Views/Nodes/Helpers/Map/NodeMapContent.swift @@ -0,0 +1,166 @@ +// +// RouteLines.swift +// Meshtastic +// +// Created by Garth Vander Houwen on 3/14/24. +// +import SwiftUI +import MapKit + +@available(iOS 17.0, macOS 14.0, *) +struct NodeMapContent: MapContent { + + @ObservedObject var node: NodeInfoEntity + @State var showUserLocation: Bool = false + @State var positions: [PositionEntity] = [] + /// Map State User Defaults + @AppStorage("meshMapShowNodeHistory") private var showNodeHistory = false + @AppStorage("meshMapShowRouteLines") private var showRouteLines = false + @AppStorage("enableMapConvexHull") private var showConvexHull = false + @AppStorage("enableMapTraffic") private var showTraffic: Bool = false + @AppStorage("enableMapPointsOfInterest") private var showPointsOfInterest: Bool = false + @AppStorage("mapLayer") private var selectedMapLayer: MapLayer = .hybrid + // Map Configuration + @Namespace var mapScope + @State var mapStyle: MapStyle = MapStyle.hybrid(elevation: .realistic, pointsOfInterest: .all, showsTraffic: true) + @State var position = MapCameraPosition.automatic + @State var scene: MKLookAroundScene? + @State var isLookingAround = false + @State var isShowingAltitude = false + @State var isEditingSettings = false + @State var selectedPosition: PositionEntity? + @State var showWaypoints = false + @State var selectedWaypoint: WaypointEntity? + @State var isMeshMap = false + + //let region: MKCoordinateRegion + + + @MapContentBuilder + var nodeMap: some MapContent { + let positionArray = node.positions?.array as? [PositionEntity] ?? [] + let lineCoords = positionArray.compactMap({(position) -> CLLocationCoordinate2D in + return position.nodeCoordinate ?? LocationsHandler.DefaultLocation + }) + /// Node Color from node.num + let nodeColor = UIColor(hex: UInt32(node.num)) + + + /// Node Annotations + ForEach(positionArray, id: \.id) { position in + let pf = PositionFlags(rawValue: Int(position.nodePosition?.metadata?.positionFlags ?? 771)) + let headingDegrees = Angle.degrees(Double(position.heading)) + /// Reduced Precision Map Circle + if position.latest && 11...16 ~= position.precisionBits { + let pp = PositionPrecision(rawValue: Int(position.precisionBits)) + let radius : CLLocationDistance = pp?.precisionMeters ?? 0 + if radius > 0.0 { + MapCircle(center: position.coordinate, radius: radius) + .foregroundStyle(Color(nodeColor).opacity(0.25)) + .stroke(.white, lineWidth: 2) + } + } + if showConvexHull { + if lineCoords.count > 0 { + let hull = lineCoords.getConvexHull() + MapPolygon(coordinates: hull) + .stroke(Color(nodeColor.darker()), lineWidth: 3) + .foregroundStyle(Color(nodeColor).opacity(0.4)) + } + } + /// Route Lines + if showRouteLines { + let gradient = LinearGradient( + colors: [Color(nodeColor.lighter().lighter().lighter()), Color(nodeColor.lighter()), Color(nodeColor)], + startPoint: .leading, endPoint: .trailing + ) + let dashed = StrokeStyle( + lineWidth: 3, + lineCap: .round, lineJoin: .round, dash: [10, 10] + ) + MapPolyline(coordinates: lineCoords) + .stroke(gradient, style: dashed) + } + + /// Node Annotations + ForEach(positionArray, id: \.id) { position in + Annotation(position.latest ? node.user?.shortName ?? "?": "", coordinate: position.coordinate) { + LazyVStack { + if position.latest { + ZStack { + Circle() + .fill(Color(nodeColor.lighter()).opacity(0.4).shadow(.drop(color: Color(nodeColor).isLight() ? .black : .white, radius: 5))) + .foregroundStyle(Color(nodeColor.lighter()).opacity(0.3)) + .frame(width: 50, height: 50) + if pf.contains(.Heading) { + Image(systemName: pf.contains(.Speed) && position.speed > 1 ? "location.north" : "octagon") + .symbolEffect(.pulse.byLayer) + .padding(5) + .foregroundStyle(Color(nodeColor).isLight() ? .black : .white) + .background(Color(nodeColor.darker())) + .clipShape(Circle()) + .rotationEffect(headingDegrees) + .onTapGesture { + selectedPosition = (selectedPosition == position ? nil : position) + } + .popover(item: $selectedPosition) { selection in + PositionPopover(position: selection) + .padding() + .opacity(0.8) + .presentationCompactAdaptation(.popover) + } + + } else { + Image(systemName: "flipphone") + .symbolEffect(.pulse.byLayer) + .padding(5) + .foregroundStyle(Color(nodeColor).isLight() ? .black : .white) + .background(Color(UIColor(hex: UInt32(node.num)).darker())) + .clipShape(Circle()) + .onTapGesture { + selectedPosition = (selectedPosition == position ? nil : position) + } + .popover(item: $selectedPosition) { selection in + PositionPopover(position: selection) + .padding() + .opacity(0.8) + .presentationCompactAdaptation(.popover) + } + } + } + } else { + if showNodeHistory { + if pf.contains(.Heading) { + Image(systemName: "location.north.circle") + .resizable() + .scaledToFit() + .foregroundStyle(Color(UIColor(hex: UInt32(node.num))).isLight() ? .black : .white) + .background(Color(UIColor(hex: UInt32(node.num)))) + .clipShape(Circle()) + .rotationEffect(headingDegrees) + .frame(width: 16, height: 16) + + } else { + Circle() + .fill(Color(UIColor(hex: UInt32(node.num)))) + .strokeBorder(Color(UIColor(hex: UInt32(node.num))).isLight() ? .black : .white ,lineWidth: 2) + .frame(width: 12, height: 12) + } + } + } + } + } + .tag(position.time) + .annotationTitles(.automatic) + .annotationSubtitles(.automatic) + } + } + } + + @MapContentBuilder + var body: some MapContent { + if node.positions?.count ?? 0 > 0 { + nodeMap + } + } +} diff --git a/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift b/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift index 91ca6db4..3b2b5d31 100644 --- a/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift +++ b/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift @@ -57,120 +57,7 @@ struct NodeMapSwiftUI: View { ZStack { MapReader { reader in Map(position: $position, bounds: MapCameraBounds(minimumDistance: 1, maximumDistance: .infinity), scope: mapScope) { - /// Node Color from node.num - let nodeColor = UIColor(hex: UInt32(node.num)) - /// Convex Hull - if showConvexHull { - if lineCoords.count > 0 { - let hull = lineCoords.getConvexHull() - MapPolygon(coordinates: hull) - .stroke(Color(nodeColor.darker()), lineWidth: 3) - .foregroundStyle(Color(nodeColor).opacity(0.4)) - } - } - /// Route Lines - if showRouteLines { - let gradient = LinearGradient( - colors: [Color(nodeColor.lighter().lighter().lighter()), Color(nodeColor.lighter()), Color(nodeColor)], - startPoint: .leading, endPoint: .trailing - ) - let dashed = StrokeStyle( - lineWidth: 3, - lineCap: .round, lineJoin: .round, dash: [10, 10] - ) - MapPolyline(coordinates: lineCoords) - .stroke(gradient, style: dashed) - } - - - - /// Node Annotations - ForEach(positionArray, id: \.id) { position in - let pf = PositionFlags(rawValue: Int(position.nodePosition?.metadata?.positionFlags ?? 771)) - let headingDegrees = Angle.degrees(Double(position.heading)) -// /// Reduced Precision Map Circle -// if position.latest && 11...16 ~= position.precisionBits { -// let pp = PositionPrecision(rawValue: Int(position.precisionBits)) -// let radius : CLLocationDistance = pp?.precisionMeters ?? 0 -// if radius > 0.0 { -// MapCircle(center: position.coordinate, radius: radius) -// .foregroundStyle(Color(nodeColor).opacity(0.25)) -// .stroke(.white, lineWidth: 2) -// } -// } -// Annotation(position.latest ? node.user?.shortName ?? "?": "", coordinate: position.coordinate) { -// LazyVStack { -// if position.latest { -// ZStack { -// Circle() -// .fill(Color(nodeColor.lighter()).opacity(0.4).shadow(.drop(color: Color(nodeColor).isLight() ? .black : .white, radius: 5))) -// .foregroundStyle(Color(nodeColor.lighter()).opacity(0.3)) -// .frame(width: 50, height: 50) -// if pf.contains(.Heading) { -// Image(systemName: pf.contains(.Speed) && position.speed > 1 ? "location.north" : "octagon") -// .symbolEffect(.pulse.byLayer) -// .padding(5) -// .foregroundStyle(Color(nodeColor).isLight() ? .black : .white) -// .background(Color(nodeColor.darker())) -// .clipShape(Circle()) -// .rotationEffect(headingDegrees) -// .onTapGesture { -// selectedPosition = (selectedPosition == position ? nil : position) -// } -// .popover(item: $selectedPosition) { selection in -// PositionPopover(position: selection) -// .padding() -// .opacity(0.8) -// .presentationCompactAdaptation(.popover) -// } -// -// } else { -// Image(systemName: "flipphone") -// .symbolEffect(.pulse.byLayer) -// .padding(5) -// .foregroundStyle(Color(nodeColor).isLight() ? .black : .white) -// .background(Color(UIColor(hex: UInt32(node.num)).darker())) -// .clipShape(Circle()) -// .onTapGesture { -// selectedPosition = (selectedPosition == position ? nil : position) -// } -// .popover(item: $selectedPosition) { selection in -// PositionPopover(position: selection) -// .padding() -// .opacity(0.8) -// .presentationCompactAdaptation(.popover) -// } -// -// } -// } -// } else { -// if showNodeHistory { -// if pf.contains(.Heading) { -// Image(systemName: "location.north.circle") -// .resizable() -// .scaledToFit() -// .foregroundStyle(Color(UIColor(hex: UInt32(node.num))).isLight() ? .black : .white) -// .background(Color(UIColor(hex: UInt32(node.num)))) -// .clipShape(Circle()) -// .rotationEffect(headingDegrees) -// .frame(width: 16, height: 16) -// -// } else { -// Circle() -// .fill(Color(UIColor(hex: UInt32(node.num)))) -// .strokeBorder(Color(UIColor(hex: UInt32(node.num))).isLight() ? .black : .white ,lineWidth: 2) -// .frame(width: 12, height: 12) -// } -// } -// } - - - } -// } -// .tag(position.time) -// .annotationTitles(.automatic) -// .annotationSubtitles(.automatic) -// } + NodeMapContent(node: node) } .mapScope(mapScope) .mapStyle(mapStyle) From 1769b63466931d5b6c26a7a924f54c3397570e44 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Thu, 14 Mar 2024 23:17:36 -0700 Subject: [PATCH 31/74] Delete extra variables, zoom out more to start on the node map --- .../Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift b/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift index 3b2b5d31..cf6d90e3 100644 --- a/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift +++ b/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift @@ -39,6 +39,8 @@ struct NodeMapSwiftUI: View { @State var selectedWaypoint: WaypointEntity? @State var isMeshMap = false + @State private var mapRegion = MKCoordinateRegion.init() + @FetchRequest(sortDescriptors: [NSSortDescriptor(key: "name", ascending: false)], predicate: NSPredicate( format: "expire == nil || expire >= %@", Date() as NSDate @@ -46,12 +48,7 @@ struct NodeMapSwiftUI: View { private var waypoints: FetchedResults var body: some View { - - let positionArray = node.positions?.array as? [PositionEntity] ?? [] var mostRecent = node.positions?.lastObject as? PositionEntity - let lineCoords = positionArray.compactMap({(position) -> CLLocationCoordinate2D in - return position.nodeCoordinate ?? LocationsHandler.DefaultLocation - }) if node.hasPositions { ZStack { @@ -119,7 +116,7 @@ struct NodeMapSwiftUI: View { if node.positions?.count ?? 0 > 1 { position = .automatic } else { - position = .camera(MapCamera(centerCoordinate: mostRecent!.coordinate, distance: 150, heading: 0, pitch: 60)) + position = .camera(MapCamera(centerCoordinate: mostRecent!.coordinate, distance: 8000, heading: 0, pitch: 60)) } if let mostRecent { Task { @@ -143,7 +140,7 @@ struct NodeMapSwiftUI: View { if node.positions?.count ?? 0 > 1 { position = .automatic } else { - position = .camera(MapCamera(centerCoordinate: mostRecent!.coordinate, distance: 5000, heading: 0, pitch: 60)) + position = .camera(MapCamera(centerCoordinate: mostRecent!.coordinate, distance: 8000, heading: 0, pitch: 60)) } if self.scene == nil { Task { From 8d6aa9e88bc2a6594593ebcd7180d7cc51efd446 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Fri, 15 Mar 2024 14:29:50 -0700 Subject: [PATCH 32/74] stop device role save crash --- Meshtastic/Views/Settings/Config/DeviceConfig.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Meshtastic/Views/Settings/Config/DeviceConfig.swift b/Meshtastic/Views/Settings/Config/DeviceConfig.swift index 6e190609..4ffa72b9 100644 --- a/Meshtastic/Views/Settings/Config/DeviceConfig.swift +++ b/Meshtastic/Views/Settings/Config/DeviceConfig.swift @@ -23,7 +23,7 @@ struct DeviceConfig: View { @State var serialEnabled = true @State var debugLogEnabled = false @State var rebroadcastMode = 0 - @State var nodeInfoBroadcastSecs = 900 + @State var nodeInfoBroadcastSecs = 10800 @State var doubleTapAsButtonPress = false @State var isManaged = false @@ -176,6 +176,9 @@ struct DeviceConfig: View { dc.buttonGpio = UInt32(buttonGPIO) dc.buzzerGpio = UInt32(buzzerGPIO) dc.rebroadcastMode = RebroadcastModes(rawValue: rebroadcastMode)?.protoEnumValue() ?? RebroadcastModes.all.protoEnumValue() + if nodeInfoBroadcastSecs < 0 { + nodeInfoBroadcastSecs = 10800 + } dc.nodeInfoBroadcastSecs = UInt32(nodeInfoBroadcastSecs) dc.doubleTapAsButtonPress = doubleTapAsButtonPress dc.isManaged = isManaged From e4284d9741db865d0621d7ce342eadcd30657b3e Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sun, 17 Mar 2024 09:07:11 -0700 Subject: [PATCH 33/74] Zero hops, defaults for node info broadcast --- Meshtastic/Views/Settings/Config/DeviceConfig.swift | 6 +++--- Meshtastic/Views/Settings/Config/LoRaConfig.swift | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Meshtastic/Views/Settings/Config/DeviceConfig.swift b/Meshtastic/Views/Settings/Config/DeviceConfig.swift index 4ffa72b9..64e5b330 100644 --- a/Meshtastic/Views/Settings/Config/DeviceConfig.swift +++ b/Meshtastic/Views/Settings/Config/DeviceConfig.swift @@ -176,9 +176,6 @@ struct DeviceConfig: View { dc.buttonGpio = UInt32(buttonGPIO) dc.buzzerGpio = UInt32(buzzerGPIO) dc.rebroadcastMode = RebroadcastModes(rawValue: rebroadcastMode)?.protoEnumValue() ?? RebroadcastModes.all.protoEnumValue() - if nodeInfoBroadcastSecs < 0 { - nodeInfoBroadcastSecs = 10800 - } dc.nodeInfoBroadcastSecs = UInt32(nodeInfoBroadcastSecs) dc.doubleTapAsButtonPress = doubleTapAsButtonPress dc.isManaged = isManaged @@ -271,6 +268,9 @@ struct DeviceConfig: View { self.buzzerGPIO = Int(node?.deviceConfig?.buzzerGpio ?? 0) self.rebroadcastMode = Int(node?.deviceConfig?.rebroadcastMode ?? 0) self.nodeInfoBroadcastSecs = Int(node?.deviceConfig?.nodeInfoBroadcastSecs ?? 900) + if nodeInfoBroadcastSecs < 3600 { + nodeInfoBroadcastSecs = 3600 + } self.doubleTapAsButtonPress = node?.deviceConfig?.doubleTapAsButtonPress ?? false self.isManaged = node?.deviceConfig?.isManaged ?? false self.hasChanges = false diff --git a/Meshtastic/Views/Settings/Config/LoRaConfig.swift b/Meshtastic/Views/Settings/Config/LoRaConfig.swift index e9a0f352..3bfe9a41 100644 --- a/Meshtastic/Views/Settings/Config/LoRaConfig.swift +++ b/Meshtastic/Views/Settings/Config/LoRaConfig.swift @@ -130,12 +130,12 @@ struct LoRaConfig: View { } VStack(alignment: .leading) { Picker("Number of hops", selection: $hopLimit) { - ForEach(1..<8) { + ForEach(0..<8) { Text("\($0)") - .tag($0 == 0 ? 3 : $0) + .tag($0) } } - Text("Sets the maximum number of hops, default is 3. Increasing hops also increases congestion and should be used carefully.") + Text("Sets the maximum number of hops, default is 3. Increasing hops also increases congestion and should be used carefully. O hop broadcast messages will not get ACKs.") .foregroundColor(.gray) .font(.callout) } From 8d2b7050684cc0d184ec13579fe547123c8fcc81 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sun, 17 Mar 2024 10:08:03 -0700 Subject: [PATCH 34/74] Split channel form out into its own view --- Meshtastic.xcodeproj/project.pbxproj | 28 +- Meshtastic/Views/Settings/Channels.swift | 234 +--------------- .../Views/Settings/Channels/ChannelForm.swift | 254 ++++++++++++++++++ 3 files changed, 276 insertions(+), 240 deletions(-) create mode 100644 Meshtastic/Views/Settings/Channels/ChannelForm.swift diff --git a/Meshtastic.xcodeproj/project.pbxproj b/Meshtastic.xcodeproj/project.pbxproj index 6ae7e268..9a07d126 100644 --- a/Meshtastic.xcodeproj/project.pbxproj +++ b/Meshtastic.xcodeproj/project.pbxproj @@ -111,6 +111,7 @@ DD90860E26F69BAE00DC5189 /* NodeMap.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD90860D26F69BAE00DC5189 /* NodeMap.swift */; }; DD913639270DFF4C00D7ACF3 /* LocalNotificationManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD913638270DFF4C00D7ACF3 /* LocalNotificationManager.swift */; }; DD93800B2BA3F968008BEC06 /* NodeMapContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD93800A2BA3F968008BEC06 /* NodeMapContent.swift */; }; + DD93800E2BA74D0C008BEC06 /* ChannelForm.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD93800D2BA74D0C008BEC06 /* ChannelForm.swift */; }; DD94B7402ACCE3BE00DCD1D1 /* MapSettingsForm.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD94B73F2ACCE3BE00DCD1D1 /* MapSettingsForm.swift */; }; DD964FBD296E6B01007C176F /* EmojiOnlyTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD964FBC296E6B01007C176F /* EmojiOnlyTextField.swift */; }; DD964FBF296E76EF007C176F /* WaypointFormMapKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD964FBE296E76EF007C176F /* WaypointFormMapKit.swift */; }; @@ -362,6 +363,7 @@ DD90860D26F69BAE00DC5189 /* NodeMap.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NodeMap.swift; sourceTree = ""; }; DD913638270DFF4C00D7ACF3 /* LocalNotificationManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalNotificationManager.swift; sourceTree = ""; }; DD93800A2BA3F968008BEC06 /* NodeMapContent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NodeMapContent.swift; sourceTree = ""; }; + DD93800D2BA74D0C008BEC06 /* ChannelForm.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChannelForm.swift; sourceTree = ""; }; DD94B73F2ACCE3BE00DCD1D1 /* MapSettingsForm.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapSettingsForm.swift; sourceTree = ""; }; DD964FBC296E6B01007C176F /* EmojiOnlyTextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiOnlyTextField.swift; sourceTree = ""; }; DD964FBE296E76EF007C176F /* WaypointFormMapKit.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WaypointFormMapKit.swift; sourceTree = ""; }; @@ -560,21 +562,6 @@ path = CoreData; sourceTree = ""; }; - DD2100802B0E676E00F2F116 /* Routes */ = { - isa = PBXGroup; - children = ( - DD2100832B0E67AD00F2F116 /* RouteMap */, - ); - path = Routes; - sourceTree = ""; - }; - DD2100832B0E67AD00F2F116 /* RouteMap */ = { - isa = PBXGroup; - children = ( - ); - path = RouteMap; - sourceTree = ""; - }; DD47E3CA26F0E50300029299 /* Nodes */ = { isa = PBXGroup; children = ( @@ -604,7 +591,7 @@ DD4A911C2708C57100501B7E /* Settings */ = { isa = PBXGroup; children = ( - DD2100802B0E676E00F2F116 /* Routes */, + DD93800C2BA74CE3008BEC06 /* Channels */, DD97E96728EFE9A00056DDA4 /* About.swift */, DD0F791A28713C8A00A6FDAD /* AdminMessageList.swift */, DD4A911D2708C65400501B7E /* AppSettings.swift */, @@ -747,6 +734,14 @@ name = Frameworks; sourceTree = ""; }; + DD93800C2BA74CE3008BEC06 /* Channels */ = { + isa = PBXGroup; + children = ( + DD93800D2BA74D0C008BEC06 /* ChannelForm.swift */, + ); + path = Channels; + sourceTree = ""; + }; DDAD49EB2AFAE82500B4425D /* Map */ = { isa = PBXGroup; children = ( @@ -1229,6 +1224,7 @@ DDB75A0F2A05920E006ED576 /* FileManager.swift in Sources */, DD1933782B084F4200771CD5 /* Measurement.swift in Sources */, DD4F23CD28779A3C001D37CB /* EnvironmentMetricsLog.swift in Sources */, + DD93800E2BA74D0C008BEC06 /* ChannelForm.swift in Sources */, DD41A61529AB0035003C5A37 /* NodeWeatherForecast.swift in Sources */, DDB6ABD628AE742000384BA1 /* BluetoothConfig.swift in Sources */, DD4640202AFF10F4002A5ECB /* WaypointForm.swift in Sources */, diff --git a/Meshtastic/Views/Settings/Channels.swift b/Meshtastic/Views/Settings/Channels.swift index db9c9a03..a7cfebf0 100644 --- a/Meshtastic/Views/Settings/Channels.swift +++ b/Meshtastic/Views/Settings/Channels.swift @@ -40,18 +40,15 @@ struct Channels: View { @State private var channelRole = 0 @State private var uplink = false @State private var downlink = false - @State private var positionPrecision = 32.0 @State private var preciseLocation = true @State private var positionsEnabled = true + @State private var supportedVersion = true /// Minimum Version for granular position configuration @State var minimumVersion = "2.2.24" - var body: some View { - - let supportedVersion = bleManager.connectedVersion == "0.0.0" || self.minimumVersion.compare(bleManager.connectedVersion, options: .numeric) == .orderedAscending || minimumVersion.compare(bleManager.connectedVersion, options: .numeric) == .orderedSame VStack { List { @@ -80,7 +77,10 @@ struct Channels: View { channelName = channel.name ?? "" uplink = channel.uplinkEnabled downlink = channel.downlinkEnabled - hasChanges = false + + print("Position Precision \(channel.positionPrecision)") + //self.positionPrecision = State(initialValue: Double(self.channel.positionPrecision)) + positionPrecision = Double(channel.positionPrecision) if !supportedVersion && channelRole == 1 { positionPrecision = 32 preciseLocation = true @@ -91,21 +91,22 @@ struct Channels: View { preciseLocation = false positionsEnabled = false } else { - positionPrecision = Double(channel.positionPrecision) if positionPrecision == 32 { preciseLocation = true positionsEnabled = true } else { preciseLocation = false } - if positionPrecision == 0 { positionsEnabled = false } else { positionsEnabled = true } } + hasChanges = false isPresentingEditView = true + + }) { VStack(alignment: .leading) { HStack { @@ -138,224 +139,9 @@ struct Channels: View { .font(.largeTitle) .padding() #endif - Form { - Section(header: Text("channel details")) { - HStack { - Text("name") - Spacer() - TextField( - "Channel Name", - text: $channelName - ) - .disableAutocorrection(true) - .keyboardType(.alphabet) - .foregroundColor(Color.gray) - .onChange(of: channelName, perform: { _ in - channelName = channelName.replacing(" ", with: "") - let totalBytes = channelName.utf8.count - // Only mess with the value if it is too big - if totalBytes > 11 { - let firstNBytes = Data(channelName.utf8.prefix(11)) - if let maxBytesString = String(data: firstNBytes, encoding: String.Encoding.utf8) { - // Set the channelName back to the last place where it was the right size - channelName = maxBytesString - } - } - hasChanges = true - }) - } - HStack { - Picker("Key Size", selection: $channelKeySize) { - Text("Empty").tag(0) - Text("Default").tag(-1) - Text("1 byte").tag(1) - Text("128 bit").tag(16) - Text("192 bit").tag(24) - Text("256 bit").tag(32) - } - .pickerStyle(DefaultPickerStyle()) - Spacer() - Button { - if channelKeySize == -1 { - channelKey = "AQ==" - } else { - let key = generateChannelKey(size: channelKeySize) - channelKey = key - } - } label: { - Image(systemName: "lock.rotation") - .font(.title) - } - .buttonStyle(.bordered) - .buttonBorderShape(.capsule) - .controlSize(.small) - } - HStack(alignment: .center) { - Text("Key") - Spacer() - TextField( - "Key", - text: $channelKey, - axis: .vertical - ) - .padding(6) - .disableAutocorrection(true) - .keyboardType(.alphabet) - .foregroundColor(Color.gray) - .textSelection(.enabled) - .background( - RoundedRectangle(cornerRadius: 10.0) - .stroke( - hasValidKey ? - Color.clear : - Color.red - , lineWidth: 2.0) - - ) - .onChange(of: channelKey, perform: { _ in - let tempKey = Data(base64Encoded: channelKey) ?? Data() - if tempKey.count == channelKeySize || channelKeySize == -1{ - hasValidKey = true - } - else { - hasValidKey = false - } - hasChanges = true - }) - .disabled(channelKeySize <= 0) - } - HStack { - if channelRole == 1 { - Picker("Channel Role", selection: $channelRole) { - Text("Primary").tag(1) - } - .pickerStyle(.automatic) - .disabled(true) - } else { - Text("Channel Role") - Spacer() - Picker("Channel Role", selection: $channelRole) { - Text("Disabled").tag(0) - Text("Secondary").tag(2) - } - .pickerStyle(.segmented) - } - } - } - - Section(header: Text("position")) { - - VStack(alignment: .leading) { - Toggle(isOn: $positionsEnabled) { - Label(channelRole == 1 ? "Positions Enabled" : "Allow Position Requests", systemImage: positionsEnabled ? "mappin" : "mappin.slash") - } - .toggleStyle(SwitchToggleStyle(tint: .accentColor)) - .disabled(!supportedVersion) - } - - if positionsEnabled { - VStack(alignment: .leading) { - Toggle(isOn: $preciseLocation) { - Label("Precise Location", systemImage: "scope") - } - .toggleStyle(SwitchToggleStyle(tint: .accentColor)) - .disabled(!supportedVersion) - .listRowSeparator(.visible) - .onChange(of: preciseLocation) { pl in - if pl == false { - positionPrecision = 13 - } - } - } - - if !preciseLocation { - VStack(alignment: .leading) { - Label("Approximate Location", systemImage: "location.slash.circle.fill") - Slider( - value: $positionPrecision, - in: 11...16, - step: 1 - ) - { - } minimumValueLabel: { - Image(systemName: "minus") - } maximumValueLabel: { - Image(systemName: "plus") - } - Text(PositionPrecision(rawValue: Int(positionPrecision))?.description ?? "") - .foregroundColor(.gray) - .font(.callout) - } - } - } - } - Section(header: Text("mqtt")) { - Toggle(isOn: $uplink) { - Label("Uplink Enabled", systemImage: "arrowshape.up") - } - .toggleStyle(SwitchToggleStyle(tint: .accentColor)) - .listRowSeparator(.visible) - - Toggle(isOn: $downlink) { - Label("Downlink Enabled", systemImage: "arrowshape.down") - } - .toggleStyle(SwitchToggleStyle(tint: .accentColor)) - .listRowSeparator(.visible) - } - } + ChannelForm(channelIndex: $channelIndex, channelName: $channelName, channelKeySize: $channelKeySize, channelKey: $channelKey, channelRole: $channelRole, uplink: $uplink, downlink: $downlink, positionPrecision: $positionPrecision, preciseLocation: $preciseLocation, positionsEnabled: $positionsEnabled, hasChanges: $hasChanges, hasValidKey: $hasValidKey, supportedVersion: $supportedVersion) .onAppear { - let tempKey = Data(base64Encoded: channelKey) ?? Data() - if tempKey.count == channelKeySize || channelKeySize == -1 { - hasValidKey = true - } - else { - hasValidKey = false - } - } - .onChange(of: channelName) { _ in - hasChanges = true - } - .onChange(of: channelKeySize) { _ in - if channelKeySize == -1 { - channelKey = "AQ==" - } else { - let key = generateChannelKey(size: channelKeySize) - channelKey = key - } - hasChanges = true - } - .onChange(of: channelKey) { _ in - hasChanges = true - } - .onChange(of: channelRole) { _ in - hasChanges = true - } - .onChange(of: preciseLocation) { loc in - if loc { - positionPrecision = 32 - } else { - positionPrecision = 14 - } - hasChanges = true - } - .onChange(of: positionPrecision) { _ in - hasChanges = true - } - .onChange(of: positionsEnabled) { pe in - if pe { - if positionPrecision == 0 { - positionPrecision = 32 - } - } else { - positionPrecision = 0 - } - hasChanges = true - } - .onChange(of: uplink) { _ in - hasChanges = true - } - .onChange(of: downlink) { _ in - hasChanges = true + supportedVersion = bleManager.connectedVersion == "0.0.0" || self.minimumVersion.compare(bleManager.connectedVersion, options: .numeric) == .orderedAscending || minimumVersion.compare(bleManager.connectedVersion, options: .numeric) == .orderedSame } HStack { Button { diff --git a/Meshtastic/Views/Settings/Channels/ChannelForm.swift b/Meshtastic/Views/Settings/Channels/ChannelForm.swift new file mode 100644 index 00000000..c191d345 --- /dev/null +++ b/Meshtastic/Views/Settings/Channels/ChannelForm.swift @@ -0,0 +1,254 @@ +// +// ChannelForm.swift +// Meshtastic +// +// Copyright(c) Garth Vander Houwen 3/17/24. +// + + +import SwiftUI +#if canImport(MapKit) +import MapKit +#endif + +struct ChannelForm: View { + + @Binding var channelIndex: Int32 + @Binding var channelName: String + @Binding var channelKeySize: Int + @Binding var channelKey: String + @Binding var channelRole: Int + @Binding var uplink: Bool + @Binding var downlink: Bool + @Binding var positionPrecision: Double + @Binding var preciseLocation: Bool + @Binding var positionsEnabled: Bool + + @Binding var hasChanges: Bool + @Binding var hasValidKey: Bool + + /// Minimum Version for granular position configuration + @Binding var supportedVersion: Bool + + var body: some View { + + NavigationStack { + Form { + Section(header: Text("channel details")) { + HStack { + Text("name") + Spacer() + TextField( + "Channel Name", + text: $channelName + ) + .disableAutocorrection(true) + .keyboardType(.alphabet) + .foregroundColor(Color.gray) + .onChange(of: channelName, perform: { _ in + channelName = channelName.replacing(" ", with: "") + let totalBytes = channelName.utf8.count + // Only mess with the value if it is too big + if totalBytes > 11 { + let firstNBytes = Data(channelName.utf8.prefix(11)) + if let maxBytesString = String(data: firstNBytes, encoding: String.Encoding.utf8) { + // Set the channelName back to the last place where it was the right size + channelName = maxBytesString + } + } + hasChanges = true + }) + } + HStack { + Picker("Key Size", selection: $channelKeySize) { + Text("Empty").tag(0) + Text("Default").tag(-1) + Text("1 byte").tag(1) + Text("128 bit").tag(16) + Text("192 bit").tag(24) + Text("256 bit").tag(32) + } + .pickerStyle(DefaultPickerStyle()) + Spacer() + Button { + if channelKeySize == -1 { + channelKey = "AQ==" + } else { + let key = generateChannelKey(size: channelKeySize) + channelKey = key + } + } label: { + Image(systemName: "lock.rotation") + .font(.title) + } + .buttonStyle(.bordered) + .buttonBorderShape(.capsule) + .controlSize(.small) + } + HStack(alignment: .center) { + Text("Key") + Spacer() + TextField( + "Key", + text: $channelKey, + axis: .vertical + ) + .padding(6) + .disableAutocorrection(true) + .keyboardType(.alphabet) + .foregroundColor(Color.gray) + .textSelection(.enabled) + .background( + RoundedRectangle(cornerRadius: 10.0) + .stroke( + hasValidKey ? + Color.clear : + Color.red + , lineWidth: 2.0) + + ) + .onChange(of: channelKey, perform: { _ in + let tempKey = Data(base64Encoded: channelKey) ?? Data() + if tempKey.count == channelKeySize || channelKeySize == -1{ + hasValidKey = true + } + else { + hasValidKey = false + } + hasChanges = true + }) + .disabled(channelKeySize <= 0) + } + HStack { + if channelRole == 1 { + Picker("Channel Role", selection: $channelRole) { + Text("Primary").tag(1) + } + .pickerStyle(.automatic) + .disabled(true) + } else { + Text("Channel Role") + Spacer() + Picker("Channel Role", selection: $channelRole) { + Text("Disabled").tag(0) + Text("Secondary").tag(2) + } + .pickerStyle(.segmented) + } + } + } + + Section(header: Text("position")) { + + VStack(alignment: .leading) { + Toggle(isOn: $positionsEnabled) { + Label(channelRole == 1 ? "Positions Enabled" : "Allow Position Requests", systemImage: positionsEnabled ? "mappin" : "mappin.slash") + } + .toggleStyle(SwitchToggleStyle(tint: .accentColor)) + .disabled(!supportedVersion) + } + + if positionsEnabled { + VStack(alignment: .leading) { + Toggle(isOn: $preciseLocation) { + Label("Precise Location", systemImage: "scope") + } + .toggleStyle(SwitchToggleStyle(tint: .accentColor)) + .disabled(!supportedVersion) + .listRowSeparator(.visible) + .onChange(of: preciseLocation) { pl in + if pl == false { + positionPrecision = 13 + } + } + } + + if !preciseLocation { + VStack(alignment: .leading) { + Label("Approximate Location", systemImage: "location.slash.circle.fill") + Slider(value: $positionPrecision, in: 11...16, step: 1) { + } minimumValueLabel: { + Image(systemName: "minus") + } maximumValueLabel: { + Image(systemName: "plus") + } + Text(PositionPrecision(rawValue: Int(positionPrecision))?.description ?? "") + .foregroundColor(.gray) + .font(.callout) + } + } + } + } + Section(header: Text("mqtt")) { + Toggle(isOn: $uplink) { + Label("Uplink Enabled", systemImage: "arrowshape.up") + } + .toggleStyle(SwitchToggleStyle(tint: .accentColor)) + .listRowSeparator(.visible) + + Toggle(isOn: $downlink) { + Label("Downlink Enabled", systemImage: "arrowshape.down") + } + .toggleStyle(SwitchToggleStyle(tint: .accentColor)) + .listRowSeparator(.visible) + } + } + .onChange(of: channelName) { _ in + hasChanges = true + } + .onChange(of: channelKeySize) { _ in + if channelKeySize == -1 { + channelKey = "AQ==" + } else { + let key = generateChannelKey(size: channelKeySize) + channelKey = key + } + hasChanges = true + } + .onChange(of: channelKey) { _ in + hasChanges = true + } + .onChange(of: channelRole) { _ in + hasChanges = true + } + .onChange(of: preciseLocation) { loc in + if loc == true { + positionPrecision = 32 + } else { + positionPrecision = 14 + } + hasChanges = true + } + .onChange(of: positionPrecision) { _ in + hasChanges = true + } + .onChange(of: positionsEnabled) { pe in + if pe { + if positionPrecision == 0 { + positionPrecision = 32 + } + } else { + positionPrecision = 0 + } + hasChanges = true + } + .onChange(of: uplink) { _ in + hasChanges = true + } + .onChange(of: downlink) { _ in + hasChanges = true + } + .onAppear { + let tempKey = Data(base64Encoded: channelKey) ?? Data() + if tempKey.count == channelKeySize || channelKeySize == -1 { + hasValidKey = true + } + else { + hasValidKey = false + } + } + } + .presentationDetents([.fraction(0.45), .fraction(0.65)]) + .presentationDragIndicator(.visible) + } +} From 8528f08572e5149d74fb35cb3ddad44b2c8fa1fe Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sun, 17 Mar 2024 10:26:42 -0700 Subject: [PATCH 35/74] Convert channels to use the selected pattern for the sheet --- Meshtastic/Views/Settings/Channels.swift | 19 ++++++------------- .../Views/Settings/Channels/ChannelForm.swift | 3 --- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/Meshtastic/Views/Settings/Channels.swift b/Meshtastic/Views/Settings/Channels.swift index a7cfebf0..6c5fe5ed 100644 --- a/Meshtastic/Views/Settings/Channels.swift +++ b/Meshtastic/Views/Settings/Channels.swift @@ -31,7 +31,6 @@ struct Channels: View { @State var hasChanges = false @State var hasValidKey = true - @State private var isPresentingEditView = false @State private var isPresentingSaveConfirm: Bool = false @State private var channelIndex: Int32 = 0 @State private var channelName = "" @@ -44,6 +43,7 @@ struct Channels: View { @State private var preciseLocation = true @State private var positionsEnabled = true @State private var supportedVersion = true + @State var selectedChannel: ChannelEntity? /// Minimum Version for granular position configuration @State var minimumVersion = "2.2.24" @@ -77,9 +77,6 @@ struct Channels: View { channelName = channel.name ?? "" uplink = channel.uplinkEnabled downlink = channel.downlinkEnabled - - print("Position Precision \(channel.positionPrecision)") - //self.positionPrecision = State(initialValue: Double(self.channel.positionPrecision)) positionPrecision = Double(channel.positionPrecision) if !supportedVersion && channelRole == 1 { positionPrecision = 32 @@ -104,9 +101,7 @@ struct Channels: View { } } hasChanges = false - isPresentingEditView = true - - + selectedChannel = channel }) { VStack(alignment: .leading) { HStack { @@ -132,8 +127,7 @@ struct Channels: View { } } } - .sheet(isPresented: $isPresentingEditView) { - + .sheet(item: $selectedChannel) { selection in #if targetEnvironment(macCatalyst) Text("channel") .font(.largeTitle) @@ -208,11 +202,10 @@ struct Channels: View { let adminMessageId = bleManager.saveChannel(channel: channel, fromUser: node!.user!, toUser: node!.user!) if adminMessageId > 0 { - self.isPresentingEditView = false + selectedChannel = nil channelName = "" channelRole = 2 hasChanges = false - //_ = bleManager.getChannel(channel: channel, fromUser: node!.user!, toUser: node!.user!) } } label: { Label("save", systemImage: "square.and.arrow.down") @@ -224,7 +217,7 @@ struct Channels: View { .padding(.bottom) #if targetEnvironment(macCatalyst) Button { - isPresentingEditView = false + goBack() } label: { Label("close", systemImage: "xmark") } @@ -256,7 +249,7 @@ struct Channels: View { uplink = false downlink = false hasChanges = true - isPresentingEditView = true + selectedChannel = ChannelEntity(context: context) } label: { Label("Add Channel", systemImage: "plus.square") diff --git a/Meshtastic/Views/Settings/Channels/ChannelForm.swift b/Meshtastic/Views/Settings/Channels/ChannelForm.swift index c191d345..7176d802 100644 --- a/Meshtastic/Views/Settings/Channels/ChannelForm.swift +++ b/Meshtastic/Views/Settings/Channels/ChannelForm.swift @@ -23,11 +23,8 @@ struct ChannelForm: View { @Binding var positionPrecision: Double @Binding var preciseLocation: Bool @Binding var positionsEnabled: Bool - @Binding var hasChanges: Bool @Binding var hasValidKey: Bool - - /// Minimum Version for granular position configuration @Binding var supportedVersion: Bool var body: some View { From c18edc5bf4f94ebd4d87020631d7c47e3438bffc Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sun, 17 Mar 2024 11:00:27 -0700 Subject: [PATCH 36/74] Add french to project file --- Meshtastic.xcodeproj/project.pbxproj | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Meshtastic.xcodeproj/project.pbxproj b/Meshtastic.xcodeproj/project.pbxproj index 9a07d126..d4787707 100644 --- a/Meshtastic.xcodeproj/project.pbxproj +++ b/Meshtastic.xcodeproj/project.pbxproj @@ -454,6 +454,7 @@ DDDB444F29F8AC9C00EE2349 /* UIImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIImage.swift; sourceTree = ""; }; DDDB445129F8ACF900EE2349 /* Date.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Date.swift; sourceTree = ""; }; DDDB445329F8AD1600EE2349 /* Data.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Data.swift; sourceTree = ""; }; + DDDC22312BA76701002C44F1 /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Localizable.strings; sourceTree = ""; }; DDDD527729B5B83F0045BC3C /* MeshtasticDataModelV9.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = MeshtasticDataModelV9.xcdatamodel; sourceTree = ""; }; DDDE59F429AF163D00490C6C /* WidgetsExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = WidgetsExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; }; DDDE59F829AF163D00490C6C /* WidgetsBundle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetsBundle.swift; sourceTree = ""; }; @@ -1117,6 +1118,7 @@ "zh-Hans", pl, he, + fr, ); mainGroup = DDC2E14B26CE248E0042C5E4; packageReferences = ( @@ -1435,6 +1437,7 @@ A65FA974296876BF00A97686 /* zh-Hans */, DDF6B24B2A9C2FC800BA6931 /* pl */, DD31EC492B7F18B7006A3995 /* he */, + DDDC22312BA76701002C44F1 /* fr */, ); name = Localizable.strings; sourceTree = ""; From 710073e7b2d48f63272afa6d82afac85a52fcde2 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sun, 17 Mar 2024 11:10:43 -0700 Subject: [PATCH 37/74] Add TW --- Meshtastic.xcodeproj/project.pbxproj | 3 + zh-Hant-TW.lproj/Localizable.strings | 333 +++++++++++++++++++++++++++ 2 files changed, 336 insertions(+) create mode 100644 zh-Hant-TW.lproj/Localizable.strings diff --git a/Meshtastic.xcodeproj/project.pbxproj b/Meshtastic.xcodeproj/project.pbxproj index d4787707..87b0ed30 100644 --- a/Meshtastic.xcodeproj/project.pbxproj +++ b/Meshtastic.xcodeproj/project.pbxproj @@ -455,6 +455,7 @@ DDDB445129F8ACF900EE2349 /* Date.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Date.swift; sourceTree = ""; }; DDDB445329F8AD1600EE2349 /* Data.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Data.swift; sourceTree = ""; }; DDDC22312BA76701002C44F1 /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Localizable.strings; sourceTree = ""; }; + DDDC22322BA76961002C44F1 /* zh-Hant-TW */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hant-TW"; path = "zh-Hant-TW.lproj/Localizable.strings"; sourceTree = ""; }; DDDD527729B5B83F0045BC3C /* MeshtasticDataModelV9.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = MeshtasticDataModelV9.xcdatamodel; sourceTree = ""; }; DDDE59F429AF163D00490C6C /* WidgetsExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = WidgetsExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; }; DDDE59F829AF163D00490C6C /* WidgetsBundle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetsBundle.swift; sourceTree = ""; }; @@ -1119,6 +1120,7 @@ pl, he, fr, + "zh-Hant-TW", ); mainGroup = DDC2E14B26CE248E0042C5E4; packageReferences = ( @@ -1438,6 +1440,7 @@ DDF6B24B2A9C2FC800BA6931 /* pl */, DD31EC492B7F18B7006A3995 /* he */, DDDC22312BA76701002C44F1 /* fr */, + DDDC22322BA76961002C44F1 /* zh-Hant-TW */, ); name = Localizable.strings; sourceTree = ""; diff --git a/zh-Hant-TW.lproj/Localizable.strings b/zh-Hant-TW.lproj/Localizable.strings new file mode 100644 index 00000000..6f36c512 --- /dev/null +++ b/zh-Hant-TW.lproj/Localizable.strings @@ -0,0 +1,333 @@ +/* + Localizable.strings + Meshtastic + + Created by BM6HIP on 2024/3/2 + +*/ +"about"="關於"; +"about.meshtastic"="關於 Meshtastic"; +"admin"="管理員"; +"admin.log"="管理員消息紀錄檔"; +"ago"="ago"; +"airtime"="廣播時間"; +"always.on"="常亮"; +"ambient.lighting"="Ambient Lighting"; +"ambient.lighting.config"="Ambient Lighting Config"; +"appsettings"="設定"; +"appsettings.provide.location"="提供定位到 Mesh 網路"; +"appsettings.smartposition"="Smart Position"; +"are.you.sure"="是否確定?"; +"ascii.capable"="ASCII Capable"; +"available.radios"="可以連接的設備"; +"automatic.detection"="自動識別"; +"battery.level"="電池電量"; +"ble.name"="藍芽名稱"; +"ble.connection.timeout %d %@"="嘗試連接%@失敗,你可能需要在系统設定的藍芽選項中忽略該電台。"; +"ble.errorcode.6 %@"="%@ 如果在首選電台的旁邊,App 將會自動重連。"; +"ble.errorcode.14 %@"="%@ 這個錯誤通常無法自動修復,你需要在系統設定的藍芽選項中忽略該電台並重新配對。"; +"ble.errorcode.pin %@"="%@ 請再次嘗試連接並仔細檢查 PIN 碼。"; +"bluetooth"="藍芽"; +"bluetooth.off"="藍芽已關閉"; +"bluetooth.config"="藍芽設置"; +"bluetooth.mode.randompin"="隨機 PIN 碼"; +"bluetooth.mode.fixedpin"="固定 PIN 碼"; +"bluetooth.mode.nopin"="不使用 PIN 碼(直接配對)"; +"bluetooth.pairingmode"="配對模式"; +"bluetooth.pin.validation"="藍芽 PIN 碼必須是 6 位數字。"; +"bytes"="字節"; +"cancel"="取消"; +"canned.messages"="通知"; +"canned.messages.config"="通知設定"; +"canned.messages.preset.manual"="手動設定"; +"canned.messages.preset.rakrotary"="RAK 旋轉編碼器"; +"canned.messages.preset.cardkb"="M5Stack 卡片鍵盤 / RAK 鍵盤"; +"channel"="頻道"; +"channel.role.disabled"="關閉"; +"channel.role.primary"="主要"; +"channel.role.secondary"="次要"; +"channel.utilization"="頻道利用率"; +"channels"="頻道"; +"clear.app.data"="清除 App 資料"; +"clear.log"="清除紀錄檔"; +"close"="關閉"; +"config.power.settings"="電源"; +"config.power.title"="電源設定"; +"config.power.section.battery"="電池"; +"config.power.section.sleep"="休眠"; +"config.power.adc.override"="ADC Override"; +"config.power.adc.multiplier"="Multiplier"; +"config.power.ls.secs"="Light Sleep Interval"; +"config.power.min.wake.secs"="最小的喚醒間隔時間"; +"config.power.saving"="省電模式"; +"config.power.saving.description"="Will sleep everything as much as possible, for the tracker and sensor role this will also include the lora radio. Don't use this setting if you want to use your device with the phone apps or are using a device without a user button."; +"config.power.shutdown.on.power.loss"="失去電源後關機"; +"config.power.shutdown.after.secs"="之後"; +"config.power.wait.bluetooth.secs"="等待藍芽"; +"config.ringtone"="RTTTL Ringtone"; +"config.ringtone.title"="鈴聲"; +"config.ringtone.label"="Ringtone Transfer Language"; +"config.ringtone.description"="Ringtone Transfer Language(RTTTL) Ringtone String used by supported buzzers in external notifications."; +"config.module.paxcounter.settings"="PAX Counter"; +"config.module.paxcounter.title"="PAX Counter Config"; +"config.module.paxcounter.enabled.description"="When enabled the PAX Counter module counts the number of people passing by using WiFi and Bluetooth. Both WiFI and Bluetooth must be enabled for PAX counter to work."; +"config.module.paxcounter.updateinterval"="Update Interval"; +"config.module.paxcounter.updateinterval.description"="How often we can send a message to the mesh when people are detected."; +"config.save.confirm"="電台將會在設定儲存後重啟。"; +"connected.radio"="已連接的電台"; +"communicating"="與電台進行通訊中..."; +"connected"="已連接"; +"connecting"="連接中..."; +"contacts"="聯絡人"; +"contacts %@"="聯絡人 (%@)"; +"copy"="複製"; +"current"="目前"; +"default"="預設"; +"delete"="刪除"; +"detection.sensor"="檢測感測器"; +"device"="設備"; +"device.config"="電台設定"; +"device.configuration"="設備設定"; +"device.metrics.delete"="刪除所有電台指標??"; +"device.metrics.log"="電台指標紀錄檔"; +"device.role.client"="標準模式 - App 可以連接到電台進行收發操作,並且會自動轉發 Mesh 網路中其他中繼點的消息。"; +"device.role.clientmute"="靜音模式 - 與標準模式類似,App 可以連接到電台進行收發操作,但不會轉發 Mesh 網路中其他中繼點的消息。"; +"device.role.clienthidden"=" Used for nodes that \"only speak when spoken to\" Turns all of the routine broadcasts but allows for ad-hoc communication. Still rebroadcasts, but with local only rebroadcast mode (known meshes only). Can be used for private operation or to dramatically reduce airtime / power consumption."; +"device.role.lostandfound"="Used to automatically send a text message to the mesh with the current position of the device on a frequent interval: \"I'm lost! Position: lat / long\""; +"device.role.router"="纯路由模式 - 自動轉發 Mesh 網路中其他中繼點的消息,中繼模式下螢幕會熄滅,Wi-Fi 和藍芽將會進入睡眠模式,App 將無法連接到電台進行收發操作。"; +"device.role.routerclient"="路由客户端模式 - 優先轉發 Mesh 網路中其他中繼點的消息,App 也可以連接到電台進行收發操作。"; +"device.role.repeater"="中繼模式 - Mesh 網路數據包將優先通過此中繼點路由。此模式可消除不必要的開銷,如 NodeInfo、DeviceTelemetry 和任何其他 Mesh 數據包,從而使設備不顯示為 Mesh 網路的一部分。有關此角色的其他特定設置,請參閱轉播模式。"; +"device.role.tracker"="追蹤模式 - 用於作為 GPS 追蹤器。從該設備發送的定位數據包優先級較高,每兩分鐘廣播一次。智能位置廣播預設為關閉。"; +"direct.messages"="聊天"; +"dismiss.keyboard"="隱藏鍵盤"; +"display"="螢幕(電台螢幕)"; +"display.config"="螢幕設定"; +"distance"="距離"; +"disconnect"="斷開連接"; +"echo"="echo"; +"email.address"="電子信箱"; +"enabled"="啟用"; +"encrypted"="加密"; +"external.notification"="外部通知"; +"external.notification.config"="外部通知設定"; +"finish"="完成"; +"firmware.version"="韌體版本"; +"firmware.version.unsupported"="檢測到不支援的韌體版本,無法連接到電台。"; +"gas"="Gas"; +"gas.resistance"="Gas Resistance"; +"generate.qr.code"="生成QRcode"; +"gpsformat.dec"="十進制"; +"gpsformat.dms"="度分秒"; +"gpsformat.utm"="通用橫軸墨卡托投影"; +"gpsformat.mgrs"="軍事網格系統"; +"gpsformat.olc"="開放的位置代碼(又稱加碼)"; +"gpsformat.osgr"="英國國土測量局網格"; +"heard"="收到"; +"heard.last"="最後收到"; +"hybrid"="混合"; +"hybrid.flyover"="混合視圖"; +"include"="包含"; +"inputevent.none"="無"; +"inputevent.up"="上"; +"inputevent.down"="下"; +"inputevent.left"="左"; +"inputevent.right"="右"; +"inputevent.select"="選擇"; +"inputevent.back"="返回"; +"inputevent.cancel"="取消"; +"interval.one.second"="一秒"; +"interval.two.seconds"="兩秒"; +"interval.three.seconds"="三秒"; +"interval.four.seconds"="四秒"; +"interval.five.seconds"="五秒"; +"interval.ten.seconds"="十秒"; +"interval.fifteen.seconds"="十五秒"; +"interval.twenty.seconds"="二十秒"; +"interval.twentyfive.seconds"="二十五秒"; +"interval.thirty.seconds"="三十秒"; +"interval.fortyfive.seconds"="四十五秒"; +"interval.one.minute"="一分鐘"; +"interval.two.minutes"="兩分鐘"; +"interval.five.minutes"="五分鐘"; +"interval.ten.minutes"="十分鐘"; +"interval.fifteen.minutes"="十五分鐘"; +"interval.thirty.minutes"="三十分鐘"; +"interval.one.hour"="一小時"; +"interval.two.hours"="兩小時"; +"interval.three.hours"="三小時"; +"interval.four.hours"="四小時"; +"interval.five.hours"="五小時"; +"interval.six.hours"="六小時"; +"interval.twelve.hours"="十二小時"; +"interval.eighteen.hours"="十八小時"; +"interval.twentyfour.hours"="二十四小時"; +"interval.thirtysix.hours"="三十六小時"; +"interval.tyeight.hours"="四十八小时小時"; +"interval.eventytwo.hours"="七十二小時"; +"keyboard.type"="鍵盤類型"; +"logging"="加載中"; +"lora"="LoRa"; +"lora.config"="LoRa 設定"; +"map"="Mesh 地圖"; +"map.centering"="居中"; +"map.tiles.delete"="刪除已緩存的地圖區塊"; +"map.recentering"="自動重新居中"; +"map.use.legacy"="Use Legacy Mesh Map"; +"map.type"="地圖類型"; +"map.usertrackingmode"="使用者跟隨模式"; +"map.usertrackingmode.none"="無"; +"map.usertrackingmode.follow"="跟隨"; +"map.usertrackingmode.followwithheading"="Follow with heading"; +"mesh.live.activity"="Mesh 即時活動"; +"mesh.log"="Mesh 紀錄檔"; +"mesh.log.ambientlighting.config %@"="Ambient Lighting module config received: %@"; +"mesh.log.bluetooth.config %@"="Bluetooth config received: %@"; +"mesh.log.cannedmessage.config %@"="Canned Message module config received: %@"; +"mesh.log.cannedmessages.messages.get %@"="Requested Canned Messages Module Messages for node: %@"; +"mesh.log.cannedmessages.messages.received %@"="Canned Messages Messages Received For: %@"; +"mesh.log.channel.sent %@ %d"="Sent a Channel for: %@ Channel Index %d"; +"mesh.log.channel.received %d %@"="Channel %d received from: %@"; +"mesh.log.device.config %@"="收到裝置設定: %@"; +"mesh.log.display.config %@"="收到顯示模組設定: %@"; +"mesh.log.devicemetadata %@"="Requesting Device Metadata for %@"; +"mesh.log.device.metadata.received %@"="Device Metadata admin message received from: %@"; +"mesh.log.detectionsensor.config %@"="Detection Sensor module config received: %@"; +"mesh.log.externalnotification.config %@"="External Notification module config received: %@"; +"mesh.log.lora.config %@"="收到LoRa設定: %@"; +"mesh.log.lora.config.sent %@"="Sent a LoRa.Config for: %@"; +"mesh.log.mqtt.config %@"="MQTT module config received: %@"; +"mesh.log.myinfo %@"="MyInfo received: %@"; +"mesh.log.network.config %@"="收到網路設定: %@"; +"mesh.log.nodeinfo.received %@"="收到中繼點訊息: %@"; +"mesh.log.paxcounter %@"="PAX Counter message received for: %@"; +"mesh.log.position.config %@"="Positon config received: %@"; +"mesh.log.position.received %@"="從中繼點接收到定位封包: %@"; +"mesh.log.rangetest.config %@"="收到拉距測試模組設定: %@"; +"mesh.log.ringtone.config %@"="RTTTL Ringtone config received: %@"; +"mesh.log.routing.message %@ %@"="Routing received for RequestID: %@ Ack Status: %@"; +"mesh.log.serial.config %@"="Serial module config received: %@"; +"mesh.log.sharelocation %@"="傳送iOS裝置的GPS定位封包到中繼點上: %@"; +"mesh.log.storeforward.config %@"="Store & Forward module config received: %@"; +"mesh.log.telemetry.config %@"="收到遠測模組設定: %@"; +"mesh.log.telemetry.received %@"="收到遠測資料: %@"; +"mesh.log.textmessage.received"="Message received from the text message app."; +"mesh.log.textmessage.send.failed %@"="訊息傳送失敗, 沒有正確連接到 %@"; +"mesh.log.textmessage.sent %@ %@ %@"="傳送訊息 %@ 從 %@ 到 %@"; +"mesh.log.traceroute.received.direct %@"="Trace Route request sent to node: %@ was recieived directly."; +"mesh.log.traceroute.received.route %@"="Trace Route request returned: %@"; +"mesh.log.traceroute.sent %@"="Sent a Trace Route Request to node: %@"; +"mesh.log.wantconfig %@"="Issuing Want Config to %@"; +"mesh.log.waypoint.sent %@"="Sent a Waypoint Packet from: %@"; +"mesh.log.waypoint.received %@"="Waypoint Packet received from node: %@"; +"message"="訊息"; +"message.details"="詳細訊息"; +"messages"="訊息"; +"mode"="模式"; +"module.configuration"="模塊設定"; +"mqtt"="MQTT"; +"mqtt.connect"="Connect to MQTT"; +"mqtt.config"="MQTT 設定"; +"mqtt.clientproxy"="MQTT 客户端代理"; +"mqtt.disconnect"="Disconnect from MQTT"; +"mqtt.username"="用戶名稱"; +"name"="名稱"; +"network"="網路"; +"network.config"="網路設定"; +"nodes"="中繼點"; +"nodes %@"="中繼點 (%@)"; +"no.nodes"="未找到 Meshtastic 中繼點"; +"not.connected"="未連接到電台"; +"numbers.punctuation"="數字和標點符號"; +"off"="關閉"; +"offline"="離線"; +"on.boot"="只在啟動時"; +"options"="選項"; +"password"="密碼"; +"pause"="暫停"; +"phone.gps"="手機 GPS"; +"phone.gps.interval.description"="電台通過手機獲得定位的時間間隔,但是向 Mesh 網路中更新定位的時間間隔由電台控制。"; +"position"="定位"; +"position.config"="定位設定"; +"preferred.radio"="首選電台"; +"radio.configuration"="電台設定"; +"range.test"="拉距測試"; +"range.test.blocked"="區塊範圍測試"; +"range.test.config"="拉距測試設定"; +"reply"="回復"; +"reboot"="重新啟動"; +"reboot.node"="重啟中繼點"; +"received.ack"="收到確認"; +"received.ack.real"="收件人確認"; +"resume"="恢復"; +"ringtone"="鈴聲"; +"ringtone.config"="鈴聲設定"; +"route.recorder"="路線錄製"; +"routes"="路線"; +"routing.acknowledged"="確認"; +"routing.noroute"="找不到目標"; +"routing.gotnak"="收到否認"; +"routing.timeout"="逾時"; +"routing.nointerface"="無連接"; +"routing.maxretransmit"="已達到最大重試次數"; +"routing.nochannel"="没有頻道"; +"routing.toolarge"="數據包過大"; +"routing.noresponse"="無回應"; +"routing.dutycyclelimit"="已達到物錢區域循環週期發射上限"; +"routing.badRequest"="錯誤請求"; +"routing.notauthorized"="未授權"; +"satellite"="衛星"; +"satellite.flyover"="衛星識圖"; +"save"="儲存"; +"save.config %@"="儲存%@的設定"; +"serial"="串口"; +"serial.config"="串口設定"; +"serial.mode.default"="預設"; +"serial.mode.simple"="簡單"; +"serial.mode.proto"="Protobufs"; +"serial.mode.txtmsg"="文本訊息"; +"serial.mode.nmea"="NMEA 位置"; +"settings"="設定"; +"share.channels"="分享頻道QRcode"; +"share.position"="分享位置"; +"subscribed"="連接到 Mesh 網路"; +"select.contact"="選擇聯絡人"; +"select.node"="選擇中繼點"; +"select.menu.item"="從菜單選擇項目"; +"set.region"="設定 LoRa 區域"; +"standard"="標準"; +"standard.muted"="標準靜音"; +"start"="開始"; +"ssid"="SSID"; +"storeforward"="儲存 & 轉發"; +"storeforward.config"="儲存 & 轉發設定"; +"storeforward.heartbeat"="發送心跳包"; +"tapback"="響應"; +"tapback.heart"="心"; +"tapback.thumbsup"="豎大拇指"; +"tapback.thumbsdown"="倒大拇指"; +"tapback.haha"="哈哈"; +"tapback.exclamation"="驚嘆號"; +"tapback.question"="問號"; +"tapback.poop"="便便"; +"telemetry"="遠測(傳感器)"; +"telemetry.config"="遠側設定"; +"timeout"="超時"; +"timestamp"="時間戳記"; +"tip.bluetooth.connect.title"="連接到 LoRa 電台"; +"tip.bluetooth.connect.message"="顯示目前通過藍芽連接的 Lora 電台的信息。您可以向左滑動斷開電台,長按查看統計訊息或開始即時活動。"; +"tip.channels.create.title"="管理頻道"; +"tip.channels.create.message"="現在 Mesh 上的資料會通過主通道發送。您可以設定輔助通道來建立由自己的金鑰保護的其他訊息組 [頻道設定提示](https://meshtastic.org/docs/configuration/radio/channels/)"; +"tip.channels.share.title"="共享 Meshtastic 頻道"; +"tip.channels.share.message"="在 Meshtastic 網路中最多有 8 個頻道。第一個頻道是主頻道,大多數活動都發生在這裡,也是必需的。如果您不共享主頻道,您的第一個共享頻道就會成為其他網路的主頻道。它會在其主頻道和您的輔助頻道上對話。名稱為 admin 的頻道可遠端控制中繼點。其他頻道用於私人群组,每個群組都有自己的密鑰。"; +"tip.messages.title"="消息"; +"tip.messages.message"="您可以發送和接收1對1聊天和群聊。在任何訊息中,您都可以長按查看可用的操作,如複製、回復、拍一拍、刪除以及詳情。"; +"twitter"="Twitter"; +"unknown"="未知"; +"unknown.age"="未知時間"; +"unset"="未設置"; +"update.firmware"="更新韌體"; +"update.interval"="更新間隔"; +"user"="使用者"; +"user.details"="使用者資料"; +"voltage"="電壓"; +"waiting"="等待中..."; From 61c7ae4f8f6020139c5438e0ca211175b2366af3 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sun, 17 Mar 2024 11:13:50 -0700 Subject: [PATCH 38/74] Heartbeat PB --- .../Protobufs/meshtastic/clientonly.pb.swift | 33 --------- .../Protobufs/meshtastic/deviceonly.pb.swift | 1 + Meshtastic/Protobufs/meshtastic/mesh.pb.swift | 68 +++++++++++++++++++ protobufs | 2 +- 4 files changed, 70 insertions(+), 34 deletions(-) diff --git a/Meshtastic/Protobufs/meshtastic/clientonly.pb.swift b/Meshtastic/Protobufs/meshtastic/clientonly.pb.swift index 64fd71c0..050c719d 100644 --- a/Meshtastic/Protobufs/meshtastic/clientonly.pb.swift +++ b/Meshtastic/Protobufs/meshtastic/clientonly.pb.swift @@ -94,22 +94,8 @@ struct DeviceProfile { fileprivate var _moduleConfig: LocalModuleConfig? = nil } -/// -/// A heartbeat message is sent by a node to indicate that it is still alive. -/// This is currently only needed to keep serial connections alive. -struct Heartbeat { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - #if swift(>=5.5) && canImport(_Concurrency) extension DeviceProfile: @unchecked Sendable {} -extension Heartbeat: @unchecked Sendable {} #endif // swift(>=5.5) && canImport(_Concurrency) // MARK: - Code below here is support for the SwiftProtobuf runtime. @@ -175,22 +161,3 @@ extension DeviceProfile: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementa return true } } - -extension Heartbeat: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".Heartbeat" - static let _protobuf_nameMap = SwiftProtobuf._NameMap() - - mutating func decodeMessage(decoder: inout D) throws { - while let _ = try decoder.nextFieldNumber() { - } - } - - func traverse(visitor: inout V) throws { - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Heartbeat, rhs: Heartbeat) -> Bool { - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} diff --git a/Meshtastic/Protobufs/meshtastic/deviceonly.pb.swift b/Meshtastic/Protobufs/meshtastic/deviceonly.pb.swift index 048c99aa..950c577e 100644 --- a/Meshtastic/Protobufs/meshtastic/deviceonly.pb.swift +++ b/Meshtastic/Protobufs/meshtastic/deviceonly.pb.swift @@ -140,6 +140,7 @@ struct DeviceState { /// /// Used only during development. /// Indicates developer is testing and changes should never be saved to flash. + /// Deprecated in 2.3.1 var noSave: Bool { get {return _storage._noSave} set {_uniqueStorage()._noSave = newValue} diff --git a/Meshtastic/Protobufs/meshtastic/mesh.pb.swift b/Meshtastic/Protobufs/meshtastic/mesh.pb.swift index bdc8da97..2890db6c 100644 --- a/Meshtastic/Protobufs/meshtastic/mesh.pb.swift +++ b/Meshtastic/Protobufs/meshtastic/mesh.pb.swift @@ -2388,6 +2388,16 @@ struct ToRadio { set {payloadVariant = .mqttClientProxyMessage(newValue)} } + /// + /// Heartbeat message (used to keep the device connection awake on serial) + var heartbeat: Heartbeat { + get { + if case .heartbeat(let v)? = payloadVariant {return v} + return Heartbeat() + } + set {payloadVariant = .heartbeat(newValue)} + } + var unknownFields = SwiftProtobuf.UnknownStorage() /// @@ -2415,6 +2425,9 @@ struct ToRadio { /// /// MQTT Client Proxy Message (for client / phone subscribed to MQTT sending to device) case mqttClientProxyMessage(MqttClientProxyMessage) + /// + /// Heartbeat message (used to keep the device connection awake on serial) + case heartbeat(Heartbeat) #if !swift(>=4.1) static func ==(lhs: ToRadio.OneOf_PayloadVariant, rhs: ToRadio.OneOf_PayloadVariant) -> Bool { @@ -2442,6 +2455,10 @@ struct ToRadio { guard case .mqttClientProxyMessage(let l) = lhs, case .mqttClientProxyMessage(let r) = rhs else { preconditionFailure() } return l == r }() + case (.heartbeat, .heartbeat): return { + guard case .heartbeat(let l) = lhs, case .heartbeat(let r) = rhs else { preconditionFailure() } + return l == r + }() default: return false } } @@ -2581,6 +2598,19 @@ struct DeviceMetadata { init() {} } +/// +/// A heartbeat message is sent to the node from the client to keep the connection alive. +/// This is currently only needed to keep serial connections alive, but can be used by any PhoneAPI. +struct Heartbeat { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + #if swift(>=5.5) && canImport(_Concurrency) extension HardwareModel: @unchecked Sendable {} extension Constants: @unchecked Sendable {} @@ -2614,6 +2644,7 @@ extension Compressed: @unchecked Sendable {} extension NeighborInfo: @unchecked Sendable {} extension Neighbor: @unchecked Sendable {} extension DeviceMetadata: @unchecked Sendable {} +extension Heartbeat: @unchecked Sendable {} #endif // swift(>=5.5) && canImport(_Concurrency) // MARK: - Code below here is support for the SwiftProtobuf runtime. @@ -4198,6 +4229,7 @@ extension ToRadio: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBa 4: .same(proto: "disconnect"), 5: .same(proto: "xmodemPacket"), 6: .same(proto: "mqttClientProxyMessage"), + 7: .same(proto: "heartbeat"), ] mutating func decodeMessage(decoder: inout D) throws { @@ -4261,6 +4293,19 @@ extension ToRadio: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBa self.payloadVariant = .mqttClientProxyMessage(v) } }() + case 7: try { + var v: Heartbeat? + var hadOneofValue = false + if let current = self.payloadVariant { + hadOneofValue = true + if case .heartbeat(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payloadVariant = .heartbeat(v) + } + }() default: break } } @@ -4292,6 +4337,10 @@ extension ToRadio: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBa guard case .mqttClientProxyMessage(let v)? = self.payloadVariant else { preconditionFailure() } try visitor.visitSingularMessageField(value: v, fieldNumber: 6) }() + case .heartbeat?: try { + guard case .heartbeat(let v)? = self.payloadVariant else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 7) + }() case nil: break } try unknownFields.traverse(visitor: &visitor) @@ -4527,3 +4576,22 @@ extension DeviceMetadata: SwiftProtobuf.Message, SwiftProtobuf._MessageImplement return true } } + +extension Heartbeat: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".Heartbeat" + static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() { + } + } + + func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Heartbeat, rhs: Heartbeat) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/protobufs b/protobufs index 7e3ee8cd..556e49ba 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 7e3ee8cd96740910d0611433cb9a05a7a692568c +Subproject commit 556e49ba619e2f4d8fa3c2dee2a94129a43d5f08 From 02cca19f263a5e266240353eb6c14eeb5ffe7dff Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sat, 23 Mar 2024 09:01:44 -0700 Subject: [PATCH 39/74] Assorted updates --- Meshtastic.xcodeproj/project.pbxproj | 14 +- Meshtastic/Enums/MessagingEnums.swift | 19 +- .../CoreData/PositionEntityExtension.swift | 11 + Meshtastic/Helpers/MeshPackets.swift | 18 -- Meshtastic/Persistence/UpdateCoreData.swift | 15 +- .../Protobufs/meshtastic/deviceonly.pb.swift | 16 ++ Meshtastic/Protobufs/meshtastic/mesh.pb.swift | 16 ++ .../Views/Messages/UserMessageList.swift | 2 +- .../Map/MapContent/MeshMapContent.swift | 162 ++++++++++++++ .../Map/{ => MapContent}/NodeMapContent.swift | 0 .../Views/Nodes/Helpers/NodeListItem.swift | 2 +- Meshtastic/Views/Nodes/MeshMap.swift | 200 ++++++------------ de.lproj/Localizable.strings | 1 + en.lproj/Localizable.strings | 1 + fr.lproj/Localizable.strings | 1 + he.lproj/Localizable.strings | 1 + pl.lproj/Localizable.strings | 1 + protobufs | 2 +- zh-Hans.lproj/Localizable.strings | 1 + zh-Hant-TW.lproj/Localizable.strings | 1 + 20 files changed, 318 insertions(+), 166 deletions(-) create mode 100644 Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift rename Meshtastic/Views/Nodes/Helpers/Map/{ => MapContent}/NodeMapContent.swift (100%) diff --git a/Meshtastic.xcodeproj/project.pbxproj b/Meshtastic.xcodeproj/project.pbxproj index 87b0ed30..ebc7efee 100644 --- a/Meshtastic.xcodeproj/project.pbxproj +++ b/Meshtastic.xcodeproj/project.pbxproj @@ -185,6 +185,7 @@ DDDB445029F8AC9C00EE2349 /* UIImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDDB444F29F8AC9C00EE2349 /* UIImage.swift */; }; DDDB445229F8ACF900EE2349 /* Date.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDDB445129F8ACF900EE2349 /* Date.swift */; }; DDDB445429F8AD1600EE2349 /* Data.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDDB445329F8AD1600EE2349 /* Data.swift */; }; + DDDC22382BA92344002C44F1 /* MeshMapContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDDC22372BA92344002C44F1 /* MeshMapContent.swift */; }; DDDE59F529AF163D00490C6C /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DD41A61C29AE7E8E003C5A37 /* WidgetKit.framework */; }; DDDE59F629AF163D00490C6C /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DD41A61E29AE7E8F003C5A37 /* SwiftUI.framework */; }; DDDE59F929AF163D00490C6C /* WidgetsBundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDDE59F829AF163D00490C6C /* WidgetsBundle.swift */; }; @@ -456,6 +457,7 @@ DDDB445329F8AD1600EE2349 /* Data.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Data.swift; sourceTree = ""; }; DDDC22312BA76701002C44F1 /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Localizable.strings; sourceTree = ""; }; DDDC22322BA76961002C44F1 /* zh-Hant-TW */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hant-TW"; path = "zh-Hant-TW.lproj/Localizable.strings"; sourceTree = ""; }; + DDDC22372BA92344002C44F1 /* MeshMapContent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MeshMapContent.swift; sourceTree = ""; }; DDDD527729B5B83F0045BC3C /* MeshtasticDataModelV9.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = MeshtasticDataModelV9.xcdatamodel; sourceTree = ""; }; DDDE59F429AF163D00490C6C /* WidgetsExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = WidgetsExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; }; DDDE59F829AF163D00490C6C /* WidgetsBundle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetsBundle.swift; sourceTree = ""; }; @@ -747,7 +749,7 @@ DDAD49EB2AFAE82500B4425D /* Map */ = { isa = PBXGroup; children = ( - DD93800A2BA3F968008BEC06 /* NodeMapContent.swift */, + DDDC22362BA9232C002C44F1 /* MapContent */, DD94B73F2ACCE3BE00DCD1D1 /* MapSettingsForm.swift */, DDB6CCFA2AAF805100945AF6 /* NodeMapSwiftUI.swift */, DD13AA482AB73BF400BA0C98 /* PositionPopover.swift */, @@ -986,6 +988,15 @@ path = Extensions; sourceTree = ""; }; + DDDC22362BA9232C002C44F1 /* MapContent */ = { + isa = PBXGroup; + children = ( + DDDC22372BA92344002C44F1 /* MeshMapContent.swift */, + DD93800A2BA3F968008BEC06 /* NodeMapContent.swift */, + ); + path = MapContent; + sourceTree = ""; + }; DDDE59F729AF163D00490C6C /* Widgets */ = { isa = PBXGroup; children = ( @@ -1214,6 +1225,7 @@ DD5E523F298F5A9E00D21B61 /* AirQualityIndexCompact.swift in Sources */, DD964FBF296E76EF007C176F /* WaypointFormMapKit.swift in Sources */, DD3501892852FC3B000FC853 /* Settings.swift in Sources */, + DDDC22382BA92344002C44F1 /* MeshMapContent.swift in Sources */, DDDB443629F6287000EE2349 /* MapButtons.swift in Sources */, DD5D0A9C2931B9F200F7EA61 /* EthernetModes.swift in Sources */, 6DEDA55A2A957B8E00321D2E /* DetectionSensorLog.swift in Sources */, diff --git a/Meshtastic/Enums/MessagingEnums.swift b/Meshtastic/Enums/MessagingEnums.swift index 010c324a..193060fa 100644 --- a/Meshtastic/Enums/MessagingEnums.swift +++ b/Meshtastic/Enums/MessagingEnums.swift @@ -13,17 +13,20 @@ enum BubblePosition { enum Tapbacks: Int, CaseIterable, Identifiable { - case heart = 0 - case thumbsUp = 1 - case thumbsDown = 2 - case haHa = 3 - case exclamation = 4 - case question = 5 - case poop = 6 + case wave = 0 + case heart = 1 + case thumbsUp = 2 + case thumbsDown = 3 + case haHa = 4 + case exclamation = 5 + case question = 6 + case poop = 7 var id: Int { self.rawValue } var emojiString: String { switch self { + case .wave: + return "👋" case .heart: return "❤️" case .thumbsUp: @@ -42,6 +45,8 @@ enum Tapbacks: Int, CaseIterable, Identifiable { } var description: String { switch self { + case .wave: + return "tapback.wave".localized case .heart: return "tapback.heart".localized case .thumbsUp: diff --git a/Meshtastic/Extensions/CoreData/PositionEntityExtension.swift b/Meshtastic/Extensions/CoreData/PositionEntityExtension.swift index d9079158..4b9ce0c2 100644 --- a/Meshtastic/Extensions/CoreData/PositionEntityExtension.swift +++ b/Meshtastic/Extensions/CoreData/PositionEntityExtension.swift @@ -11,6 +11,17 @@ import MapKit import SwiftUI extension PositionEntity { + + static func allPositionsFetchRequest() -> NSFetchRequest { + let request: NSFetchRequest = PositionEntity.fetchRequest() + // request.fetchLimit = 100 + //request.fetchBatchSize = 2 + //request.includesSubentities = false + request.returnsDistinctResults = true + request.sortDescriptors = [NSSortDescriptor(key: "time", ascending: true)] + request.predicate = NSPredicate(format: "nodePosition != nil && latest == true", Calendar.current.date(byAdding: .day, value: -7, to: Date())! as NSDate) + return request + } var latitude: Double? { diff --git a/Meshtastic/Helpers/MeshPackets.swift b/Meshtastic/Helpers/MeshPackets.swift index c02835e7..e89aeb82 100644 --- a/Meshtastic/Helpers/MeshPackets.swift +++ b/Meshtastic/Helpers/MeshPackets.swift @@ -724,24 +724,6 @@ func telemetryPacket(packet: MeshPacket, connectedNode: Int64, context: NSManage ) ] manager.schedule() - -// let content = UNMutableNotificationContent() -// content.title = "Critically Low Battery!" -// content.body = "Time to charge your radio, there is \(telemetry.batteryLevel)% battery remaining." -// content.userInfo["target"] = "node" -// content.userInfo["path"] = "meshtastic://node/\(telemetry.nodeTelemetry?.num ?? 0)" -// let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 1, repeats: false) -// let uuidString = UUID().uuidString -// let request = UNNotificationRequest(identifier: uuidString, content: content, trigger: trigger) -// let notificationCenter = UNUserNotificationCenter.current() -// notificationCenter.add(request) { (error) in -// if error != nil { -// // Handle any errors. -// print("Error creating local low battery notification: \(error?.localizedDescription ?? "no description")") -// } else { -// print("Created local low battery notification.") -// } -// } } // Update our live activity if there is one running, not available on mac iOS >= 16.2 #if !targetEnvironment(macCatalyst) diff --git a/Meshtastic/Persistence/UpdateCoreData.swift b/Meshtastic/Persistence/UpdateCoreData.swift index 121cab33..98561c0d 100644 --- a/Meshtastic/Persistence/UpdateCoreData.swift +++ b/Meshtastic/Persistence/UpdateCoreData.swift @@ -148,7 +148,9 @@ func upsertNodeInfoPacket (packet: MeshPacket, context: NSManagedObjectContext) newNode.channel = Int32(packet.channel) } if let nodeInfoMessage = try? NodeInfo(serializedData: packet.decoded.payload) { - newNode.hopsAway = Int32(truncatingIfNeeded: nodeInfoMessage.hopsAway) + newNode.hopsAway = Int32(nodeInfoMessage.hopsAway) + } else if packet.hopStart != 0 && packet.hopLimit <= packet.hopStart { + newNode.hopsAway = Int32(packet.hopStart - packet.hopLimit) } if let newUserMessage = try? User(serializedData: packet.decoded.payload) { @@ -218,8 +220,8 @@ func upsertNodeInfoPacket (packet: MeshPacket, context: NSManagedObjectContext) } if let nodeInfoMessage = try? NodeInfo(serializedData: packet.decoded.payload) { - fetchedNode[0].channel = Int32(nodeInfoMessage.channel) - fetchedNode[0].hopsAway = Int32(truncatingIfNeeded: nodeInfoMessage.hopsAway) + + fetchedNode[0].hopsAway = Int32(nodeInfoMessage.hopsAway) if nodeInfoMessage.hasDeviceMetrics { let telemetry = TelemetryEntity(context: context) telemetry.batteryLevel = Int32(nodeInfoMessage.deviceMetrics.batteryLevel) @@ -231,6 +233,7 @@ func upsertNodeInfoPacket (packet: MeshPacket, context: NSManagedObjectContext) fetchedNode[0].telemetries? = NSOrderedSet(array: newTelemetries) } if nodeInfoMessage.hasUser { + fetchedNode[0].user!.vip = nodeInfoMessage.isFavorite /// Seeing Some crashes here ? fetchedNode[0].user!.userId = nodeInfoMessage.user.id fetchedNode[0].user!.num = Int64(nodeInfoMessage.num) @@ -239,6 +242,8 @@ func upsertNodeInfoPacket (packet: MeshPacket, context: NSManagedObjectContext) fetchedNode[0].user!.role = Int32(nodeInfoMessage.user.role.rawValue) fetchedNode[0].user!.hwModel = String(describing: nodeInfoMessage.user.hwModel).uppercased() } + } else if packet.hopStart != 0 && packet.hopLimit <= packet.hopStart { + fetchedNode[0].hopsAway = Int32(packet.hopStart - packet.hopLimit) } if (fetchedNode[0].user == nil) { let newUser = UserEntity(context: context) @@ -317,9 +322,9 @@ func upsertPositionPacket (packet: MeshPacket, context: NSManagedObjectContext) return } /// Don't save nearly the same position over and over. If the next position is less than 10 meters from the new position, delete the previous position and save the new one. - if mutablePositions.count > 0 && position.precisionBits == 32 { + if mutablePositions.count > 0 && (position.precisionBits == 32 || position.precisionBits == 0) { let mostRecent = mutablePositions.lastObject as! PositionEntity - if mostRecent.coordinate.distance(from: position.coordinate) < 15 { + if mostRecent.coordinate.distance(from: position.coordinate) < 15.0 { mutablePositions.remove(mostRecent) } } else if mutablePositions.count > 0 && 11...16 ~= position.precisionBits { diff --git a/Meshtastic/Protobufs/meshtastic/deviceonly.pb.swift b/Meshtastic/Protobufs/meshtastic/deviceonly.pb.swift index 950c577e..f25a5cd1 100644 --- a/Meshtastic/Protobufs/meshtastic/deviceonly.pb.swift +++ b/Meshtastic/Protobufs/meshtastic/deviceonly.pb.swift @@ -269,6 +269,14 @@ struct NodeInfoLite { set {_uniqueStorage()._hopsAway = newValue} } + /// + /// True if node is in our favorites list + /// Persists between NodeDB internal clean ups + var isFavorite: Bool { + get {return _storage._isFavorite} + set {_uniqueStorage()._isFavorite = newValue} + } + var unknownFields = SwiftProtobuf.UnknownStorage() init() {} @@ -600,6 +608,7 @@ extension NodeInfoLite: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat 7: .same(proto: "channel"), 8: .standard(proto: "via_mqtt"), 9: .standard(proto: "hops_away"), + 10: .standard(proto: "is_favorite"), ] fileprivate class _StorageClass { @@ -612,6 +621,7 @@ extension NodeInfoLite: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat var _channel: UInt32 = 0 var _viaMqtt: Bool = false var _hopsAway: UInt32 = 0 + var _isFavorite: Bool = false static let defaultInstance = _StorageClass() @@ -627,6 +637,7 @@ extension NodeInfoLite: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat _channel = source._channel _viaMqtt = source._viaMqtt _hopsAway = source._hopsAway + _isFavorite = source._isFavorite } } @@ -654,6 +665,7 @@ extension NodeInfoLite: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat case 7: try { try decoder.decodeSingularUInt32Field(value: &_storage._channel) }() case 8: try { try decoder.decodeSingularBoolField(value: &_storage._viaMqtt) }() case 9: try { try decoder.decodeSingularUInt32Field(value: &_storage._hopsAway) }() + case 10: try { try decoder.decodeSingularBoolField(value: &_storage._isFavorite) }() default: break } } @@ -693,6 +705,9 @@ extension NodeInfoLite: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat if _storage._hopsAway != 0 { try visitor.visitSingularUInt32Field(value: _storage._hopsAway, fieldNumber: 9) } + if _storage._isFavorite != false { + try visitor.visitSingularBoolField(value: _storage._isFavorite, fieldNumber: 10) + } } try unknownFields.traverse(visitor: &visitor) } @@ -711,6 +726,7 @@ extension NodeInfoLite: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat if _storage._channel != rhs_storage._channel {return false} if _storage._viaMqtt != rhs_storage._viaMqtt {return false} if _storage._hopsAway != rhs_storage._hopsAway {return false} + if _storage._isFavorite != rhs_storage._isFavorite {return false} return true } if !storagesAreEqual {return false} diff --git a/Meshtastic/Protobufs/meshtastic/mesh.pb.swift b/Meshtastic/Protobufs/meshtastic/mesh.pb.swift index 2890db6c..18da455b 100644 --- a/Meshtastic/Protobufs/meshtastic/mesh.pb.swift +++ b/Meshtastic/Protobufs/meshtastic/mesh.pb.swift @@ -1861,6 +1861,14 @@ struct NodeInfo { set {_uniqueStorage()._hopsAway = newValue} } + /// + /// True if node is in our favorites list + /// Persists between NodeDB internal clean ups + var isFavorite: Bool { + get {return _storage._isFavorite} + set {_uniqueStorage()._isFavorite = newValue} + } + var unknownFields = SwiftProtobuf.UnknownStorage() init() {} @@ -3647,6 +3655,7 @@ extension NodeInfo: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationB 7: .same(proto: "channel"), 8: .standard(proto: "via_mqtt"), 9: .standard(proto: "hops_away"), + 10: .standard(proto: "is_favorite"), ] fileprivate class _StorageClass { @@ -3659,6 +3668,7 @@ extension NodeInfo: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationB var _channel: UInt32 = 0 var _viaMqtt: Bool = false var _hopsAway: UInt32 = 0 + var _isFavorite: Bool = false static let defaultInstance = _StorageClass() @@ -3674,6 +3684,7 @@ extension NodeInfo: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationB _channel = source._channel _viaMqtt = source._viaMqtt _hopsAway = source._hopsAway + _isFavorite = source._isFavorite } } @@ -3701,6 +3712,7 @@ extension NodeInfo: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationB case 7: try { try decoder.decodeSingularUInt32Field(value: &_storage._channel) }() case 8: try { try decoder.decodeSingularBoolField(value: &_storage._viaMqtt) }() case 9: try { try decoder.decodeSingularUInt32Field(value: &_storage._hopsAway) }() + case 10: try { try decoder.decodeSingularBoolField(value: &_storage._isFavorite) }() default: break } } @@ -3740,6 +3752,9 @@ extension NodeInfo: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationB if _storage._hopsAway != 0 { try visitor.visitSingularUInt32Field(value: _storage._hopsAway, fieldNumber: 9) } + if _storage._isFavorite != false { + try visitor.visitSingularBoolField(value: _storage._isFavorite, fieldNumber: 10) + } } try unknownFields.traverse(visitor: &visitor) } @@ -3758,6 +3773,7 @@ extension NodeInfo: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationB if _storage._channel != rhs_storage._channel {return false} if _storage._viaMqtt != rhs_storage._viaMqtt {return false} if _storage._hopsAway != rhs_storage._hopsAway {return false} + if _storage._isFavorite != rhs_storage._isFavorite {return false} return true } if !storagesAreEqual {return false} diff --git a/Meshtastic/Views/Messages/UserMessageList.swift b/Meshtastic/Views/Messages/UserMessageList.swift index 7f0660ee..c62def59 100644 --- a/Meshtastic/Views/Messages/UserMessageList.swift +++ b/Meshtastic/Views/Messages/UserMessageList.swift @@ -73,7 +73,7 @@ struct UserMessageList: View { if message.realACK { Text("\(ackErrorVal?.display ?? "Empty Ack Error")").font(.caption2).foregroundColor(.gray) } else { - Text("Implicit ACK from another node").font(.caption2).foregroundColor(.orange) + Text("Acknowledged by another node").font(.caption2).foregroundColor(.orange) } } else if currentUser && message.ackError == 0 { // Empty Error diff --git a/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift b/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift new file mode 100644 index 00000000..0e0c519f --- /dev/null +++ b/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift @@ -0,0 +1,162 @@ +// +// MeshMapContent.swift +// Meshtastic +// +// Created by Garth Vander Houwen on 3/17/24. +// + +import SwiftUI +import MapKit + +import SwiftUI +import MapKit + +@available(iOS 17.0, macOS 14.0, *) +struct MeshMapContent: MapContent { + + @State var positions: [PositionEntity] = [] + @State var waypoints: [WaypointEntity] = [] + @State var routes: [RouteEntity] = [] + /// Parameters + @Binding var showUserLocation: Bool + @Binding var showNodeHistory: Bool + @Binding var showRouteLines: Bool + @Binding var showConvexHull: Bool + @Binding var showTraffic: Bool + @Binding var showPointsOfInterest: Bool + @Binding var selectedMapLayer: MapLayer + // Map Configuration + ///@Namespace var mapScope + + @State var mapStyle: MapStyle = MapStyle.standard(elevation: .realistic, emphasis: MapStyle.StandardEmphasis.muted ,pointsOfInterest: .excludingAll, showsTraffic: false) + //@State var position = MapCameraPosition.automatic + //@State var scene: MKLookAroundScene? + //@State var isLookingAround = false + //@State var isEditingSettings = false + @Binding var selectedPosition: PositionEntity? + @Binding var showWaypoints: Bool + //@Binding var editingWaypoint: WaypointEntity? + @Binding var selectedWaypoint: WaypointEntity? + + var delay: Double = 0 + @State private var scale: CGFloat = 0.5 + + @MapContentBuilder + var meshMap: some MapContent { + let lineCoords = positions.compactMap({(position) -> CLLocationCoordinate2D in + return position.nodeCoordinate ?? LocationsHandler.DefaultLocation + }) + /// Convex Hull + if showConvexHull { + if lineCoords.count > 0 { + let hull = lineCoords.getConvexHull() + MapPolygon(coordinates: hull) + .stroke(.blue, lineWidth: 3) + .foregroundStyle(.indigo.opacity(0.4)) + } + } + /// Position Annotations + ForEach(Array(positions), id: \.id) { position in + /// Node color from node.num + let nodeColor = UIColor(hex: UInt32(position.nodePosition?.num ?? 0)) + Annotation(position.nodePosition?.user?.longName ?? "?", coordinate: position.coordinate) { + LazyVStack { + ZStack { + let nodeColor = UIColor(hex: UInt32(position.nodePosition?.num ?? 0)) + if position.nodePosition?.isOnline ?? false { + Circle() + .fill(Color(nodeColor.lighter()).opacity(0.4).shadow(.drop(color: Color(nodeColor).isLight() ? .black : .white, radius: 5))) + .foregroundStyle(Color(nodeColor.lighter()).opacity(0.3)) +// .scaleEffect(scale) +// .animation( +// Animation.easeInOut(duration: 0.6) +// .repeatForever().delay(delay), value: scale +// ) +// .onAppear { +// self.scale = 1 +// } +// .frame(width: 60, height: 60) + } + if position.nodePosition?.hasDetectionSensorMetrics ?? false { + Image(systemName: "sensor.fill") + .symbolRenderingMode(.palette) + .symbolEffect(.variableColor) + .padding() + .foregroundStyle(.white) + .background(Color(nodeColor)) + .clipShape(Circle()) + } else { + CircleText(text: position.nodePosition?.user?.shortName ?? "?", color: Color(nodeColor), circleSize: 40) + } + } + } + .onTapGesture { location in + selectedPosition = (selectedPosition == position ? nil : position) + } + } + /// Reduced Precision Map Circles + if 11...16 ~= position.precisionBits { + let pp = PositionPrecision(rawValue: Int(position.precisionBits)) + let radius : CLLocationDistance = pp?.precisionMeters ?? 0 + if radius > 0.0 { + MapCircle(center: position.coordinate, radius: radius) + .foregroundStyle(Color(nodeColor).opacity(0.25)) + .stroke(.white, lineWidth: 2) + } + } + /// Routes + ForEach(Array(routes), id: \.id) { route in + let routeLocations = Array(route.locations!) as! [LocationEntity] + let routeCoords = routeLocations.compactMap({(loc) -> CLLocationCoordinate2D in + return loc.locationCoordinate ?? LocationHelper.DefaultLocation + }) + Annotation("Start", coordinate: routeCoords.first ?? LocationHelper.DefaultLocation) { + ZStack { + Circle() + .fill(Color(.green)) + .strokeBorder(.white, lineWidth: 3) + .frame(width: 15, height: 15) + } + } + .annotationTitles(.automatic) + Annotation("Finish", coordinate: routeCoords.last ?? LocationHelper.DefaultLocation) { + ZStack { + Circle() + .fill(Color(.black)) + .strokeBorder(.white, lineWidth: 3) + .frame(width: 15, height: 15) + } + } + .annotationTitles(.automatic) + let solid = StrokeStyle( + lineWidth: 3, + lineCap: .round, lineJoin: .round + ) + MapPolyline(coordinates: routeCoords) + .stroke(Color(UIColor(hex: UInt32(route.color))), style: solid) + + } + } + + /// Waypoint Annotations + if waypoints.count > 0 && showWaypoints { + ForEach(Array(waypoints), id: \.id) { waypoint in + Annotation(waypoint.name ?? "?", coordinate: waypoint.coordinate) { + LazyVStack { + CircleText(text: String(UnicodeScalar(Int(waypoint.icon)) ?? "📍"), color: Color.orange, circleSize: 40) + .onTapGesture(perform: { location in + selectedWaypoint = (selectedWaypoint == waypoint ? nil : waypoint) + }) + } + } + } + } + } + + @MapContentBuilder + var body: some MapContent { + if positions.count > 0 { + meshMap + } + } +} diff --git a/Meshtastic/Views/Nodes/Helpers/Map/NodeMapContent.swift b/Meshtastic/Views/Nodes/Helpers/Map/MapContent/NodeMapContent.swift similarity index 100% rename from Meshtastic/Views/Nodes/Helpers/Map/NodeMapContent.swift rename to Meshtastic/Views/Nodes/Helpers/Map/MapContent/NodeMapContent.swift diff --git a/Meshtastic/Views/Nodes/Helpers/NodeListItem.swift b/Meshtastic/Views/Nodes/Helpers/NodeListItem.swift index c880d27b..feb528f6 100644 --- a/Meshtastic/Views/Nodes/Helpers/NodeListItem.swift +++ b/Meshtastic/Views/Nodes/Helpers/NodeListItem.swift @@ -130,7 +130,7 @@ struct NodeListItem: View { .font(UIDevice.current.userInterfaceIdiom == .phone ? .callout : .caption) } } - + if node.viaMqtt && connectedNode != node.num { Image(systemName: "network") .symbolRenderingMode(.hierarchical) diff --git a/Meshtastic/Views/Nodes/MeshMap.swift b/Meshtastic/Views/Nodes/MeshMap.swift index 4394efce..ddc66314 100644 --- a/Meshtastic/Views/Nodes/MeshMap.swift +++ b/Meshtastic/Views/Nodes/MeshMap.swift @@ -13,6 +13,8 @@ import Foundation import MapKit #endif + + @available(iOS 17.0, macOS 14.0, *) struct MeshMap: View { @@ -32,22 +34,36 @@ struct MeshMap: View { @Namespace var mapScope @State var mapStyle: MapStyle = MapStyle.standard(elevation: .realistic, emphasis: MapStyle.StandardEmphasis.muted ,pointsOfInterest: .all, showsTraffic: true) @State var position = MapCameraPosition.automatic - @State var scene: MKLookAroundScene? - @State var isLookingAround = false + //@State var scene: MKLookAroundScene? + //@State var isLookingAround = false @State var isEditingSettings = false @State var selectedPosition: PositionEntity? @State var showWaypoints = true @State var editingWaypoint: WaypointEntity? @State var selectedWaypoint: WaypointEntity? - @State var newWaypointCoord :CLLocationCoordinate2D? + @State var newWaypointCoord: CLLocationCoordinate2D? @State var isMeshMap = true - var delay: Double = 0 - @State private var scale: CGFloat = 0.5 + let positionRequest: NSFetchRequest = { + // Create a fetch request. + let request = PositionEntity.fetchRequest() + + // Limit the maximum number of items that the request returns. + request.fetchLimit = 100 + + // Filter the request results, such as to only return unchecked items. + request.predicate = NSPredicate(format: "nodePosition != nil && latest == true && time >= %@", Calendar.current.date(byAdding: .hour, value: -6, to: Date())! as NSDate) + + // Sort the fetched results + request.sortDescriptors = [NSSortDescriptor(key: "time", ascending: true)] + + + return request + }() + /// && time >= %@ - @FetchRequest(sortDescriptors: [NSSortDescriptor(key: "time", ascending: true)], - predicate: NSPredicate(format: "nodePosition != nil && latest == true", Calendar.current.date(byAdding: .day, value: -7, to: Date())! as NSDate), animation: .none) - private var positions: FetchedResults + @FetchRequest(fetchRequest: PositionEntity.allPositionsFetchRequest(), animation: .none) + var positions: FetchedResults @FetchRequest(sortDescriptors: [NSSortDescriptor(key: "name", ascending: false)], predicate: NSPredicate( @@ -61,118 +77,46 @@ struct MeshMap: View { var body: some View { - let lineCoords = Array(positions).compactMap({(position) -> CLLocationCoordinate2D in - return position.nodeCoordinate ?? LocationHelper.DefaultLocation - }) NavigationStack { ZStack { MapReader { reader in Map(position: $position, bounds: MapCameraBounds(minimumDistance: 1, maximumDistance: .infinity), scope: mapScope) { - /// Convex Hull - if showConvexHull { - if lineCoords.count > 0 { - let hull = lineCoords.getConvexHull() - MapPolygon(coordinates: hull) - .stroke(.blue, lineWidth: 3) - .foregroundStyle(.indigo.opacity(0.4)) - } - } - /// Position Annotations - ForEach(Array(positions), id: \.id) { position in - /// Node color from node.num - let nodeColor = UIColor(hex: UInt32(position.nodePosition?.num ?? 0)) - Annotation(position.nodePosition?.user?.longName ?? "?", coordinate: position.coordinate) { - LazyVStack { - ZStack { - let nodeColor = UIColor(hex: UInt32(position.nodePosition?.num ?? 0)) - if position.nodePosition?.isOnline ?? false { - Circle() - .fill(Color(nodeColor.lighter()).opacity(0.4).shadow(.drop(color: Color(nodeColor).isLight() ? .black : .white, radius: 5))) - .foregroundStyle(Color(nodeColor.lighter()).opacity(0.3)) - .scaleEffect(scale) - .animation( - Animation.easeInOut(duration: 0.6) - .repeatForever().delay(delay), value: scale - ) - .onAppear { - self.scale = 1 - } - .frame(width: 60, height: 60) - } - if position.nodePosition?.hasDetectionSensorMetrics ?? false { - Image(systemName: "sensor.fill") - .symbolRenderingMode(.palette) - .symbolEffect(.variableColor) - .padding() - .foregroundStyle(.white) - .background(Color(nodeColor)) - .clipShape(Circle()) - } else { - CircleText(text: position.nodePosition?.user?.shortName ?? "?", color: Color(nodeColor), circleSize: 40) - } - } - } - .onTapGesture { location in - selectedPosition = (selectedPosition == position ? nil : position) - } - } - /// Reduced Precision Map Circles - if 11...16 ~= position.precisionBits { - let pp = PositionPrecision(rawValue: Int(position.precisionBits)) - let radius : CLLocationDistance = pp?.precisionMeters ?? 0 - if radius > 0.0 { - MapCircle(center: position.coordinate, radius: radius) - .foregroundStyle(Color(nodeColor).opacity(0.25)) - .stroke(.white, lineWidth: 2) - } - } - /// Routes - ForEach(Array(routes), id: \.id) { route in - let routeLocations = Array(route.locations!) as! [LocationEntity] - let routeCoords = routeLocations.compactMap({(loc) -> CLLocationCoordinate2D in - return loc.locationCoordinate ?? LocationHelper.DefaultLocation - }) - Annotation("Start", coordinate: routeCoords.first ?? LocationHelper.DefaultLocation) { - ZStack { - Circle() - .fill(Color(.green)) - .strokeBorder(.white, lineWidth: 3) - .frame(width: 15, height: 15) - } - } - .annotationTitles(.automatic) - Annotation("Finish", coordinate: routeCoords.last ?? LocationHelper.DefaultLocation) { - ZStack { - Circle() - .fill(Color(.black)) - .strokeBorder(.white, lineWidth: 3) - .frame(width: 15, height: 15) - } - } - .annotationTitles(.automatic) - let solid = StrokeStyle( - lineWidth: 3, - lineCap: .round, lineJoin: .round - ) - MapPolyline(coordinates: routeCoords) - .stroke(Color(UIColor(hex: UInt32(route.color))), style: solid) - - } - } - - /// Waypoint Annotations - if waypoints.count > 0 && showWaypoints { - ForEach(Array(waypoints), id: \.id) { waypoint in - Annotation(waypoint.name ?? "?", coordinate: waypoint.coordinate) { - LazyVStack { - CircleText(text: String(UnicodeScalar(Int(waypoint.icon)) ?? "📍"), color: Color.orange, circleSize: 40) - .onTapGesture(perform: { location in - selectedWaypoint = (selectedWaypoint == waypoint ? nil : waypoint) - }) - } - } - } - } + MeshMapContent(positions: Array(positions), waypoints: Array(waypoints), routes: Array(routes), showUserLocation: $showUserLocation, showNodeHistory: $showNodeHistory, showRouteLines: $showRouteLines, showConvexHull: $showConvexHull, showTraffic: $showTraffic, showPointsOfInterest: $showPointsOfInterest, selectedMapLayer: $selectedMapLayer, selectedPosition: $selectedPosition, showWaypoints: $showWaypoints, selectedWaypoint: $selectedWaypoint) + +// /// Routes +// ForEach(Array(routes), id: \.id) { route in +// let routeLocations = Array(route.locations!) as! [LocationEntity] +// let routeCoords = routeLocations.compactMap({(loc) -> CLLocationCoordinate2D in +// return loc.locationCoordinate ?? LocationHelper.DefaultLocation +// }) +// Annotation("Start", coordinate: routeCoords.first ?? LocationHelper.DefaultLocation) { +// ZStack { +// Circle() +// .fill(Color(.green)) +// .strokeBorder(.white, lineWidth: 3) +// .frame(width: 15, height: 15) +// } +// } +// .annotationTitles(.automatic) +// Annotation("Finish", coordinate: routeCoords.last ?? LocationHelper.DefaultLocation) { +// ZStack { +// Circle() +// .fill(Color(.black)) +// .strokeBorder(.white, lineWidth: 3) +// .frame(width: 15, height: 15) +// } +// } +// .annotationTitles(.automatic) +// let solid = StrokeStyle( +// lineWidth: 3, +// lineCap: .round, lineJoin: .round +// ) +// MapPolyline(coordinates: routeCoords) +// .stroke(Color(UIColor(hex: UInt32(route.color))), style: solid) +// +// } +// } +// } .mapScope(mapScope) .mapStyle(mapStyle) @@ -185,8 +129,14 @@ struct MeshMap: View { .mapControlVisibility(.automatic) } .controlSize(.regular) + .onTapGesture(count: 1, perform: { + position in + print(position) + // tapText = "map tap" + newWaypointCoord = reader.convert(position, from: .local) ?? CLLocationCoordinate2D.init() + }) .onTapGesture(count: 1, perform: { location in - newWaypointCoord = reader.convert(location , from: .local) + // newWaypointCoord = reader.convert(location , from: .local) }) .onLongPressGesture(minimumDuration: 0.5, maximumDistance: 10) { editingWaypoint = WaypointEntity(context: context) @@ -286,26 +236,12 @@ struct MeshMap: View { .foregroundColor(.accentColor) .buttonStyle(.borderedProminent) } - /// Look Around Button - if self.scene != nil { - Button(action: { - withAnimation { - isLookingAround = !isLookingAround - } - }) { - Image(systemName: isLookingAround ? "binoculars.fill" : "binoculars") - .padding(.vertical, 5) - } - .tint(Color(UIColor.secondarySystemBackground)) - .foregroundColor(.accentColor) - .buttonStyle(.borderedProminent) - } } .controlSize(.regular) .padding(5) } } - .navigationTitle("Mesh Map") + .navigationTitle("\(positions.count) Nodes") .navigationBarItems(leading: MeshtasticLogo(), trailing: ZStack { ConnectedDevice(bluetoothOn: bleManager.isSwitchedOn, deviceConnected: bleManager.connectedPeripheral != nil, name: (bleManager.connectedPeripheral != nil) ? bleManager.connectedPeripheral.shortName : "?") }) diff --git a/de.lproj/Localizable.strings b/de.lproj/Localizable.strings index ada6bdc1..2599d7b2 100644 --- a/de.lproj/Localizable.strings +++ b/de.lproj/Localizable.strings @@ -309,6 +309,7 @@ "tapback.exclamation"="Ausrufezeichen"; "tapback.question"="Fragezeichen"; "tapback.poop"="Kacke"; +"tapback.wave"="Wave"; "telemetry"="Telemetrie (Sensoren)"; "telemetry.config"="Telemetrie Einstellungen"; "timeout"="Zeitlimit erreicht"; diff --git a/en.lproj/Localizable.strings b/en.lproj/Localizable.strings index 69961f21..251e1b0d 100644 --- a/en.lproj/Localizable.strings +++ b/en.lproj/Localizable.strings @@ -326,6 +326,7 @@ "tapback.exclamation"="Exclamation Mark"; "tapback.question"="Question Mark"; "tapback.poop"="Poop"; +"tapback.wave"="Wave"; "telemetry"="Telemetry (Sensors)"; "telemetry.config"="Telemetry Config"; "timeout"="Timeout"; diff --git a/fr.lproj/Localizable.strings b/fr.lproj/Localizable.strings index 4a5ea20d..31642beb 100644 --- a/fr.lproj/Localizable.strings +++ b/fr.lproj/Localizable.strings @@ -292,6 +292,7 @@ "tapback.exclamation"="Point d'exclamation"; "tapback.question"="Point d'interrogation"; "tapback.poop"="Caca"; +"tapback.wave"="Wave"; "telemetry"="Télémetrie (Capteurs)"; "telemetry.config"="Configuration de télémetrie"; "timeout"="Délai d'expiration"; diff --git a/he.lproj/Localizable.strings b/he.lproj/Localizable.strings index c4418a90..22e5a2df 100644 --- a/he.lproj/Localizable.strings +++ b/he.lproj/Localizable.strings @@ -316,6 +316,7 @@ "tapback.exclamation"="סימן קריאה"; "tapback.question"="סימן שאלה"; "tapback.poop"="חרא"; +"tapback.wave"="Wave"; "telemetry"="טלמטריה (חיישנים)"; "telemetry.config"="הגדרות טלמטריה"; "timeout"="זמן קצוב"; diff --git a/pl.lproj/Localizable.strings b/pl.lproj/Localizable.strings index b50eff01..2c5aa853 100644 --- a/pl.lproj/Localizable.strings +++ b/pl.lproj/Localizable.strings @@ -310,6 +310,7 @@ "tapback.exclamation"="Wykrzyknik"; "tapback.question"="Znak zapytania"; "tapback.poop"="Kupa"; +"tapback.wave"="Wave"; "telemetry"="Telemetria (czujniki)"; "telemetry.config"="Konfiguracja telemetrii"; "timeout"="Limit czasu"; diff --git a/protobufs b/protobufs index 556e49ba..bcfb49c4 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 556e49ba619e2f4d8fa3c2dee2a94129a43d5f08 +Subproject commit bcfb49c4988b1539fc35e568a58b9f2f5b60738a diff --git a/zh-Hans.lproj/Localizable.strings b/zh-Hans.lproj/Localizable.strings index 67c9ac65..6c8f6b0a 100644 --- a/zh-Hans.lproj/Localizable.strings +++ b/zh-Hans.lproj/Localizable.strings @@ -309,6 +309,7 @@ "tapback.exclamation"="感叹号"; "tapback.question"="问号"; "tapback.poop"="便便"; +"tapback.wave"="Wave"; "telemetry"="遥测(传感器)"; "telemetry.config"="遥测配置"; "timeout"="超时"; diff --git a/zh-Hant-TW.lproj/Localizable.strings b/zh-Hant-TW.lproj/Localizable.strings index 6f36c512..d0f8e876 100644 --- a/zh-Hant-TW.lproj/Localizable.strings +++ b/zh-Hant-TW.lproj/Localizable.strings @@ -309,6 +309,7 @@ "tapback.exclamation"="驚嘆號"; "tapback.question"="問號"; "tapback.poop"="便便"; +"tapback.wave"="Wave"; "telemetry"="遠測(傳感器)"; "telemetry.config"="遠側設定"; "timeout"="超時"; From 6d073d008629a5e29c973b78d75a1d3011e62738 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sat, 23 Mar 2024 09:11:18 -0700 Subject: [PATCH 40/74] Bump version --- Meshtastic.xcodeproj/project.pbxproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Meshtastic.xcodeproj/project.pbxproj b/Meshtastic.xcodeproj/project.pbxproj index ebc7efee..67e51a8e 100644 --- a/Meshtastic.xcodeproj/project.pbxproj +++ b/Meshtastic.xcodeproj/project.pbxproj @@ -1603,7 +1603,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 2.3.1; + MARKETING_VERSION = 2.3.2; PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient; PRODUCT_NAME = "$(TARGET_NAME)"; SUPPORTS_MACCATALYST = YES; @@ -1637,7 +1637,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 2.3.1; + MARKETING_VERSION = 2.3.2; PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient; PRODUCT_NAME = "$(TARGET_NAME)"; SUPPORTS_MACCATALYST = YES; @@ -1759,7 +1759,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 2.3.1; + MARKETING_VERSION = 2.3.2; PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient.Widgets; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -1792,7 +1792,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 2.3.1; + MARKETING_VERSION = 2.3.2; PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient.Widgets; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; From e07c20a1ad5eb5463be1b5c97ee023d62617878e Mon Sep 17 00:00:00 2001 From: ChDel Date: Sat, 23 Mar 2024 14:18:41 -0700 Subject: [PATCH 41/74] Refactoring User Defaults extension --- Meshtastic/Extensions/UserDefaults.swift | 281 ++++++++--------------- 1 file changed, 95 insertions(+), 186 deletions(-) diff --git a/Meshtastic/Extensions/UserDefaults.swift b/Meshtastic/Extensions/UserDefaults.swift index 39cc9b89..c42ee9bc 100644 --- a/Meshtastic/Extensions/UserDefaults.swift +++ b/Meshtastic/Extensions/UserDefaults.swift @@ -7,6 +7,26 @@ import Foundation +@propertyWrapper +struct UserDefault { + let key: UserDefaults.Keys + let defaultValue: T + + init(_ key: UserDefaults.Keys, defaultValue: T) { + self.key = key + self.defaultValue = defaultValue + } + + var wrappedValue: T { + get { + UserDefaults.standard.object(forKey: key.rawValue) as? T ?? defaultValue + } + set { + UserDefaults.standard.set(newValue, forKey: key.rawValue) + } + } +} + extension UserDefaults { enum Keys: String, CaseIterable { case preferredPeripheralId @@ -18,10 +38,16 @@ extension UserDefaults { case meshMapShowNodeHistory case meshMapShowRouteLines case enableMapConvexHull + case enableMapRecentering + case enableMapNodeHistoryPins + case enableMapRouteLines case enableMapTraffic case enableMapPointsOfInterest case enableOfflineMaps + case enableOfflineMapsMBTiles case mapTileServer + case enableOverlayServer + case mapOverlayServer case mapTilesAboveLabels case mapUseLegacy case enableDetectionNotifications @@ -34,190 +60,73 @@ extension UserDefaults { func reset() { Keys.allCases.forEach { removeObject(forKey: $0.rawValue) } } - static var preferredPeripheralId: String { - get { - UserDefaults.standard.string(forKey: "preferredPeripheralId") ?? "" - } - set { - UserDefaults.standard.set(newValue, forKey: "preferredPeripheralId") - } - } - static var preferredPeripheralNum: Int { - get { - UserDefaults.standard.integer(forKey: "preferredPeripheralNum") - } - set { - UserDefaults.standard.set(newValue, forKey: "preferredPeripheralNum") - } - } - static var provideLocation: Bool { - get { - UserDefaults.standard.bool(forKey: "provideLocation") - } set { - UserDefaults.standard.set(newValue, forKey: "provideLocation") - } - } - static var provideLocationInterval: Int { - get { - UserDefaults.standard.integer(forKey: "provideLocationInterval") - } - set { - UserDefaults.standard.set(newValue, forKey: "provideLocationInterval") - } - } - static var mapLayer: MapLayer { - get { - MapLayer(rawValue: UserDefaults.standard.string(forKey: "mapLayer") ?? MapLayer.standard.rawValue) ?? MapLayer.standard - } - set { - UserDefaults.standard.set(newValue.rawValue, forKey: "mapLayer") - } - } - static var enableMapRecentering: Bool { - get { - UserDefaults.standard.bool(forKey: "meshMapRecentering") - } - set { - UserDefaults.standard.set(newValue, forKey: "meshMapRecentering") - } - } - static var enableMapNodeHistoryPins: Bool { - get { - UserDefaults.standard.bool(forKey: "meshMapShowNodeHistory") - } - set { - UserDefaults.standard.set(newValue, forKey: "meshMapShowNodeHistory") - } - } - static var enableMapRouteLines: Bool { - get { - UserDefaults.standard.bool(forKey: "meshMapShowRouteLines") - } - set { - UserDefaults.standard.set(newValue, forKey: "meshMapShowRouteLines") - } - } - static var enableMapConvexHull: Bool { - get { - UserDefaults.standard.bool(forKey: "enableMapConvexHull") - } - set { - UserDefaults.standard.set(newValue, forKey: "enableMapConvexHull") - } - } - static var enableMapTraffic: Bool { - get { - UserDefaults.standard.bool(forKey: "enableMapTraffic") - } - set { - UserDefaults.standard.set(newValue, forKey: "enableMapTraffic") - } - } - static var enableMapPointsOfInterest: Bool { - get { - UserDefaults.standard.bool(forKey: "enableMapPointsOfInterest") - } - set { - UserDefaults.standard.set(newValue, forKey: "enableMapPointsOfInterest") - } - } - static var enableOfflineMaps: Bool { - get { - UserDefaults.standard.bool(forKey: "enableOfflineMaps") - } - set { - UserDefaults.standard.set(newValue, forKey: "enableOfflineMaps") - } - } - static var enableOfflineMapsMBTiles: Bool { - get { - UserDefaults.standard.bool(forKey: "enableOfflineMapsMBTiles") - } - set { - UserDefaults.standard.set(newValue, forKey: "enableOfflineMapsMBTiles") - } - } - static var mapTileServer: MapTileServer { - get { - MapTileServer(rawValue: UserDefaults.standard.string(forKey: "mapTileServer") ?? MapTileServer.openStreetMap.rawValue) ?? MapTileServer.openStreetMap - } - set { - UserDefaults.standard.set(newValue.rawValue, forKey: "mapTileServer") - } - } - static var enableOverlayServer: Bool { - get { - UserDefaults.standard.bool(forKey: "enableOverlayServer") - } - set { - UserDefaults.standard.set(newValue, forKey: "enableOverlayServer") - } - } - static var mapOverlayServer: MapOverlayServer { - get { - MapOverlayServer(rawValue: UserDefaults.standard.string(forKey: "mapOverlayServer") ?? MapOverlayServer.baseReReflectivityCurrent.rawValue) ?? MapOverlayServer.baseReReflectivityCurrent - } - set { - UserDefaults.standard.set(newValue.rawValue, forKey: "mapOverlayServer") - } - } - static var mapTilesAboveLabels: Bool { - get { - UserDefaults.standard.bool(forKey: "mapTilesAboveLabels") - } - set { - UserDefaults.standard.set(newValue, forKey: "mapTilesAboveLabels") - } - } - - static var mapUseLegacy: Bool { - get { - UserDefaults.standard.bool(forKey: "mapUseLegacy") - } - set { - UserDefaults.standard.set(newValue, forKey: "mapUseLegacy") - } - } - - static var enableDetectionNotifications: Bool { - get { - UserDefaults.standard.bool(forKey: "enableDetectionNotifications") - } - set { - UserDefaults.standard.set(newValue, forKey: "enableDetectionNotifications") - } - } - - static var detectionSensorRole: DetectionSensorRole { - get { - DetectionSensorRole(rawValue: UserDefaults.standard.string(forKey: "detectionSensorRole") ?? DetectionSensorRole.sensor.rawValue) ?? DetectionSensorRole.sensor - } - set { - UserDefaults.standard.set(newValue.rawValue, forKey: "detectionSensorRole") - } - } - static var enableSmartPosition: Bool { - get { - UserDefaults.standard.bool(forKey: "enableSmartPosition") - } - set { - UserDefaults.standard.set(newValue, forKey: "enableSmartPosition") - } - } - static var modemPreset: Int { - get { - UserDefaults.standard.integer(forKey: "modemPreset") - } - set { - UserDefaults.standard.set(newValue, forKey: "modemPreset") - } - } - static var firmwareVersion: String { - get { - UserDefaults.standard.string(forKey: "firmwareVersion") ?? "0.0.0" - } - set { - UserDefaults.standard.set(newValue, forKey: "firmwareVersion") - } - } + + @UserDefault(.preferredPeripheralId, defaultValue: "") + static var preferredPeripheralId: String + + @UserDefault(.preferredPeripheralNum, defaultValue: 0) + static var preferredPeripheralNum: Int + + @UserDefault(.provideLocation, defaultValue: false) + static var provideLocation: Bool + + @UserDefault(.provideLocationInterval, defaultValue: 0) + static var provideLocationInterval: Int + + @UserDefault(.mapLayer, defaultValue: .standard) + static var mapLayer: MapLayer + + @UserDefault(.enableMapRecentering, defaultValue: false) + static var enableMapRecentering: Bool + + @UserDefault(.enableMapNodeHistoryPins, defaultValue: false) + static var enableMapNodeHistoryPins: Bool + + @UserDefault(.enableMapRouteLines, defaultValue: false) + static var enableMapRouteLines: Bool + + @UserDefault(.enableMapConvexHull, defaultValue: false) + static var enableMapConvexHull: Bool + + @UserDefault(.enableMapTraffic, defaultValue: false) + static var enableMapTraffic: Bool + + @UserDefault(.enableMapPointsOfInterest, defaultValue: false) + static var enableMapPointsOfInterest: Bool + + @UserDefault(.enableOfflineMaps, defaultValue: false) + static var enableOfflineMaps: Bool + + @UserDefault(.enableOfflineMapsMBTiles, defaultValue: false) + static var enableOfflineMapsMBTiles: Bool + + @UserDefault(.mapTileServer, defaultValue: .openStreetMap) + static var mapTileServer: MapTileServer + + @UserDefault(.enableOverlayServer, defaultValue: false) + static var enableOverlayServer: Bool + + @UserDefault(.mapOverlayServer, defaultValue: .baseReReflectivityCurrent) + static var mapOverlayServer: MapOverlayServer + + @UserDefault(.mapTilesAboveLabels, defaultValue: false) + static var mapTilesAboveLabels: Bool + + @UserDefault(.mapUseLegacy, defaultValue: false) + static var mapUseLegacy: Bool + + @UserDefault(.enableDetectionNotifications, defaultValue: false) + static var enableDetectionNotifications: Bool + + @UserDefault(.detectionSensorRole, defaultValue: .sensor) + static var detectionSensorRole: DetectionSensorRole + + @UserDefault(.enableSmartPosition, defaultValue: false) + static var enableSmartPosition: Bool + + @UserDefault(.modemPreset, defaultValue: 0) + static var modemPreset: Int + + @UserDefault(.firmwareVersion, defaultValue: "0.0.0") + static var firmwareVersion: String } From 7d00a5882b9c7173978ab39d38244ab74c5a5c1f Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sat, 23 Mar 2024 18:01:20 -0700 Subject: [PATCH 42/74] Try and use less ram on the mesh map --- .../CoreData/PositionEntityExtension.swift | 7 +- .../CoreData/WaypointEntityExtension.swift | 10 ++ .../contents | 7 +- .../Map/MapContent/MeshMapContent.swift | 25 ++-- Meshtastic/Views/Nodes/MeshMap.swift | 117 ++++++------------ 5 files changed, 66 insertions(+), 100 deletions(-) diff --git a/Meshtastic/Extensions/CoreData/PositionEntityExtension.swift b/Meshtastic/Extensions/CoreData/PositionEntityExtension.swift index 4b9ce0c2..1d1fd991 100644 --- a/Meshtastic/Extensions/CoreData/PositionEntityExtension.swift +++ b/Meshtastic/Extensions/CoreData/PositionEntityExtension.swift @@ -14,11 +14,12 @@ extension PositionEntity { static func allPositionsFetchRequest() -> NSFetchRequest { let request: NSFetchRequest = PositionEntity.fetchRequest() - // request.fetchLimit = 100 - //request.fetchBatchSize = 2 + request.fetchLimit = 75 + //request.fetchBatchSize = 1 + //request.returnsObjectsAsFaults = true //request.includesSubentities = false request.returnsDistinctResults = true - request.sortDescriptors = [NSSortDescriptor(key: "time", ascending: true)] + request.sortDescriptors = [NSSortDescriptor(key: "time", ascending: false)] request.predicate = NSPredicate(format: "nodePosition != nil && latest == true", Calendar.current.date(byAdding: .day, value: -7, to: Date())! as NSDate) return request } diff --git a/Meshtastic/Extensions/CoreData/WaypointEntityExtension.swift b/Meshtastic/Extensions/CoreData/WaypointEntityExtension.swift index 968381b2..76fe8f8e 100644 --- a/Meshtastic/Extensions/CoreData/WaypointEntityExtension.swift +++ b/Meshtastic/Extensions/CoreData/WaypointEntityExtension.swift @@ -10,6 +10,16 @@ import MapKit import SwiftUI extension WaypointEntity { + + static func allWaypointssFetchRequest() -> NSFetchRequest { + let request: NSFetchRequest = WaypointEntity.fetchRequest() + //request.fetchLimit = 100 + //request.fetchBatchSize = 1 + request.returnsDistinctResults = true + request.sortDescriptors = [NSSortDescriptor(key: "name", ascending: false)] + request.predicate = NSPredicate(format: "expire == nil || expire >= %@", Date() as NSDate) + return request + } var latitude: Double? { diff --git a/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 30.xcdatamodel/contents b/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 30.xcdatamodel/contents index 733896d1..72ba98d4 100644 --- a/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 30.xcdatamodel/contents +++ b/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 30.xcdatamodel/contents @@ -1,5 +1,5 @@ - + @@ -448,5 +448,10 @@ + + + + + \ No newline at end of file diff --git a/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift b/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift index 0e0c519f..8b3440ac 100644 --- a/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift +++ b/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift @@ -26,13 +26,6 @@ struct MeshMapContent: MapContent { @Binding var showPointsOfInterest: Bool @Binding var selectedMapLayer: MapLayer // Map Configuration - ///@Namespace var mapScope - - @State var mapStyle: MapStyle = MapStyle.standard(elevation: .realistic, emphasis: MapStyle.StandardEmphasis.muted ,pointsOfInterest: .excludingAll, showsTraffic: false) - //@State var position = MapCameraPosition.automatic - //@State var scene: MKLookAroundScene? - //@State var isLookingAround = false - //@State var isEditingSettings = false @Binding var selectedPosition: PositionEntity? @Binding var showWaypoints: Bool //@Binding var editingWaypoint: WaypointEntity? @@ -67,15 +60,15 @@ struct MeshMapContent: MapContent { Circle() .fill(Color(nodeColor.lighter()).opacity(0.4).shadow(.drop(color: Color(nodeColor).isLight() ? .black : .white, radius: 5))) .foregroundStyle(Color(nodeColor.lighter()).opacity(0.3)) -// .scaleEffect(scale) -// .animation( -// Animation.easeInOut(duration: 0.6) -// .repeatForever().delay(delay), value: scale -// ) -// .onAppear { -// self.scale = 1 -// } -// .frame(width: 60, height: 60) + .scaleEffect(scale) + .animation( + Animation.easeInOut(duration: 0.6) + .repeatForever().delay(delay), value: scale + ) + .onAppear { + self.scale = 1 + } + .frame(width: 60, height: 60) } if position.nodePosition?.hasDetectionSensorMetrics ?? false { Image(systemName: "sensor.fill") diff --git a/Meshtastic/Views/Nodes/MeshMap.swift b/Meshtastic/Views/Nodes/MeshMap.swift index ddc66314..47d83edb 100644 --- a/Meshtastic/Views/Nodes/MeshMap.swift +++ b/Meshtastic/Views/Nodes/MeshMap.swift @@ -32,44 +32,22 @@ struct MeshMap: View { @AppStorage("mapLayer") private var selectedMapLayer: MapLayer = .hybrid // Map Configuration @Namespace var mapScope - @State var mapStyle: MapStyle = MapStyle.standard(elevation: .realistic, emphasis: MapStyle.StandardEmphasis.muted ,pointsOfInterest: .all, showsTraffic: true) + @State var mapStyle: MapStyle = MapStyle.standard(elevation: .flat, emphasis: MapStyle.StandardEmphasis.muted ,pointsOfInterest: .all, showsTraffic: true) @State var position = MapCameraPosition.automatic - //@State var scene: MKLookAroundScene? - //@State var isLookingAround = false @State var isEditingSettings = false @State var selectedPosition: PositionEntity? - @State var showWaypoints = true + @State var showWaypoints = false @State var editingWaypoint: WaypointEntity? @State var selectedWaypoint: WaypointEntity? @State var newWaypointCoord: CLLocationCoordinate2D? @State var isMeshMap = true - let positionRequest: NSFetchRequest = { - // Create a fetch request. - let request = PositionEntity.fetchRequest() - - // Limit the maximum number of items that the request returns. - request.fetchLimit = 100 - - // Filter the request results, such as to only return unchecked items. - request.predicate = NSPredicate(format: "nodePosition != nil && latest == true && time >= %@", Calendar.current.date(byAdding: .hour, value: -6, to: Date())! as NSDate) - - // Sort the fetched results - request.sortDescriptors = [NSSortDescriptor(key: "time", ascending: true)] - - - return request - }() - /// && time >= %@ @FetchRequest(fetchRequest: PositionEntity.allPositionsFetchRequest(), animation: .none) var positions: FetchedResults - @FetchRequest(sortDescriptors: [NSSortDescriptor(key: "name", ascending: false)], - predicate: NSPredicate( - format: "expire == nil || expire >= %@", Date() as NSDate - ), animation: .none) - private var waypoints: FetchedResults + @FetchRequest(fetchRequest: WaypointEntity.allWaypointssFetchRequest(), animation: .none) + var waypoints: FetchedResults @FetchRequest(sortDescriptors: [NSSortDescriptor(key: "name", ascending: true)], predicate: NSPredicate(format: "enabled == true", ""), animation: .none) @@ -82,41 +60,7 @@ struct MeshMap: View { MapReader { reader in Map(position: $position, bounds: MapCameraBounds(minimumDistance: 1, maximumDistance: .infinity), scope: mapScope) { MeshMapContent(positions: Array(positions), waypoints: Array(waypoints), routes: Array(routes), showUserLocation: $showUserLocation, showNodeHistory: $showNodeHistory, showRouteLines: $showRouteLines, showConvexHull: $showConvexHull, showTraffic: $showTraffic, showPointsOfInterest: $showPointsOfInterest, selectedMapLayer: $selectedMapLayer, selectedPosition: $selectedPosition, showWaypoints: $showWaypoints, selectedWaypoint: $selectedWaypoint) - -// /// Routes -// ForEach(Array(routes), id: \.id) { route in -// let routeLocations = Array(route.locations!) as! [LocationEntity] -// let routeCoords = routeLocations.compactMap({(loc) -> CLLocationCoordinate2D in -// return loc.locationCoordinate ?? LocationHelper.DefaultLocation -// }) -// Annotation("Start", coordinate: routeCoords.first ?? LocationHelper.DefaultLocation) { -// ZStack { -// Circle() -// .fill(Color(.green)) -// .strokeBorder(.white, lineWidth: 3) -// .frame(width: 15, height: 15) -// } -// } -// .annotationTitles(.automatic) -// Annotation("Finish", coordinate: routeCoords.last ?? LocationHelper.DefaultLocation) { -// ZStack { -// Circle() -// .fill(Color(.black)) -// .strokeBorder(.white, lineWidth: 3) -// .frame(width: 15, height: 15) -// } -// } -// .annotationTitles(.automatic) -// let solid = StrokeStyle( -// lineWidth: 3, -// lineCap: .round, lineJoin: .round -// ) -// MapPolyline(coordinates: routeCoords) -// .stroke(Color(UIColor(hex: UInt32(route.color))), style: solid) -// -// } -// } -// + } .mapScope(mapScope) .mapStyle(mapStyle) @@ -129,28 +73,41 @@ struct MeshMap: View { .mapControlVisibility(.automatic) } .controlSize(.regular) - .onTapGesture(count: 1, perform: { - position in - print(position) - // tapText = "map tap" - newWaypointCoord = reader.convert(position, from: .local) ?? CLLocationCoordinate2D.init() - }) - .onTapGesture(count: 1, perform: { location in - // newWaypointCoord = reader.convert(location , from: .local) + + .onTapGesture(count: 1, perform: { position in + print(position) + newWaypointCoord = reader.convert(position, from: .local) ?? CLLocationCoordinate2D.init() + }) + .gesture( + LongPressGesture(minimumDuration: 0.5) + .sequenced(before: SpatialTapGesture(coordinateSpace: .local)) + .onEnded { value in + switch value { + case let .second(_, tapValue): + guard let point = tapValue?.location else { + print("Unable to retreive tap location from gesture data.") + return + } + + guard let coordinate = reader.convert(point, from: .local) else { + print("Unable to convert local point to coordinate on map.") + return + } + + newWaypointCoord = coordinate + editingWaypoint = WaypointEntity(context: context) + editingWaypoint!.name = "Waypoint Pin" + editingWaypoint!.expire = Date.now.addingTimeInterval(60 * 480) + editingWaypoint!.latitudeI = Int32((newWaypointCoord?.latitude ?? 0) * 1e7) + editingWaypoint!.longitudeI = Int32((newWaypointCoord?.longitude ?? 0) * 1e7) + editingWaypoint!.expire = Date.now.addingTimeInterval(60 * 480) + editingWaypoint!.id = 0 + print("Long press occured at: \(coordinate)") + default: return + } }) - .onLongPressGesture(minimumDuration: 0.5, maximumDistance: 10) { - editingWaypoint = WaypointEntity(context: context) - editingWaypoint!.name = "Waypoint Pin" - editingWaypoint!.expire = Date.now.addingTimeInterval(60 * 480) - editingWaypoint!.latitudeI = Int32((newWaypointCoord?.latitude ?? 0) * 1e7) - editingWaypoint!.longitudeI = Int32((newWaypointCoord?.longitude ?? 0) * 1e7) - editingWaypoint!.expire = Date.now.addingTimeInterval(60 * 480) - editingWaypoint!.id = 0 - } - } } - .sheet(item: $selectedPosition) { selection in PositionPopover(position: selection, popover: false) .padding() From 03a210e415646ca99f0b8911fca78c11cbf68ffe Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sat, 23 Mar 2024 18:22:10 -0700 Subject: [PATCH 43/74] Get the last 50 nodes seen for the mesh map, zoom much closer by default, only show nodes from the last 48 hours on the mesh map --- Meshtastic/Extensions/CoreData/PositionEntityExtension.swift | 4 ++-- Meshtastic/Views/Nodes/MeshMap.swift | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Meshtastic/Extensions/CoreData/PositionEntityExtension.swift b/Meshtastic/Extensions/CoreData/PositionEntityExtension.swift index 1d1fd991..79d4f581 100644 --- a/Meshtastic/Extensions/CoreData/PositionEntityExtension.swift +++ b/Meshtastic/Extensions/CoreData/PositionEntityExtension.swift @@ -14,13 +14,13 @@ extension PositionEntity { static func allPositionsFetchRequest() -> NSFetchRequest { let request: NSFetchRequest = PositionEntity.fetchRequest() - request.fetchLimit = 75 + request.fetchLimit = 50 //request.fetchBatchSize = 1 //request.returnsObjectsAsFaults = true //request.includesSubentities = false request.returnsDistinctResults = true request.sortDescriptors = [NSSortDescriptor(key: "time", ascending: false)] - request.predicate = NSPredicate(format: "nodePosition != nil && latest == true", Calendar.current.date(byAdding: .day, value: -7, to: Date())! as NSDate) + request.predicate = NSPredicate(format: "nodePosition != nil && latest == true && time >= %@", Calendar.current.date(byAdding: .day, value: -2, to: Date())! as NSDate) return request } diff --git a/Meshtastic/Views/Nodes/MeshMap.swift b/Meshtastic/Views/Nodes/MeshMap.swift index 47d83edb..d17c24cd 100644 --- a/Meshtastic/Views/Nodes/MeshMap.swift +++ b/Meshtastic/Views/Nodes/MeshMap.swift @@ -29,11 +29,11 @@ struct MeshMap: View { @AppStorage("enableMapConvexHull") private var showConvexHull = false @AppStorage("enableMapTraffic") private var showTraffic: Bool = false @AppStorage("enableMapPointsOfInterest") private var showPointsOfInterest: Bool = false - @AppStorage("mapLayer") private var selectedMapLayer: MapLayer = .hybrid + @AppStorage("mapLayer") private var selectedMapLayer: MapLayer = .standard // Map Configuration @Namespace var mapScope @State var mapStyle: MapStyle = MapStyle.standard(elevation: .flat, emphasis: MapStyle.StandardEmphasis.muted ,pointsOfInterest: .all, showsTraffic: true) - @State var position = MapCameraPosition.automatic + @State var position = MapCameraPosition.camera(MapCamera(centerCoordinate: LocationHelper.currentLocation, distance: 2500000, heading: 0, pitch: 0)) @State var isEditingSettings = false @State var selectedPosition: PositionEntity? @State var showWaypoints = false @@ -42,7 +42,6 @@ struct MeshMap: View { @State var newWaypointCoord: CLLocationCoordinate2D? @State var isMeshMap = true - /// && time >= %@ @FetchRequest(fetchRequest: PositionEntity.allPositionsFetchRequest(), animation: .none) var positions: FetchedResults From e9e886e5bc58efbf05865da994e0581880208c15 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sun, 24 Mar 2024 11:45:49 -0700 Subject: [PATCH 44/74] Filter out far away positions on the node map --- .../CoreData/PositionEntityExtension.swift | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/Meshtastic/Extensions/CoreData/PositionEntityExtension.swift b/Meshtastic/Extensions/CoreData/PositionEntityExtension.swift index 79d4f581..9e9a6c49 100644 --- a/Meshtastic/Extensions/CoreData/PositionEntityExtension.swift +++ b/Meshtastic/Extensions/CoreData/PositionEntityExtension.swift @@ -14,13 +14,33 @@ extension PositionEntity { static func allPositionsFetchRequest() -> NSFetchRequest { let request: NSFetchRequest = PositionEntity.fetchRequest() - request.fetchLimit = 50 + request.fetchLimit = 200 //request.fetchBatchSize = 1 - //request.returnsObjectsAsFaults = true + request.returnsObjectsAsFaults = false //request.includesSubentities = false request.returnsDistinctResults = true request.sortDescriptors = [NSSortDescriptor(key: "time", ascending: false)] - request.predicate = NSPredicate(format: "nodePosition != nil && latest == true && time >= %@", Calendar.current.date(byAdding: .day, value: -2, to: Date())! as NSDate) + + let positionPredicate = NSPredicate(format: "nodePosition != nil && latest == true && time >= %@", Calendar.current.date(byAdding: .day, value: -2, to: Date())! as NSDate) + + let pointOfInterest = LocationHelper.currentLocation + + if pointOfInterest.latitude != LocationHelper.DefaultLocation.latitude && pointOfInterest.longitude != LocationHelper.DefaultLocation.longitude { + /// Lets just get nodes within about 500 miles + let D: Double = 800000 * 1.1 + let R: Double = 6371009 + let meanLatitidue = pointOfInterest.latitude * .pi / 180 + let deltaLatitude = D / R * 180 / .pi + let deltaLongitude = D / (R * cos(meanLatitidue)) * 180 / .pi + let minLatitude: Double = pointOfInterest.latitude - deltaLatitude + let maxLatitude: Double = pointOfInterest.latitude + deltaLatitude + let minLongitude: Double = pointOfInterest.longitude - deltaLongitude + let maxLongitude: Double = pointOfInterest.longitude + deltaLongitude + let distancePredicate = NSPredicate(format: "(%lf <= (longitudeI / 1e7)) AND ((longitudeI / 1e7) <= %lf) AND (%lf <= (latitudeI / 1e7)) AND ((latitudeI / 1e7) <= %lf)", minLongitude, maxLongitude,minLatitude, maxLatitude) + request.predicate = NSCompoundPredicate(type: .and, subpredicates: [distancePredicate, positionPredicate]) + } else { + request.predicate = positionPredicate + } return request } From 6be729305d52cfe137932ebf712289fee71bd4f5 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sun, 24 Mar 2024 13:13:05 -0700 Subject: [PATCH 45/74] All positions query updates --- .../Extensions/CoreData/PositionEntityExtension.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Meshtastic/Extensions/CoreData/PositionEntityExtension.swift b/Meshtastic/Extensions/CoreData/PositionEntityExtension.swift index 9e9a6c49..5d5e2fa5 100644 --- a/Meshtastic/Extensions/CoreData/PositionEntityExtension.swift +++ b/Meshtastic/Extensions/CoreData/PositionEntityExtension.swift @@ -14,14 +14,14 @@ extension PositionEntity { static func allPositionsFetchRequest() -> NSFetchRequest { let request: NSFetchRequest = PositionEntity.fetchRequest() - request.fetchLimit = 200 + //request.fetchLimit = 200 //request.fetchBatchSize = 1 request.returnsObjectsAsFaults = false - //request.includesSubentities = false + request.includesSubentities = true request.returnsDistinctResults = true request.sortDescriptors = [NSSortDescriptor(key: "time", ascending: false)] - let positionPredicate = NSPredicate(format: "nodePosition != nil && latest == true && time >= %@", Calendar.current.date(byAdding: .day, value: -2, to: Date())! as NSDate) + let positionPredicate = NSPredicate(format: "nodePosition != nil && nodePosition.user.shortName != nil && latest == true && time >= %@", Calendar.current.date(byAdding: .day, value: -2, to: Date())! as NSDate) let pointOfInterest = LocationHelper.currentLocation @@ -37,7 +37,7 @@ extension PositionEntity { let minLongitude: Double = pointOfInterest.longitude - deltaLongitude let maxLongitude: Double = pointOfInterest.longitude + deltaLongitude let distancePredicate = NSPredicate(format: "(%lf <= (longitudeI / 1e7)) AND ((longitudeI / 1e7) <= %lf) AND (%lf <= (latitudeI / 1e7)) AND ((latitudeI / 1e7) <= %lf)", minLongitude, maxLongitude,minLatitude, maxLatitude) - request.predicate = NSCompoundPredicate(type: .and, subpredicates: [distancePredicate, positionPredicate]) + request.predicate = NSCompoundPredicate(type: .and, subpredicates: [positionPredicate, distancePredicate]) } else { request.predicate = positionPredicate } From 554fe9a3ca0b9fbd1b04e3db2a3cf2f7ab32bad6 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sun, 24 Mar 2024 22:23:55 -0700 Subject: [PATCH 46/74] Node distance filter for the mesh map --- Meshtastic/Enums/AppSettingsEnums.swift | 14 +++++++++++ .../CoreData/PositionEntityExtension.swift | 4 +-- Meshtastic/Extensions/String.swift | 25 +++++++++++++++++++ Meshtastic/Extensions/UserDefaults.swift | 4 +++ Meshtastic/Helpers/MeshPackets.swift | 13 +++++++--- .../Nodes/Helpers/Map/MapSettingsForm.swift | 22 ++++++++++++++++ .../Nodes/Helpers/Map/NodeMapSwiftUI.swift | 3 ++- Meshtastic/Views/Nodes/MeshMap.swift | 7 +++--- .../Views/Settings/Channels/ChannelForm.swift | 2 +- 9 files changed, 83 insertions(+), 11 deletions(-) diff --git a/Meshtastic/Enums/AppSettingsEnums.swift b/Meshtastic/Enums/AppSettingsEnums.swift index dd0a94ed..fd4fe088 100644 --- a/Meshtastic/Enums/AppSettingsEnums.swift +++ b/Meshtastic/Enums/AppSettingsEnums.swift @@ -50,6 +50,20 @@ enum MeshMapTypes: Int, CaseIterable, Identifiable { } } +enum MeshMapDistances: Double, CaseIterable, Identifiable { + case fiftyMiles = 80467.2 + case oneHundredMiles = 160934 + case twoHundredMiles = 321869 + case fiveHundredMiles = 804672 + case oneThousandMiles = 1609000 + case twoThousandMiles = 3218688 + var id: Double { self.rawValue } + var description: String { + let distanceFormatter = MKDistanceFormatter() + return "\(distanceFormatter.string(fromDistance: Double(self.rawValue))) away" + } +} + enum UserTrackingModes: Int, CaseIterable, Identifiable { case none = 0 case follow = 1 diff --git a/Meshtastic/Extensions/CoreData/PositionEntityExtension.swift b/Meshtastic/Extensions/CoreData/PositionEntityExtension.swift index 5d5e2fa5..44777bb3 100644 --- a/Meshtastic/Extensions/CoreData/PositionEntityExtension.swift +++ b/Meshtastic/Extensions/CoreData/PositionEntityExtension.swift @@ -21,13 +21,13 @@ extension PositionEntity { request.returnsDistinctResults = true request.sortDescriptors = [NSSortDescriptor(key: "time", ascending: false)] - let positionPredicate = NSPredicate(format: "nodePosition != nil && nodePosition.user.shortName != nil && latest == true && time >= %@", Calendar.current.date(byAdding: .day, value: -2, to: Date())! as NSDate) + let positionPredicate = NSPredicate(format: "nodePosition != nil && (nodePosition.user.shortName != nil || nodePosition.user.shortName != '') && latest == true && time >= %@", Calendar.current.date(byAdding: .day, value: -2, to: Date())! as NSDate) let pointOfInterest = LocationHelper.currentLocation if pointOfInterest.latitude != LocationHelper.DefaultLocation.latitude && pointOfInterest.longitude != LocationHelper.DefaultLocation.longitude { /// Lets just get nodes within about 500 miles - let D: Double = 800000 * 1.1 + let D: Double = UserDefaults.meshMapDistance * 1.1 let R: Double = 6371009 let meanLatitidue = pointOfInterest.latitude * .pi / 180 let deltaLatitude = D / R * 180 / .pi diff --git a/Meshtastic/Extensions/String.swift b/Meshtastic/Extensions/String.swift index 6ac1672a..6255b151 100644 --- a/Meshtastic/Extensions/String.swift +++ b/Meshtastic/Extensions/String.swift @@ -67,4 +67,29 @@ extension String { : $0 + String($1) } } + + var length: Int { + return count + } + + subscript (i: Int) -> String { + return self[i ..< i + 1] + } + + func substring(fromIndex: Int) -> String { + return self[min(fromIndex, length) ..< length] + } + + func substring(toIndex: Int) -> String { + return self[0 ..< max(0, toIndex)] + } + + subscript (r: Range) -> String { + let range = Range(uncheckedBounds: (lower: max(0, min(length, r.lowerBound)), + upper: min(length, max(0, r.upperBound)))) + let start = index(startIndex, offsetBy: range.lowerBound) + let end = index(start, offsetBy: range.upperBound - range.lowerBound) + return String(self[start ..< end]) + } + } diff --git a/Meshtastic/Extensions/UserDefaults.swift b/Meshtastic/Extensions/UserDefaults.swift index c42ee9bc..b497495d 100644 --- a/Meshtastic/Extensions/UserDefaults.swift +++ b/Meshtastic/Extensions/UserDefaults.swift @@ -34,6 +34,7 @@ extension UserDefaults { case provideLocation case provideLocationInterval case mapLayer + case meshMapDistance case meshMapRecentering case meshMapShowNodeHistory case meshMapShowRouteLines @@ -76,6 +77,9 @@ extension UserDefaults { @UserDefault(.mapLayer, defaultValue: .standard) static var mapLayer: MapLayer + @UserDefault(.meshMapDistance, defaultValue: 800000) + static var meshMapDistance: Double + @UserDefault(.enableMapRecentering, defaultValue: false) static var enableMapRecentering: Bool diff --git a/Meshtastic/Helpers/MeshPackets.swift b/Meshtastic/Helpers/MeshPackets.swift index e89aeb82..2e1e31cf 100644 --- a/Meshtastic/Helpers/MeshPackets.swift +++ b/Meshtastic/Helpers/MeshPackets.swift @@ -15,7 +15,7 @@ import ActivityKit func generateMessageMarkdown (message: String) -> String { let types: NSTextCheckingResult.CheckingType = [.address, .link, .phoneNumber] let detector = try! NSDataDetector(types: types.rawValue) - let matches = detector.matches(in: message, options: [], range: NSRange(location: 0, length: message.utf16.count)) + let matches = detector.matches(in: message, options: [], range: NSRange(location: 0, length: message.utf8.count)) var messageWithMarkdown = message if matches.count > 0 { for match in matches { @@ -28,9 +28,14 @@ func generateMessageMarkdown (message: String) -> String { let phone = messageWithMarkdown[range] messageWithMarkdown = messageWithMarkdown.replacingOccurrences(of: phone, with: "[\(phone)](tel:\(phone))") } else if match.resultType == .link { - let url = messageWithMarkdown[range] - let absoluteUrl = match.url?.absoluteString ?? "" - messageWithMarkdown = messageWithMarkdown.replacingOccurrences(of: url, with: "[\(String(match.url?.host ?? "Link"))\(String(match.url?.path ?? ""))](\(absoluteUrl))") + let start = match.range.lowerBound + let stop = match.range.upperBound + if stop > start { + let url = message[start ..< stop] + let absoluteUrl = match.url?.absoluteString ?? "" + let markdownUrl = "[\(url)](\(absoluteUrl))" + messageWithMarkdown = messageWithMarkdown.replacingOccurrences(of: url, with: markdownUrl) + } } } } diff --git a/Meshtastic/Views/Nodes/Helpers/Map/MapSettingsForm.swift b/Meshtastic/Views/Nodes/Helpers/Map/MapSettingsForm.swift index 4c18ef19..55b11484 100644 --- a/Meshtastic/Views/Nodes/Helpers/Map/MapSettingsForm.swift +++ b/Meshtastic/Views/Nodes/Helpers/Map/MapSettingsForm.swift @@ -19,6 +19,7 @@ struct MapSettingsForm: View { @Binding var traffic: Bool @Binding var pointsOfInterest: Bool @Binding var mapLayer: MapLayer + @Binding var meshMapDistance: Double @Binding var meshMap: Bool var body: some View { @@ -56,6 +57,27 @@ struct MapSettingsForm: View { self.routeLines.toggle() UserDefaults.enableMapRouteLines = self.routeLines } + } else { + VStack { + HStack { + Label("Show nodes up to", systemImage: "lines.measurement.horizontal") + Picker("", selection: $meshMapDistance) { + ForEach(MeshMapDistances.allCases) { di in + Text(di.description) + .tag(di.id) + } + } + .pickerStyle(DefaultPickerStyle()) + } + .listRowSeparator(.hidden) + Text("You will need to close and re-open the app for this to take effect.") + .font(.callout) + .foregroundColor(.gray) + .listRowSeparator(/*@START_MENU_TOKEN@*/.visible/*@END_MENU_TOKEN@*/) + } + .onChange(of: meshMapDistance) { newMeshMapDistance in + UserDefaults.meshMapDistance = newMeshMapDistance + } } Toggle(isOn: $convexHull) { Label("Convex Hull", systemImage: "button.angledbottom.horizontal.right") diff --git a/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift b/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift index cf6d90e3..3f2fb0fb 100644 --- a/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift +++ b/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift @@ -20,6 +20,7 @@ struct NodeMapSwiftUI: View { @State var showUserLocation: Bool = false @State var positions: [PositionEntity] = [] /// Map State User Defaults + @AppStorage("meshMapDistance") private var meshMapDistance: Double = 800000 @AppStorage("meshMapShowNodeHistory") private var showNodeHistory = false @AppStorage("meshMapShowRouteLines") private var showRouteLines = false @AppStorage("enableMapConvexHull") private var showConvexHull = false @@ -92,7 +93,7 @@ struct NodeMapSwiftUI: View { .padding() } .sheet(isPresented: $isEditingSettings) { - MapSettingsForm(nodeHistory: $showNodeHistory, routeLines: $showRouteLines, convexHull: $showConvexHull, traffic: $showTraffic, pointsOfInterest: $showPointsOfInterest, mapLayer: $selectedMapLayer, meshMap: $isMeshMap) + MapSettingsForm(nodeHistory: $showNodeHistory, routeLines: $showRouteLines, convexHull: $showConvexHull, traffic: $showTraffic, pointsOfInterest: $showPointsOfInterest, mapLayer: $selectedMapLayer, meshMapDistance: $meshMapDistance, meshMap: $isMeshMap) .onChange(of: (selectedMapLayer)) { newMapLayer in switch selectedMapLayer { case .standard: diff --git a/Meshtastic/Views/Nodes/MeshMap.swift b/Meshtastic/Views/Nodes/MeshMap.swift index d17c24cd..780ebde2 100644 --- a/Meshtastic/Views/Nodes/MeshMap.swift +++ b/Meshtastic/Views/Nodes/MeshMap.swift @@ -24,6 +24,7 @@ struct MeshMap: View { /// Parameters @State var showUserLocation: Bool = true /// Map State User Defaults + @AppStorage("meshMapDistance") private var meshMapDistance: Double = 800000 @AppStorage("meshMapShowNodeHistory") private var showNodeHistory = false @AppStorage("meshMapShowRouteLines") private var showRouteLines = false @AppStorage("enableMapConvexHull") private var showConvexHull = false @@ -32,8 +33,8 @@ struct MeshMap: View { @AppStorage("mapLayer") private var selectedMapLayer: MapLayer = .standard // Map Configuration @Namespace var mapScope - @State var mapStyle: MapStyle = MapStyle.standard(elevation: .flat, emphasis: MapStyle.StandardEmphasis.muted ,pointsOfInterest: .all, showsTraffic: true) - @State var position = MapCameraPosition.camera(MapCamera(centerCoordinate: LocationHelper.currentLocation, distance: 2500000, heading: 0, pitch: 0)) + @State var mapStyle: MapStyle = MapStyle.standard(elevation: .flat, emphasis: MapStyle.StandardEmphasis.muted ,pointsOfInterest: .excludingAll, showsTraffic: false) + @State var position = MapCameraPosition.automatic @State var isEditingSettings = false @State var selectedPosition: PositionEntity? @State var showWaypoints = false @@ -120,7 +121,7 @@ struct MeshMap: View { .padding() } .sheet(isPresented: $isEditingSettings) { - MapSettingsForm(nodeHistory: $showNodeHistory, routeLines: $showRouteLines, convexHull: $showConvexHull, traffic: $showTraffic, pointsOfInterest: $showPointsOfInterest, mapLayer: $selectedMapLayer, meshMap: $isMeshMap) + MapSettingsForm(nodeHistory: $showNodeHistory, routeLines: $showRouteLines, convexHull: $showConvexHull, traffic: $showTraffic, pointsOfInterest: $showPointsOfInterest, mapLayer: $selectedMapLayer, meshMapDistance: $meshMapDistance, meshMap: $isMeshMap) } .onChange(of: (appState.navigationPath)) { newPath in diff --git a/Meshtastic/Views/Settings/Channels/ChannelForm.swift b/Meshtastic/Views/Settings/Channels/ChannelForm.swift index 7176d802..da6127df 100644 --- a/Meshtastic/Views/Settings/Channels/ChannelForm.swift +++ b/Meshtastic/Views/Settings/Channels/ChannelForm.swift @@ -245,7 +245,7 @@ struct ChannelForm: View { } } } - .presentationDetents([.fraction(0.45), .fraction(0.65)]) + .presentationDetents([.large]) .presentationDragIndicator(.visible) } } From d768eb64e9304e34750fbe2ad5bce9006a48b49f Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sun, 24 Mar 2024 22:31:47 -0700 Subject: [PATCH 47/74] Dont allow json and the client proxy, max position request of 300 for the mesh map --- .../Extensions/CoreData/PositionEntityExtension.swift | 2 +- Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Meshtastic/Extensions/CoreData/PositionEntityExtension.swift b/Meshtastic/Extensions/CoreData/PositionEntityExtension.swift index 44777bb3..20fbbd35 100644 --- a/Meshtastic/Extensions/CoreData/PositionEntityExtension.swift +++ b/Meshtastic/Extensions/CoreData/PositionEntityExtension.swift @@ -14,7 +14,7 @@ extension PositionEntity { static func allPositionsFetchRequest() -> NSFetchRequest { let request: NSFetchRequest = PositionEntity.fetchRequest() - //request.fetchLimit = 200 + request.fetchLimit = 300 //request.fetchBatchSize = 1 request.returnsObjectsAsFaults = false request.includesSubentities = true diff --git a/Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift b/Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift index 3d228ad3..cfcaa930 100644 --- a/Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift +++ b/Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift @@ -276,6 +276,9 @@ struct MQTTConfig: View { } } .onChange(of: proxyToClientEnabled) { newProxyToClientEnabled in + if newProxyToClientEnabled { + jsonEnabled = false + } if node != nil && node?.mqttConfig != nil { if newProxyToClientEnabled != node!.mqttConfig!.proxyToClientEnabled { hasChanges = true } if newProxyToClientEnabled { @@ -289,6 +292,9 @@ struct MQTTConfig: View { } } .onChange(of: jsonEnabled) { newJsonEnabled in + if newJsonEnabled { + proxyToClientEnabled = false + } if node != nil && node?.mqttConfig != nil { if newJsonEnabled != node!.mqttConfig!.jsonEnabled { hasChanges = true } } From c372a8e940254525f96738ab1935acfbef7ad1d7 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sun, 24 Mar 2024 22:37:50 -0700 Subject: [PATCH 48/74] Shorten label for mesh map node distance --- Meshtastic/Views/Nodes/Helpers/Map/MapSettingsForm.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Meshtastic/Views/Nodes/Helpers/Map/MapSettingsForm.swift b/Meshtastic/Views/Nodes/Helpers/Map/MapSettingsForm.swift index 55b11484..58405043 100644 --- a/Meshtastic/Views/Nodes/Helpers/Map/MapSettingsForm.swift +++ b/Meshtastic/Views/Nodes/Helpers/Map/MapSettingsForm.swift @@ -60,7 +60,7 @@ struct MapSettingsForm: View { } else { VStack { HStack { - Label("Show nodes up to", systemImage: "lines.measurement.horizontal") + Label("Show nodes", systemImage: "lines.measurement.horizontal") Picker("", selection: $meshMapDistance) { ForEach(MeshMapDistances.allCases) { di in Text(di.description) From f3f126da38ead8ea6da996d9d8c06761a76599d0 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sun, 24 Mar 2024 22:56:38 -0700 Subject: [PATCH 49/74] Add node history and route lines back to the mesh map for favorites --- .../Map/MapContent/MeshMapContent.swift | 51 +++++++++++++++++++ .../Nodes/Helpers/Map/MapSettingsForm.swift | 36 ++++++------- 2 files changed, 69 insertions(+), 18 deletions(-) diff --git a/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift b/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift index 8b3440ac..336b6002 100644 --- a/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift +++ b/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift @@ -52,6 +52,7 @@ struct MeshMapContent: MapContent { ForEach(Array(positions), id: \.id) { position in /// Node color from node.num let nodeColor = UIColor(hex: UInt32(position.nodePosition?.num ?? 0)) + /// Latest Position Anotations Annotation(position.nodePosition?.user?.longName ?? "?", coordinate: position.coordinate) { LazyVStack { ZStack { @@ -87,6 +88,56 @@ struct MeshMapContent: MapContent { selectedPosition = (selectedPosition == position ? nil : position) } } + + /// Node History and Route Lines for favorites + if position.nodePosition?.user?.vip ?? false { + if showRouteLines { + let nodePositions = Array(position.nodePosition!.positions!) as! [PositionEntity] + let routeCoords = nodePositions.compactMap({(pos) -> CLLocationCoordinate2D in + return pos.nodeCoordinate ?? LocationHelper.DefaultLocation + }) + let gradient = LinearGradient( + colors: [Color(nodeColor.lighter().lighter()), Color(nodeColor.lighter()), Color(nodeColor)], + startPoint: .leading, endPoint: .trailing + ) + let dashed = StrokeStyle( + lineWidth: 3, + lineCap: .round, lineJoin: .round, dash: [10, 10] + ) + MapPolyline(coordinates: routeCoords) + .stroke(gradient, style: dashed) + } + if showNodeHistory { + ForEach(Array(position.nodePosition!.positions!) as! [PositionEntity], id: \.self) { (mappin: PositionEntity) in + if mappin.latest == false && mappin.nodePosition?.user?.vip ?? false { + let pf = PositionFlags(rawValue: Int(mappin.nodePosition?.metadata?.positionFlags ?? 771)) + let headingDegrees = Angle.degrees(Double(mappin.heading)) + Annotation("", coordinate: mappin.coordinate) { + LazyVStack { + if pf.contains(.Heading) { + Image(systemName: "location.north.circle") + .resizable() + .scaledToFit() + .foregroundStyle(Color(UIColor(hex: UInt32(mappin.nodePosition?.num ?? 0))).isLight() ? .black : .white) + .background(Color(UIColor(hex: UInt32(mappin.nodePosition?.num ?? 0)))) + .clipShape(Circle()) + .rotationEffect(headingDegrees) + .frame(width: 16, height: 16) + + } else { + Circle() + .fill(Color(UIColor(hex: UInt32(mappin.nodePosition?.num ?? 0)))) + .strokeBorder(Color(UIColor(hex: UInt32(mappin.nodePosition?.num ?? 0))).isLight() ? .black : .white ,lineWidth: 2) + .frame(width: 12, height: 12) + } + } + } + .annotationTitles(.hidden) + .annotationSubtitles(.hidden) + } + } + } + } /// Reduced Precision Map Circles if 11...16 ~= position.precisionBits { let pp = PositionPrecision(rawValue: Int(position.precisionBits)) diff --git a/Meshtastic/Views/Nodes/Helpers/Map/MapSettingsForm.swift b/Meshtastic/Views/Nodes/Helpers/Map/MapSettingsForm.swift index 58405043..17339bf0 100644 --- a/Meshtastic/Views/Nodes/Helpers/Map/MapSettingsForm.swift +++ b/Meshtastic/Views/Nodes/Helpers/Map/MapSettingsForm.swift @@ -40,24 +40,7 @@ struct MapSettingsForm: View { .onChange(of: mapLayer) { newMapLayer in UserDefaults.mapLayer = newMapLayer } - if !meshMap { - Toggle(isOn: $nodeHistory) { - Label("Node History", systemImage: "building.columns.fill") - } - .toggleStyle(SwitchToggleStyle(tint: .accentColor)) - .onTapGesture { - self.nodeHistory.toggle() - UserDefaults.enableMapNodeHistoryPins = self.nodeHistory - } - Toggle(isOn: $routeLines) { - Label("Route Lines", systemImage: "road.lanes") - } - .toggleStyle(SwitchToggleStyle(tint: .accentColor)) - .onTapGesture { - self.routeLines.toggle() - UserDefaults.enableMapRouteLines = self.routeLines - } - } else { + if meshMap { VStack { HStack { Label("Show nodes", systemImage: "lines.measurement.horizontal") @@ -79,6 +62,23 @@ struct MapSettingsForm: View { UserDefaults.meshMapDistance = newMeshMapDistance } } + Toggle(isOn: $nodeHistory) { + Label("Node History", systemImage: "building.columns.fill") + } + .toggleStyle(SwitchToggleStyle(tint: .accentColor)) + .onTapGesture { + self.nodeHistory.toggle() + UserDefaults.enableMapNodeHistoryPins = self.nodeHistory + } + Toggle(isOn: $routeLines) { + Label("Route Lines", systemImage: "road.lanes") + } + + .toggleStyle(SwitchToggleStyle(tint: .accentColor)) + .onTapGesture { + self.routeLines.toggle() + UserDefaults.enableMapRouteLines = self.routeLines + } Toggle(isOn: $convexHull) { Label("Convex Hull", systemImage: "button.angledbottom.horizontal.right") } From b0101ab4ce750ba4b4193a26fc3a6d650a077754 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sun, 24 Mar 2024 23:13:35 -0700 Subject: [PATCH 50/74] A little more map cleanup --- .../Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift | 5 +---- Meshtastic/Views/Nodes/Helpers/Map/MapSettingsForm.swift | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift b/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift index 336b6002..ae1f8a0c 100644 --- a/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift +++ b/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift @@ -28,7 +28,6 @@ struct MeshMapContent: MapContent { // Map Configuration @Binding var selectedPosition: PositionEntity? @Binding var showWaypoints: Bool - //@Binding var editingWaypoint: WaypointEntity? @Binding var selectedWaypoint: WaypointEntity? var delay: Double = 0 @@ -199,8 +198,6 @@ struct MeshMapContent: MapContent { @MapContentBuilder var body: some MapContent { - if positions.count > 0 { - meshMap - } + meshMap } } diff --git a/Meshtastic/Views/Nodes/Helpers/Map/MapSettingsForm.swift b/Meshtastic/Views/Nodes/Helpers/Map/MapSettingsForm.swift index 17339bf0..fa1ce751 100644 --- a/Meshtastic/Views/Nodes/Helpers/Map/MapSettingsForm.swift +++ b/Meshtastic/Views/Nodes/Helpers/Map/MapSettingsForm.swift @@ -119,7 +119,7 @@ Spacer() .padding(.bottom) #endif } - .presentationDetents([.fraction(0.45), .fraction(0.65)]) + .presentationDetents([.fraction(meshMap ? 0.55 : 0.45), .fraction(0.65)]) .presentationDragIndicator(.visible) } From 7eb6659c0c81d79e39374f78e9c55f87419f4a9e Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Mon, 25 Mar 2024 15:21:38 -0700 Subject: [PATCH 51/74] Move fetch requests to mapcontent --- Meshtastic/Enums/AppSettingsEnums.swift | 2 +- .../CoreData/WaypointEntityExtension.swift | 4 +- Meshtastic/Helpers/MeshPackets.swift | 6 +-- .../Map/MapContent/MeshMapContent.swift | 26 +++++++---- .../Map/MapContent/NodeMapContent.swift | 2 - .../Nodes/Helpers/Map/MapSettingsForm.swift | 21 +++------ .../Nodes/Helpers/Map/NodeMapSwiftUI.swift | 21 --------- Meshtastic/Views/Nodes/MeshMap.swift | 46 ++++++++----------- Meshtastic/Views/Nodes/NodeList.swift | 21 ++++++++- .../Settings/Config/PositionConfig.swift | 21 +++++++-- Meshtastic/Views/Settings/Firmware.swift | 2 +- 11 files changed, 88 insertions(+), 84 deletions(-) diff --git a/Meshtastic/Enums/AppSettingsEnums.swift b/Meshtastic/Enums/AppSettingsEnums.swift index fd4fe088..4169444e 100644 --- a/Meshtastic/Enums/AppSettingsEnums.swift +++ b/Meshtastic/Enums/AppSettingsEnums.swift @@ -60,7 +60,7 @@ enum MeshMapDistances: Double, CaseIterable, Identifiable { var id: Double { self.rawValue } var description: String { let distanceFormatter = MKDistanceFormatter() - return "\(distanceFormatter.string(fromDistance: Double(self.rawValue))) away" + return "up to \(distanceFormatter.string(fromDistance: Double(self.rawValue))) away" } } diff --git a/Meshtastic/Extensions/CoreData/WaypointEntityExtension.swift b/Meshtastic/Extensions/CoreData/WaypointEntityExtension.swift index 76fe8f8e..0c3d6854 100644 --- a/Meshtastic/Extensions/CoreData/WaypointEntityExtension.swift +++ b/Meshtastic/Extensions/CoreData/WaypointEntityExtension.swift @@ -13,8 +13,10 @@ extension WaypointEntity { static func allWaypointssFetchRequest() -> NSFetchRequest { let request: NSFetchRequest = WaypointEntity.fetchRequest() - //request.fetchLimit = 100 + request.fetchLimit = 50 //request.fetchBatchSize = 1 + //request.returnsObjectsAsFaults = false + //request.includesSubentities = true request.returnsDistinctResults = true request.sortDescriptors = [NSSortDescriptor(key: "name", ascending: false)] request.predicate = NSPredicate(format: "expire == nil || expire >= %@", Date() as NSDate) diff --git a/Meshtastic/Helpers/MeshPackets.swift b/Meshtastic/Helpers/MeshPackets.swift index 2e1e31cf..0655b89f 100644 --- a/Meshtastic/Helpers/MeshPackets.swift +++ b/Meshtastic/Helpers/MeshPackets.swift @@ -28,9 +28,9 @@ func generateMessageMarkdown (message: String) -> String { let phone = messageWithMarkdown[range] messageWithMarkdown = messageWithMarkdown.replacingOccurrences(of: phone, with: "[\(phone)](tel:\(phone))") } else if match.resultType == .link { - let start = match.range.lowerBound - let stop = match.range.upperBound - if stop > start { + if (match.range.location != NSNotFound) { + let start = match.range.lowerBound + let stop = match.range.upperBound let url = message[start ..< stop] let absoluteUrl = match.url?.absoluteString ?? "" let markdownUrl = "[\(url)](\(absoluteUrl))" diff --git a/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift b/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift index ae1f8a0c..7a96c3d1 100644 --- a/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift +++ b/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift @@ -14,8 +14,7 @@ import MapKit @available(iOS 17.0, macOS 14.0, *) struct MeshMapContent: MapContent { - @State var positions: [PositionEntity] = [] - @State var waypoints: [WaypointEntity] = [] + //@State var waypoints: [WaypointEntity] = [] @State var routes: [RouteEntity] = [] /// Parameters @Binding var showUserLocation: Bool @@ -29,13 +28,19 @@ struct MeshMapContent: MapContent { @Binding var selectedPosition: PositionEntity? @Binding var showWaypoints: Bool @Binding var selectedWaypoint: WaypointEntity? + + @FetchRequest(fetchRequest: PositionEntity.allPositionsFetchRequest(), animation: .easeIn) + var positions: FetchedResults + + @FetchRequest(fetchRequest: WaypointEntity.allWaypointssFetchRequest(), animation: .none) + var waypoints: FetchedResults var delay: Double = 0 @State private var scale: CGFloat = 0.5 @MapContentBuilder var meshMap: some MapContent { - let lineCoords = positions.compactMap({(position) -> CLLocationCoordinate2D in + let lineCoords = Array(positions).compactMap({(position) -> CLLocationCoordinate2D in return position.nodeCoordinate ?? LocationsHandler.DefaultLocation }) /// Convex Hull @@ -148,7 +153,7 @@ struct MeshMapContent: MapContent { } } /// Routes - ForEach(Array(routes), id: \.id) { route in + ForEach(Array(routes)) { route in let routeLocations = Array(route.locations!) as! [LocationEntity] let routeCoords = routeLocations.compactMap({(loc) -> CLLocationCoordinate2D in return loc.locationCoordinate ?? LocationHelper.DefaultLocation @@ -183,13 +188,15 @@ struct MeshMapContent: MapContent { /// Waypoint Annotations if waypoints.count > 0 && showWaypoints { - ForEach(Array(waypoints), id: \.id) { waypoint in + ForEach(Array(waypoints) as! [WaypointEntity], id: \.self) { waypoint in Annotation(waypoint.name ?? "?", coordinate: waypoint.coordinate) { LazyVStack { - CircleText(text: String(UnicodeScalar(Int(waypoint.icon)) ?? "📍"), color: Color.orange, circleSize: 40) - .onTapGesture(perform: { location in - selectedWaypoint = (selectedWaypoint == waypoint ? nil : waypoint) - }) + ZStack { + CircleText(text: String(UnicodeScalar(Int(waypoint.icon)) ?? "📍"), color: Color.orange, circleSize: 40) + .onTapGesture(perform: { location in + selectedWaypoint = (selectedWaypoint == waypoint ? nil : waypoint) + }) + } } } } @@ -199,5 +206,6 @@ struct MeshMapContent: MapContent { @MapContentBuilder var body: some MapContent { meshMap + } } diff --git a/Meshtastic/Views/Nodes/Helpers/Map/MapContent/NodeMapContent.swift b/Meshtastic/Views/Nodes/Helpers/Map/MapContent/NodeMapContent.swift index 2c15e9de..8e8d0b26 100644 --- a/Meshtastic/Views/Nodes/Helpers/Map/MapContent/NodeMapContent.swift +++ b/Meshtastic/Views/Nodes/Helpers/Map/MapContent/NodeMapContent.swift @@ -29,8 +29,6 @@ struct NodeMapContent: MapContent { @State var isShowingAltitude = false @State var isEditingSettings = false @State var selectedPosition: PositionEntity? - @State var showWaypoints = false - @State var selectedWaypoint: WaypointEntity? @State var isMeshMap = false //let region: MKCoordinateRegion diff --git a/Meshtastic/Views/Nodes/Helpers/Map/MapSettingsForm.swift b/Meshtastic/Views/Nodes/Helpers/Map/MapSettingsForm.swift index fa1ce751..6a65c356 100644 --- a/Meshtastic/Views/Nodes/Helpers/Map/MapSettingsForm.swift +++ b/Meshtastic/Views/Nodes/Helpers/Map/MapSettingsForm.swift @@ -41,22 +41,15 @@ struct MapSettingsForm: View { UserDefaults.mapLayer = newMapLayer } if meshMap { - VStack { - HStack { - Label("Show nodes", systemImage: "lines.measurement.horizontal") - Picker("", selection: $meshMapDistance) { - ForEach(MeshMapDistances.allCases) { di in - Text(di.description) - .tag(di.id) - } + HStack { + Label("Show nodes", systemImage: "lines.measurement.horizontal") + Picker("", selection: $meshMapDistance) { + ForEach(MeshMapDistances.allCases) { di in + Text(di.description) + .tag(di.id) } - .pickerStyle(DefaultPickerStyle()) } - .listRowSeparator(.hidden) - Text("You will need to close and re-open the app for this to take effect.") - .font(.callout) - .foregroundColor(.gray) - .listRowSeparator(/*@START_MENU_TOKEN@*/.visible/*@END_MENU_TOKEN@*/) + .pickerStyle(DefaultPickerStyle()) } .onChange(of: meshMapDistance) { newMeshMapDistance in UserDefaults.meshMapDistance = newMeshMapDistance diff --git a/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift b/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift index 3f2fb0fb..282a5a8c 100644 --- a/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift +++ b/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift @@ -36,8 +36,6 @@ struct NodeMapSwiftUI: View { @State var isShowingAltitude = false @State var isEditingSettings = false @State var selectedPosition: PositionEntity? - @State var showWaypoints = false - @State var selectedWaypoint: WaypointEntity? @State var isMeshMap = false @State private var mapRegion = MKCoordinateRegion.init() @@ -88,10 +86,6 @@ struct NodeMapSwiftUI: View { .padding(.horizontal, 20) } } - .sheet(item: $selectedWaypoint) { selection in - WaypointForm(waypoint: selection) - .padding() - } .sheet(isPresented: $isEditingSettings) { MapSettingsForm(nodeHistory: $showNodeHistory, routeLines: $showRouteLines, convexHull: $showConvexHull, traffic: $showTraffic, pointsOfInterest: $showPointsOfInterest, mapLayer: $selectedMapLayer, meshMapDistance: $meshMapDistance, meshMap: $isMeshMap) .onChange(of: (selectedMapLayer)) { newMapLayer in @@ -162,21 +156,6 @@ struct NodeMapSwiftUI: View { .tint(Color(UIColor.secondarySystemBackground)) .foregroundColor(.accentColor) .buttonStyle(.borderedProminent) - /// Show / Hide Waypoints Button - if waypoints.count > 0 { - - Button(action: { - withAnimation { - showWaypoints = !showWaypoints - } - }) { - Image(systemName: showWaypoints ? "signpost.right.and.left.fill" : "signpost.right.and.left") - .padding(.vertical, 5) - } - .tint(Color(UIColor.secondarySystemBackground)) - .foregroundColor(.accentColor) - .buttonStyle(.borderedProminent) - } /// Look Around Button if self.scene != nil { Button(action: { diff --git a/Meshtastic/Views/Nodes/MeshMap.swift b/Meshtastic/Views/Nodes/MeshMap.swift index 780ebde2..b992635f 100644 --- a/Meshtastic/Views/Nodes/MeshMap.swift +++ b/Meshtastic/Views/Nodes/MeshMap.swift @@ -37,17 +37,12 @@ struct MeshMap: View { @State var position = MapCameraPosition.automatic @State var isEditingSettings = false @State var selectedPosition: PositionEntity? - @State var showWaypoints = false + @State var showWaypoints = true @State var editingWaypoint: WaypointEntity? @State var selectedWaypoint: WaypointEntity? @State var newWaypointCoord: CLLocationCoordinate2D? @State var isMeshMap = true - - @FetchRequest(fetchRequest: PositionEntity.allPositionsFetchRequest(), animation: .none) - var positions: FetchedResults - - @FetchRequest(fetchRequest: WaypointEntity.allWaypointssFetchRequest(), animation: .none) - var waypoints: FetchedResults + @FetchRequest(sortDescriptors: [NSSortDescriptor(key: "name", ascending: true)], predicate: NSPredicate(format: "enabled == true", ""), animation: .none) @@ -59,7 +54,7 @@ struct MeshMap: View { ZStack { MapReader { reader in Map(position: $position, bounds: MapCameraBounds(minimumDistance: 1, maximumDistance: .infinity), scope: mapScope) { - MeshMapContent(positions: Array(positions), waypoints: Array(waypoints), routes: Array(routes), showUserLocation: $showUserLocation, showNodeHistory: $showNodeHistory, showRouteLines: $showRouteLines, showConvexHull: $showConvexHull, showTraffic: $showTraffic, showPointsOfInterest: $showPointsOfInterest, selectedMapLayer: $selectedMapLayer, selectedPosition: $selectedPosition, showWaypoints: $showWaypoints, selectedWaypoint: $selectedWaypoint) + MeshMapContent(routes: Array(routes), showUserLocation: $showUserLocation, showNodeHistory: $showNodeHistory, showRouteLines: $showRouteLines, showConvexHull: $showConvexHull, showTraffic: $showTraffic, showPointsOfInterest: $showPointsOfInterest, selectedMapLayer: $selectedMapLayer, selectedPosition: $selectedPosition, showWaypoints: $showWaypoints, selectedWaypoint: $selectedWaypoint) } .mapScope(mapScope) @@ -142,12 +137,12 @@ struct MeshMap: View { print("Waypoint id not found") return } - guard let waypoint = waypoints.first(where: { $0.id == Int64(waypointId) }) else { - print("Waypoint not found") - return - } +// guard let waypoint = waypoints.first(where: { $0.id == Int64(waypointId) }) else { +// print("Waypoint not found") +// return +// } showWaypoints = true - position = .camera(MapCamera(centerCoordinate: waypoint.coordinate, distance: 1000, heading: 0, pitch: 60)) + //position = .camera(MapCamera(centerCoordinate: waypoint.coordinate, distance: 1000, heading: 0, pitch: 60)) } } .onChange(of: (selectedMapLayer)) { newMapLayer in @@ -179,26 +174,25 @@ struct MeshMap: View { .foregroundColor(.accentColor) .buttonStyle(.borderedProminent) /// Show / Hide Waypoints Button - if waypoints.count > 0 { - - Button(action: { - withAnimation { - showWaypoints = !showWaypoints - } - }) { - Image(systemName: showWaypoints ? "signpost.right.and.left.fill" : "signpost.right.and.left") - .padding(.vertical, 5) + + Button(action: { + withAnimation { + showWaypoints = !showWaypoints } - .tint(Color(UIColor.secondarySystemBackground)) - .foregroundColor(.accentColor) - .buttonStyle(.borderedProminent) + }) { + Image(systemName: showWaypoints ? "signpost.right.and.left.fill" : "signpost.right.and.left") + .padding(.vertical, 5) } + .tint(Color(UIColor.secondarySystemBackground)) + .foregroundColor(.accentColor) + .buttonStyle(.borderedProminent) + } .controlSize(.regular) .padding(5) } } - .navigationTitle("\(positions.count) Nodes") + .navigationTitle("Mesh Map") .navigationBarItems(leading: MeshtasticLogo(), trailing: ZStack { ConnectedDevice(bluetoothOn: bleManager.isSwitchedOn, deviceConnected: bleManager.connectedPeripheral != nil, name: (bleManager.connectedPeripheral != nil) ? bleManager.connectedPeripheral.shortName : "?") }) diff --git a/Meshtastic/Views/Nodes/NodeList.swift b/Meshtastic/Views/Nodes/NodeList.swift index c2532ad7..902d7df5 100644 --- a/Meshtastic/Views/Nodes/NodeList.swift +++ b/Meshtastic/Views/Nodes/NodeList.swift @@ -159,6 +159,25 @@ struct NodeList: View { Text("Any missed messages will be delivered again.") } } + .safeAreaInset(edge: .bottom, alignment: .trailing) { + HStack { + Button(action: { + withAnimation { + //isEditingSettings = !isEditingSettings + } + }) { + Image(systemName: true ? "line.3.horizontal.decrease.circle" : "line.3.horizontal.decrease.circle.fill") + .padding(.vertical, 5) + } + .tint(Color(UIColor.secondarySystemBackground)) + .foregroundColor(.accentColor) + .buttonStyle(.borderedProminent) + + } + .controlSize(.regular) + .padding(5) + } + .padding(.bottom, 5) .searchable(text: $searchState.searchText, placement: nodes.count > 10 ? .navigationBarDrawer(displayMode: .always) : .automatic, prompt: "Find a node") .disableAutocorrection(true) .scrollDismissesKeyboard(.immediately) @@ -220,7 +239,7 @@ struct NodeList: View { name: (bleManager.connectedPeripheral != nil) ? bleManager.connectedPeripheral.shortName : "?", phoneOnly: true) }) } - .padding(.bottom, 5) + } else { if #available (iOS 17, *) { ContentUnavailableView("select.node", systemImage: "flipphone") diff --git a/Meshtastic/Views/Settings/Config/PositionConfig.swift b/Meshtastic/Views/Settings/Config/PositionConfig.swift index 9f96ef8b..b18ff5e6 100644 --- a/Meshtastic/Views/Settings/Config/PositionConfig.swift +++ b/Meshtastic/Views/Settings/Config/PositionConfig.swift @@ -72,6 +72,10 @@ struct PositionConfig: View { /// walking speeds are likely to be error prone like the compass @State var includeHeading = false + /// Minimum Version for fixed postion admin messages + @State var minimumVersion = "2.3.3" + @State private var supportedVersion = true + var body: some View { VStack { Form { @@ -159,6 +163,15 @@ struct PositionConfig: View { Text("If enabled your current phone location will be sent to the device and will broadcast over the mesh on the position interval. Fixed position will always use the most recent position the device has.") } .toggleStyle(SwitchToggleStyle(tint: .accentColor)) + + } + .onChange(of: fixedPosition) { newFixed in + if node != nil && node!.positionConfig != nil { + if newFixed != node!.positionConfig!.fixedPosition { hasChanges = true } + } + if supportedVersion && hasChanges && !newFixed { + // Send Admin message to remove the fixed position + } } } } @@ -316,6 +329,9 @@ struct PositionConfig: View { self.bleManager.context = context } setPositionValues() + supportedVersion = bleManager.connectedVersion == "0.0.0" || self.minimumVersion.compare(bleManager.connectedVersion, options: .numeric) == .orderedAscending || minimumVersion.compare(bleManager.connectedVersion, options: .numeric) == .orderedSame + + // Need to request a PositionConfig from the remote node before allowing changes if bleManager.connectedPeripheral != nil && node?.positionConfig == nil { print("empty position config") @@ -355,11 +371,6 @@ struct PositionConfig: View { if newSmartPositionEnabled != node!.positionConfig!.smartPositionEnabled { hasChanges = true } } } - .onChange(of: fixedPosition) { newFixed in - if node != nil && node!.positionConfig != nil { - if newFixed != node!.positionConfig!.fixedPosition { hasChanges = true } - } - } .onChange(of: positionBroadcastSeconds) { newPositionBroadcastSeconds in if node != nil && node!.positionConfig != nil { if newPositionBroadcastSeconds != node!.positionConfig!.positionBroadcastSeconds { hasChanges = true } diff --git a/Meshtastic/Views/Settings/Firmware.swift b/Meshtastic/Views/Settings/Firmware.swift index 98b29957..3558da1f 100644 --- a/Meshtastic/Views/Settings/Firmware.swift +++ b/Meshtastic/Views/Settings/Firmware.swift @@ -12,7 +12,7 @@ struct Firmware: View { @Environment(\.managedObjectContext) var context @EnvironmentObject var bleManager: BLEManager var node: NodeInfoEntity? - @State var minimumVersion = "2.3.0" + @State var minimumVersion = "2.3.2" @State var version = "" @State private var currentDevice: DeviceHardware? @State private var latestStable: FirmwareRelease? From 6577eaaa9fc0c651b522fd03475901719ba526e7 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Mon, 25 Mar 2024 15:49:10 -0700 Subject: [PATCH 52/74] Turn waypoints off by default --- Meshtastic/Views/Nodes/MeshMap.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Meshtastic/Views/Nodes/MeshMap.swift b/Meshtastic/Views/Nodes/MeshMap.swift index b992635f..8dee5f86 100644 --- a/Meshtastic/Views/Nodes/MeshMap.swift +++ b/Meshtastic/Views/Nodes/MeshMap.swift @@ -37,7 +37,7 @@ struct MeshMap: View { @State var position = MapCameraPosition.automatic @State var isEditingSettings = false @State var selectedPosition: PositionEntity? - @State var showWaypoints = true + @State var showWaypoints = false @State var editingWaypoint: WaypointEntity? @State var selectedWaypoint: WaypointEntity? @State var newWaypointCoord: CLLocationCoordinate2D? From 594ece35a504d75e9a27ee8c529fd8e57aa98e41 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Mon, 25 Mar 2024 17:19:03 -0700 Subject: [PATCH 53/74] Dont crash when you get emoji --- Meshtastic/Helpers/MeshPackets.swift | 35 ++++++++++++++-------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/Meshtastic/Helpers/MeshPackets.swift b/Meshtastic/Helpers/MeshPackets.swift index 0655b89f..f05bb3cd 100644 --- a/Meshtastic/Helpers/MeshPackets.swift +++ b/Meshtastic/Helpers/MeshPackets.swift @@ -13,22 +13,22 @@ import ActivityKit #endif func generateMessageMarkdown (message: String) -> String { - let types: NSTextCheckingResult.CheckingType = [.address, .link, .phoneNumber] - let detector = try! NSDataDetector(types: types.rawValue) - let matches = detector.matches(in: message, options: [], range: NSRange(location: 0, length: message.utf8.count)) - var messageWithMarkdown = message - if matches.count > 0 { - for match in matches { - guard let range = Range(match.range, in: message) else { continue } - if match.resultType == .address { - let address = message[range] - let urlEncodedAddress = address.addingPercentEncoding(withAllowedCharacters: .alphanumerics) - messageWithMarkdown = messageWithMarkdown.replacingOccurrences(of: address, with: "[\(address)](http://maps.apple.com/?address=\(urlEncodedAddress ?? ""))") - } else if match.resultType == .phoneNumber { - let phone = messageWithMarkdown[range] - messageWithMarkdown = messageWithMarkdown.replacingOccurrences(of: phone, with: "[\(phone)](tel:\(phone))") - } else if match.resultType == .link { - if (match.range.location != NSNotFound) { + if !message.isEmoji() { + let types: NSTextCheckingResult.CheckingType = [.address, .link, .phoneNumber] + let detector = try! NSDataDetector(types: types.rawValue) + let matches = detector.matches(in: message, options: [], range: NSRange(location: 0, length: message.utf16.count)) + var messageWithMarkdown = message + if matches.count > 0 { + for match in matches { + guard let range = Range(match.range, in: message) else { continue } + if match.resultType == .address { + let address = message[range] + let urlEncodedAddress = address.addingPercentEncoding(withAllowedCharacters: .alphanumerics) + messageWithMarkdown = messageWithMarkdown.replacingOccurrences(of: address, with: "[\(address)](http://maps.apple.com/?address=\(urlEncodedAddress ?? ""))") + } else if match.resultType == .phoneNumber { + let phone = messageWithMarkdown[range] + messageWithMarkdown = messageWithMarkdown.replacingOccurrences(of: phone, with: "[\(phone)](tel:\(phone))") + } else if match.resultType == .link { let start = match.range.lowerBound let stop = match.range.upperBound let url = message[start ..< stop] @@ -38,8 +38,9 @@ func generateMessageMarkdown (message: String) -> String { } } } + return messageWithMarkdown } - return messageWithMarkdown + return message } func localConfig (config: Config, context: NSManagedObjectContext, nodeNum: Int64, nodeLongName: String) { From 80103ebda28b711a408896ca9ca94be452b0b31e Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Mon, 25 Mar 2024 18:43:03 -0700 Subject: [PATCH 54/74] Revert user default updates, move everything to the map settings form --- Meshtastic/Extensions/UserDefaults.swift | 439 ++++++++++++++---- .../Map/MapContent/MeshMapContent.swift | 8 +- .../Nodes/Helpers/Map/MapSettingsForm.swift | 16 +- .../Nodes/Helpers/Map/NodeMapSwiftUI.swift | 6 +- Meshtastic/Views/Nodes/MeshMap.swift | 27 +- 5 files changed, 363 insertions(+), 133 deletions(-) diff --git a/Meshtastic/Extensions/UserDefaults.swift b/Meshtastic/Extensions/UserDefaults.swift index b497495d..ccb8a7a3 100644 --- a/Meshtastic/Extensions/UserDefaults.swift +++ b/Meshtastic/Extensions/UserDefaults.swift @@ -4,29 +4,15 @@ // // Copyright(c) Garth Vander Houwen 4/24/23. // +// +// UserDefaults.swift +// Meshtastic +// +// Copyright(c) Garth Vander Houwen 4/24/23. +// import Foundation -@propertyWrapper -struct UserDefault { - let key: UserDefaults.Keys - let defaultValue: T - - init(_ key: UserDefaults.Keys, defaultValue: T) { - self.key = key - self.defaultValue = defaultValue - } - - var wrappedValue: T { - get { - UserDefaults.standard.object(forKey: key.rawValue) as? T ?? defaultValue - } - set { - UserDefaults.standard.set(newValue, forKey: key.rawValue) - } - } -} - extension UserDefaults { enum Keys: String, CaseIterable { case preferredPeripheralId @@ -35,20 +21,15 @@ extension UserDefaults { case provideLocationInterval case mapLayer case meshMapDistance + case enableMapWaypoints case meshMapRecentering case meshMapShowNodeHistory case meshMapShowRouteLines case enableMapConvexHull - case enableMapRecentering - case enableMapNodeHistoryPins - case enableMapRouteLines case enableMapTraffic case enableMapPointsOfInterest case enableOfflineMaps - case enableOfflineMapsMBTiles case mapTileServer - case enableOverlayServer - case mapOverlayServer case mapTilesAboveLabels case mapUseLegacy case enableDetectionNotifications @@ -61,76 +42,340 @@ extension UserDefaults { func reset() { Keys.allCases.forEach { removeObject(forKey: $0.rawValue) } } - - @UserDefault(.preferredPeripheralId, defaultValue: "") - static var preferredPeripheralId: String - - @UserDefault(.preferredPeripheralNum, defaultValue: 0) - static var preferredPeripheralNum: Int - - @UserDefault(.provideLocation, defaultValue: false) - static var provideLocation: Bool - - @UserDefault(.provideLocationInterval, defaultValue: 0) - static var provideLocationInterval: Int - - @UserDefault(.mapLayer, defaultValue: .standard) - static var mapLayer: MapLayer - - @UserDefault(.meshMapDistance, defaultValue: 800000) - static var meshMapDistance: Double + static var preferredPeripheralId: String { + get { + UserDefaults.standard.string(forKey: "preferredPeripheralId") ?? "" + } + set { + UserDefaults.standard.set(newValue, forKey: "preferredPeripheralId") + } + } + static var preferredPeripheralNum: Int { + get { + UserDefaults.standard.integer(forKey: "preferredPeripheralNum") + } + set { + UserDefaults.standard.set(newValue, forKey: "preferredPeripheralNum") + } + } + static var provideLocation: Bool { + get { + UserDefaults.standard.bool(forKey: "provideLocation") + } set { + UserDefaults.standard.set(newValue, forKey: "provideLocation") + } + } + static var provideLocationInterval: Int { + get { + UserDefaults.standard.integer(forKey: "provideLocationInterval") + } + set { + UserDefaults.standard.set(newValue, forKey: "provideLocationInterval") + } + } + static var mapLayer: MapLayer { + get { + MapLayer(rawValue: UserDefaults.standard.string(forKey: "mapLayer") ?? MapLayer.standard.rawValue) ?? MapLayer.standard + } + set { + UserDefaults.standard.set(newValue.rawValue, forKey: "mapLayer") + } + } + static var meshMapDistance: Double { + get { + UserDefaults.standard.double(forKey: "meshMapDistance") + } + set { + UserDefaults.standard.set(newValue, forKey: "meshMapDistance") + } + } + static var enableMapWaypoints: Bool { + get { + UserDefaults.standard.bool(forKey: "enableMapWaypoints") + } + set { + UserDefaults.standard.set(newValue, forKey: "enableMapWaypoints") + } + } + static var enableMapRecentering: Bool { + get { + UserDefaults.standard.bool(forKey: "meshMapRecentering") + } + set { + UserDefaults.standard.set(newValue, forKey: "meshMapRecentering") + } + } + static var enableMapNodeHistoryPins: Bool { + get { + UserDefaults.standard.bool(forKey: "meshMapShowNodeHistory") + } + set { + UserDefaults.standard.set(newValue, forKey: "meshMapShowNodeHistory") + } + } + static var enableMapRouteLines: Bool { + get { + UserDefaults.standard.bool(forKey: "meshMapShowRouteLines") + } + set { + UserDefaults.standard.set(newValue, forKey: "meshMapShowRouteLines") + } + } + static var enableMapConvexHull: Bool { + get { + UserDefaults.standard.bool(forKey: "enableMapConvexHull") + } + set { + UserDefaults.standard.set(newValue, forKey: "enableMapConvexHull") + } + } + static var enableMapTraffic: Bool { + get { + UserDefaults.standard.bool(forKey: "enableMapTraffic") + } + set { + UserDefaults.standard.set(newValue, forKey: "enableMapTraffic") + } + } + static var enableMapPointsOfInterest: Bool { + get { + UserDefaults.standard.bool(forKey: "enableMapPointsOfInterest") + } + set { + UserDefaults.standard.set(newValue, forKey: "enableMapPointsOfInterest") + } + } + static var enableOfflineMaps: Bool { + get { + UserDefaults.standard.bool(forKey: "enableOfflineMaps") + } + set { + UserDefaults.standard.set(newValue, forKey: "enableOfflineMaps") + } + } + static var enableOfflineMapsMBTiles: Bool { + get { + UserDefaults.standard.bool(forKey: "enableOfflineMapsMBTiles") + } + set { + UserDefaults.standard.set(newValue, forKey: "enableOfflineMapsMBTiles") + } + } + static var mapTileServer: MapTileServer { + get { + MapTileServer(rawValue: UserDefaults.standard.string(forKey: "mapTileServer") ?? MapTileServer.openStreetMap.rawValue) ?? MapTileServer.openStreetMap + } + set { + UserDefaults.standard.set(newValue.rawValue, forKey: "mapTileServer") + } + } + static var enableOverlayServer: Bool { + get { + UserDefaults.standard.bool(forKey: "enableOverlayServer") + } + set { + UserDefaults.standard.set(newValue, forKey: "enableOverlayServer") + } + } + static var mapOverlayServer: MapOverlayServer { + get { + MapOverlayServer(rawValue: UserDefaults.standard.string(forKey: "mapOverlayServer") ?? MapOverlayServer.baseReReflectivityCurrent.rawValue) ?? MapOverlayServer.baseReReflectivityCurrent + } + set { + UserDefaults.standard.set(newValue.rawValue, forKey: "mapOverlayServer") + } + } + static var mapTilesAboveLabels: Bool { + get { + UserDefaults.standard.bool(forKey: "mapTilesAboveLabels") + } + set { + UserDefaults.standard.set(newValue, forKey: "mapTilesAboveLabels") + } + } - @UserDefault(.enableMapRecentering, defaultValue: false) - static var enableMapRecentering: Bool - - @UserDefault(.enableMapNodeHistoryPins, defaultValue: false) - static var enableMapNodeHistoryPins: Bool - - @UserDefault(.enableMapRouteLines, defaultValue: false) - static var enableMapRouteLines: Bool - - @UserDefault(.enableMapConvexHull, defaultValue: false) - static var enableMapConvexHull: Bool - - @UserDefault(.enableMapTraffic, defaultValue: false) - static var enableMapTraffic: Bool - - @UserDefault(.enableMapPointsOfInterest, defaultValue: false) - static var enableMapPointsOfInterest: Bool - - @UserDefault(.enableOfflineMaps, defaultValue: false) - static var enableOfflineMaps: Bool - - @UserDefault(.enableOfflineMapsMBTiles, defaultValue: false) - static var enableOfflineMapsMBTiles: Bool - - @UserDefault(.mapTileServer, defaultValue: .openStreetMap) - static var mapTileServer: MapTileServer - - @UserDefault(.enableOverlayServer, defaultValue: false) - static var enableOverlayServer: Bool - - @UserDefault(.mapOverlayServer, defaultValue: .baseReReflectivityCurrent) - static var mapOverlayServer: MapOverlayServer - - @UserDefault(.mapTilesAboveLabels, defaultValue: false) - static var mapTilesAboveLabels: Bool - - @UserDefault(.mapUseLegacy, defaultValue: false) - static var mapUseLegacy: Bool - - @UserDefault(.enableDetectionNotifications, defaultValue: false) - static var enableDetectionNotifications: Bool - - @UserDefault(.detectionSensorRole, defaultValue: .sensor) - static var detectionSensorRole: DetectionSensorRole - - @UserDefault(.enableSmartPosition, defaultValue: false) - static var enableSmartPosition: Bool - - @UserDefault(.modemPreset, defaultValue: 0) - static var modemPreset: Int - - @UserDefault(.firmwareVersion, defaultValue: "0.0.0") - static var firmwareVersion: String + static var mapUseLegacy: Bool { + get { + UserDefaults.standard.bool(forKey: "mapUseLegacy") + } + set { + UserDefaults.standard.set(newValue, forKey: "mapUseLegacy") + } + } + + static var enableDetectionNotifications: Bool { + get { + UserDefaults.standard.bool(forKey: "enableDetectionNotifications") + } + set { + UserDefaults.standard.set(newValue, forKey: "enableDetectionNotifications") + } + } + + static var detectionSensorRole: DetectionSensorRole { + get { + DetectionSensorRole(rawValue: UserDefaults.standard.string(forKey: "detectionSensorRole") ?? DetectionSensorRole.sensor.rawValue) ?? DetectionSensorRole.sensor + } + set { + UserDefaults.standard.set(newValue.rawValue, forKey: "detectionSensorRole") + } + } + static var enableSmartPosition: Bool { + get { + UserDefaults.standard.bool(forKey: "enableSmartPosition") + } + set { + UserDefaults.standard.set(newValue, forKey: "enableSmartPosition") + } + } + static var modemPreset: Int { + get { + UserDefaults.standard.integer(forKey: "modemPreset") + } + set { + UserDefaults.standard.set(newValue, forKey: "modemPreset") + } + } + static var firmwareVersion: String { + get { + UserDefaults.standard.string(forKey: "firmwareVersion") ?? "0.0.0" + } + set { + UserDefaults.standard.set(newValue, forKey: "firmwareVersion") + } + } } + +//import Foundation +// +//@propertyWrapper +//struct UserDefault { +// let key: UserDefaults.Keys +// let defaultValue: T +// +// init(_ key: UserDefaults.Keys, defaultValue: T) { +// self.key = key +// self.defaultValue = defaultValue +// } +// +// var wrappedValue: T { +// get { +// UserDefaults.standard.object(forKey: key.rawValue) as? T ?? defaultValue +// } +// set { +// UserDefaults.standard.set(newValue, forKey: key.rawValue) +// } +// } +//} +// +//extension UserDefaults { +// enum Keys: String, CaseIterable { +// case preferredPeripheralId +// case preferredPeripheralNum +// case provideLocation +// case provideLocationInterval +// case mapLayer +// case meshMapDistance +// case enableMapWaypoints +// case meshMapRecentering +// case meshMapShowNodeHistory +// case meshMapShowRouteLines +// case enableMapConvexHull +// case enableMapRecentering +// case enableMapNodeHistoryPins +// case enableMapRouteLines +// case enableMapTraffic +// case enableMapPointsOfInterest +// case enableOfflineMaps +// case enableOfflineMapsMBTiles +// case mapTileServer +// case enableOverlayServer +// case mapOverlayServer +// case mapTilesAboveLabels +// case mapUseLegacy +// case enableDetectionNotifications +// case detectionSensorRole +// case enableSmartPosition +// case modemPreset +// case firmwareVersion +// } +// +// func reset() { +// Keys.allCases.forEach { removeObject(forKey: $0.rawValue) } +// } +// +// @UserDefault(.preferredPeripheralId, defaultValue: "") +// static var preferredPeripheralId: String +// +// @UserDefault(.preferredPeripheralNum, defaultValue: 0) +// static var preferredPeripheralNum: Int +// +// @UserDefault(.provideLocation, defaultValue: false) +// static var provideLocation: Bool +// +// @UserDefault(.provideLocationInterval, defaultValue: 0) +// static var provideLocationInterval: Int +// +// @UserDefault(.mapLayer, defaultValue: .standard) +// static var mapLayer: MapLayer +// +// @UserDefault(.meshMapDistance, defaultValue: 800000) +// static var meshMapDistance: Double +// +// @UserDefault(.enableMapWaypoints, defaultValue: false) +// static var enableMapWaypoints: Bool +// +// @UserDefault(.enableMapRecentering, defaultValue: false) +// static var enableMapRecentering: Bool +// +// @UserDefault(.enableMapNodeHistoryPins, defaultValue: false) +// static var enableMapNodeHistoryPins: Bool +// +// @UserDefault(.enableMapRouteLines, defaultValue: false) +// static var enableMapRouteLines: Bool +// +// @UserDefault(.enableMapConvexHull, defaultValue: false) +// static var enableMapConvexHull: Bool +// +// @UserDefault(.enableMapTraffic, defaultValue: false) +// static var enableMapTraffic: Bool +// +// @UserDefault(.enableMapPointsOfInterest, defaultValue: false) +// static var enableMapPointsOfInterest: Bool +// +// @UserDefault(.enableOfflineMaps, defaultValue: false) +// static var enableOfflineMaps: Bool +// +// @UserDefault(.enableOfflineMapsMBTiles, defaultValue: false) +// static var enableOfflineMapsMBTiles: Bool +// +// @UserDefault(.mapTileServer, defaultValue: .openStreetMap) +// static var mapTileServer: MapTileServer +// +// @UserDefault(.enableOverlayServer, defaultValue: false) +// static var enableOverlayServer: Bool +// +// @UserDefault(.mapOverlayServer, defaultValue: .baseReReflectivityCurrent) +// static var mapOverlayServer: MapOverlayServer +// +// @UserDefault(.mapTilesAboveLabels, defaultValue: false) +// static var mapTilesAboveLabels: Bool +// +// @UserDefault(.mapUseLegacy, defaultValue: false) +// static var mapUseLegacy: Bool +// +// @UserDefault(.enableDetectionNotifications, defaultValue: false) +// static var enableDetectionNotifications: Bool +// +// @UserDefault(.detectionSensorRole, defaultValue: .sensor) +// static var detectionSensorRole: DetectionSensorRole +// +// @UserDefault(.enableSmartPosition, defaultValue: false) +// static var enableSmartPosition: Bool +// +// @UserDefault(.modemPreset, defaultValue: 0) +// static var modemPreset: Int +// +// @UserDefault(.firmwareVersion, defaultValue: "0.0.0") +// static var firmwareVersion: String +//} diff --git a/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift b/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift index 7a96c3d1..e64febb5 100644 --- a/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift +++ b/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift @@ -18,15 +18,15 @@ struct MeshMapContent: MapContent { @State var routes: [RouteEntity] = [] /// Parameters @Binding var showUserLocation: Bool - @Binding var showNodeHistory: Bool - @Binding var showRouteLines: Bool - @Binding var showConvexHull: Bool + @AppStorage("meshMapShowNodeHistory") private var showNodeHistory = false + @AppStorage("meshMapShowRouteLines") private var showRouteLines = false + @AppStorage("enableMapConvexHull") private var showConvexHull = false @Binding var showTraffic: Bool @Binding var showPointsOfInterest: Bool @Binding var selectedMapLayer: MapLayer // Map Configuration @Binding var selectedPosition: PositionEntity? - @Binding var showWaypoints: Bool + @AppStorage("enableMapWaypoints") private var showWaypoints = false @Binding var selectedWaypoint: WaypointEntity? @FetchRequest(fetchRequest: PositionEntity.allPositionsFetchRequest(), animation: .easeIn) diff --git a/Meshtastic/Views/Nodes/Helpers/Map/MapSettingsForm.swift b/Meshtastic/Views/Nodes/Helpers/Map/MapSettingsForm.swift index 6a65c356..80d6a61f 100644 --- a/Meshtastic/Views/Nodes/Helpers/Map/MapSettingsForm.swift +++ b/Meshtastic/Views/Nodes/Helpers/Map/MapSettingsForm.swift @@ -13,13 +13,14 @@ import MapKit @available(iOS 17.0, macOS 14.0, *) struct MapSettingsForm: View { @Environment(\.dismiss) private var dismiss - @Binding var nodeHistory: Bool - @Binding var routeLines: Bool - @Binding var convexHull: Bool + @AppStorage("meshMapShowNodeHistory") private var nodeHistory = false + @AppStorage("meshMapShowRouteLines") private var routeLines = false + @AppStorage("enableMapConvexHull") private var convexHull = false + @AppStorage("enableMapWaypoints") private var waypoints = false @Binding var traffic: Bool @Binding var pointsOfInterest: Bool @Binding var mapLayer: MapLayer - @Binding var meshMapDistance: Double + @AppStorage("meshMapDistance") private var meshMapDistance: Double = 800000 @Binding var meshMap: Bool var body: some View { @@ -55,6 +56,13 @@ struct MapSettingsForm: View { UserDefaults.meshMapDistance = newMeshMapDistance } } + Toggle(isOn: $waypoints) { + Label("Show Waypoints ", systemImage: "signpost.right.and.left") + } + .toggleStyle(SwitchToggleStyle(tint: .accentColor)) + .onTapGesture { + UserDefaults.enableMapWaypoints = !waypoints + } Toggle(isOn: $nodeHistory) { Label("Node History", systemImage: "building.columns.fill") } diff --git a/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift b/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift index 282a5a8c..bd512e94 100644 --- a/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift +++ b/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift @@ -20,10 +20,6 @@ struct NodeMapSwiftUI: View { @State var showUserLocation: Bool = false @State var positions: [PositionEntity] = [] /// Map State User Defaults - @AppStorage("meshMapDistance") private var meshMapDistance: Double = 800000 - @AppStorage("meshMapShowNodeHistory") private var showNodeHistory = false - @AppStorage("meshMapShowRouteLines") private var showRouteLines = false - @AppStorage("enableMapConvexHull") private var showConvexHull = false @AppStorage("enableMapTraffic") private var showTraffic: Bool = false @AppStorage("enableMapPointsOfInterest") private var showPointsOfInterest: Bool = false @AppStorage("mapLayer") private var selectedMapLayer: MapLayer = .hybrid @@ -87,7 +83,7 @@ struct NodeMapSwiftUI: View { } } .sheet(isPresented: $isEditingSettings) { - MapSettingsForm(nodeHistory: $showNodeHistory, routeLines: $showRouteLines, convexHull: $showConvexHull, traffic: $showTraffic, pointsOfInterest: $showPointsOfInterest, mapLayer: $selectedMapLayer, meshMapDistance: $meshMapDistance, meshMap: $isMeshMap) + MapSettingsForm(traffic: $showTraffic, pointsOfInterest: $showPointsOfInterest, mapLayer: $selectedMapLayer, meshMap: $isMeshMap) .onChange(of: (selectedMapLayer)) { newMapLayer in switch selectedMapLayer { case .standard: diff --git a/Meshtastic/Views/Nodes/MeshMap.swift b/Meshtastic/Views/Nodes/MeshMap.swift index 8dee5f86..0787ea55 100644 --- a/Meshtastic/Views/Nodes/MeshMap.swift +++ b/Meshtastic/Views/Nodes/MeshMap.swift @@ -24,10 +24,6 @@ struct MeshMap: View { /// Parameters @State var showUserLocation: Bool = true /// Map State User Defaults - @AppStorage("meshMapDistance") private var meshMapDistance: Double = 800000 - @AppStorage("meshMapShowNodeHistory") private var showNodeHistory = false - @AppStorage("meshMapShowRouteLines") private var showRouteLines = false - @AppStorage("enableMapConvexHull") private var showConvexHull = false @AppStorage("enableMapTraffic") private var showTraffic: Bool = false @AppStorage("enableMapPointsOfInterest") private var showPointsOfInterest: Bool = false @AppStorage("mapLayer") private var selectedMapLayer: MapLayer = .standard @@ -37,7 +33,6 @@ struct MeshMap: View { @State var position = MapCameraPosition.automatic @State var isEditingSettings = false @State var selectedPosition: PositionEntity? - @State var showWaypoints = false @State var editingWaypoint: WaypointEntity? @State var selectedWaypoint: WaypointEntity? @State var newWaypointCoord: CLLocationCoordinate2D? @@ -54,7 +49,7 @@ struct MeshMap: View { ZStack { MapReader { reader in Map(position: $position, bounds: MapCameraBounds(minimumDistance: 1, maximumDistance: .infinity), scope: mapScope) { - MeshMapContent(routes: Array(routes), showUserLocation: $showUserLocation, showNodeHistory: $showNodeHistory, showRouteLines: $showRouteLines, showConvexHull: $showConvexHull, showTraffic: $showTraffic, showPointsOfInterest: $showPointsOfInterest, selectedMapLayer: $selectedMapLayer, selectedPosition: $selectedPosition, showWaypoints: $showWaypoints, selectedWaypoint: $selectedWaypoint) + MeshMapContent(routes: Array(routes), showUserLocation: $showUserLocation, showTraffic: $showTraffic, showPointsOfInterest: $showPointsOfInterest, selectedMapLayer: $selectedMapLayer, selectedPosition: $selectedPosition, selectedWaypoint: $selectedWaypoint) } .mapScope(mapScope) @@ -116,7 +111,7 @@ struct MeshMap: View { .padding() } .sheet(isPresented: $isEditingSettings) { - MapSettingsForm(nodeHistory: $showNodeHistory, routeLines: $showRouteLines, convexHull: $showConvexHull, traffic: $showTraffic, pointsOfInterest: $showPointsOfInterest, mapLayer: $selectedMapLayer, meshMapDistance: $meshMapDistance, meshMap: $isMeshMap) + MapSettingsForm(traffic: $showTraffic, pointsOfInterest: $showPointsOfInterest, mapLayer: $selectedMapLayer, meshMap: $isMeshMap) } .onChange(of: (appState.navigationPath)) { newPath in @@ -141,7 +136,7 @@ struct MeshMap: View { // print("Waypoint not found") // return // } - showWaypoints = true + //showWaypoints = true //position = .camera(MapCamera(centerCoordinate: waypoint.coordinate, distance: 1000, heading: 0, pitch: 60)) } } @@ -172,21 +167,7 @@ struct MeshMap: View { } .tint(Color(UIColor.secondarySystemBackground)) .foregroundColor(.accentColor) - .buttonStyle(.borderedProminent) - /// Show / Hide Waypoints Button - - Button(action: { - withAnimation { - showWaypoints = !showWaypoints - } - }) { - Image(systemName: showWaypoints ? "signpost.right.and.left.fill" : "signpost.right.and.left") - .padding(.vertical, 5) - } - .tint(Color(UIColor.secondarySystemBackground)) - .foregroundColor(.accentColor) - .buttonStyle(.borderedProminent) - + .buttonStyle(.borderedProminent) } .controlSize(.regular) .padding(5) From 525b1b2509ae985dabe57bd6ec898dbb9e077f9e Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Mon, 25 Mar 2024 19:20:36 -0700 Subject: [PATCH 55/74] More map cleanup --- .../Helpers/Map/MapContent/MeshMapContent.swift | 9 ++++----- .../Helpers/Map/MapContent/NodeMapContent.swift | 8 +++----- .../Views/Nodes/Helpers/Map/MapSettingsForm.swift | 15 ++++++++------- .../Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift | 3 ++- Meshtastic/Views/Nodes/MeshMap.swift | 7 +------ 5 files changed, 18 insertions(+), 24 deletions(-) diff --git a/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift b/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift index e64febb5..19bcd6ca 100644 --- a/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift +++ b/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift @@ -8,14 +8,9 @@ import SwiftUI import MapKit -import SwiftUI -import MapKit - @available(iOS 17.0, macOS 14.0, *) struct MeshMapContent: MapContent { - //@State var waypoints: [WaypointEntity] = [] - @State var routes: [RouteEntity] = [] /// Parameters @Binding var showUserLocation: Bool @AppStorage("meshMapShowNodeHistory") private var showNodeHistory = false @@ -34,6 +29,10 @@ struct MeshMapContent: MapContent { @FetchRequest(fetchRequest: WaypointEntity.allWaypointssFetchRequest(), animation: .none) var waypoints: FetchedResults + + @FetchRequest(sortDescriptors: [NSSortDescriptor(key: "name", ascending: true)], + predicate: NSPredicate(format: "enabled == true", ""), animation: .none) + private var routes: FetchedResults var delay: Double = 0 @State private var scale: CGFloat = 0.5 diff --git a/Meshtastic/Views/Nodes/Helpers/Map/MapContent/NodeMapContent.swift b/Meshtastic/Views/Nodes/Helpers/Map/MapContent/NodeMapContent.swift index 8e8d0b26..7805e288 100644 --- a/Meshtastic/Views/Nodes/Helpers/Map/MapContent/NodeMapContent.swift +++ b/Meshtastic/Views/Nodes/Helpers/Map/MapContent/NodeMapContent.swift @@ -6,6 +6,7 @@ // import SwiftUI import MapKit +import CoreData @available(iOS 17.0, macOS 14.0, *) struct NodeMapContent: MapContent { @@ -16,10 +17,12 @@ struct NodeMapContent: MapContent { /// Map State User Defaults @AppStorage("meshMapShowNodeHistory") private var showNodeHistory = false @AppStorage("meshMapShowRouteLines") private var showRouteLines = false + @AppStorage("enableMapWaypoints") private var showWaypoints = false @AppStorage("enableMapConvexHull") private var showConvexHull = false @AppStorage("enableMapTraffic") private var showTraffic: Bool = false @AppStorage("enableMapPointsOfInterest") private var showPointsOfInterest: Bool = false @AppStorage("mapLayer") private var selectedMapLayer: MapLayer = .hybrid + // Map Configuration @Namespace var mapScope @State var mapStyle: MapStyle = MapStyle.hybrid(elevation: .realistic, pointsOfInterest: .all, showsTraffic: true) @@ -31,9 +34,6 @@ struct NodeMapContent: MapContent { @State var selectedPosition: PositionEntity? @State var isMeshMap = false - //let region: MKCoordinateRegion - - @MapContentBuilder var nodeMap: some MapContent { let positionArray = node.positions?.array as? [PositionEntity] ?? [] @@ -43,7 +43,6 @@ struct NodeMapContent: MapContent { /// Node Color from node.num let nodeColor = UIColor(hex: UInt32(node.num)) - /// Node Annotations ForEach(positionArray, id: \.id) { position in let pf = PositionFlags(rawValue: Int(position.nodePosition?.metadata?.positionFlags ?? 771)) @@ -79,7 +78,6 @@ struct NodeMapContent: MapContent { MapPolyline(coordinates: lineCoords) .stroke(gradient, style: dashed) } - /// Node Annotations ForEach(positionArray, id: \.id) { position in Annotation(position.latest ? node.user?.shortName ?? "?": "", coordinate: position.coordinate) { diff --git a/Meshtastic/Views/Nodes/Helpers/Map/MapSettingsForm.swift b/Meshtastic/Views/Nodes/Helpers/Map/MapSettingsForm.swift index 80d6a61f..9a775911 100644 --- a/Meshtastic/Views/Nodes/Helpers/Map/MapSettingsForm.swift +++ b/Meshtastic/Views/Nodes/Helpers/Map/MapSettingsForm.swift @@ -55,14 +55,15 @@ struct MapSettingsForm: View { .onChange(of: meshMapDistance) { newMeshMapDistance in UserDefaults.meshMapDistance = newMeshMapDistance } + Toggle(isOn: $waypoints) { + Label("Show Waypoints ", systemImage: "signpost.right.and.left") + } + .toggleStyle(SwitchToggleStyle(tint: .accentColor)) + .onTapGesture { + UserDefaults.enableMapWaypoints = !waypoints + } } - Toggle(isOn: $waypoints) { - Label("Show Waypoints ", systemImage: "signpost.right.and.left") - } - .toggleStyle(SwitchToggleStyle(tint: .accentColor)) - .onTapGesture { - UserDefaults.enableMapWaypoints = !waypoints - } + Toggle(isOn: $nodeHistory) { Label("Node History", systemImage: "building.columns.fill") } diff --git a/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift b/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift index bd512e94..6bb5c18c 100644 --- a/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift +++ b/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift @@ -31,7 +31,6 @@ struct NodeMapSwiftUI: View { @State var isLookingAround = false @State var isShowingAltitude = false @State var isEditingSettings = false - @State var selectedPosition: PositionEntity? @State var isMeshMap = false @State private var mapRegion = MKCoordinateRegion.init() @@ -42,6 +41,8 @@ struct NodeMapSwiftUI: View { ), animation: .none) private var waypoints: FetchedResults + + var body: some View { var mostRecent = node.positions?.lastObject as? PositionEntity diff --git a/Meshtastic/Views/Nodes/MeshMap.swift b/Meshtastic/Views/Nodes/MeshMap.swift index 0787ea55..2b17ab92 100644 --- a/Meshtastic/Views/Nodes/MeshMap.swift +++ b/Meshtastic/Views/Nodes/MeshMap.swift @@ -38,18 +38,13 @@ struct MeshMap: View { @State var newWaypointCoord: CLLocationCoordinate2D? @State var isMeshMap = true - - @FetchRequest(sortDescriptors: [NSSortDescriptor(key: "name", ascending: true)], - predicate: NSPredicate(format: "enabled == true", ""), animation: .none) - private var routes: FetchedResults - var body: some View { NavigationStack { ZStack { MapReader { reader in Map(position: $position, bounds: MapCameraBounds(minimumDistance: 1, maximumDistance: .infinity), scope: mapScope) { - MeshMapContent(routes: Array(routes), showUserLocation: $showUserLocation, showTraffic: $showTraffic, showPointsOfInterest: $showPointsOfInterest, selectedMapLayer: $selectedMapLayer, selectedPosition: $selectedPosition, selectedWaypoint: $selectedWaypoint) + MeshMapContent(showUserLocation: $showUserLocation, showTraffic: $showTraffic, showPointsOfInterest: $showPointsOfInterest, selectedMapLayer: $selectedMapLayer, selectedPosition: $selectedPosition, selectedWaypoint: $selectedWaypoint) } .mapScope(mapScope) From 496451c15caf551a60d79d5eddb5648591ae82fb Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Tue, 26 Mar 2024 07:54:16 -0700 Subject: [PATCH 56/74] Add node filters --- Meshtastic.xcodeproj/project.pbxproj | 4 + Meshtastic/Enums/AppSettingsEnums.swift | 2 +- Meshtastic/Enums/DeviceEnums.swift | 6 +- .../CoreData/PositionEntityExtension.swift | 1 - .../Map/MapContent/MeshMapContent.swift | 1 - .../Views/Nodes/Helpers/NodeListFilter.swift | 117 +++++++++ .../Views/Nodes/Helpers/NodeListItem.swift | 2 +- Meshtastic/Views/Nodes/NodeList.swift | 129 +++++----- .../Settings/Config/Module/MQTTConfig.swift | 2 +- Meshtastic/Views/Settings/Settings.swift | 226 +++++++++++------- 10 files changed, 344 insertions(+), 146 deletions(-) create mode 100644 Meshtastic/Views/Nodes/Helpers/NodeListFilter.swift diff --git a/Meshtastic.xcodeproj/project.pbxproj b/Meshtastic.xcodeproj/project.pbxproj index 67e51a8e..5e714267 100644 --- a/Meshtastic.xcodeproj/project.pbxproj +++ b/Meshtastic.xcodeproj/project.pbxproj @@ -186,6 +186,7 @@ DDDB445229F8ACF900EE2349 /* Date.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDDB445129F8ACF900EE2349 /* Date.swift */; }; DDDB445429F8AD1600EE2349 /* Data.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDDB445329F8AD1600EE2349 /* Data.swift */; }; DDDC22382BA92344002C44F1 /* MeshMapContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDDC22372BA92344002C44F1 /* MeshMapContent.swift */; }; + DDDCD5702BB26F5C00BE6B60 /* NodeListFilter.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDDCD56F2BB26F5C00BE6B60 /* NodeListFilter.swift */; }; DDDE59F529AF163D00490C6C /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DD41A61C29AE7E8E003C5A37 /* WidgetKit.framework */; }; DDDE59F629AF163D00490C6C /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DD41A61E29AE7E8F003C5A37 /* SwiftUI.framework */; }; DDDE59F929AF163D00490C6C /* WidgetsBundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDDE59F829AF163D00490C6C /* WidgetsBundle.swift */; }; @@ -458,6 +459,7 @@ DDDC22312BA76701002C44F1 /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Localizable.strings; sourceTree = ""; }; DDDC22322BA76961002C44F1 /* zh-Hant-TW */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hant-TW"; path = "zh-Hant-TW.lproj/Localizable.strings"; sourceTree = ""; }; DDDC22372BA92344002C44F1 /* MeshMapContent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MeshMapContent.swift; sourceTree = ""; }; + DDDCD56F2BB26F5C00BE6B60 /* NodeListFilter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NodeListFilter.swift; sourceTree = ""; }; DDDD527729B5B83F0045BC3C /* MeshtasticDataModelV9.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = MeshtasticDataModelV9.xcdatamodel; sourceTree = ""; }; DDDE59F429AF163D00490C6C /* WidgetsExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = WidgetsExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; }; DDDE59F829AF163D00490C6C /* WidgetsBundle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetsBundle.swift; sourceTree = ""; }; @@ -960,6 +962,7 @@ DDDB26432AAC0206003AFCB7 /* NodeDetail.swift */, DDDB26452AACC0B7003AFCB7 /* NodeInfoItem.swift */, DDDB26412AABF655003AFCB7 /* NodeListItem.swift */, + DDDCD56F2BB26F5C00BE6B60 /* NodeListFilter.swift */, ); path = Helpers; sourceTree = ""; @@ -1355,6 +1358,7 @@ DDB6ABE228B13FB500384BA1 /* PositionConfigEnums.swift in Sources */, DD5E520E298EE33B00D21B61 /* mqtt.pb.swift in Sources */, DD994B69295F88B60013760A /* IntervalEnums.swift in Sources */, + DDDCD5702BB26F5C00BE6B60 /* NodeListFilter.swift in Sources */, DD1933762B0835D500771CD5 /* PositionAltitudeChart.swift in Sources */, DD415828285859C4009B0E59 /* TelemetryConfig.swift in Sources */, DDDB443D29F6592F00EE2349 /* NetworkManager.swift in Sources */, diff --git a/Meshtastic/Enums/AppSettingsEnums.swift b/Meshtastic/Enums/AppSettingsEnums.swift index 4169444e..0250119a 100644 --- a/Meshtastic/Enums/AppSettingsEnums.swift +++ b/Meshtastic/Enums/AppSettingsEnums.swift @@ -56,7 +56,7 @@ enum MeshMapDistances: Double, CaseIterable, Identifiable { case twoHundredMiles = 321869 case fiveHundredMiles = 804672 case oneThousandMiles = 1609000 - case twoThousandMiles = 3218688 + case twentyFiveHundredMiles = 4023360 var id: Double { self.rawValue } var description: String { let distanceFormatter = MKDistanceFormatter() diff --git a/Meshtastic/Enums/DeviceEnums.swift b/Meshtastic/Enums/DeviceEnums.swift index b754e986..8f2bbc7b 100644 --- a/Meshtastic/Enums/DeviceEnums.swift +++ b/Meshtastic/Enums/DeviceEnums.swift @@ -74,11 +74,13 @@ enum DeviceRoles: Int, CaseIterable, Identifiable { var systemName: String { switch self { case .client: - return "iphone.gen3.radiowaves.left.and.right" + return "apps.iphone" case .clientMute: return "speaker.slash" - case .router, .routerClient, .repeater: + case .router, .routerClient: return "wifi.router" + case .repeater: + return "repeat" case .tracker: return "mappin.and.ellipse.circle" case .sensor: diff --git a/Meshtastic/Extensions/CoreData/PositionEntityExtension.swift b/Meshtastic/Extensions/CoreData/PositionEntityExtension.swift index 20fbbd35..b24ec821 100644 --- a/Meshtastic/Extensions/CoreData/PositionEntityExtension.swift +++ b/Meshtastic/Extensions/CoreData/PositionEntityExtension.swift @@ -26,7 +26,6 @@ extension PositionEntity { let pointOfInterest = LocationHelper.currentLocation if pointOfInterest.latitude != LocationHelper.DefaultLocation.latitude && pointOfInterest.longitude != LocationHelper.DefaultLocation.longitude { - /// Lets just get nodes within about 500 miles let D: Double = UserDefaults.meshMapDistance * 1.1 let R: Double = 6371009 let meanLatitidue = pointOfInterest.latitude * .pi / 180 diff --git a/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift b/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift index 19bcd6ca..2655fbd4 100644 --- a/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift +++ b/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift @@ -205,6 +205,5 @@ struct MeshMapContent: MapContent { @MapContentBuilder var body: some MapContent { meshMap - } } diff --git a/Meshtastic/Views/Nodes/Helpers/NodeListFilter.swift b/Meshtastic/Views/Nodes/Helpers/NodeListFilter.swift new file mode 100644 index 00000000..03e04d84 --- /dev/null +++ b/Meshtastic/Views/Nodes/Helpers/NodeListFilter.swift @@ -0,0 +1,117 @@ +// +// NodeListFilter.swift +// Meshtastic +// +// Created by Garth Vander Houwen on 3/25/24. +// + +import Foundation +import SwiftUI + +struct NodeListFilter: View { + @Environment(\.dismiss) private var dismiss + /// Filters + @Binding var viaLora: Bool + @Binding var viaMqtt: Bool + @Binding var distanceFilter: Bool + @Binding var maximumDistance: Double + @Binding var hopsAway: Int + @Binding var deviceRole: Int + + var body: some View { + + NavigationStack { + Form { + Section(header: Text("Node Filters")) { + Toggle(isOn: $viaLora) { + + Label { + Text("Via Lora") + } icon: { + Image(systemName: "dot.radiowaves.left.and.right") + .rotationEffect(.degrees(-90)) + } + } + .toggleStyle(SwitchToggleStyle(tint: .accentColor)) + Toggle(isOn: $viaMqtt) { + + Label { + Text("Via Mqtt") + } icon: { + Image(systemName: "dot.radiowaves.up.forward") + } + } + .toggleStyle(SwitchToggleStyle(tint: .accentColor)) + .listRowSeparator(.visible) + +// Toggle(isOn: $distanceFilter) { +// +// Label { +// Text("Distance") +// } icon: { +// Image(systemName: "map") +// } +// } +// .toggleStyle(SwitchToggleStyle(tint: .accentColor)) +// +// .listRowSeparator(distanceFilter ? .hidden : .visible) +// if distanceFilter { +// HStack { +// Label("Show nodes", systemImage: "lines.measurement.horizontal") +// Picker("", selection: $maximumDistance) { +// ForEach(MeshMapDistances.allCases) { di in +// Text(di.description) +// .tag(di.id) +// } +// } +// .pickerStyle(DefaultPickerStyle()) +// } +// } + HStack { + Label("Hops Away", systemImage: "hare") + Picker("", selection: $hopsAway) { + Text("Any") + .tag(-1) + Text("Direct") + .tag(0) + ForEach(1..<8) { + Text("\($0)") + .tag($0) + } + } + .pickerStyle(DefaultPickerStyle()) + } + HStack { + Label("Device Role", systemImage: "apps.iphone") + Picker("", selection: $deviceRole) { + Text("All Roles") + .tag(-1) + ForEach(DeviceRoles.allCases) { dr in + Label { + Text(" \(dr.name)") + } icon: { + Image(systemName: dr.systemName) + } + } + } + .pickerStyle(DefaultPickerStyle()) + } + } + } +#if targetEnvironment(macCatalyst) + Spacer() + Button { + dismiss() + } label: { + Label("close", systemImage: "xmark") + } + .buttonStyle(.bordered) + .buttonBorderShape(.capsule) + .controlSize(.large) + .padding(.bottom) +#endif + } + .presentationDetents([.fraction(0.35), .fraction(0.45)]) + .presentationDragIndicator(.visible) + } +} diff --git a/Meshtastic/Views/Nodes/Helpers/NodeListItem.swift b/Meshtastic/Views/Nodes/Helpers/NodeListItem.swift index feb528f6..f7ea4ffc 100644 --- a/Meshtastic/Views/Nodes/Helpers/NodeListItem.swift +++ b/Meshtastic/Views/Nodes/Helpers/NodeListItem.swift @@ -132,7 +132,7 @@ struct NodeListItem: View { } if node.viaMqtt && connectedNode != node.num { - Image(systemName: "network") + Image(systemName: "dot.radiowaves.up.forward") .symbolRenderingMode(.hierarchical) .font(.callout) .frame(width: 30) diff --git a/Meshtastic/Views/Nodes/NodeList.swift b/Meshtastic/Views/Nodes/NodeList.swift index 902d7df5..4efad7a4 100644 --- a/Meshtastic/Views/Nodes/NodeList.swift +++ b/Meshtastic/Views/Nodes/NodeList.swift @@ -7,28 +7,6 @@ import SwiftUI import CoreLocation -struct NodeSearchState { - var searchText = "" - var searchScope = SearchScopes.all - var predicate: NSPredicate = .init() - - enum SearchScopes: CaseIterable, Identifiable { - case all - case lora - case mqtt - - var id: Self { self } - - var title: LocalizedStringKey { - switch self { - case .all: return "All" - case .lora: return "LoRa" - case .mqtt: return "MQTT" - } - } - } -} - struct NodeList: View { @State private var columnVisibility = NavigationSplitViewVisibility.all @@ -38,11 +16,17 @@ struct NodeList: View { @State private var isPresentingDeleteNodeAlert = false @State private var isPresentingPositionSentAlert = false @State private var deleteNodeId: Int64 = 0 - @State private var searchState = NodeSearchState() + @State private var searchText = "" + @State private var viaLora = true + @State private var viaMqtt = true + @State private var distanceFilter = false + @State private var maxDistance: Double = 800000 + @State private var hopsAway: Int = -1 + @State private var deviceRole: Int = -1 + + @State var isEditingFilters = false @SceneStorage("selectedDetailView") var selectedDetailView: String? - - @State private var searchText = "" @Environment(\.managedObjectContext) var context @EnvironmentObject var bleManager: BLEManager @@ -159,14 +143,17 @@ struct NodeList: View { Text("Any missed messages will be delivered again.") } } + .sheet(isPresented: $isEditingFilters) { + NodeListFilter(viaLora: $viaLora, viaMqtt: $viaMqtt, distanceFilter: $distanceFilter, maximumDistance: $maxDistance, hopsAway: $hopsAway, deviceRole: $deviceRole) + } .safeAreaInset(edge: .bottom, alignment: .trailing) { HStack { Button(action: { withAnimation { - //isEditingSettings = !isEditingSettings + isEditingFilters = !isEditingFilters } }) { - Image(systemName: true ? "line.3.horizontal.decrease.circle" : "line.3.horizontal.decrease.circle.fill") + Image(systemName: !isEditingFilters ? "line.3.horizontal.decrease.circle" : "line.3.horizontal.decrease.circle.fill") .padding(.vertical, 5) } .tint(Color(UIColor.secondarySystemBackground)) @@ -178,14 +165,9 @@ struct NodeList: View { .padding(5) } .padding(.bottom, 5) - .searchable(text: $searchState.searchText, placement: nodes.count > 10 ? .navigationBarDrawer(displayMode: .always) : .automatic, prompt: "Find a node") + .searchable(text: $searchText, placement: .automatic, prompt: "Find a node") .disableAutocorrection(true) .scrollDismissesKeyboard(.immediately) - .searchScopes($searchState.searchScope) { - ForEach(NodeSearchState.SearchScopes.allCases) { scope in - Text(scope.title).tag(scope) - } - } .navigationTitle(String.localizedStringWithFormat("nodes %@".localized, String(nodes.count))) .listStyle(.plain) .confirmationDialog( @@ -256,10 +238,19 @@ struct NodeList: View { } .navigationSplitViewStyle(.balanced) - .onChange(of: searchState.searchText) { _ in + .onChange(of: searchText) { _ in searchNodeList() } - .onChange(of: searchState.searchScope) { _ in + .onChange(of: viaLora) { _ in + searchNodeList() + } + .onChange(of: viaMqtt) { _ in + searchNodeList() + } + .onChange(of: deviceRole) { _ in + searchNodeList() + } + .onChange(of: hopsAway) { _ in searchNodeList() } .onAppear { @@ -272,35 +263,63 @@ struct NodeList: View { private func searchNodeList() { /// Case Insensitive Search Text Predicates let searchPredicates = ["user.userId", "user.hwModel", "user.longName", "user.shortName"].map { property in - return NSPredicate(format: "%K CONTAINS[c] %@", property, searchState.searchText) + return NSPredicate(format: "%K CONTAINS[c] %@", property, searchText) } /// Create a compound predicate using each text search preicate as an OR let textSearchPredicate = NSCompoundPredicate(type: .or, subpredicates: searchPredicates) + /// Create an array of predicates to hold our AND predicates + var predicates: [NSPredicate] = [] + /// Mqtt + if !(viaLora && viaMqtt) { + if viaLora { + let loraPredicate = NSPredicate(format: "viaMqtt == NO") + predicates.append(loraPredicate) + } else { + let mqttPredicate = NSPredicate(format: "viaMqtt == YES") + predicates.append(mqttPredicate) + } + } + /// Role + if deviceRole > 0 { + let rolePredicate = NSPredicate(format: "user.role == %i", Int32(deviceRole)) + predicates.append(rolePredicate) + } + /// Hops Away + if hopsAway > 0 { + let hopsAwayPredicate = NSPredicate(format: "hopsAway == %i", Int32(hopsAway)) + predicates.append(hopsAwayPredicate) + } + /// Distance + if distanceFilter { + let pointOfInterest = LocationHelper.currentLocation - /// Set the predicate to nil if the search string is empty - if searchState.searchText.isEmpty { - nodes.nsPredicate = nil - return + if pointOfInterest.latitude != LocationHelper.DefaultLocation.latitude && pointOfInterest.longitude != LocationHelper.DefaultLocation.longitude { + let D: Double = maxDistance * 1.1 + let R: Double = 6371009 + let meanLatitidue = pointOfInterest.latitude * .pi / 180 + let deltaLatitude = D / R * 180 / .pi + let deltaLongitude = D / (R * cos(meanLatitidue)) * 180 / .pi + let minLatitude: Double = pointOfInterest.latitude - deltaLatitude + let maxLatitude: Double = pointOfInterest.latitude + deltaLatitude + let minLongitude: Double = pointOfInterest.longitude - deltaLongitude + let maxLongitude: Double = pointOfInterest.longitude + deltaLongitude + let distancePredicate = NSPredicate(format: "(%lf <= (positions[first].longitudeI / 1e7))", minLongitude, maxLongitude,minLatitude, maxLatitude) + //let distancePredicate = NSPredicate(format: "(%lf <= (positions[LAST].longitudeI / 1e7)) AND ((positions[LAST].longitudeI / 1e7) <= %lf) AND (%lf <= (positions[LAST].latitudeI / 1e7)) AND ((positions[LAST].latitudeI / 1e7) <= %lf)", minLongitude, maxLongitude,minLatitude, maxLatitude) + + //predicates.append(distancePredicate) + } } - /// Add a predicate for the search scope if selected - if searchState.searchScope != .all { + if predicates.count > 0 { - if searchState.searchScope == .lora { - let loraPredicate = NSPredicate(format: "viaMqtt == NO") - let scopePredicate = NSCompoundPredicate(type: .and, subpredicates: [loraPredicate]) - nodes.nsPredicate = NSCompoundPredicate(type: .and, subpredicates: [textSearchPredicate, scopePredicate]) - return - - } else if searchState.searchScope == .mqtt { - let mqttPredicate = NSPredicate(format: "viaMqtt == YES") - let scopePredicate = NSCompoundPredicate(type: .and, subpredicates: [mqttPredicate]) - nodes.nsPredicate = NSCompoundPredicate(type: .and, subpredicates: [textSearchPredicate, scopePredicate]) - return + if !searchText.isEmpty { + let filterPredicates = NSCompoundPredicate(type: .and, subpredicates: predicates) + nodes.nsPredicate = NSCompoundPredicate(type: .and, subpredicates: [textSearchPredicate, filterPredicates]) + } else { + nodes.nsPredicate = NSCompoundPredicate(type: .and, subpredicates: predicates) } } else { - /// Use the text search predicate - nodes.nsPredicate = textSearchPredicate + nodes.nsPredicate = nil } } } diff --git a/Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift b/Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift index cfcaa930..8191aec9 100644 --- a/Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift +++ b/Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift @@ -47,7 +47,7 @@ struct MQTTConfig: View { Section(header: Text("options")) { Toggle(isOn: $enabled) { - Label("enabled", systemImage: "dot.radiowaves.right") + Label("enabled", systemImage: "dot.radiowaves.up.forward") } .toggleStyle(SwitchToggleStyle(tint: .accentColor)) diff --git a/Meshtastic/Views/Settings/Settings.swift b/Meshtastic/Views/Settings/Settings.swift index b98893e9..b1883c1c 100644 --- a/Meshtastic/Views/Settings/Settings.swift +++ b/Meshtastic/Views/Settings/Settings.swift @@ -50,34 +50,43 @@ struct Settings: View { NavigationLink { AboutMeshtastic() } label: { - Image(systemName: "questionmark.app") - .symbolRenderingMode(.hierarchical) - Text("about.meshtastic") + Label { + Text("about.meshtastic") + } icon: { + Image(systemName: "questionmark.app") + } } .tag(SettingsSidebar.about) NavigationLink { AppSettings() } label: { - Image(systemName: "gearshape") - .symbolRenderingMode(.hierarchical) - Text("appsettings") + Label { + Text("appsettings") + } icon: { + Image(systemName: "gearshape") + } } .tag(SettingsSidebar.appSettings) if #available(iOS 17.0, macOS 14.0, *) { NavigationLink { Routes() } label: { - Image(systemName: "road.lanes.curved.right") - .symbolRenderingMode(.hierarchical) - Text("routes") + Label { + Text("routes") + } icon: { + Image(systemName: "road.lanes.curved.right") + } } .tag(SettingsSidebar.routes) NavigationLink { RouteRecorder() } label: { - Image(systemName: "record.circle") - .symbolRenderingMode(.hierarchical) - Text("route.recorder") + Label { + Text("route.recorder") + } icon: { + Image(systemName: "record.circle") + .foregroundColor(.red) + } } .tag(SettingsSidebar.routeRecorder) } @@ -152,26 +161,33 @@ struct Settings: View { NavigationLink { LoRaConfig(node: nodes.first(where: { $0.num == selectedNode })) } label: { - Image(systemName: "dot.radiowaves.left.and.right") - .symbolRenderingMode(.hierarchical) - Text("lora") + Label { + Text("lora") + } icon: { + Image(systemName: "dot.radiowaves.left.and.right") + .rotationEffect(.degrees(-90)) + } } .tag(SettingsSidebar.loraConfig) NavigationLink { Channels(node: nodes.first(where: { $0.num == preferredNodeNum })) } label: { - Image(systemName: "fibrechannel") - .symbolRenderingMode(.hierarchical) - Text("channels") + Label { + Text("channels") + } icon: { + Image(systemName: "fibrechannel") + } } .tag(SettingsSidebar.channelConfig) .disabled(selectedNode > 0 && selectedNode != preferredNodeNum) NavigationLink { ShareChannels(node: nodes.first(where: { $0.num == preferredNodeNum })) } label: { - Image(systemName: "qrcode") - .symbolRenderingMode(.hierarchical) - Text("share.channels") + Label { + Text("share.channels") + } icon: { + Image(systemName: "qrcode") + } } .tag(SettingsSidebar.shareChannels) .disabled(selectedNode > 0 && selectedNode != preferredNodeNum) @@ -180,58 +196,72 @@ struct Settings: View { NavigationLink { UserConfig(node: nodes.first(where: { $0.num == selectedNode })) } label: { - Image(systemName: "person.crop.rectangle.fill") - .symbolRenderingMode(.hierarchical) - Text("user") + Label { + Text("user") + } icon: { + Image(systemName: "person.crop.rectangle.fill") + } } .tag(SettingsSidebar.userConfig) NavigationLink { BluetoothConfig(node: nodes.first(where: { $0.num == selectedNode })) } label: { - Image(systemName: "antenna.radiowaves.left.and.right") - .symbolRenderingMode(.hierarchical) - Text("bluetooth") + Label { + Text("bluetooth") + } icon: { + Image(systemName: "antenna.radiowaves.left.and.right") + } } .tag(SettingsSidebar.bluetoothConfig) NavigationLink { DeviceConfig(node: nodes.first(where: { $0.num == selectedNode })) } label: { - Image(systemName: "flipphone") - .symbolRenderingMode(.hierarchical) - Text("device") + Label { + Text("device") + } icon: { + Image(systemName: "flipphone") + } } .tag(SettingsSidebar.deviceConfig) NavigationLink { DisplayConfig(node: nodes.first(where: { $0.num == selectedNode })) } label: { - Image(systemName: "display") - .symbolRenderingMode(.hierarchical) - Text("display") + Label { + Text("display") + } icon: { + Image(systemName: "display") + } } .tag(SettingsSidebar.displayConfig) NavigationLink { NetworkConfig(node: nodes.first(where: { $0.num == selectedNode })) } label: { - Image(systemName: "network") - .symbolRenderingMode(.hierarchical) - Text("network") + Label { + Text("network") + } icon: { + Image(systemName: "network") + } } .tag(SettingsSidebar.networkConfig) NavigationLink { PositionConfig(node: nodes.first(where: { $0.num == selectedNode })) } label: { - Image(systemName: "location") - .symbolRenderingMode(.hierarchical) - Text("position") + Label { + Text("position") + } icon: { + Image(systemName: "location") + } } .tag(SettingsSidebar.positionConfig) NavigationLink { PowerConfig(node: nodes.first(where: { $0.num == selectedNode })) } label: { - Image(systemName: "bolt.fill") - .symbolRenderingMode(.hierarchical) - Text("config.power.settings") + Label { + Text("config.power.settings") + } icon: { + Image(systemName: "bolt.fill") + } } .tag(SettingsSidebar.powerConfig) } @@ -240,92 +270,114 @@ struct Settings: View { NavigationLink { AmbientLightingConfig(node: nodes.first(where: { $0.num == selectedNode })) } label: { - Image(systemName: "light.max") - .symbolRenderingMode(.hierarchical) - Text("ambient.lighting") + Label { + Text("ambient.lighting") + } icon: { + Image(systemName: "light.max") + } } .tag(SettingsSidebar.ambientLightingConfig) } NavigationLink { CannedMessagesConfig(node: nodes.first(where: { $0.num == selectedNode })) } label: { - Image(systemName: "list.bullet.rectangle.fill") - .symbolRenderingMode(.hierarchical) - Text("canned.messages") + Label { + Text("canned.messages") + } icon: { + Image(systemName: "list.bullet.rectangle.fill") + } } .tag(SettingsSidebar.cannedMessagesConfig) NavigationLink { DetectionSensorConfig(node: nodes.first(where: { $0.num == selectedNode })) } label: { - Image(systemName: "sensor") - .symbolRenderingMode(.hierarchical) - Text("detection.sensor") + Label { + Text("detection.sensor") + } icon: { + Image(systemName: "sensor") + } } .tag(SettingsSidebar.detectionSensorConfig) NavigationLink { ExternalNotificationConfig(node: nodes.first(where: { $0.num == selectedNode })) } label: { - Image(systemName: "megaphone") - .symbolRenderingMode(.hierarchical) - Text("external.notification") + Label { + Text("external.notification") + } icon: { + Image(systemName: "megaphone") + } } .tag(SettingsSidebar.externalNotificationConfig) NavigationLink { MQTTConfig(node: nodes.first(where: { $0.num == selectedNode })) } label: { - Image(systemName: "dot.radiowaves.right") - .symbolRenderingMode(.hierarchical) - Text("mqtt") + Label { + Text("mqtt") + } icon: { + Image(systemName: "dot.radiowaves.up.forward") + } } .tag(SettingsSidebar.mqttConfig) NavigationLink { RangeTestConfig(node: nodes.first(where: { $0.num == selectedNode })) } label: { - Image(systemName: "point.3.connected.trianglepath.dotted") - .symbolRenderingMode(.hierarchical) - Text("range.test") + Label { + Text("range.test") + } icon: { + Image(systemName: "point.3.connected.trianglepath.dotted") + } } .tag(SettingsSidebar.rangeTestConfig) if node?.metadata?.hasWifi ?? false { NavigationLink { PaxCounterConfig(node: nodes.first(where: { $0.num == selectedNode })) } label: { - Image(systemName: "figure.walk.motion") - .symbolRenderingMode(.hierarchical) - Text("config.module.paxcounter.settings") + Label { + Text("config.module.paxcounter.setting") + } icon: { + Image(systemName: "figure.walk.motion") + } } .tag(SettingsSidebar.paxCounterConfig) } NavigationLink { RtttlConfig(node: nodes.first(where: { $0.num == selectedNode })) } label: { - Image(systemName: "music.note.list") - .symbolRenderingMode(.hierarchical) - Text("ringtone") + Label { + Text("ringtone") + } icon: { + Image(systemName: "music.note.list") + } } .tag(SettingsSidebar.ringtoneConfig) NavigationLink { SerialConfig(node: nodes.first(where: { $0.num == selectedNode })) } label: { - Image(systemName: "terminal") - .symbolRenderingMode(.hierarchical) - Text("serial") + Label { + Text("serial") + } icon: { + Image(systemName: "terminal") + } } .tag(SettingsSidebar.serialConfig) NavigationLink { StoreForwardConfig(node: nodes.first(where: { $0.num == selectedNode })) } label: { - Image(systemName: "envelope.arrow.triangle.branch") - .symbolRenderingMode(.hierarchical) - Text("storeforward") + Label { + Text("storeforward") + } icon: { + Image(systemName: "envelope.arrow.triangle.branch") + } } .tag(SettingsSidebar.storeAndForwardConfig) NavigationLink { TelemetryConfig(node: nodes.first(where: { $0.num == selectedNode })) } label: { - Image(systemName: "chart.xyaxis.line") - .symbolRenderingMode(.hierarchical) - Text("telemetry") + Label { + Text("telemetry") + } icon: { + Image(systemName: "chart.xyaxis.line") + } } .tag(SettingsSidebar.telemetryConfig) } @@ -333,18 +385,22 @@ struct Settings: View { NavigationLink { MeshLog() } label: { - Image(systemName: "list.bullet.rectangle") - .symbolRenderingMode(.hierarchical) - Text("mesh.log") + Label { + Text("mesh.log") + } icon: { + Image(systemName: "list.bullet.rectangle") + } } .tag(SettingsSidebar.meshLog) NavigationLink { let connectedNode = nodes.first(where: { $0.num == preferredNodeNum }) AdminMessageList(user: connectedNode?.user) } label: { - Image(systemName: "building.columns") - .symbolRenderingMode(.hierarchical) - Text("admin.log") + Label { + Text("admin.log") + } icon: { + Image(systemName: "building.columns") + } } .tag(SettingsSidebar.adminMessageLog) } @@ -352,9 +408,11 @@ struct Settings: View { NavigationLink { Firmware(node: nodes.first(where: { $0.num == preferredNodeNum })) } label: { - Image(systemName: "arrow.up.arrow.down.square") - .symbolRenderingMode(.hierarchical) - Text("Firmware Updates") + Label { + Text("Firmware Updates") + } icon: { + Image(systemName: "arrow.up.arrow.down.square") + } } .tag(SettingsSidebar.about) .disabled(selectedNode > 0 && selectedNode != preferredNodeNum) From 4f3cd0f72bd91f315f344a4c8cd94db4853ed099 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Tue, 26 Mar 2024 08:55:38 -0700 Subject: [PATCH 57/74] Add TAK tracker, bump db version --- Meshtastic.xcodeproj/project.pbxproj | 4 +- Meshtastic/Enums/DeviceEnums.swift | 10 + .../Meshtastic.xcdatamodeld/.xccurrentversion | 2 +- .../contents | 457 ++++++++++++++++++ .../Protobufs/meshtastic/admin.pb.swift | 125 +++++ .../Protobufs/meshtastic/deviceonly.pb.swift | 72 --- Meshtastic/Protobufs/meshtastic/mesh.pb.swift | 72 +++ protobufs | 2 +- 8 files changed, 669 insertions(+), 75 deletions(-) create mode 100644 Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 31.xcdatamodel/contents diff --git a/Meshtastic.xcodeproj/project.pbxproj b/Meshtastic.xcodeproj/project.pbxproj index 5e714267..5cdd8853 100644 --- a/Meshtastic.xcodeproj/project.pbxproj +++ b/Meshtastic.xcodeproj/project.pbxproj @@ -460,6 +460,7 @@ DDDC22322BA76961002C44F1 /* zh-Hant-TW */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hant-TW"; path = "zh-Hant-TW.lproj/Localizable.strings"; sourceTree = ""; }; DDDC22372BA92344002C44F1 /* MeshMapContent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MeshMapContent.swift; sourceTree = ""; }; DDDCD56F2BB26F5C00BE6B60 /* NodeListFilter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NodeListFilter.swift; sourceTree = ""; }; + DDDCD5712BB3246500BE6B60 /* MeshtasticDataModelV 31.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "MeshtasticDataModelV 31.xcdatamodel"; sourceTree = ""; }; DDDD527729B5B83F0045BC3C /* MeshtasticDataModelV9.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = MeshtasticDataModelV9.xcdatamodel; sourceTree = ""; }; DDDE59F429AF163D00490C6C /* WidgetsExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = WidgetsExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; }; DDDE59F829AF163D00490C6C /* WidgetsBundle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetsBundle.swift; sourceTree = ""; }; @@ -1907,6 +1908,7 @@ DD3CC6BA28E366DF00FA9159 /* Meshtastic.xcdatamodeld */ = { isa = XCVersionGroup; children = ( + DDDCD5712BB3246500BE6B60 /* MeshtasticDataModelV 31.xcdatamodel */, DD9A1A912BA2D2D3001E602E /* MeshtasticDataModelV 30.xcdatamodel */, DD398EBD2B93F640002B4C51 /* MeshtasticDataModelV 29.xcdatamodel */, DD0E20FF2B892E1300F2D100 /* MeshtasticDataModelV 28.xcdatamodel */, @@ -1938,7 +1940,7 @@ DD5D0A9A2931AD6B00F7EA61 /* MeshtasticDataModelV2.xcdatamodel */, DD3CC6BB28E366DF00FA9159 /* MeshtasticDataModel.xcdatamodel */, ); - currentVersion = DD9A1A912BA2D2D3001E602E /* MeshtasticDataModelV 30.xcdatamodel */; + currentVersion = DDDCD5712BB3246500BE6B60 /* MeshtasticDataModelV 31.xcdatamodel */; name = Meshtastic.xcdatamodeld; path = Meshtastic/Meshtastic.xcdatamodeld; sourceTree = ""; diff --git a/Meshtastic/Enums/DeviceEnums.swift b/Meshtastic/Enums/DeviceEnums.swift index 8f2bbc7b..dbbc6dc2 100644 --- a/Meshtastic/Enums/DeviceEnums.swift +++ b/Meshtastic/Enums/DeviceEnums.swift @@ -17,6 +17,7 @@ enum DeviceRoles: Int, CaseIterable, Identifiable { case lostAndFound = 9 case sensor = 6 case tak = 7 + case takTracker = 10 case repeater = 4 case router = 2 case routerClient = 3 @@ -40,11 +41,14 @@ enum DeviceRoles: Int, CaseIterable, Identifiable { return "Sensor" case .tak: return "TAK" + case .takTracker: + return "TAK Tracker" case .clientHidden: return "Client Hidden" case .lostAndFound: return "Lost and Found" } + } var description: String { switch self { @@ -64,6 +68,8 @@ enum DeviceRoles: Int, CaseIterable, Identifiable { return "device.role.sensor".localized case .tak: return "device.role.tak".localized + case .takTracker: + return "device.role.taktracker".localized case .clientHidden: return "device.role.clienthidden".localized case .lostAndFound: @@ -87,6 +93,8 @@ enum DeviceRoles: Int, CaseIterable, Identifiable { return "sensor" case .tak: return "shield.checkered" + case .takTracker: + return "dog" case .clientHidden: return "eye.slash" case .lostAndFound: @@ -112,6 +120,8 @@ enum DeviceRoles: Int, CaseIterable, Identifiable { return Config.DeviceConfig.Role.sensor case .tak: return Config.DeviceConfig.Role.tak + case .takTracker: + return Config.DeviceConfig.Role.takTracker case .clientHidden: return Config.DeviceConfig.Role.clientHidden case .lostAndFound: diff --git a/Meshtastic/Meshtastic.xcdatamodeld/.xccurrentversion b/Meshtastic/Meshtastic.xcdatamodeld/.xccurrentversion index e8a31698..825d8915 100644 --- a/Meshtastic/Meshtastic.xcdatamodeld/.xccurrentversion +++ b/Meshtastic/Meshtastic.xcdatamodeld/.xccurrentversion @@ -3,6 +3,6 @@ _XCCurrentVersionName - MeshtasticDataModelV 30.xcdatamodel + MeshtasticDataModelV 31.xcdatamodel diff --git a/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 31.xcdatamodel/contents b/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 31.xcdatamodel/contents new file mode 100644 index 00000000..72ba98d4 --- /dev/null +++ b/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 31.xcdatamodel/contents @@ -0,0 +1,457 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Meshtastic/Protobufs/meshtastic/admin.pb.swift b/Meshtastic/Protobufs/meshtastic/admin.pb.swift index baa3c742..fa1ac990 100644 --- a/Meshtastic/Protobufs/meshtastic/admin.pb.swift +++ b/Meshtastic/Protobufs/meshtastic/admin.pb.swift @@ -319,6 +319,46 @@ struct AdminMessage { set {payloadVariant = .removeByNodenum(newValue)} } + /// + /// Set specified node-num to be favorited on the NodeDB on the device + var setFavoriteNode: UInt32 { + get { + if case .setFavoriteNode(let v)? = payloadVariant {return v} + return 0 + } + set {payloadVariant = .setFavoriteNode(newValue)} + } + + /// + /// Set specified node-num to be un-favorited on the NodeDB on the device + var removeFavoriteNode: UInt32 { + get { + if case .removeFavoriteNode(let v)? = payloadVariant {return v} + return 0 + } + set {payloadVariant = .removeFavoriteNode(newValue)} + } + + /// + /// Set fixed position data on the node and then set the position.fixed_position = true + var setFixedPosition: Position { + get { + if case .setFixedPosition(let v)? = payloadVariant {return v} + return Position() + } + set {payloadVariant = .setFixedPosition(newValue)} + } + + /// + /// Clear fixed position coordinates and then set position.fixed_position = false + var removeFixedPosition: Bool { + get { + if case .removeFixedPosition(let v)? = payloadVariant {return v} + return false + } + set {payloadVariant = .removeFixedPosition(newValue)} + } + /// /// Begins an edit transaction for config, module config, owner, and channel settings changes /// This will delay the standard *implicit* save to the file system and subsequent reboot behavior until committed (commit_edit_settings) @@ -498,6 +538,18 @@ struct AdminMessage { /// Remove the node by the specified node-num from the NodeDB on the device case removeByNodenum(UInt32) /// + /// Set specified node-num to be favorited on the NodeDB on the device + case setFavoriteNode(UInt32) + /// + /// Set specified node-num to be un-favorited on the NodeDB on the device + case removeFavoriteNode(UInt32) + /// + /// Set fixed position data on the node and then set the position.fixed_position = true + case setFixedPosition(Position) + /// + /// Clear fixed position coordinates and then set position.fixed_position = false + case removeFixedPosition(Bool) + /// /// Begins an edit transaction for config, module config, owner, and channel settings changes /// This will delay the standard *implicit* save to the file system and subsequent reboot behavior until committed (commit_edit_settings) case beginEditSettings(Bool) @@ -643,6 +695,22 @@ struct AdminMessage { guard case .removeByNodenum(let l) = lhs, case .removeByNodenum(let r) = rhs else { preconditionFailure() } return l == r }() + case (.setFavoriteNode, .setFavoriteNode): return { + guard case .setFavoriteNode(let l) = lhs, case .setFavoriteNode(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.removeFavoriteNode, .removeFavoriteNode): return { + guard case .removeFavoriteNode(let l) = lhs, case .removeFavoriteNode(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.setFixedPosition, .setFixedPosition): return { + guard case .setFixedPosition(let l) = lhs, case .setFixedPosition(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.removeFixedPosition, .removeFixedPosition): return { + guard case .removeFixedPosition(let l) = lhs, case .removeFixedPosition(let r) = rhs else { preconditionFailure() } + return l == r + }() case (.beginEditSettings, .beginEditSettings): return { guard case .beginEditSettings(let l) = lhs, case .beginEditSettings(let r) = rhs else { preconditionFailure() } return l == r @@ -978,6 +1046,10 @@ extension AdminMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat 36: .standard(proto: "set_canned_message_module_messages"), 37: .standard(proto: "set_ringtone_message"), 38: .standard(proto: "remove_by_nodenum"), + 39: .standard(proto: "set_favorite_node"), + 40: .standard(proto: "remove_favorite_node"), + 41: .standard(proto: "set_fixed_position"), + 42: .standard(proto: "remove_fixed_position"), 64: .standard(proto: "begin_edit_settings"), 65: .standard(proto: "commit_edit_settings"), 95: .standard(proto: "reboot_ota_seconds"), @@ -1278,6 +1350,43 @@ extension AdminMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat self.payloadVariant = .removeByNodenum(v) } }() + case 39: try { + var v: UInt32? + try decoder.decodeSingularUInt32Field(value: &v) + if let v = v { + if self.payloadVariant != nil {try decoder.handleConflictingOneOf()} + self.payloadVariant = .setFavoriteNode(v) + } + }() + case 40: try { + var v: UInt32? + try decoder.decodeSingularUInt32Field(value: &v) + if let v = v { + if self.payloadVariant != nil {try decoder.handleConflictingOneOf()} + self.payloadVariant = .removeFavoriteNode(v) + } + }() + case 41: try { + var v: Position? + var hadOneofValue = false + if let current = self.payloadVariant { + hadOneofValue = true + if case .setFixedPosition(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payloadVariant = .setFixedPosition(v) + } + }() + case 42: try { + var v: Bool? + try decoder.decodeSingularBoolField(value: &v) + if let v = v { + if self.payloadVariant != nil {try decoder.handleConflictingOneOf()} + self.payloadVariant = .removeFixedPosition(v) + } + }() case 64: try { var v: Bool? try decoder.decodeSingularBoolField(value: &v) @@ -1465,6 +1574,22 @@ extension AdminMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat guard case .removeByNodenum(let v)? = self.payloadVariant else { preconditionFailure() } try visitor.visitSingularUInt32Field(value: v, fieldNumber: 38) }() + case .setFavoriteNode?: try { + guard case .setFavoriteNode(let v)? = self.payloadVariant else { preconditionFailure() } + try visitor.visitSingularUInt32Field(value: v, fieldNumber: 39) + }() + case .removeFavoriteNode?: try { + guard case .removeFavoriteNode(let v)? = self.payloadVariant else { preconditionFailure() } + try visitor.visitSingularUInt32Field(value: v, fieldNumber: 40) + }() + case .setFixedPosition?: try { + guard case .setFixedPosition(let v)? = self.payloadVariant else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 41) + }() + case .removeFixedPosition?: try { + guard case .removeFixedPosition(let v)? = self.payloadVariant else { preconditionFailure() } + try visitor.visitSingularBoolField(value: v, fieldNumber: 42) + }() case .beginEditSettings?: try { guard case .beginEditSettings(let v)? = self.payloadVariant else { preconditionFailure() } try visitor.visitSingularBoolField(value: v, fieldNumber: 64) diff --git a/Meshtastic/Protobufs/meshtastic/deviceonly.pb.swift b/Meshtastic/Protobufs/meshtastic/deviceonly.pb.swift index f25a5cd1..3080ae9f 100644 --- a/Meshtastic/Protobufs/meshtastic/deviceonly.pb.swift +++ b/Meshtastic/Protobufs/meshtastic/deviceonly.pb.swift @@ -405,35 +405,6 @@ struct OEMStore { fileprivate var _oemLocalModuleConfig: LocalModuleConfig? = nil } -/// -/// RemoteHardwarePins associated with a node -struct NodeRemoteHardwarePin { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// - /// The node_num exposing the available gpio pin - var nodeNum: UInt32 = 0 - - /// - /// The the available gpio pin for usage with RemoteHardware module - var pin: RemoteHardwarePin { - get {return _pin ?? RemoteHardwarePin()} - set {_pin = newValue} - } - /// Returns true if `pin` has been explicitly set. - var hasPin: Bool {return self._pin != nil} - /// Clears the value of `pin`. Subsequent reads from it will return its default value. - mutating func clearPin() {self._pin = nil} - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} - - fileprivate var _pin: RemoteHardwarePin? = nil -} - #if swift(>=5.5) && canImport(_Concurrency) extension ScreenFonts: @unchecked Sendable {} extension DeviceState: @unchecked Sendable {} @@ -441,7 +412,6 @@ extension NodeInfoLite: @unchecked Sendable {} extension PositionLite: @unchecked Sendable {} extension ChannelFile: @unchecked Sendable {} extension OEMStore: @unchecked Sendable {} -extension NodeRemoteHardwarePin: @unchecked Sendable {} #endif // swift(>=5.5) && canImport(_Concurrency) // MARK: - Code below here is support for the SwiftProtobuf runtime. @@ -907,45 +877,3 @@ extension OEMStore: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationB return true } } - -extension NodeRemoteHardwarePin: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".NodeRemoteHardwarePin" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "node_num"), - 2: .same(proto: "pin"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularUInt32Field(value: &self.nodeNum) }() - case 2: try { try decoder.decodeSingularMessageField(value: &self._pin) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - if self.nodeNum != 0 { - try visitor.visitSingularUInt32Field(value: self.nodeNum, fieldNumber: 1) - } - try { if let v = self._pin { - try visitor.visitSingularMessageField(value: v, fieldNumber: 2) - } }() - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: NodeRemoteHardwarePin, rhs: NodeRemoteHardwarePin) -> Bool { - if lhs.nodeNum != rhs.nodeNum {return false} - if lhs._pin != rhs._pin {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} diff --git a/Meshtastic/Protobufs/meshtastic/mesh.pb.swift b/Meshtastic/Protobufs/meshtastic/mesh.pb.swift index 18da455b..1ae038f4 100644 --- a/Meshtastic/Protobufs/meshtastic/mesh.pb.swift +++ b/Meshtastic/Protobufs/meshtastic/mesh.pb.swift @@ -2619,6 +2619,35 @@ struct Heartbeat { init() {} } +/// +/// RemoteHardwarePins associated with a node +struct NodeRemoteHardwarePin { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// + /// The node_num exposing the available gpio pin + var nodeNum: UInt32 = 0 + + /// + /// The the available gpio pin for usage with RemoteHardware module + var pin: RemoteHardwarePin { + get {return _pin ?? RemoteHardwarePin()} + set {_pin = newValue} + } + /// Returns true if `pin` has been explicitly set. + var hasPin: Bool {return self._pin != nil} + /// Clears the value of `pin`. Subsequent reads from it will return its default value. + mutating func clearPin() {self._pin = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _pin: RemoteHardwarePin? = nil +} + #if swift(>=5.5) && canImport(_Concurrency) extension HardwareModel: @unchecked Sendable {} extension Constants: @unchecked Sendable {} @@ -2653,6 +2682,7 @@ extension NeighborInfo: @unchecked Sendable {} extension Neighbor: @unchecked Sendable {} extension DeviceMetadata: @unchecked Sendable {} extension Heartbeat: @unchecked Sendable {} +extension NodeRemoteHardwarePin: @unchecked Sendable {} #endif // swift(>=5.5) && canImport(_Concurrency) // MARK: - Code below here is support for the SwiftProtobuf runtime. @@ -4611,3 +4641,45 @@ extension Heartbeat: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementation return true } } + +extension NodeRemoteHardwarePin: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".NodeRemoteHardwarePin" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "node_num"), + 2: .same(proto: "pin"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularUInt32Field(value: &self.nodeNum) }() + case 2: try { try decoder.decodeSingularMessageField(value: &self._pin) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + if self.nodeNum != 0 { + try visitor.visitSingularUInt32Field(value: self.nodeNum, fieldNumber: 1) + } + try { if let v = self._pin { + try visitor.visitSingularMessageField(value: v, fieldNumber: 2) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: NodeRemoteHardwarePin, rhs: NodeRemoteHardwarePin) -> Bool { + if lhs.nodeNum != rhs.nodeNum {return false} + if lhs._pin != rhs._pin {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/protobufs b/protobufs index bcfb49c4..dea3a82e 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit bcfb49c4988b1539fc35e568a58b9f2f5b60738a +Subproject commit dea3a82ef2accd25112b4ef1c6f8991b579740f4 From 08a936f7e1f321bc4e2ba52b035df032f3e5e6e0 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Tue, 26 Mar 2024 09:13:15 -0700 Subject: [PATCH 58/74] Filter by client role too --- .../MeshtasticDataModelV 31.xcdatamodel/contents | 2 ++ Meshtastic/Views/Nodes/NodeList.swift | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 31.xcdatamodel/contents b/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 31.xcdatamodel/contents index 72ba98d4..9852b36b 100644 --- a/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 31.xcdatamodel/contents +++ b/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 31.xcdatamodel/contents @@ -189,6 +189,7 @@ + @@ -230,6 +231,7 @@ + diff --git a/Meshtastic/Views/Nodes/NodeList.swift b/Meshtastic/Views/Nodes/NodeList.swift index 4efad7a4..a06aa681 100644 --- a/Meshtastic/Views/Nodes/NodeList.swift +++ b/Meshtastic/Views/Nodes/NodeList.swift @@ -280,7 +280,7 @@ struct NodeList: View { } } /// Role - if deviceRole > 0 { + if deviceRole > -1 { let rolePredicate = NSPredicate(format: "user.role == %i", Int32(deviceRole)) predicates.append(rolePredicate) } From e42b1ae500794a21a4edf4d9dfd8f03856775564 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Tue, 26 Mar 2024 09:21:47 -0700 Subject: [PATCH 59/74] force slelection of at least one option in the lora / mqtt filters --- Meshtastic/Views/Nodes/NodeList.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Meshtastic/Views/Nodes/NodeList.swift b/Meshtastic/Views/Nodes/NodeList.swift index a06aa681..0ab993c7 100644 --- a/Meshtastic/Views/Nodes/NodeList.swift +++ b/Meshtastic/Views/Nodes/NodeList.swift @@ -242,9 +242,15 @@ struct NodeList: View { searchNodeList() } .onChange(of: viaLora) { _ in + if !viaLora && !viaMqtt { + viaMqtt = true + } searchNodeList() } .onChange(of: viaMqtt) { _ in + if !viaLora && !viaMqtt { + viaLora = true + } searchNodeList() } .onChange(of: deviceRole) { _ in From 457116657afc2fd2aa2b1e6a3e6265b19e934361 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Tue, 26 Mar 2024 09:59:07 -0700 Subject: [PATCH 60/74] Save favorite and hops away --- Meshtastic/Helpers/MeshPackets.swift | 4 ++++ Meshtastic/Persistence/UpdateCoreData.swift | 3 +++ de.lproj/Localizable.strings | 4 ++++ en.lproj/Localizable.strings | 1 + fr.lproj/Localizable.strings | 1 + he.lproj/Localizable.strings | 1 + pl.lproj/Localizable.strings | 4 ++++ zh-Hans.lproj/Localizable.strings | 4 ++++ zh-Hant-TW.lproj/Localizable.strings | 3 +++ 9 files changed, 25 insertions(+) diff --git a/Meshtastic/Helpers/MeshPackets.swift b/Meshtastic/Helpers/MeshPackets.swift index f05bb3cd..a408af14 100644 --- a/Meshtastic/Helpers/MeshPackets.swift +++ b/Meshtastic/Helpers/MeshPackets.swift @@ -263,6 +263,8 @@ func nodeInfoPacket (nodeInfo: NodeInfo, channel: UInt32, context: NSManagedObje newNode.id = Int64(nodeInfo.num) newNode.num = Int64(nodeInfo.num) newNode.channel = Int32(nodeInfo.channel) + newNode.favorite = nodeInfo.isFavorite + newNode.hopsAway = Int32(nodeInfo.hopsAway) if nodeInfo.hasDeviceMetrics { let telemetry = TelemetryEntity(context: context) @@ -346,6 +348,8 @@ func nodeInfoPacket (nodeInfo: NodeInfo, channel: UInt32, context: NSManagedObje fetchedNode[0].lastHeard = Date(timeIntervalSince1970: TimeInterval(Int64(nodeInfo.lastHeard))) fetchedNode[0].snr = nodeInfo.snr fetchedNode[0].channel = Int32(nodeInfo.channel) + fetchedNode[0].favorite = nodeInfo.isFavorite + fetchedNode[0].hopsAway = Int32(nodeInfo.hopsAway) if nodeInfo.hasUser { if (fetchedNode[0].user == nil) { diff --git a/Meshtastic/Persistence/UpdateCoreData.swift b/Meshtastic/Persistence/UpdateCoreData.swift index 98561c0d..41920890 100644 --- a/Meshtastic/Persistence/UpdateCoreData.swift +++ b/Meshtastic/Persistence/UpdateCoreData.swift @@ -144,11 +144,13 @@ func upsertNodeInfoPacket (packet: MeshPacket, context: NSManagedObjectContext) newNode.snr = packet.rxSnr newNode.rssi = packet.rxRssi newNode.viaMqtt = packet.viaMqtt + if packet.to == 4294967295 || packet.to == UserDefaults.preferredPeripheralNum { newNode.channel = Int32(packet.channel) } if let nodeInfoMessage = try? NodeInfo(serializedData: packet.decoded.payload) { newNode.hopsAway = Int32(nodeInfoMessage.hopsAway) + newNode.favorite = nodeInfoMessage.isFavorite } else if packet.hopStart != 0 && packet.hopLimit <= packet.hopStart { newNode.hopsAway = Int32(packet.hopStart - packet.hopLimit) } @@ -222,6 +224,7 @@ func upsertNodeInfoPacket (packet: MeshPacket, context: NSManagedObjectContext) if let nodeInfoMessage = try? NodeInfo(serializedData: packet.decoded.payload) { fetchedNode[0].hopsAway = Int32(nodeInfoMessage.hopsAway) + fetchedNode[0].favorite = nodeInfoMessage.isFavorite if nodeInfoMessage.hasDeviceMetrics { let telemetry = TelemetryEntity(context: context) telemetry.batteryLevel = Int32(nodeInfoMessage.deviceMetrics.batteryLevel) diff --git a/de.lproj/Localizable.strings b/de.lproj/Localizable.strings index 2599d7b2..c3d3d0fc 100644 --- a/de.lproj/Localizable.strings +++ b/de.lproj/Localizable.strings @@ -98,6 +98,10 @@ "device.role.routerclient"="Router Client - Mesh Pakete werden bevorzugt über diesen Node gerouted. Der Router Client kann parallel auch von einer Client-App genutzt werden."; "device.role.repeater"="Repeater - Mesh packets will prefer to be routed over this node. This role eliminates unnecessary overhead such as NodeInfo, DeviceTelemetry, and any other mesh packet, resulting in the device not appearing as part of the network. Please see Rebroadcast Mode for additional settings specific to this role."; "device.role.tracker"="Tracker - For use with devices intended as a GPS tracker. Position packets sent from this device will be higher priority, with position broadcasting every two minutes. Smart Position Broadcast will default to off."; +"device.role.lostandfound"="Broadcasts location as message to default channel regularly for to assist with device recovery."; +"device.role.sensor"="Broadcasts telemetry packets as priority."; +"device.role.tak"="Optimized for ATAK system communication, reduces routine broadcasts."; +"device.role.taktracker"="Enables automatic TAK PLI broadcasts and reduces routine broadcasts."; "direct.messages"="Direktnachrichten"; "dismiss.keyboard"="Dismiss Keyboard"; "display"="Display (Device Screen)"; diff --git a/en.lproj/Localizable.strings b/en.lproj/Localizable.strings index 251e1b0d..e0d113b8 100644 --- a/en.lproj/Localizable.strings +++ b/en.lproj/Localizable.strings @@ -99,6 +99,7 @@ "device.role.lostandfound"="Broadcasts location as message to default channel regularly for to assist with device recovery."; "device.role.sensor"="Broadcasts telemetry packets as priority."; "device.role.tak"="Optimized for ATAK system communication, reduces routine broadcasts."; +"device.role.taktracker"="Enables automatic TAK PLI broadcasts and reduces routine broadcasts."; "device.role.repeater"="Infrastructure node for extending network coverage by relaying messages with minimal overhead. Not visible in Nodes list."; "device.role.router"="Infrastructure node for extending network coverage by relaying messages. Visible in Nodes list."; "device.role.routerclient"="Combination of both ROUTER and CLIENT. Not for mobile devices."; diff --git a/fr.lproj/Localizable.strings b/fr.lproj/Localizable.strings index 31642beb..b41a35a4 100644 --- a/fr.lproj/Localizable.strings +++ b/fr.lproj/Localizable.strings @@ -76,6 +76,7 @@ "device.role.lostandfound"="Transmet régulièrement la position par message dans le canal par défaut pour vous aider à retrouver l'appareil."; "device.role.sensor"="Transmet les paquets de télémétrie en priorité."; "device.role.tak"="Optimisé pour le système de communication ATAK, diminue les émissions de routine."; +"device.role.taktracker"="Enables automatic TAK PLI broadcasts and reduces routine broadcasts."; "device.role.repeater"="Noeud d'infrastructure qui étend la couverture du réseau en relayant les messages avec un minimum de surcharge. Invisible dans la liste des noeuds."; "device.role.router"="Noeud d'infrastructure qui étend la couverture du réseau en relayant les messages. Visible dans la liste des noeuds."; "device.role.routerclient"="Combinaison des modes ROUTER et CLIENT. Pas pour les appareils mobiles."; diff --git a/he.lproj/Localizable.strings b/he.lproj/Localizable.strings index 22e5a2df..e9dc8ce1 100644 --- a/he.lproj/Localizable.strings +++ b/he.lproj/Localizable.strings @@ -99,6 +99,7 @@ "device.role.lostandfound"="משדר מיקום כהודעה לערוץ ברירת מחדל לעיתים קבועות בכדי לסייע במציאת המכשיר."; "device.role.sensor"="משדר טלמטריה בעדיפות גבוהה."; "device.role.tak"="מותאם למערכת ATAK, מקטין תקשורת קבועה."; +"device.role.taktracker"="Enables automatic TAK PLI broadcasts and reduces routine broadcasts."; "device.role.repeater"="מכשיר תשתית להרחבת המש על ידי העברת הודעות עם דאטה נוסף מינימלי."; "device.role.router"="מכשיר תשתית להרחבת המש על ידי העברת הודעות. מופיע ברשימת מכשירים."; "device.role.routerclient"="קומבינציה של ROUTER וCLIENT. לא למכשירים ניידים."; diff --git a/pl.lproj/Localizable.strings b/pl.lproj/Localizable.strings index 2c5aa853..5e194834 100644 --- a/pl.lproj/Localizable.strings +++ b/pl.lproj/Localizable.strings @@ -100,6 +100,10 @@ "device.role.routerclient"="Router Client - Hybryda ról klienta i routera. Podobnie jak w przypadku routera, z tym że Router Client może być używany zarówno jako router, jak i klient połączony z aplikacją. Radia BLE/Wi-Fi i ekran OLED nie zostaną uśpione."; "device.role.repeater"="Przekaźnik - Pakiety siatki będą preferować trasowanie przez ten węzeł. Ta rola eliminuje niepotrzebny nadmiar, taki jak NodeInfo, DeviceTelemetry i inne pakiety siatki, skutkując tym, że urządzenie nie będzie widoczne jako część sieci. Proszę zobaczyć tryb Rebroadcast dla dodatkowych ustawień specyficznych dla tej roli."; "device.role.tracker"="Tracker - Do użytku z urządzeniami przeznaczonymi jako śledzenie GPS. Pakiety pozycyjne wysyłane z tego urządzenia będą miały wyższy priorytet, z nadawaniem pozycji co dwie minuty. Inteligentna transmisja pozycji będzie domyślnie wyłączona."; +"device.role.lostandfound"="Broadcasts location as message to default channel regularly for to assist with device recovery."; +"device.role.sensor"="Broadcasts telemetry packets as priority."; +"device.role.tak"="Optimized for ATAK system communication, reduces routine broadcasts."; +"device.role.taktracker"="Enables automatic TAK PLI broadcasts and reduces routine broadcasts."; "direct.messages"="Bezpośrednie Wiadomości"; "dismiss.keyboard"="Zamknij"; "display"="Wyświetlacz (Ekran Urządzenia)"; diff --git a/zh-Hans.lproj/Localizable.strings b/zh-Hans.lproj/Localizable.strings index 6c8f6b0a..d4521ef2 100644 --- a/zh-Hans.lproj/Localizable.strings +++ b/zh-Hans.lproj/Localizable.strings @@ -98,6 +98,10 @@ "device.role.routerclient"="路由客户端模式 - 优先转发 Mesh 网络中其他节点的消息,App 也可以连接到电台进行收发操作。"; "device.role.repeater"="中继模式 - Mesh 网络数据包将优先通过此节点路由。此模式可消除不必要的开销,如 NodeInfo、DeviceTelemetry 和任何其他 Mesh 数据包,从而使设备不显示为 Mesh 网络的一部分。有关此角色的其他特定设置,请参阅转播模式。"; "device.role.tracker"="定位模式 - 用于作为 GPS 跟踪器。从该设备发送的定位数据包优先级较高,每两分钟广播一次。智能位置广播默认为关闭。"; +"device.role.lostandfound"="Broadcasts location as message to default channel regularly for to assist with device recovery."; +"device.role.sensor"="Broadcasts telemetry packets as priority."; +"device.role.tak"="Optimized for ATAK system communication, reduces routine broadcasts."; +"device.role.taktracker"="Enables automatic TAK PLI broadcasts and reduces routine broadcasts."; "direct.messages"="直频消息"; "dismiss.keyboard"="隐藏键盘"; "display"="屏幕(电台屏幕)"; diff --git a/zh-Hant-TW.lproj/Localizable.strings b/zh-Hant-TW.lproj/Localizable.strings index d0f8e876..8bef85fd 100644 --- a/zh-Hant-TW.lproj/Localizable.strings +++ b/zh-Hant-TW.lproj/Localizable.strings @@ -98,6 +98,9 @@ "device.role.routerclient"="路由客户端模式 - 優先轉發 Mesh 網路中其他中繼點的消息,App 也可以連接到電台進行收發操作。"; "device.role.repeater"="中繼模式 - Mesh 網路數據包將優先通過此中繼點路由。此模式可消除不必要的開銷,如 NodeInfo、DeviceTelemetry 和任何其他 Mesh 數據包,從而使設備不顯示為 Mesh 網路的一部分。有關此角色的其他特定設置,請參閱轉播模式。"; "device.role.tracker"="追蹤模式 - 用於作為 GPS 追蹤器。從該設備發送的定位數據包優先級較高,每兩分鐘廣播一次。智能位置廣播預設為關閉。"; +"device.role.sensor"="Broadcasts telemetry packets as priority."; +"device.role.tak"="Optimized for ATAK system communication, reduces routine broadcasts."; +"device.role.taktracker"="Enables automatic TAK PLI broadcasts and reduces routine broadcasts."; "direct.messages"="聊天"; "dismiss.keyboard"="隱藏鍵盤"; "display"="螢幕(電台螢幕)"; From 5cd2b3342b330aae8f9ad71b8331a0390befaa61 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Tue, 26 Mar 2024 13:26:23 -0700 Subject: [PATCH 61/74] Mqtt config updates --- .../contents | 2 + Meshtastic/Persistence/UpdateCoreData.swift | 6 + .../Settings/Config/Module/MQTTConfig.swift | 200 ++++++++++++------ 3 files changed, 147 insertions(+), 61 deletions(-) diff --git a/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 31.xcdatamodel/contents b/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 31.xcdatamodel/contents index 9852b36b..16c3d91a 100644 --- a/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 31.xcdatamodel/contents +++ b/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 31.xcdatamodel/contents @@ -189,6 +189,8 @@ + + diff --git a/Meshtastic/Persistence/UpdateCoreData.swift b/Meshtastic/Persistence/UpdateCoreData.swift index 41920890..f2933922 100644 --- a/Meshtastic/Persistence/UpdateCoreData.swift +++ b/Meshtastic/Persistence/UpdateCoreData.swift @@ -1119,6 +1119,9 @@ func upsertMqttModuleConfigPacket(config: Meshtastic.ModuleConfig.MQTTConfig, no newMQTTConfig.encryptionEnabled = config.encryptionEnabled newMQTTConfig.jsonEnabled = config.jsonEnabled newMQTTConfig.tlsEnabled = config.tlsEnabled + newMQTTConfig.mapReportingEnabled = config.mapReportingEnabled + newMQTTConfig.mapPositionPrecision = Int32(config.mapReportSettings.positionPrecision) + newMQTTConfig.mapPublishIntervalSecs = Int32(config.mapReportSettings.publishIntervalSecs) fetchedNode[0].mqttConfig = newMQTTConfig } else { fetchedNode[0].mqttConfig?.enabled = config.enabled @@ -1130,6 +1133,9 @@ func upsertMqttModuleConfigPacket(config: Meshtastic.ModuleConfig.MQTTConfig, no fetchedNode[0].mqttConfig?.encryptionEnabled = config.encryptionEnabled fetchedNode[0].mqttConfig?.jsonEnabled = config.jsonEnabled fetchedNode[0].mqttConfig?.tlsEnabled = config.tlsEnabled + fetchedNode[0].mqttConfig?.mapReportingEnabled = config.mapReportingEnabled + fetchedNode[0].mqttConfig?.mapPositionPrecision = Int32(config.mapReportSettings.positionPrecision) + fetchedNode[0].mqttConfig?.mapPublishIntervalSecs = Int32(config.mapReportSettings.publishIntervalSecs) } do { try context.save() diff --git a/Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift b/Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift index 8191aec9..10563eb3 100644 --- a/Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift +++ b/Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift @@ -28,6 +28,12 @@ struct MQTTConfig: View { @State var mqttConnected: Bool = false @State var defaultTopic = "msh/US" @State var nearbyTopics = [String]() + @State var mapReportingEnabled = false + @State var mapPublishIntervalSecs = 3600 + @State var preciseLocation: Bool = false + @State var mapPositionPrecision: Double = 13.0 + + let locale = Locale.current var body: some View { @@ -58,7 +64,7 @@ struct MQTTConfig: View { } .toggleStyle(SwitchToggleStyle(tint: .accentColor)) - if enabled && proxyToClientEnabled { + if enabled && proxyToClientEnabled && node!.mqttConfig!.proxyToClientEnabled == true { Toggle(isOn: $mqttConnected) { Label(mqttConnected ? "mqtt.disconnect".localized : "mqtt.connect".localized, systemImage: "server.rack") } @@ -75,14 +81,95 @@ struct MQTTConfig: View { Text("JSON mode is a limited, unencrypted MQTT output for locally integrating with home assistant") } .toggleStyle(SwitchToggleStyle(tint: .accentColor)) + } + + Section(header: Text("Map Report")) { - Toggle(isOn: $tlsEnabled) { - Label("TLS Enabled", systemImage: "checkmark.shield.fill") - Text("Your MQTT Server must support TLS.") + Toggle(isOn: $mapReportingEnabled) { + Label("enabled", systemImage: "map") } .toggleStyle(SwitchToggleStyle(tint: .accentColor)) - + if mapReportingEnabled { + Picker("Map Publish Interval", selection: $mapPublishIntervalSecs ) { + ForEach(UpdateIntervals.allCases) { ui in + if ui.rawValue >= 3600 { + Text(ui.description) + } + } + } + .pickerStyle(DefaultPickerStyle()) + + VStack(alignment: .leading) { + Toggle(isOn: $preciseLocation) { + Label("Precise Location", systemImage: "scope") + } + .toggleStyle(SwitchToggleStyle(tint: .accentColor)) + .listRowSeparator(.visible) + .onChange(of: preciseLocation) { pl in + if pl == false { + mapPositionPrecision = 12 + } else { + mapPositionPrecision = 32 + } + } + } + + if !preciseLocation { + VStack(alignment: .leading) { + Label("Approximate Location", systemImage: "location.slash.circle.fill") + Slider(value: $mapPositionPrecision, in: 11...16, step: 1) { + } minimumValueLabel: { + Image(systemName: "minus") + } maximumValueLabel: { + Image(systemName: "plus") + } + Text(PositionPrecision(rawValue: Int(mapPositionPrecision))?.description ?? "") + .foregroundColor(.gray) + .font(.callout) + } + } + } } + Section(header: Text("Root Topic")) { + HStack { + Label("Root Topic", systemImage: "tree") + TextField("Root Topic", text: $root) + .foregroundColor(.gray) + .onChange(of: root, perform: { _ in + let totalBytes = root.utf8.count + // Only mess with the value if it is too big + if totalBytes > 30 { + let firstNBytes = Data(root.utf8.prefix(30)) + if let maxBytesString = String(data: firstNBytes, encoding: String.Encoding.utf8) { + // Set the shortName back to the last place where it was the right size + root = maxBytesString + } + } + }) + .foregroundColor(.gray) + } + .keyboardType(.asciiCapable) + .scrollDismissesKeyboard(.interactively) + .disableAutocorrection(true) + .listRowSeparator(.hidden) + Text("The root topic to use for MQTT.") + .foregroundColor(.gray) + .font(.callout) + + if nearbyTopics.count > 0 { + Picker("Nearby Topics", selection: $selectedTopic ) { + ForEach(nearbyTopics, id: \.self) { nt in + Text(nt) + } + } + .pickerStyle(InlinePickerStyle()) + .listRowSeparator(.hidden) + Text("If the default region topic is too busy you can choose a more local topic.") + .foregroundColor(.gray) + .font(.callout) + } + } + Section(header: Text("Server")) { HStack { Label("Address", systemImage: "server.rack") @@ -161,45 +248,13 @@ struct MQTTConfig: View { .keyboardType(.default) .scrollDismissesKeyboard(.interactively) .listRowSeparator(/*@START_MENU_TOKEN@*/.visible/*@END_MENU_TOKEN@*/) - HStack { - Label("Root Topic", systemImage: "tree") - TextField("Root Topic", text: $root) - .foregroundColor(.gray) - .onChange(of: root, perform: { _ in - let totalBytes = root.utf8.count - // Only mess with the value if it is too big - if totalBytes > 30 { - let firstNBytes = Data(root.utf8.prefix(30)) - if let maxBytesString = String(data: firstNBytes, encoding: String.Encoding.utf8) { - // Set the shortName back to the last place where it was the right size - root = maxBytesString - } - } - }) - .foregroundColor(.gray) - } - .keyboardType(.asciiCapable) - .scrollDismissesKeyboard(.interactively) - .disableAutocorrection(true) - .listRowSeparator(.hidden) - Text("The root topic to use for MQTT.") - .foregroundColor(.gray) - .font(.callout) - - if nearbyTopics.count > 0 { - Picker("Nearby Topics", selection: $selectedTopic ) { - ForEach(nearbyTopics, id: \.self) { nt in - Text(nt) - } - } - .pickerStyle(InlinePickerStyle()) - .listRowSeparator(.hidden) - Text("If the default region topic is too busy you can choose a more local topic.") - .foregroundColor(.gray) - .font(.callout) + Toggle(isOn: $tlsEnabled) { + Label("TLS Enabled", systemImage: "checkmark.shield.fill") + Text("Your MQTT Server must support TLS.") } + .toggleStyle(SwitchToggleStyle(tint: .accentColor)) } - Text("You can set uplink and downlink for each channel.") + Text("For all Mqtt functionality other than the map report you must also set uplink and downlink for each channel you want to brige over Mqtt.") .font(.callout) } .scrollDismissesKeyboard(.interactively) @@ -219,6 +274,9 @@ struct MQTTConfig: View { mqtt.encryptionEnabled = self.encryptionEnabled mqtt.jsonEnabled = self.jsonEnabled mqtt.tlsEnabled = self.tlsEnabled + mqtt.mapReportingEnabled = self.mapReportingEnabled + mqtt.mapReportSettings.positionPrecision = UInt32(self.mapPositionPrecision) + mqtt.mapReportSettings.publishIntervalSecs = UInt32(self.mapPublishIntervalSecs) let adminMessageId = bleManager.saveMQTTConfig(config: mqtt, fromUser: connectedNode!.user!, toUser: node!.user!, adminIndex: connectedNode?.myInfo?.adminIndex ?? 0) if adminMessageId > 0 { // Should show a saved successfully alert once I know that to be true @@ -233,20 +291,6 @@ struct MQTTConfig: View { ZStack { ConnectedDevice(bluetoothOn: bleManager.isSwitchedOn, deviceConnected: bleManager.connectedPeripheral != nil, name: (bleManager.connectedPeripheral != nil) ? bleManager.connectedPeripheral.shortName : "?", mqttProxyConnected: bleManager.mqttProxyConnected) }) - .onAppear { - if self.bleManager.context == nil { - self.bleManager.context = context - } - setMqttValues() - // Need to request a TelemetryModuleConfig from the remote node before allowing changes - if bleManager.connectedPeripheral != nil && node?.mqttConfig == nil { - print("empty mqtt module config") - let connectedNode = getNodeInfo(id: bleManager.connectedPeripheral.num, context: context) - if node != nil && connectedNode != nil { - _ = bleManager.requestMqttModuleConfig(fromUser: connectedNode!.user!, toUser: node!.user!, adminIndex: connectedNode?.myInfo?.adminIndex ?? 0) - } - } - } .onChange(of: address) { newAddress in if node != nil && node?.mqttConfig != nil { if newAddress != node!.mqttConfig!.address { hasChanges = true } @@ -315,6 +359,33 @@ struct MQTTConfig: View { } } } + .onChange(of: mapReportingEnabled) { newMapReportingEnabled in + if node != nil && node?.mqttConfig != nil { + if newMapReportingEnabled != node!.mqttConfig!.mapReportingEnabled { hasChanges = true } + } + } + .onChange(of: preciseLocation) { _ in + hasChanges = true + } + .onChange(of: mapPublishIntervalSecs) { newMapPublishIntervalSecs in + if node != nil && node?.mqttConfig != nil { + if newMapPublishIntervalSecs != node!.mqttConfig!.mapPublishIntervalSecs { hasChanges = true } + } + } + .onAppear { + if self.bleManager.context == nil { + self.bleManager.context = context + } + setMqttValues() + // Need to request a TelemetryModuleConfig from the remote node before allowing changes + if bleManager.connectedPeripheral != nil && node?.mqttConfig == nil { + print("empty mqtt module config") + let connectedNode = getNodeInfo(id: bleManager.connectedPeripheral.num, context: context) + if node != nil && connectedNode != nil { + _ = bleManager.requestMqttModuleConfig(fromUser: connectedNode!.user!, toUser: node!.user!, adminIndex: connectedNode?.myInfo?.adminIndex ?? 0) + } + } + } } func setMqttValues() { @@ -367,16 +438,23 @@ struct MQTTConfig: View { }) } } - self.enabled = (node?.mqttConfig?.enabled ?? false) - self.proxyToClientEnabled = (node?.mqttConfig?.proxyToClientEnabled ?? false) + self.enabled = node?.mqttConfig?.enabled ?? false + self.proxyToClientEnabled = node?.mqttConfig?.proxyToClientEnabled ?? false self.address = node?.mqttConfig?.address ?? "" self.username = node?.mqttConfig?.username ?? "" self.password = node?.mqttConfig?.password ?? "" self.root = node?.mqttConfig?.root ?? "msh" - self.encryptionEnabled = (node?.mqttConfig?.encryptionEnabled ?? false) - self.jsonEnabled = (node?.mqttConfig?.jsonEnabled ?? false) - self.tlsEnabled = (node?.mqttConfig?.tlsEnabled ?? false) + self.encryptionEnabled = node?.mqttConfig?.encryptionEnabled ?? false + self.jsonEnabled = node?.mqttConfig?.jsonEnabled ?? false + self.tlsEnabled = node?.mqttConfig?.tlsEnabled ?? false self.mqttConnected = bleManager.mqttProxyConnected + self.mapReportingEnabled = node?.mqttConfig?.mapReportingEnabled ?? false + self.mapPublishIntervalSecs = Int(node?.mqttConfig?.mapPublishIntervalSecs ?? 3600) + self.mapPositionPrecision = Double(node?.mqttConfig?.mapPositionPrecision ?? 12) + if mapPositionPrecision == 0.0 { + self.mapPositionPrecision = 12 + } + self.preciseLocation = mapPositionPrecision == 32 self.hasChanges = false } } From 35c943aa68b1be10ff6fbbc0410983c8a44ae0ca Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Tue, 26 Mar 2024 14:01:59 -0700 Subject: [PATCH 62/74] Fix text search not running if there was not a filter set, fix typo on pax counter settings localized string --- Meshtastic/Views/Nodes/NodeList.swift | 2 +- Meshtastic/Views/Settings/Settings.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Meshtastic/Views/Nodes/NodeList.swift b/Meshtastic/Views/Nodes/NodeList.swift index 0ab993c7..2e8bda18 100644 --- a/Meshtastic/Views/Nodes/NodeList.swift +++ b/Meshtastic/Views/Nodes/NodeList.swift @@ -316,7 +316,7 @@ struct NodeList: View { } } - if predicates.count > 0 { + if predicates.count > 0 || !searchText.isEmpty { if !searchText.isEmpty { let filterPredicates = NSCompoundPredicate(type: .and, subpredicates: predicates) diff --git a/Meshtastic/Views/Settings/Settings.swift b/Meshtastic/Views/Settings/Settings.swift index b1883c1c..f0b221aa 100644 --- a/Meshtastic/Views/Settings/Settings.swift +++ b/Meshtastic/Views/Settings/Settings.swift @@ -333,7 +333,7 @@ struct Settings: View { PaxCounterConfig(node: nodes.first(where: { $0.num == selectedNode })) } label: { Label { - Text("config.module.paxcounter.setting") + Text("config.module.paxcounter.settings") } icon: { Image(systemName: "figure.walk.motion") } From 0c112e2a5571b52f7dbec124761c966c1ac641b3 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Tue, 26 Mar 2024 14:57:00 -0700 Subject: [PATCH 63/74] Online only filter --- Meshtastic/Views/Nodes/Helpers/NodeListFilter.swift | 13 +++++++++++++ Meshtastic/Views/Nodes/NodeList.swift | 12 +++++++++++- .../Views/Settings/Config/Module/MQTTConfig.swift | 2 +- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Meshtastic/Views/Nodes/Helpers/NodeListFilter.swift b/Meshtastic/Views/Nodes/Helpers/NodeListFilter.swift index 03e04d84..a49fa9f2 100644 --- a/Meshtastic/Views/Nodes/Helpers/NodeListFilter.swift +++ b/Meshtastic/Views/Nodes/Helpers/NodeListFilter.swift @@ -13,6 +13,7 @@ struct NodeListFilter: View { /// Filters @Binding var viaLora: Bool @Binding var viaMqtt: Bool + @Binding var isOnline: Bool @Binding var distanceFilter: Bool @Binding var maximumDistance: Double @Binding var hopsAway: Int @@ -44,6 +45,18 @@ struct NodeListFilter: View { .toggleStyle(SwitchToggleStyle(tint: .accentColor)) .listRowSeparator(.visible) + Toggle(isOn: $isOnline) { + + Label { + Text("Online Only") + } icon: { + Image(systemName: "checkmark.circle.fill") + .foregroundColor(.green) + } + } + .toggleStyle(SwitchToggleStyle(tint: .accentColor)) + .listRowSeparator(.visible) + // Toggle(isOn: $distanceFilter) { // // Label { diff --git a/Meshtastic/Views/Nodes/NodeList.swift b/Meshtastic/Views/Nodes/NodeList.swift index 2e8bda18..a750658b 100644 --- a/Meshtastic/Views/Nodes/NodeList.swift +++ b/Meshtastic/Views/Nodes/NodeList.swift @@ -19,6 +19,7 @@ struct NodeList: View { @State private var searchText = "" @State private var viaLora = true @State private var viaMqtt = true + @State private var isOnline = false @State private var distanceFilter = false @State private var maxDistance: Double = 800000 @State private var hopsAway: Int = -1 @@ -144,7 +145,7 @@ struct NodeList: View { } } .sheet(isPresented: $isEditingFilters) { - NodeListFilter(viaLora: $viaLora, viaMqtt: $viaMqtt, distanceFilter: $distanceFilter, maximumDistance: $maxDistance, hopsAway: $hopsAway, deviceRole: $deviceRole) + NodeListFilter(viaLora: $viaLora, viaMqtt: $viaMqtt, isOnline: $isOnline, distanceFilter: $distanceFilter, maximumDistance: $maxDistance, hopsAway: $hopsAway, deviceRole: $deviceRole) } .safeAreaInset(edge: .bottom, alignment: .trailing) { HStack { @@ -259,6 +260,9 @@ struct NodeList: View { .onChange(of: hopsAway) { _ in searchNodeList() } + .onChange(of: isOnline) { _ in + searchNodeList() + } .onAppear { if self.bleManager.context == nil { self.bleManager.context = context @@ -295,6 +299,12 @@ struct NodeList: View { let hopsAwayPredicate = NSPredicate(format: "hopsAway == %i", Int32(hopsAway)) predicates.append(hopsAwayPredicate) } + + /// Online + if isOnline { + let isOnlinePredicate = NSPredicate(format: "lastHeard >= %@", Calendar.current.date(byAdding: .minute, value: -15, to: Date())! as NSDate) + predicates.append(isOnlinePredicate) + } /// Distance if distanceFilter { let pointOfInterest = LocationHelper.currentLocation diff --git a/Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift b/Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift index 10563eb3..be067293 100644 --- a/Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift +++ b/Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift @@ -254,7 +254,7 @@ struct MQTTConfig: View { } .toggleStyle(SwitchToggleStyle(tint: .accentColor)) } - Text("For all Mqtt functionality other than the map report you must also set uplink and downlink for each channel you want to brige over Mqtt.") + Text("For all Mqtt functionality other than the map report you must also set uplink and downlink for each channel you want to bridge over Mqtt.") .font(.callout) } .scrollDismissesKeyboard(.interactively) From 1354427bfe2d681b8267a87a705157626746b101 Mon Sep 17 00:00:00 2001 From: ChDel Date: Tue, 26 Mar 2024 16:45:32 -0700 Subject: [PATCH 64/74] Fixing UserDefault wrapper crashing with enums --- Meshtastic/Enums/AppSettingsEnums.swift | 6 +- Meshtastic/Extensions/UserDefaults.swift | 447 +++++------------- .../Config/Module/DetectionSensorConfig.swift | 2 +- 3 files changed, 115 insertions(+), 340 deletions(-) diff --git a/Meshtastic/Enums/AppSettingsEnums.swift b/Meshtastic/Enums/AppSettingsEnums.swift index 0250119a..c53c3826 100644 --- a/Meshtastic/Enums/AppSettingsEnums.swift +++ b/Meshtastic/Enums/AppSettingsEnums.swift @@ -130,7 +130,7 @@ enum LocationUpdateInterval: Int, CaseIterable, Identifiable { } } -enum MapLayer: String, CaseIterable, Equatable { +enum MapLayer: String, CaseIterable, Equatable, Decodable { case standard case hybrid case satellite @@ -138,7 +138,7 @@ enum MapLayer: String, CaseIterable, Equatable { var localized: String { self.rawValue.localized } } -enum MapTileServer: String, CaseIterable, Identifiable { +enum MapTileServer: String, CaseIterable, Identifiable, Decodable { case openStreetMap case openStreetMapDE case openStreetMapFR @@ -273,7 +273,7 @@ enum OverlayType: String, CaseIterable, Equatable { var localized: String { self.rawValue.localized } } -enum MapOverlayServer: String, CaseIterable, Identifiable { +enum MapOverlayServer: String, CaseIterable, Identifiable, Decodable { case baseReReflectivityCurrent case baseReReflectivityOneHourAgo case echoTopsEetCurrent diff --git a/Meshtastic/Extensions/UserDefaults.swift b/Meshtastic/Extensions/UserDefaults.swift index ccb8a7a3..c714efbf 100644 --- a/Meshtastic/Extensions/UserDefaults.swift +++ b/Meshtastic/Extensions/UserDefaults.swift @@ -13,6 +13,36 @@ import Foundation +@propertyWrapper +struct UserDefault { + let key: UserDefaults.Keys + let defaultValue: T + + init(_ key: UserDefaults.Keys, defaultValue: T) { + self.key = key + self.defaultValue = defaultValue + } + + var wrappedValue: T { + get { + if defaultValue as? any RawRepresentable != nil { + let storedValue = UserDefaults.standard.object(forKey: key.rawValue) + + guard let storedValue, + let data = ("\"\(storedValue)\"".data(using: .utf8)), + let value = (try? JSONDecoder().decode(T.self, from: data)) else { return defaultValue } + + return value + } + + return UserDefaults.standard.object(forKey: key.rawValue) as? T ?? defaultValue + } + set { + UserDefaults.standard.set((newValue as? any RawRepresentable)?.rawValue ?? newValue, forKey: key.rawValue) + } + } +} + extension UserDefaults { enum Keys: String, CaseIterable { case preferredPeripheralId @@ -26,10 +56,16 @@ extension UserDefaults { case meshMapShowNodeHistory case meshMapShowRouteLines case enableMapConvexHull + case enableMapRecentering + case enableMapNodeHistoryPins + case enableMapRouteLines case enableMapTraffic case enableMapPointsOfInterest case enableOfflineMaps + case enableOfflineMapsMBTiles case mapTileServer + case enableOverlayServer + case mapOverlayServer case mapTilesAboveLabels case mapUseLegacy case enableDetectionNotifications @@ -42,340 +78,79 @@ extension UserDefaults { func reset() { Keys.allCases.forEach { removeObject(forKey: $0.rawValue) } } - static var preferredPeripheralId: String { - get { - UserDefaults.standard.string(forKey: "preferredPeripheralId") ?? "" - } - set { - UserDefaults.standard.set(newValue, forKey: "preferredPeripheralId") - } - } - static var preferredPeripheralNum: Int { - get { - UserDefaults.standard.integer(forKey: "preferredPeripheralNum") - } - set { - UserDefaults.standard.set(newValue, forKey: "preferredPeripheralNum") - } - } - static var provideLocation: Bool { - get { - UserDefaults.standard.bool(forKey: "provideLocation") - } set { - UserDefaults.standard.set(newValue, forKey: "provideLocation") - } - } - static var provideLocationInterval: Int { - get { - UserDefaults.standard.integer(forKey: "provideLocationInterval") - } - set { - UserDefaults.standard.set(newValue, forKey: "provideLocationInterval") - } - } - static var mapLayer: MapLayer { - get { - MapLayer(rawValue: UserDefaults.standard.string(forKey: "mapLayer") ?? MapLayer.standard.rawValue) ?? MapLayer.standard - } - set { - UserDefaults.standard.set(newValue.rawValue, forKey: "mapLayer") - } - } - static var meshMapDistance: Double { - get { - UserDefaults.standard.double(forKey: "meshMapDistance") - } - set { - UserDefaults.standard.set(newValue, forKey: "meshMapDistance") - } - } - static var enableMapWaypoints: Bool { - get { - UserDefaults.standard.bool(forKey: "enableMapWaypoints") - } - set { - UserDefaults.standard.set(newValue, forKey: "enableMapWaypoints") - } - } - static var enableMapRecentering: Bool { - get { - UserDefaults.standard.bool(forKey: "meshMapRecentering") - } - set { - UserDefaults.standard.set(newValue, forKey: "meshMapRecentering") - } - } - static var enableMapNodeHistoryPins: Bool { - get { - UserDefaults.standard.bool(forKey: "meshMapShowNodeHistory") - } - set { - UserDefaults.standard.set(newValue, forKey: "meshMapShowNodeHistory") - } - } - static var enableMapRouteLines: Bool { - get { - UserDefaults.standard.bool(forKey: "meshMapShowRouteLines") - } - set { - UserDefaults.standard.set(newValue, forKey: "meshMapShowRouteLines") - } - } - static var enableMapConvexHull: Bool { - get { - UserDefaults.standard.bool(forKey: "enableMapConvexHull") - } - set { - UserDefaults.standard.set(newValue, forKey: "enableMapConvexHull") - } - } - static var enableMapTraffic: Bool { - get { - UserDefaults.standard.bool(forKey: "enableMapTraffic") - } - set { - UserDefaults.standard.set(newValue, forKey: "enableMapTraffic") - } - } - static var enableMapPointsOfInterest: Bool { - get { - UserDefaults.standard.bool(forKey: "enableMapPointsOfInterest") - } - set { - UserDefaults.standard.set(newValue, forKey: "enableMapPointsOfInterest") - } - } - static var enableOfflineMaps: Bool { - get { - UserDefaults.standard.bool(forKey: "enableOfflineMaps") - } - set { - UserDefaults.standard.set(newValue, forKey: "enableOfflineMaps") - } - } - static var enableOfflineMapsMBTiles: Bool { - get { - UserDefaults.standard.bool(forKey: "enableOfflineMapsMBTiles") - } - set { - UserDefaults.standard.set(newValue, forKey: "enableOfflineMapsMBTiles") - } - } - static var mapTileServer: MapTileServer { - get { - MapTileServer(rawValue: UserDefaults.standard.string(forKey: "mapTileServer") ?? MapTileServer.openStreetMap.rawValue) ?? MapTileServer.openStreetMap - } - set { - UserDefaults.standard.set(newValue.rawValue, forKey: "mapTileServer") - } - } - static var enableOverlayServer: Bool { - get { - UserDefaults.standard.bool(forKey: "enableOverlayServer") - } - set { - UserDefaults.standard.set(newValue, forKey: "enableOverlayServer") - } - } - static var mapOverlayServer: MapOverlayServer { - get { - MapOverlayServer(rawValue: UserDefaults.standard.string(forKey: "mapOverlayServer") ?? MapOverlayServer.baseReReflectivityCurrent.rawValue) ?? MapOverlayServer.baseReReflectivityCurrent - } - set { - UserDefaults.standard.set(newValue.rawValue, forKey: "mapOverlayServer") - } - } - static var mapTilesAboveLabels: Bool { - get { - UserDefaults.standard.bool(forKey: "mapTilesAboveLabels") - } - set { - UserDefaults.standard.set(newValue, forKey: "mapTilesAboveLabels") - } - } - - static var mapUseLegacy: Bool { - get { - UserDefaults.standard.bool(forKey: "mapUseLegacy") - } - set { - UserDefaults.standard.set(newValue, forKey: "mapUseLegacy") - } - } - - static var enableDetectionNotifications: Bool { - get { - UserDefaults.standard.bool(forKey: "enableDetectionNotifications") - } - set { - UserDefaults.standard.set(newValue, forKey: "enableDetectionNotifications") - } - } - - static var detectionSensorRole: DetectionSensorRole { - get { - DetectionSensorRole(rawValue: UserDefaults.standard.string(forKey: "detectionSensorRole") ?? DetectionSensorRole.sensor.rawValue) ?? DetectionSensorRole.sensor - } - set { - UserDefaults.standard.set(newValue.rawValue, forKey: "detectionSensorRole") - } - } - static var enableSmartPosition: Bool { - get { - UserDefaults.standard.bool(forKey: "enableSmartPosition") - } - set { - UserDefaults.standard.set(newValue, forKey: "enableSmartPosition") - } - } - static var modemPreset: Int { - get { - UserDefaults.standard.integer(forKey: "modemPreset") - } - set { - UserDefaults.standard.set(newValue, forKey: "modemPreset") - } - } - static var firmwareVersion: String { - get { - UserDefaults.standard.string(forKey: "firmwareVersion") ?? "0.0.0" - } - set { - UserDefaults.standard.set(newValue, forKey: "firmwareVersion") - } - } -} -//import Foundation -// -//@propertyWrapper -//struct UserDefault { -// let key: UserDefaults.Keys -// let defaultValue: T -// -// init(_ key: UserDefaults.Keys, defaultValue: T) { -// self.key = key -// self.defaultValue = defaultValue -// } -// -// var wrappedValue: T { -// get { -// UserDefaults.standard.object(forKey: key.rawValue) as? T ?? defaultValue -// } -// set { -// UserDefaults.standard.set(newValue, forKey: key.rawValue) -// } -// } -//} -// -//extension UserDefaults { -// enum Keys: String, CaseIterable { -// case preferredPeripheralId -// case preferredPeripheralNum -// case provideLocation -// case provideLocationInterval -// case mapLayer -// case meshMapDistance -// case enableMapWaypoints -// case meshMapRecentering -// case meshMapShowNodeHistory -// case meshMapShowRouteLines -// case enableMapConvexHull -// case enableMapRecentering -// case enableMapNodeHistoryPins -// case enableMapRouteLines -// case enableMapTraffic -// case enableMapPointsOfInterest -// case enableOfflineMaps -// case enableOfflineMapsMBTiles -// case mapTileServer -// case enableOverlayServer -// case mapOverlayServer -// case mapTilesAboveLabels -// case mapUseLegacy -// case enableDetectionNotifications -// case detectionSensorRole -// case enableSmartPosition -// case modemPreset -// case firmwareVersion -// } -// -// func reset() { -// Keys.allCases.forEach { removeObject(forKey: $0.rawValue) } -// } -// -// @UserDefault(.preferredPeripheralId, defaultValue: "") -// static var preferredPeripheralId: String -// -// @UserDefault(.preferredPeripheralNum, defaultValue: 0) -// static var preferredPeripheralNum: Int -// -// @UserDefault(.provideLocation, defaultValue: false) -// static var provideLocation: Bool -// -// @UserDefault(.provideLocationInterval, defaultValue: 0) -// static var provideLocationInterval: Int -// -// @UserDefault(.mapLayer, defaultValue: .standard) -// static var mapLayer: MapLayer -// -// @UserDefault(.meshMapDistance, defaultValue: 800000) -// static var meshMapDistance: Double -// -// @UserDefault(.enableMapWaypoints, defaultValue: false) -// static var enableMapWaypoints: Bool -// -// @UserDefault(.enableMapRecentering, defaultValue: false) -// static var enableMapRecentering: Bool -// -// @UserDefault(.enableMapNodeHistoryPins, defaultValue: false) -// static var enableMapNodeHistoryPins: Bool -// -// @UserDefault(.enableMapRouteLines, defaultValue: false) -// static var enableMapRouteLines: Bool -// -// @UserDefault(.enableMapConvexHull, defaultValue: false) -// static var enableMapConvexHull: Bool -// -// @UserDefault(.enableMapTraffic, defaultValue: false) -// static var enableMapTraffic: Bool -// -// @UserDefault(.enableMapPointsOfInterest, defaultValue: false) -// static var enableMapPointsOfInterest: Bool -// -// @UserDefault(.enableOfflineMaps, defaultValue: false) -// static var enableOfflineMaps: Bool -// -// @UserDefault(.enableOfflineMapsMBTiles, defaultValue: false) -// static var enableOfflineMapsMBTiles: Bool -// -// @UserDefault(.mapTileServer, defaultValue: .openStreetMap) -// static var mapTileServer: MapTileServer -// -// @UserDefault(.enableOverlayServer, defaultValue: false) -// static var enableOverlayServer: Bool -// -// @UserDefault(.mapOverlayServer, defaultValue: .baseReReflectivityCurrent) -// static var mapOverlayServer: MapOverlayServer -// -// @UserDefault(.mapTilesAboveLabels, defaultValue: false) -// static var mapTilesAboveLabels: Bool -// -// @UserDefault(.mapUseLegacy, defaultValue: false) -// static var mapUseLegacy: Bool -// -// @UserDefault(.enableDetectionNotifications, defaultValue: false) -// static var enableDetectionNotifications: Bool -// -// @UserDefault(.detectionSensorRole, defaultValue: .sensor) -// static var detectionSensorRole: DetectionSensorRole -// -// @UserDefault(.enableSmartPosition, defaultValue: false) -// static var enableSmartPosition: Bool -// -// @UserDefault(.modemPreset, defaultValue: 0) -// static var modemPreset: Int -// -// @UserDefault(.firmwareVersion, defaultValue: "0.0.0") -// static var firmwareVersion: String -//} + @UserDefault(.preferredPeripheralId, defaultValue: "") + static var preferredPeripheralId: String + + @UserDefault(.preferredPeripheralNum, defaultValue: 0) + static var preferredPeripheralNum: Int + + @UserDefault(.provideLocation, defaultValue: false) + static var provideLocation: Bool + + @UserDefault(.provideLocationInterval, defaultValue: 0) + static var provideLocationInterval: Int + + @UserDefault(.mapLayer, defaultValue: .standard) + static var mapLayer: MapLayer + + @UserDefault(.meshMapDistance, defaultValue: 800000) + static var meshMapDistance: Double + + @UserDefault(.enableMapWaypoints, defaultValue: false) + static var enableMapWaypoints: Bool + + @UserDefault(.enableMapRecentering, defaultValue: false) + static var enableMapRecentering: Bool + + @UserDefault(.enableMapNodeHistoryPins, defaultValue: false) + static var enableMapNodeHistoryPins: Bool + + @UserDefault(.enableMapRouteLines, defaultValue: false) + static var enableMapRouteLines: Bool + + @UserDefault(.enableMapConvexHull, defaultValue: false) + static var enableMapConvexHull: Bool + + @UserDefault(.enableMapTraffic, defaultValue: false) + static var enableMapTraffic: Bool + + @UserDefault(.enableMapPointsOfInterest, defaultValue: false) + static var enableMapPointsOfInterest: Bool + + @UserDefault(.enableOfflineMaps, defaultValue: false) + static var enableOfflineMaps: Bool + + @UserDefault(.enableOfflineMapsMBTiles, defaultValue: false) + static var enableOfflineMapsMBTiles: Bool + + @UserDefault(.mapTileServer, defaultValue: .openStreetMap) + static var mapTileServer: MapTileServer + + @UserDefault(.enableOverlayServer, defaultValue: false) + static var enableOverlayServer: Bool + + @UserDefault(.mapOverlayServer, defaultValue: .baseReReflectivityCurrent) + static var mapOverlayServer: MapOverlayServer + + @UserDefault(.mapTilesAboveLabels, defaultValue: false) + static var mapTilesAboveLabels: Bool + + @UserDefault(.mapUseLegacy, defaultValue: false) + static var mapUseLegacy: Bool + + @UserDefault(.enableDetectionNotifications, defaultValue: false) + static var enableDetectionNotifications: Bool + + @UserDefault(.detectionSensorRole, defaultValue: .sensor) + static var detectionSensorRole: DetectionSensorRole + + @UserDefault(.enableSmartPosition, defaultValue: false) + static var enableSmartPosition: Bool + + @UserDefault(.modemPreset, defaultValue: 0) + static var modemPreset: Int + + @UserDefault(.firmwareVersion, defaultValue: "0.0.0") + static var firmwareVersion: String +} diff --git a/Meshtastic/Views/Settings/Config/Module/DetectionSensorConfig.swift b/Meshtastic/Views/Settings/Config/Module/DetectionSensorConfig.swift index 54570be2..bd00c76e 100644 --- a/Meshtastic/Views/Settings/Config/Module/DetectionSensorConfig.swift +++ b/Meshtastic/Views/Settings/Config/Module/DetectionSensorConfig.swift @@ -6,7 +6,7 @@ // import SwiftUI -enum DetectionSensorRole: String, CaseIterable, Equatable { +enum DetectionSensorRole: String, CaseIterable, Equatable, Decodable { case sensor case client var description: String { From d9ab828d4a9eb56cb0932f7ee4ce6304428ff160 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Tue, 26 Mar 2024 19:17:13 -0700 Subject: [PATCH 65/74] Fix icon for isonline icon --- Meshtastic/Views/Nodes/Helpers/NodeListFilter.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Meshtastic/Views/Nodes/Helpers/NodeListFilter.swift b/Meshtastic/Views/Nodes/Helpers/NodeListFilter.swift index a49fa9f2..79574927 100644 --- a/Meshtastic/Views/Nodes/Helpers/NodeListFilter.swift +++ b/Meshtastic/Views/Nodes/Helpers/NodeListFilter.swift @@ -52,6 +52,7 @@ struct NodeListFilter: View { } icon: { Image(systemName: "checkmark.circle.fill") .foregroundColor(.green) + .symbolRenderingMode(.hierarchical) } } .toggleStyle(SwitchToggleStyle(tint: .accentColor)) @@ -124,7 +125,7 @@ struct NodeListFilter: View { .padding(.bottom) #endif } - .presentationDetents([.fraction(0.35), .fraction(0.45)]) + .presentationDetents([.fraction(0.40), .fraction(0.50)]) .presentationDragIndicator(.visible) } } From 8149863621e7302b11876190525f839add91c407 Mon Sep 17 00:00:00 2001 From: ChDel Date: Tue, 26 Mar 2024 19:40:48 -0700 Subject: [PATCH 66/74] Allow for numerical enum to decode --- Meshtastic/Extensions/UserDefaults.swift | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Meshtastic/Extensions/UserDefaults.swift b/Meshtastic/Extensions/UserDefaults.swift index c714efbf..a93a4114 100644 --- a/Meshtastic/Extensions/UserDefaults.swift +++ b/Meshtastic/Extensions/UserDefaults.swift @@ -29,7 +29,8 @@ struct UserDefault { let storedValue = UserDefaults.standard.object(forKey: key.rawValue) guard let storedValue, - let data = ("\"\(storedValue)\"".data(using: .utf8)), + let jsonString = (storedValue as? String != nil) ? "\"\(storedValue)\"" : "\(storedValue)", + let data = jsonString.data(using: .utf8), let value = (try? JSONDecoder().decode(T.self, from: data)) else { return defaultValue } return value @@ -73,6 +74,7 @@ extension UserDefaults { case enableSmartPosition case modemPreset case firmwareVersion + case testIntEnum } func reset() { @@ -153,4 +155,13 @@ extension UserDefaults { @UserDefault(.firmwareVersion, defaultValue: "0.0.0") static var firmwareVersion: String + + @UserDefault(.testIntEnum, defaultValue: .one) + static var testIntEnum: TestIntEnum +} + +enum TestIntEnum: Int, Decodable { + case one = 1 + case two + case three } From 78095caf08cfe185524ba7b1c2f5656e600c7f0b Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Tue, 26 Mar 2024 19:49:30 -0700 Subject: [PATCH 67/74] Fix firmware version comparison, filter the node list when it appears --- Meshtastic/Helpers/Mqtt/MqttClientProxyManager.swift | 7 ++++--- Meshtastic/Views/Nodes/NodeList.swift | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Meshtastic/Helpers/Mqtt/MqttClientProxyManager.swift b/Meshtastic/Helpers/Mqtt/MqttClientProxyManager.swift index 5a1a33d4..80555aea 100644 --- a/Meshtastic/Helpers/Mqtt/MqttClientProxyManager.swift +++ b/Meshtastic/Helpers/Mqtt/MqttClientProxyManager.swift @@ -36,8 +36,9 @@ class MqttClientProxyManager { defaultServerPort = Int(fullHost.components(separatedBy: ":")[1]) ?? (useSsl ? 8883 : 1883) } } - let minimumVersion = "2.3.0" - let latestVersion = minimumVersion.compare(UserDefaults.firmwareVersion, options: .numeric) == .orderedSame + let minimumVersion = "2.3.3" + let currentVersion = UserDefaults.firmwareVersion + let supportedVersion = minimumVersion.compare(currentVersion, options: .numeric) == .orderedAscending || minimumVersion.compare(currentVersion, options: .numeric) == .orderedSame if let host = host { let port = defaultServerPort @@ -45,7 +46,7 @@ class MqttClientProxyManager { let password = node.mqttConfig?.password let root = node.mqttConfig?.root?.count ?? 0 > 0 ? node.mqttConfig?.root : "msh" let prefix = root! - topic = prefix + (latestVersion ? "/2/e" : "/2/c") + "/#" + topic = prefix + (supportedVersion ? "/2/e" : "/2/c") + "/#" let qos = CocoaMQTTQoS(rawValue: UInt8(1))! connect(host: host, port: port, useSsl: useSsl, username: username, password: password, topic: topic, qos: qos, cleanSession: true) } diff --git a/Meshtastic/Views/Nodes/NodeList.swift b/Meshtastic/Views/Nodes/NodeList.swift index a750658b..8a63d2a9 100644 --- a/Meshtastic/Views/Nodes/NodeList.swift +++ b/Meshtastic/Views/Nodes/NodeList.swift @@ -267,6 +267,7 @@ struct NodeList: View { if self.bleManager.context == nil { self.bleManager.context = context } + searchNodeList() } } From 1c9d9b65b59fa1a94e7ef3ef42cb4ae2f38499af Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Tue, 26 Mar 2024 23:36:11 -0700 Subject: [PATCH 68/74] Hook up ui for new fixed position set and remove admin messages. --- Meshtastic.xcodeproj/project.pbxproj | 2 + Meshtastic/Helpers/BLEManager.swift | 65 +++++++++++++++++-- .../Settings/Config/PositionConfig.swift | 42 ++++++++++-- 3 files changed, 96 insertions(+), 13 deletions(-) diff --git a/Meshtastic.xcodeproj/project.pbxproj b/Meshtastic.xcodeproj/project.pbxproj index 5cdd8853..9339e55d 100644 --- a/Meshtastic.xcodeproj/project.pbxproj +++ b/Meshtastic.xcodeproj/project.pbxproj @@ -187,6 +187,7 @@ DDDB445429F8AD1600EE2349 /* Data.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDDB445329F8AD1600EE2349 /* Data.swift */; }; DDDC22382BA92344002C44F1 /* MeshMapContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDDC22372BA92344002C44F1 /* MeshMapContent.swift */; }; DDDCD5702BB26F5C00BE6B60 /* NodeListFilter.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDDCD56F2BB26F5C00BE6B60 /* NodeListFilter.swift */; }; + DDDCD5722BB3E46400BE6B60 /* BLEManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDAF8C5226EB1DF10058C060 /* BLEManager.swift */; }; DDDE59F529AF163D00490C6C /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DD41A61C29AE7E8E003C5A37 /* WidgetKit.framework */; }; DDDE59F629AF163D00490C6C /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DD41A61E29AE7E8F003C5A37 /* SwiftUI.framework */; }; DDDE59F929AF163D00490C6C /* WidgetsBundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDDE59F829AF163D00490C6C /* WidgetsBundle.swift */; }; @@ -1404,6 +1405,7 @@ buildActionMask = 2147483647; files = ( DDD3BBD5292D763200D609B3 /* MeshtasticTests.swift in Sources */, + DDDCD5722BB3E46400BE6B60 /* BLEManager.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Meshtastic/Helpers/BLEManager.swift b/Meshtastic/Helpers/BLEManager.swift index 980e2870..9327ebc8 100644 --- a/Meshtastic/Helpers/BLEManager.swift +++ b/Meshtastic/Helpers/BLEManager.swift @@ -983,9 +983,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate return success } - public func sendPosition(channel: Int32, destNum: Int64, wantResponse: Bool) -> Bool { - var success = false - let fromNodeNum = connectedPeripheral.num + public func getPositionFromPhoneGPS(channel: Int32, destNum: Int64) -> Position? { var positionPacket = Position() let fetchChannelRequest: NSFetchRequest = NSFetchRequest.init(entityName: "ChannelEntity") @@ -993,7 +991,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate do { guard let fetchedChannel = try context!.fetch(fetchChannelRequest) as? [ChannelEntity] else { - return false + return nil } if #available(iOS 17.0, macOS 14.0, *) { @@ -1019,8 +1017,8 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate } } else { - if fromNodeNum <= 0 || LocationHelper.currentLocation.distance(from: LocationHelper.DefaultLocation) == 0.0 { - return false + if destNum <= 0 || LocationHelper.currentLocation.distance(from: LocationHelper.DefaultLocation) == 0.0 { + return nil } positionPacket.latitudeI = Int32(LocationHelper.currentLocation.latitude * 1e7) positionPacket.longitudeI = Int32(LocationHelper.currentLocation.longitude * 1e7) @@ -1041,6 +1039,61 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate } } catch { + return nil + } + + return positionPacket + } + + public func setFixedPosition(fromUser: UserEntity, channel: Int32) -> Bool { + var adminPacket = AdminMessage() + guard let positionPacket = getPositionFromPhoneGPS(channel: channel, destNum: fromUser.num) else { + return false + } + adminPacket.setFixedPosition = positionPacket + var meshPacket: MeshPacket = MeshPacket() + meshPacket.to = UInt32(fromUser.num) + meshPacket.from = UInt32(fromUser.num) + meshPacket.id = UInt32.random(in: UInt32(UInt8.max).. Bool { + var adminPacket = AdminMessage() + adminPacket.removeFixedPosition = true + var meshPacket: MeshPacket = MeshPacket() + meshPacket.to = UInt32(fromUser.num) + meshPacket.from = UInt32(fromUser.num) + meshPacket.id = UInt32.random(in: UInt32(UInt8.max).. Bool { + var success = false + let fromNodeNum = connectedPeripheral.num + guard let positionPacket = getPositionFromPhoneGPS(channel: channel, destNum: destNum) else { return false } diff --git a/Meshtastic/Views/Settings/Config/PositionConfig.swift b/Meshtastic/Views/Settings/Config/PositionConfig.swift index b18ff5e6..37bb12e7 100644 --- a/Meshtastic/Views/Settings/Config/PositionConfig.swift +++ b/Meshtastic/Views/Settings/Config/PositionConfig.swift @@ -73,8 +73,10 @@ struct PositionConfig: View { @State var includeHeading = false /// Minimum Version for fixed postion admin messages - @State var minimumVersion = "2.3.3" + @State var minimumVersion = "2.3.2" @State private var supportedVersion = true + @State private var showingSetFixedAlert = false + @State private var showingRemoveFixedAlert = false var body: some View { VStack { @@ -160,19 +162,45 @@ struct PositionConfig: View { VStack(alignment: .leading) { Toggle(isOn: $fixedPosition) { Label("Fixed Position", systemImage: "location.square.fill") - Text("If enabled your current phone location will be sent to the device and will broadcast over the mesh on the position interval. Fixed position will always use the most recent position the device has.") + Text("If enabled your current phone location will be sent to the device and will broadcast over the mesh on the position interval.") } .toggleStyle(SwitchToggleStyle(tint: .accentColor)) - } .onChange(of: fixedPosition) { newFixed in if node != nil && node!.positionConfig != nil { - if newFixed != node!.positionConfig!.fixedPosition { hasChanges = true } - } - if supportedVersion && hasChanges && !newFixed { - // Send Admin message to remove the fixed position + /// Fixed Position is off to start + if !node!.positionConfig!.fixedPosition && newFixed && supportedVersion { + showingSetFixedAlert = true + } else if node!.positionConfig!.fixedPosition && newFixed && supportedVersion { + /// Fixed Position is on to start + showingRemoveFixedAlert = true + } } } + .alert(isPresented: $showingSetFixedAlert) { + Alert( + title: Text("Set Fixed Position"), + message: Text("This will send a current position from your phone and enable fixed position."), + primaryButton: .default(Text("Set")) { + print("Set a fixed position here") + }, + secondaryButton: .cancel(Text("Cancel")) { + fixedPosition = false + } + ) + } + .alert(isPresented: $showingRemoveFixedAlert) { + Alert( + title: Text("Remove Fixed Position"), + message: Text("This will disable fixed position and remove the currently set position."), + primaryButton: .destructive(Text("Remove")) { + print("Remove a fixed position here") + }, + secondaryButton: .cancel(Text("Cancel")) { + fixedPosition = true + } + ) + } } } Section(header: Text("Position Flags")) { From 7c022813a24f0597feef2706bb489fde9d17cb14 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Wed, 27 Mar 2024 16:06:24 -0700 Subject: [PATCH 69/74] Fixed position updates --- Meshtastic/Enums/PositionConfigEnums.swift | 3 + .../CoreData/PositionEntityExtension.swift | 4 +- .../Helpers/Mqtt/MqttClientProxyManager.swift | 2 +- Meshtastic/Views/Nodes/MeshMap.swift | 4 +- .../Settings/Config/PositionConfig.swift | 113 ++++++++++-------- 5 files changed, 73 insertions(+), 53 deletions(-) diff --git a/Meshtastic/Enums/PositionConfigEnums.swift b/Meshtastic/Enums/PositionConfigEnums.swift index e9d4fec2..0773112c 100644 --- a/Meshtastic/Enums/PositionConfigEnums.swift +++ b/Meshtastic/Enums/PositionConfigEnums.swift @@ -57,6 +57,7 @@ enum GpsUpdateIntervals: Int, CaseIterable, Identifiable { case thirtySeconds = 30 case oneMinute = 60 + case twoMinutes = 120 case fiveMinutes = 300 case tenMinutes = 600 case fifteenMinutes = 900 @@ -74,6 +75,8 @@ enum GpsUpdateIntervals: Int, CaseIterable, Identifiable { return "interval.thirty.seconds".localized case .oneMinute: return "interval.one.minute".localized + case .twoMinutes: + return "interval.two.minutes".localized case .fiveMinutes: return "interval.five.minutes".localized case .tenMinutes: diff --git a/Meshtastic/Extensions/CoreData/PositionEntityExtension.swift b/Meshtastic/Extensions/CoreData/PositionEntityExtension.swift index b24ec821..f1f280e5 100644 --- a/Meshtastic/Extensions/CoreData/PositionEntityExtension.swift +++ b/Meshtastic/Extensions/CoreData/PositionEntityExtension.swift @@ -20,8 +20,8 @@ extension PositionEntity { request.includesSubentities = true request.returnsDistinctResults = true request.sortDescriptors = [NSSortDescriptor(key: "time", ascending: false)] - - let positionPredicate = NSPredicate(format: "nodePosition != nil && (nodePosition.user.shortName != nil || nodePosition.user.shortName != '') && latest == true && time >= %@", Calendar.current.date(byAdding: .day, value: -2, to: Date())! as NSDate) + /// && time >= %@ + let positionPredicate = NSPredicate(format: "nodePosition != nil && (nodePosition.user.shortName != nil || nodePosition.user.shortName != '') && latest == true", Calendar.current.date(byAdding: .day, value: -2, to: Date())! as NSDate) let pointOfInterest = LocationHelper.currentLocation diff --git a/Meshtastic/Helpers/Mqtt/MqttClientProxyManager.swift b/Meshtastic/Helpers/Mqtt/MqttClientProxyManager.swift index 80555aea..4de5f67e 100644 --- a/Meshtastic/Helpers/Mqtt/MqttClientProxyManager.swift +++ b/Meshtastic/Helpers/Mqtt/MqttClientProxyManager.swift @@ -36,7 +36,7 @@ class MqttClientProxyManager { defaultServerPort = Int(fullHost.components(separatedBy: ":")[1]) ?? (useSsl ? 8883 : 1883) } } - let minimumVersion = "2.3.3" + let minimumVersion = "2.3.2" let currentVersion = UserDefaults.firmwareVersion let supportedVersion = minimumVersion.compare(currentVersion, options: .numeric) == .orderedAscending || minimumVersion.compare(currentVersion, options: .numeric) == .orderedSame diff --git a/Meshtastic/Views/Nodes/MeshMap.swift b/Meshtastic/Views/Nodes/MeshMap.swift index 2b17ab92..7f1e803e 100644 --- a/Meshtastic/Views/Nodes/MeshMap.swift +++ b/Meshtastic/Views/Nodes/MeshMap.swift @@ -58,10 +58,8 @@ struct MeshMap: View { .mapControlVisibility(.automatic) } .controlSize(.regular) - .onTapGesture(count: 1, perform: { position in - print(position) - newWaypointCoord = reader.convert(position, from: .local) ?? CLLocationCoordinate2D.init() + newWaypointCoord = reader.convert(position, from: .local) ?? CLLocationCoordinate2D.init() }) .gesture( LongPressGesture(minimumDuration: 0.5) diff --git a/Meshtastic/Views/Settings/Config/PositionConfig.swift b/Meshtastic/Views/Settings/Config/PositionConfig.swift index 37bb12e7..38139d4c 100644 --- a/Meshtastic/Views/Settings/Config/PositionConfig.swift +++ b/Meshtastic/Views/Settings/Config/PositionConfig.swift @@ -73,10 +73,10 @@ struct PositionConfig: View { @State var includeHeading = false /// Minimum Version for fixed postion admin messages - @State var minimumVersion = "2.3.2" + @State var minimumVersion = "2.3.3" @State private var supportedVersion = true @State private var showingSetFixedAlert = false - @State private var showingRemoveFixedAlert = false + //@State private var showingRemoveFixedAlert = false var body: some View { VStack { @@ -158,49 +158,13 @@ struct PositionConfig: View { .foregroundColor(.gray) .font(.callout) } - } else { - VStack(alignment: .leading) { - Toggle(isOn: $fixedPosition) { - Label("Fixed Position", systemImage: "location.square.fill") - Text("If enabled your current phone location will be sent to the device and will broadcast over the mesh on the position interval.") - } - .toggleStyle(SwitchToggleStyle(tint: .accentColor)) - } - .onChange(of: fixedPosition) { newFixed in - if node != nil && node!.positionConfig != nil { - /// Fixed Position is off to start - if !node!.positionConfig!.fixedPosition && newFixed && supportedVersion { - showingSetFixedAlert = true - } else if node!.positionConfig!.fixedPosition && newFixed && supportedVersion { - /// Fixed Position is on to start - showingRemoveFixedAlert = true - } - } - } - .alert(isPresented: $showingSetFixedAlert) { - Alert( - title: Text("Set Fixed Position"), - message: Text("This will send a current position from your phone and enable fixed position."), - primaryButton: .default(Text("Set")) { - print("Set a fixed position here") - }, - secondaryButton: .cancel(Text("Cancel")) { - fixedPosition = false - } - ) - } - .alert(isPresented: $showingRemoveFixedAlert) { - Alert( - title: Text("Remove Fixed Position"), - message: Text("This will disable fixed position and remove the currently set position."), - primaryButton: .destructive(Text("Remove")) { - print("Remove a fixed position here") - }, - secondaryButton: .cancel(Text("Cancel")) { - fixedPosition = true - } - ) + } + VStack(alignment: .leading) { + Toggle(isOn: $fixedPosition) { + Label("Fixed Position", systemImage: "location.square.fill") + Text("If enabled your current phone location will be sent to the device and will broadcast over the mesh on the position interval.") } + .toggleStyle(SwitchToggleStyle(tint: .accentColor)) } } Section(header: Text("Position Flags")) { @@ -304,9 +268,49 @@ struct PositionConfig: View { } } .disabled(self.bleManager.connectedPeripheral == nil || node?.positionConfig == nil) + .alert(node?.positionConfig?.fixedPosition ?? false ? "Remove Fixed Position" : "Set Fixed Position", isPresented: $showingSetFixedAlert) { + Button("Cancel", role: .cancel) { + fixedPosition = !fixedPosition + } + if node?.positionConfig?.fixedPosition ?? false { + Button("Remove", role: .destructive) { + if !bleManager.removeFixedPosition(fromUser: node!.user!, channel: 0) { + print("Set Position Failed") + } + print("Remove a fixed position here") + node?.positionConfig?.fixedPosition = false + do { + try context.save() + print("💾 Updated Position Config with Fixed Position = false") + } catch { + context.rollback() + let nsError = error as NSError + print("💥 Error Saving Position Config Entity \(nsError)") + } + } + } else { + Button("Set") { + if !bleManager.setFixedPosition(fromUser: node!.user!, channel: 0) { + print("Set Position Failed") + } + print("Set a fixed position") + node?.positionConfig?.fixedPosition = true + do { + try context.save() + print("💾 Updated Position Config with Fixed Position = true") + } catch { + context.rollback() + let nsError = error as NSError + print("💥 Error Saving Position Config Entity \(nsError)") + } + } + } + } message: { + Text(node?.positionConfig?.fixedPosition ?? false ? "This will disable fixed position and remove the currently set position." : "This will send a current position from your phone and enable fixed position.") + } SaveConfigButton(node: node, hasChanges: $hasChanges) { - if fixedPosition { + if fixedPosition && !supportedVersion { _ = bleManager.sendPosition(channel: 0, destNum: node?.num ?? 0, wantResponse: true) } let connectedNode = getNodeInfo(id: bleManager.connectedPeripheral.num, context: context) @@ -358,8 +362,6 @@ struct PositionConfig: View { } setPositionValues() supportedVersion = bleManager.connectedVersion == "0.0.0" || self.minimumVersion.compare(bleManager.connectedVersion, options: .numeric) == .orderedAscending || minimumVersion.compare(bleManager.connectedVersion, options: .numeric) == .orderedSame - - // Need to request a PositionConfig from the remote node before allowing changes if bleManager.connectedPeripheral != nil && node?.positionConfig == nil { print("empty position config") @@ -369,6 +371,23 @@ struct PositionConfig: View { } } } + .onChange(of: fixedPosition) { newFixed in + print("Changing Fixed Position Value") + if supportedVersion { + if node != nil && node!.positionConfig != nil { + print("We have a node and position config") + print("We have turned on fixed position \(!node!.positionConfig!.fixedPosition && newFixed)") + /// Fixed Position is off to start + if !node!.positionConfig!.fixedPosition && newFixed { + print("fire alert") + showingSetFixedAlert = true + } else if node!.positionConfig!.fixedPosition && !newFixed { + /// Fixed Position is on to start + showingSetFixedAlert = true + } + } + } + } .onChange(of: deviceGpsEnabled) { newDeviceGps in if node != nil && node!.positionConfig != nil { if newDeviceGps != node!.positionConfig!.deviceGpsEnabled { hasChanges = true } From 4d584f64c9b40b06e01a31eafc19635c1e11bef9 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Wed, 27 Mar 2024 16:30:58 -0700 Subject: [PATCH 70/74] Flat the map by default so precision circles are prettier --- Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift b/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift index 6bb5c18c..3f316cf5 100644 --- a/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift +++ b/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift @@ -25,7 +25,7 @@ struct NodeMapSwiftUI: View { @AppStorage("mapLayer") private var selectedMapLayer: MapLayer = .hybrid // Map Configuration @Namespace var mapScope - @State var mapStyle: MapStyle = MapStyle.hybrid(elevation: .realistic, pointsOfInterest: .all, showsTraffic: true) + @State var mapStyle: MapStyle = MapStyle.hybrid(elevation: .flat, pointsOfInterest: .all, showsTraffic: true) @State var position = MapCameraPosition.automatic @State var scene: MKLookAroundScene? @State var isLookingAround = false From 6a7baf1ebe1de6ecf147628c368acc125f846ebf Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Thu, 28 Mar 2024 08:39:34 -0700 Subject: [PATCH 71/74] Add back 48 hour filter to the mesh map, add admin channel tip --- .../CoreData/PositionEntityExtension.swift | 5 ++--- Meshtastic/Tips/ChannelTips.swift | 17 +++++++++++++++++ .../Nodes/Helpers/Map/NodeMapSwiftUI.swift | 2 -- Meshtastic/Views/Settings/Settings.swift | 6 ++++++ de.lproj/Localizable.strings | 2 ++ en.lproj/Localizable.strings | 2 ++ fr.lproj/Localizable.strings | 2 ++ he.lproj/Localizable.strings | 2 ++ pl.lproj/Localizable.strings | 2 ++ zh-Hans.lproj/Localizable.strings | 2 ++ zh-Hant-TW.lproj/Localizable.strings | 2 ++ 11 files changed, 39 insertions(+), 5 deletions(-) diff --git a/Meshtastic/Extensions/CoreData/PositionEntityExtension.swift b/Meshtastic/Extensions/CoreData/PositionEntityExtension.swift index f1f280e5..0221a1da 100644 --- a/Meshtastic/Extensions/CoreData/PositionEntityExtension.swift +++ b/Meshtastic/Extensions/CoreData/PositionEntityExtension.swift @@ -14,14 +14,13 @@ extension PositionEntity { static func allPositionsFetchRequest() -> NSFetchRequest { let request: NSFetchRequest = PositionEntity.fetchRequest() - request.fetchLimit = 300 + request.fetchLimit = 200 //request.fetchBatchSize = 1 request.returnsObjectsAsFaults = false request.includesSubentities = true request.returnsDistinctResults = true request.sortDescriptors = [NSSortDescriptor(key: "time", ascending: false)] - /// && time >= %@ - let positionPredicate = NSPredicate(format: "nodePosition != nil && (nodePosition.user.shortName != nil || nodePosition.user.shortName != '') && latest == true", Calendar.current.date(byAdding: .day, value: -2, to: Date())! as NSDate) + let positionPredicate = NSPredicate(format: "nodePosition != nil && (nodePosition.user.shortName != nil || nodePosition.user.shortName != '') && latest == true && time >= %@", Calendar.current.date(byAdding: .day, value: -2, to: Date())! as NSDate) let pointOfInterest = LocationHelper.currentLocation diff --git a/Meshtastic/Tips/ChannelTips.swift b/Meshtastic/Tips/ChannelTips.swift index 871af684..be241951 100644 --- a/Meshtastic/Tips/ChannelTips.swift +++ b/Meshtastic/Tips/ChannelTips.swift @@ -42,3 +42,20 @@ struct CreateChannelsTip: Tip { Image(systemName: "fibrechannel") } } + +@available(iOS 17.0, macOS 14.0, *) +struct AdminChannelTip: Tip { + + var id: String { + return "tip.channel.admin" + } + var title: Text { + Text("tip.channel.admin.title") + } + var message: Text? { + Text("tip.channel.admin.message") + } + var image: Image? { + Image(systemName: "fibrechannel") + } +} diff --git a/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift b/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift index 3f316cf5..9cbb352b 100644 --- a/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift +++ b/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift @@ -41,8 +41,6 @@ struct NodeMapSwiftUI: View { ), animation: .none) private var waypoints: FetchedResults - - var body: some View { var mostRecent = node.positions?.lastObject as? PositionEntity diff --git a/Meshtastic/Views/Settings/Settings.swift b/Meshtastic/Views/Settings/Settings.swift index f0b221aa..b990b0f4 100644 --- a/Meshtastic/Views/Settings/Settings.swift +++ b/Meshtastic/Views/Settings/Settings.swift @@ -6,6 +6,9 @@ // import SwiftUI +#if canImport(TipKit) +import TipKit +#endif struct Settings: View { @Environment(\.managedObjectContext) var context @@ -131,6 +134,9 @@ struct Settings: View { } } } + if #available(iOS 17.0, macOS 14.0, *) { + TipView(AdminChannelTip(), arrowEdge: .top) + } } else { if bleManager.connectedPeripheral != nil { Text("Connected Node \(node?.user?.longName ?? "unknown".localized)") diff --git a/de.lproj/Localizable.strings b/de.lproj/Localizable.strings index c3d3d0fc..bf9e8d39 100644 --- a/de.lproj/Localizable.strings +++ b/de.lproj/Localizable.strings @@ -320,6 +320,8 @@ "timestamp"="Timestamp"; "tip.bluetooth.connect.title"="Connected LoRa Radio"; "tip.bluetooth.connect.message"="Shows information for the Lora radio currently connected via bluetooth. You can swipe left to disconnect the radio and long press to view stats or start the live activity."; +"tip.channel.admin.title"="Admin Channel"; +"tip.channel.admin.message"="Admin channel detected: Select a node from the drop down to manage connected or remote devices."; "tip.channels.create.title"="Manage Channels"; "tip.channels.create.message"="Most data on your mesh is sent over the primary channel. You can set up secondary channels to create additional messaging groups secured by their own key. [Channel config tips](https://meshtastic.org/docs/configuration/radio/channels/)"; "tip.channels.share.title"="Sharing Meshtastic Channels"; diff --git a/en.lproj/Localizable.strings b/en.lproj/Localizable.strings index e0d113b8..e031fd63 100644 --- a/en.lproj/Localizable.strings +++ b/en.lproj/Localizable.strings @@ -334,6 +334,8 @@ "timestamp"="Timestamp"; "tip.bluetooth.connect.title"="Connected Radio"; "tip.bluetooth.connect.message"="Shows information for the Lora radio connected via bluetooth. You can swipe left to disconnect the radio and long press to view stats or start the live activity."; +"tip.channel.admin.title"="Admin Channel"; +"tip.channel.admin.message"="Admin channel detected: Select a node from the drop down to manage connected or remote devices."; "tip.channels.create.title"="Manage Channels"; "tip.channels.create.message"="Most data on your mesh is sent over the primary channel. You can set up secondary channels to create additional messaging groups secured by their own key. [Channel config tips](https://meshtastic.org/docs/configuration/tips/)"; "tip.channels.share.title"="Sharing Meshtastic Channels"; diff --git a/fr.lproj/Localizable.strings b/fr.lproj/Localizable.strings index b41a35a4..34a507da 100644 --- a/fr.lproj/Localizable.strings +++ b/fr.lproj/Localizable.strings @@ -302,6 +302,8 @@ "tip.bluetooth.connect.message"="Affiche les informations de la radio Lora connectée via le bluetooth. Vous pouvez faire un glissé vers la gauche pour déconnecter la radio et un appui long pour voir les statistiques ou démarrer l'activité en direct."; "tip.channels.create.title"="Gérer les canaux"; "tip.channels.create.message"="La pluspart des données de votre maillage sont envoyées sur le canal principal. Vous pouvez définir des canaux secondaires pour créer des groupes de messagerie additionnelle sécurisés avec leur propre clé. [Conseils de configuration du canal](https://meshtastic.org/docs/configuration/tips/)"; +"tip.channel.admin.title"="Admin Channel"; +"tip.channel.admin.message"="Admin channel detected: Select a node from the drop down to manage connected or remote devices."; "tip.channels.share.title"="Partage des canaux Meshtastic"; "tip.channels.share.message"="Un code QR Meshtastic contient la configuration LoRa et les valeurs de canal nécessaires pour communiquer. La plupart des activités du maillage ont lieu sur le canal principal requis. Si vous ne partagez pas votre canal principal, votre premier canal partagé devient le canal principal de l’autre réseau. Les autres canaux sont pour les groupes privés, chacun avec sa propre clé."; "tip.messages.title"="Messages"; diff --git a/he.lproj/Localizable.strings b/he.lproj/Localizable.strings index e9dc8ce1..d7e0a05d 100644 --- a/he.lproj/Localizable.strings +++ b/he.lproj/Localizable.strings @@ -324,6 +324,8 @@ "timestamp"="שעה/תאריך"; "tip.bluetooth.connect.title"="מכשיר מחובר"; "tip.bluetooth.connect.message"="מראה מידע אודות מכשיר המשטסטיק המחובר כעת לבלוטוס. ניתן לגרור שמאלה להתנתקות או לחיצה ארוכה לראות סטטיסטיקה או להתחיל פעילות."; +"tip.channel.admin.title"="Admin Channel"; +"tip.channel.admin.message"="Admin channel detected: Select a node from the drop down to manage connected or remote devices."; "tip.channels.create.title"="Manage Channels"; "tip.channels.create.message"="Most data on your mesh is sent over the primary channel. You can set up secondary channels to create additional messaging groups secured by their own key. [Channel config tips](https://meshtastic.org/docs/configuration/radio/channels/)"; "tip.channels.share.title"="משתף ערוצי משטסטיק"; diff --git a/pl.lproj/Localizable.strings b/pl.lproj/Localizable.strings index 5e194834..6a3b18b8 100644 --- a/pl.lproj/Localizable.strings +++ b/pl.lproj/Localizable.strings @@ -321,6 +321,8 @@ "timestamp"="Znacznik czasu"; "tip.bluetooth.connect.title"="Connected LoRa Radio"; "tip.bluetooth.connect.message"="Shows information for the Lora radio currently connected via bluetooth. You can swipe left to disconnect the radio and long press to view stats or start the live activity."; +"tip.channel.admin.title"="Admin Channel"; +"tip.channel.admin.message"="Admin channel detected: Select a node from the drop down to manage connected or remote devices."; "tip.channels.create.title"="Manage Channels"; "tip.channels.create.message"="Most data on your mesh is sent over the primary channel. You can set up secondary channels to create additional messaging groups secured by their own key. [Channel config tips](https://meshtastic.org/docs/configuration/radio/channels/)"; "tip.channels.share.title"="Sharing Meshtastic Channels"; diff --git a/zh-Hans.lproj/Localizable.strings b/zh-Hans.lproj/Localizable.strings index d4521ef2..886cab0a 100644 --- a/zh-Hans.lproj/Localizable.strings +++ b/zh-Hans.lproj/Localizable.strings @@ -320,6 +320,8 @@ "timestamp"="时间戳"; "tip.bluetooth.connect.title"="连接到 LoRa 电台"; "tip.bluetooth.connect.message"="显示当前通过蓝牙连接的 Lora 电台的信息。您可以向左滑动断开电台,长按查看统计信息或开始实时活动。"; +"tip.channel.admin.title"="Admin Channel"; +"tip.channel.admin.message"="Admin channel detected: Select a node from the drop down to manage connected or remote devices."; "tip.channels.create.title"="Manage Channels"; "tip.channels.create.message"="Most data on your mesh is sent over the primary channel. You can set up secondary channels to create additional messaging groups secured by their own key. [Channel config tips](https://meshtastic.org/docs/configuration/radio/channels/)"; "tip.channels.share.title"="共享 Meshtastic 频道"; diff --git a/zh-Hant-TW.lproj/Localizable.strings b/zh-Hant-TW.lproj/Localizable.strings index 8bef85fd..68562e56 100644 --- a/zh-Hant-TW.lproj/Localizable.strings +++ b/zh-Hant-TW.lproj/Localizable.strings @@ -319,6 +319,8 @@ "timestamp"="時間戳記"; "tip.bluetooth.connect.title"="連接到 LoRa 電台"; "tip.bluetooth.connect.message"="顯示目前通過藍芽連接的 Lora 電台的信息。您可以向左滑動斷開電台,長按查看統計訊息或開始即時活動。"; +"tip.channel.admin.title"="Admin Channel"; +"tip.channel.admin.message"="Admin channel detected: Select a node from the drop down to manage connected or remote devices."; "tip.channels.create.title"="管理頻道"; "tip.channels.create.message"="現在 Mesh 上的資料會通過主通道發送。您可以設定輔助通道來建立由自己的金鑰保護的其他訊息組 [頻道設定提示](https://meshtastic.org/docs/configuration/radio/channels/)"; "tip.channels.share.title"="共享 Meshtastic 頻道"; From 9c0430f956ae6af70517912cd8aed11fedd142bd Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Thu, 28 Mar 2024 08:44:10 -0700 Subject: [PATCH 72/74] Remove extra comment --- Meshtastic/Extensions/UserDefaults.swift | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Meshtastic/Extensions/UserDefaults.swift b/Meshtastic/Extensions/UserDefaults.swift index a93a4114..ab5f2ba9 100644 --- a/Meshtastic/Extensions/UserDefaults.swift +++ b/Meshtastic/Extensions/UserDefaults.swift @@ -4,12 +4,6 @@ // // Copyright(c) Garth Vander Houwen 4/24/23. // -// -// UserDefaults.swift -// Meshtastic -// -// Copyright(c) Garth Vander Houwen 4/24/23. -// import Foundation From 1162a7ef441c108912a9f8f75943dc1f4a046207 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Thu, 28 Mar 2024 16:14:57 -0700 Subject: [PATCH 73/74] Show firmware version for remotely administered nodes on the node deails. Don't show the delete waypoint button if you are not conneced to a node --- Meshtastic/Views/Nodes/Helpers/Map/WaypointForm.swift | 2 +- Meshtastic/Views/Nodes/Helpers/NodeInfoItem.swift | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Meshtastic/Views/Nodes/Helpers/Map/WaypointForm.swift b/Meshtastic/Views/Nodes/Helpers/Map/WaypointForm.swift index 54aa5b29..7ab6c7a6 100644 --- a/Meshtastic/Views/Nodes/Helpers/Map/WaypointForm.swift +++ b/Meshtastic/Views/Nodes/Helpers/Map/WaypointForm.swift @@ -187,7 +187,7 @@ struct WaypointForm: View { .controlSize(.regular) .padding(.bottom) - if waypoint.id > 0 { + if waypoint.id > 0 && bleManager.isConnected { Menu { Button("For me", action: { diff --git a/Meshtastic/Views/Nodes/Helpers/NodeInfoItem.swift b/Meshtastic/Views/Nodes/Helpers/NodeInfoItem.swift index 0b381b9c..c3c877f2 100644 --- a/Meshtastic/Views/Nodes/Helpers/NodeInfoItem.swift +++ b/Meshtastic/Views/Nodes/Helpers/NodeInfoItem.swift @@ -79,5 +79,12 @@ struct NodeInfoItem: View { } } Divider() + if node.metadata != nil { + HStack(alignment: .center) { + Text("firmware.version").font(.title2)+Text(": \(node.metadata?.firmwareVersion ?? "unknown".localized)") + .font(.title3).foregroundColor(Color.gray) + } + Divider() + } } } From 170ec3b88baf376035556ee0ec9689925d15f0b5 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Fri, 29 Mar 2024 10:54:30 -0700 Subject: [PATCH 74/74] Fix node map display bug --- .../Map/MapContent/NodeMapContent.swift | 61 +++++++++++-------- 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/Meshtastic/Views/Nodes/Helpers/Map/MapContent/NodeMapContent.swift b/Meshtastic/Views/Nodes/Helpers/Map/MapContent/NodeMapContent.swift index 7805e288..f196bf07 100644 --- a/Meshtastic/Views/Nodes/Helpers/Map/MapContent/NodeMapContent.swift +++ b/Meshtastic/Views/Nodes/Helpers/Map/MapContent/NodeMapContent.swift @@ -44,7 +44,8 @@ struct NodeMapContent: MapContent { let nodeColor = UIColor(hex: UInt32(node.num)) /// Node Annotations - ForEach(positionArray, id: \.id) { position in + ForEach(node.positions?.array as? [PositionEntity] ?? [], id: \.id) { position in + let pf = PositionFlags(rawValue: Int(position.nodePosition?.metadata?.positionFlags ?? 771)) let headingDegrees = Angle.degrees(Double(position.heading)) /// Reduced Precision Map Circle @@ -57,6 +58,7 @@ struct NodeMapContent: MapContent { .stroke(.white, lineWidth: 2) } } + /// Convex Hull if showConvexHull { if lineCoords.count > 0 { let hull = lineCoords.getConvexHull() @@ -78,11 +80,11 @@ struct NodeMapContent: MapContent { MapPolyline(coordinates: lineCoords) .stroke(gradient, style: dashed) } - /// Node Annotations - ForEach(positionArray, id: \.id) { position in + /// Lastest Position Pin + if position.latest { + /// Node Annotations Annotation(position.latest ? node.user?.shortName ?? "?": "", coordinate: position.coordinate) { LazyVStack { - if position.latest { ZStack { Circle() .fill(Color(nodeColor.lighter()).opacity(0.4).shadow(.drop(color: Color(nodeColor).isLight() ? .black : .white, radius: 5))) @@ -124,31 +126,40 @@ struct NodeMapContent: MapContent { } } } - } else { - if showNodeHistory { - if pf.contains(.Heading) { - Image(systemName: "location.north.circle") - .resizable() - .scaledToFit() - .foregroundStyle(Color(UIColor(hex: UInt32(node.num))).isLight() ? .black : .white) - .background(Color(UIColor(hex: UInt32(node.num)))) - .clipShape(Circle()) - .rotationEffect(headingDegrees) - .frame(width: 16, height: 16) - - } else { - Circle() - .fill(Color(UIColor(hex: UInt32(node.num)))) - .strokeBorder(Color(UIColor(hex: UInt32(node.num))).isLight() ? .black : .white ,lineWidth: 2) - .frame(width: 12, height: 12) - } + } + } + // .tag(position.time) + .annotationTitles(.automatic) + .annotationSubtitles(.automatic) + } + /// Node History + if showNodeHistory { + if position.latest == false && position.nodePosition?.user?.vip ?? false { + let pf = PositionFlags(rawValue: Int(position.nodePosition?.metadata?.positionFlags ?? 771)) + let headingDegrees = Angle.degrees(Double(position.heading)) + Annotation("", coordinate: position.coordinate) { + LazyVStack { + if pf.contains(.Heading) { + Image(systemName: "location.north.circle") + .resizable() + .scaledToFit() + .foregroundStyle(Color(UIColor(hex: UInt32(position.nodePosition?.num ?? 0))).isLight() ? .black : .white) + .background(Color(UIColor(hex: UInt32(position.nodePosition?.num ?? 0)))) + .clipShape(Circle()) + .rotationEffect(headingDegrees) + .frame(width: 16, height: 16) + + } else { + Circle() + .fill(Color(UIColor(hex: UInt32(position.nodePosition?.num ?? 0)))) + .strokeBorder(Color(UIColor(hex: UInt32(position.nodePosition?.num ?? 0))).isLight() ? .black : .white ,lineWidth: 2) + .frame(width: 12, height: 12) } } } + .annotationTitles(.hidden) + .annotationSubtitles(.hidden) } - .tag(position.time) - .annotationTitles(.automatic) - .annotationSubtitles(.automatic) } } }