Skip to content

Commit

Permalink
1.0.35
Browse files Browse the repository at this point in the history
Updates for new NodeInfo and protobufs
Also fixed the geochat bug where the same text couldnt be shown twice
  • Loading branch information
niccellular committed Oct 2, 2024
1 parent e388685 commit a659440
Show file tree
Hide file tree
Showing 11 changed files with 510 additions and 99 deletions.
13 changes: 12 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
buildscript {


ext.PLUGIN_VERSION = "1.0.33"
ext.PLUGIN_VERSION = "1.0.35"
ext.ATAK_VERSION = "4.10.0"

def takdevVersion = '2.+'
Expand Down Expand Up @@ -231,6 +231,17 @@ dependencies {
implementation 'net.java.dev.jna:jna:5.13.0@aar'
implementation 'com.alphacephei:vosk-android:0.3.47@aar'
implementation project(':models')

// Osmdroid & Maps
def osmdroid_version = '6.1.14'
implementation "org.osmdroid:osmdroid-android:$osmdroid_version"
implementation "org.osmdroid:osmdroid-wms:$osmdroid_version"
implementation("org.osmdroid:osmdroid-geopackage:$osmdroid_version") {
exclude group: 'com.j256.ormlite'
}
implementation 'com.github.MKergall:osmbonuspack:6.9.0'
implementation "mil.nga:mgrs:2.1.3"

}

protobuf {
Expand Down
21 changes: 11 additions & 10 deletions app/src/main/aidl/com/geeksville/mesh/IMeshService.aidl
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,12 @@ Once you have bound to the service you should register your broadcast receivers
// com.geeksville.mesh.x broadcast intents, where x is:
// RECEIVED_DATA for data received from other nodes. payload will contain a DataPacket, this action is DEPRECATED (because it sends all received data)
// far better to instead use RECEIVED.<portnumm>
// RECEIVED.<portnumm> - will **only** deliver packets for the specified port number. If a wellknown portnums.proto name for portnum is known it will be used
// (i.e. com.geeksville.mesh.RECEIVED.TEXT_MESSAGE_APP) else the numeric portnum will be included as a base 10 integer (com.geeksville.mesh.RECEIVED.4403 etc...)
// NODE_CHANGE for new IDs appearing or disappearing
// CONNECTION_CHANGED for losing/gaining connection to the packet radio
// MESSAGE_STATUS_CHANGED for any message status changes (for sent messages only, other messages come via RECEIVED_DATA. payload will contain a message ID and a MessageStatus)
At the very least you will probably want to receive RECEIVED_DATA.
// MESSAGE_STATUS_CHANGED for any message status changes (for sent messages only, payload will contain a message ID and a MessageStatus)
Note - these calls might throw RemoteException to indicate mesh error states
*/
Expand All @@ -58,7 +53,7 @@ interface IMeshService {
*/
void setOwner(in MeshUser user);

void setRemoteOwner(in int destNum, in byte []payload);
void setRemoteOwner(in int requestId, in byte []payload);
void getRemoteOwner(in int requestId, in int destNum);

/// Return my unique user ID string
Expand Down Expand Up @@ -91,11 +86,11 @@ interface IMeshService {
void setConfig(in byte []payload);

/// Set and get a Config protobuf via admin packet
void setRemoteConfig(in int destNum, in byte []payload);
void setRemoteConfig(in int requestId, in int destNum, in byte []payload);
void getRemoteConfig(in int requestId, in int destNum, in int configTypeValue);

/// Set and get a ModuleConfig protobuf via admin packet
void setModuleConfig(in int destNum, in byte []payload);
void setModuleConfig(in int requestId, in int destNum, in byte []payload);
void getModuleConfig(in int requestId, in int destNum, in int moduleConfigTypeValue);

/// Set and get the Ext Notification Ringtone string via admin packet
Expand All @@ -111,7 +106,7 @@ interface IMeshService {
void setChannel(in byte []payload);

/// Set and get a Channel protobuf via admin packet
void setRemoteChannel(in int destNum, in byte []payload);
void setRemoteChannel(in int requestId, in int destNum, in byte []payload);
void getRemoteChannel(in int requestId, in int destNum, in int channelIndex);

/// Send beginEditSettings admin packet to nodeNum
Expand All @@ -120,9 +115,15 @@ interface IMeshService {
/// Send commitEditSettings admin packet to nodeNum
void commitEditSettings();

/// delete a specific nodeNum from nodeDB
void removeByNodenum(in int requestID, in int nodeNum);

/// Send position packet with wantResponse to nodeNum
void requestPosition(in int destNum, in Position position);

/// Send setFixedPosition admin packet (or removeFixedPosition if Position is empty)
void setFixedPosition(in int destNum, in Position position);

/// Send traceroute packet with wantResponse to nodeNum
void requestTraceroute(in int requestId, in int destNum);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,11 +380,11 @@ public void processCotEvent(CotEvent cotEvent, String[] strings) {
e.printStackTrace();
return;
}

/*
if (cotEvent.getUID().startsWith("!") && cotEvent.getType().equals("a-f-G-E-S")) {
Log.d(TAG, "Don't forward Meshtastic Nodes");
return;
} else if (cotEvent.getUID().equals(getMapView().getSelfMarker().getUID())) {
} else */if (cotEvent.getUID().equals(getMapView().getSelfMarker().getUID())) {
// self PLI report
/*
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
Expand Down Expand Up @@ -793,7 +793,7 @@ public void onCreate(final Context context, Intent intent, MapView view) {
prefs = PreferenceManager.getDefaultSharedPreferences(MapView.getMapView().getContext());
editor = prefs.edit();
editor.putBoolean("plugin_meshtastic_file_transfer", false);
editor.putBoolean("plugin_meshtastic_chunking", true);
editor.putBoolean("plugin_meshtastic_chunking", false);
editor.apply();
prefs.registerOnSharedPreferenceChangeListener(this);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import android.os.Bundle;
import android.os.Environment;
import android.os.RemoteException;
import android.os.SystemClock;
import android.preference.PreferenceManager;
import android.speech.tts.TextToSpeech;
import android.widget.Toast;
Expand Down Expand Up @@ -472,6 +473,9 @@ public void onReceive(Context context, Intent intent) {
contactDetail.setAttribute("endpoint", "0.0.0.0:4242:tcp");
cotDetail.addChild(contactDetail);

CotDetail meshDetail = new CotDetail("__meshtastic");
cotDetail.addChild(meshDetail);

if (cotEvent.isValid()) {
CotMapComponent.getInternalDispatcher().dispatch(cotEvent);
if (prefs.getBoolean("plugin_meshtastic_server", false)) {
Expand Down Expand Up @@ -848,7 +852,7 @@ else if (team.equals("DarkGreen"))

String callsign = contact.getCallsign();
String deviceCallsign = contact.getDeviceCallsign();
String msgId = callsign + "-" + deviceCallsign + "-" + geoChat.getMessage().hashCode();
String msgId = callsign + "-" + deviceCallsign + "-" + geoChat.getMessage().hashCode() + "-" + System.currentTimeMillis();

//Bundle chatMessage = ChatDatabase.getInstance(_mapView.getContext()).getChatMessage(msgId);
//if (chatMessage != null) {
Expand Down Expand Up @@ -949,7 +953,7 @@ else if (team.equals("DarkGreen"))
String to = geoChat.getTo();
String callsign = contact.getCallsign();
String deviceCallsign = contact.getDeviceCallsign();
String msgId = callsign + "-" + deviceCallsign + "-" + geoChat.getMessage().hashCode();
String msgId = callsign + "-" + deviceCallsign + "-" + geoChat.getMessage().hashCode() + "-" + System.currentTimeMillis();

//Bundle chatMessage = ChatDatabase.getInstance(_mapView.getContext()).getChatMessage(msgId);
//if (chatMessage != null) {
Expand Down
74 changes: 56 additions & 18 deletions app/src/main/java/com/geeksville/mesh/DataPacket.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.geeksville.mesh
import android.os.Parcel
import android.os.Parcelable
import kotlinx.parcelize.Parcelize
import kotlinx.serialization.Serializable

/**
* Generic [Parcel.readParcelable] Android 13 compatibility extension.
Expand All @@ -15,6 +16,7 @@ private inline fun <reified T : Parcelable> Parcel.readParcelableCompat(loader:
readParcelable(loader, T::class.java)
}
}

@Parcelize
enum class MessageStatus : Parcelable {
UNKNOWN, // Not set for this message
Expand All @@ -28,35 +30,68 @@ enum class MessageStatus : Parcelable {
/**
* A parcelable version of the protobuf MeshPacket + Data subpacket.
*/
@Serializable
data class DataPacket(
var to: String? = ID_BROADCAST, // a nodeID string, or ID_BROADCAST for broadcast
val bytes: ByteArray?,
val dataType: Int, // A port number for this packet (formerly called DataType, see portnums.proto for new usage instructions)
var from: String? = ID_LOCAL, // a nodeID string, or ID_LOCAL for localhost
var time: Long = System.currentTimeMillis(), // msecs since 1970
var id: Int = 0, // 0 means unassigned
var status: MessageStatus? = MessageStatus.UNKNOWN,
var hopLimit: Int = 0,
var channel: Int = 0, // channel index
var to: String? = ID_BROADCAST, // a nodeID string, or ID_BROADCAST for broadcast
val bytes: ByteArray?,
val dataType: Int, // A port number for this packet (formerly called DataType, see portnums.proto for new usage instructions)
var from: String? = ID_LOCAL, // a nodeID string, or ID_LOCAL for localhost
var time: Long = System.currentTimeMillis(), // msecs since 1970
var id: Int = 0, // 0 means unassigned
var status: MessageStatus? = MessageStatus.UNKNOWN,
var hopLimit: Int = 0,
var channel: Int = 0, // channel index
) : Parcelable {

/**
* If there was an error with this message, this string describes what was wrong.
*/
var errorMessage: String? = null

/**
* Syntactic sugar to make it easy to create text messages
*/
constructor(to: String?, channel: Int, text: String) : this(
to = to,
bytes = text.encodeToByteArray(),
dataType = Portnums.PortNum.TEXT_MESSAGE_APP_VALUE,
channel = channel
)

/**
* If this is a text message, return the string, otherwise null
*/
val text: String?
get() = if (dataType == Portnums.PortNum.TEXT_MESSAGE_APP_VALUE)
bytes?.decodeToString()
else
null

constructor(to: String?, channel: Int, waypoint: MeshProtos.Waypoint) : this(
to = to,
bytes = waypoint.toByteArray(),
dataType = Portnums.PortNum.WAYPOINT_APP_VALUE,
channel = channel
)

val waypoint: MeshProtos.Waypoint?
get() = if (dataType == Portnums.PortNum.WAYPOINT_APP_VALUE)
MeshProtos.Waypoint.parseFrom(bytes)
else
null

// Autogenerated comparision, because we have a byte array

constructor(parcel: Parcel) : this(
parcel.readString(),
parcel.createByteArray(),
parcel.readInt(),
parcel.readString(),
parcel.readLong(),
parcel.readInt(),
parcel.readParcelableCompat(MessageStatus::class.java.classLoader),
parcel.readInt(),
parcel.readInt(),
parcel.readString(),
parcel.createByteArray(),
parcel.readInt(),
parcel.readString(),
parcel.readLong(),
parcel.readInt(),
parcel.readParcelableCompat(MessageStatus::class.java.classLoader),
parcel.readInt(),
parcel.readInt(),
)

override fun equals(other: Any?): Boolean {
Expand Down Expand Up @@ -132,6 +167,9 @@ data class DataPacket(
/// special broadcast address
const val NODENUM_BROADCAST = (0xffffffff).toInt()

// Public-key cryptography (PKC) channel index
const val PKC_CHANNEL_INDEX = 8

fun nodeNumToDefaultId(n: Int): String = "!%08x".format(n)
fun idToDefaultNodeNum(id: String?): Int? = id?.toLong(16)?.toInt()

Expand Down
5 changes: 0 additions & 5 deletions app/src/main/java/com/geeksville/mesh/MyNodeInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ package com.geeksville.mesh
import android.os.Parcelable
import kotlinx.parcelize.Parcelize

/**
* Room [Entity] and [PrimaryKey] annotations and imports can be removed when only using the API.
* For details check the AIDL interface in [com.geeksville.mesh.IMeshService]
*/

// MyNodeInfo sent via special protobuf from radio
@Parcelize
data class MyNodeInfo(
Expand Down
Loading

0 comments on commit a659440

Please sign in to comment.