WIP for new protobufs

pull/203/head
Kevin Hester 2020-12-07 19:50:06 +08:00
rodzic 663ac774de
commit cc2b99fdfc
7 zmienionych plików z 34 dodań i 26 usunięć

Wyświetl plik

@ -30,8 +30,8 @@ android {
applicationId "com.geeksville.mesh" applicationId "com.geeksville.mesh"
minSdkVersion 21 // The oldest emulator image I have tried is 22 (though 21 probably works) minSdkVersion 21 // The oldest emulator image I have tried is 22 (though 21 probably works)
targetSdkVersion 29 targetSdkVersion 29
versionCode 20109 // format is Mmmss (where M is 1+the numeric major number versionCode 20120 // format is Mmmss (where M is 1+the numeric major number
versionName "1.1.9" versionName "1.1.20"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
} }
buildTypes { buildTypes {
@ -166,7 +166,7 @@ dependencies {
implementation 'com.google.android.gms:play-services-auth:19.0.0' implementation 'com.google.android.gms:play-services-auth:19.0.0'
// Add the Firebase SDK for Crashlytics. // Add the Firebase SDK for Crashlytics.
implementation 'com.google.firebase:firebase-crashlytics:17.2.2' implementation 'com.google.firebase:firebase-crashlytics:17.3.0'
// alas implementation bug deep in the bowels when I tried it for my SyncBluetoothDevice class // alas implementation bug deep in the bowels when I tried it for my SyncBluetoothDevice class
// implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3" // implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3"

Wyświetl plik

@ -133,7 +133,7 @@
<!-- The QR codes to share channel settings are shared as meshtastic URLS <!-- The QR codes to share channel settings are shared as meshtastic URLS
an approximate example: an approximate example:
http://www.meshtastic.org/s/YXNkZnF3ZXJhc2RmcXdlcmFzZGZxd2Vy http://www.meshtastic.org/c/YXNkZnF3ZXJhc2RmcXdlcmFzZGZxd2Vy
--> -->
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />

Wyświetl plik

@ -22,7 +22,7 @@ enum class MessageStatus : Parcelable {
data class DataPacket( data class DataPacket(
var to: String? = ID_BROADCAST, // a nodeID string, or ID_BROADCAST for broadcast var to: String? = ID_BROADCAST, // a nodeID string, or ID_BROADCAST for broadcast
val bytes: ByteArray?, val bytes: ByteArray?,
val dataType: Int, // A value such as MeshProtos.Data.Type.OPAQUE_VALUE 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 from: String? = ID_LOCAL, // a nodeID string, or ID_LOCAL for localhost
var time: Long = System.currentTimeMillis(), // msecs since 1970 var time: Long = System.currentTimeMillis(), // msecs since 1970
var id: Int = 0, // 0 means unassigned var id: Int = 0, // 0 means unassigned
@ -39,14 +39,14 @@ data class DataPacket(
*/ */
constructor(to: String? = ID_BROADCAST, text: String) : this( constructor(to: String? = ID_BROADCAST, text: String) : this(
to, text.toByteArray(utf8), to, text.toByteArray(utf8),
MeshProtos.Data.Type.CLEAR_TEXT_VALUE Portnums.PortNum.TEXT_MESSAGE_APP_VALUE
) )
/** /**
* If this is a text message, return the string, otherwise null * If this is a text message, return the string, otherwise null
*/ */
val text: String? val text: String?
get() = if (dataType == MeshProtos.Data.Type.CLEAR_TEXT_VALUE) get() = if (dataType == Portnums.PortNum.TEXT_MESSAGE_APP_VALUE)
bytes?.toString(utf8) bytes?.toString(utf8)
else else
null null

Wyświetl plik

@ -324,14 +324,14 @@ class MainActivity : AppCompatActivity(), Logging,
DataPacket( DataPacket(
"+16508675310", "+16508675310",
testPayload, testPayload,
MeshProtos.Data.Type.OPAQUE_VALUE Portnums.PortNum.PRIVATE_APP_VALUE
) )
) )
m.send( m.send(
DataPacket( DataPacket(
"+16508675310", "+16508675310",
testPayload, testPayload,
MeshProtos.Data.Type.CLEAR_TEXT_VALUE Portnums.PortNum.TEXT_MESSAGE_APP_VALUE
) )
) )
} }
@ -707,7 +707,7 @@ class MainActivity : AppCompatActivity(), Logging,
intent.getParcelableExtra<DataPacket>(EXTRA_PAYLOAD)!! intent.getParcelableExtra<DataPacket>(EXTRA_PAYLOAD)!!
when (payload.dataType) { when (payload.dataType) {
MeshProtos.Data.Type.CLEAR_TEXT_VALUE -> { Portnums.PortNum.TEXT_MESSAGE_APP_VALUE -> {
model.messagesState.addMessage(payload) model.messagesState.addMessage(payload)
} }
else -> else ->

Wyświetl plik

@ -547,7 +547,7 @@ class MeshService : Service(), Logging {
to = toId, to = toId,
time = rxTime * 1000L, time = rxTime * 1000L,
id = packet.id, id = packet.id,
dataType = data.typValue, dataType = data.portnumValue,
bytes = bytes bytes = bytes
) )
} }
@ -558,7 +558,7 @@ class MeshService : Service(), Logging {
private fun toMeshPacket(p: DataPacket): MeshPacket { private fun toMeshPacket(p: DataPacket): MeshPacket {
return buildMeshPacket(p.to!!, id = p.id, wantAck = true) { return buildMeshPacket(p.to!!, id = p.id, wantAck = true) {
data = MeshProtos.Data.newBuilder().also { data = MeshProtos.Data.newBuilder().also {
it.typ = MeshProtos.Data.Type.forNumber(p.dataType) it.portnumValue = p.dataType
it.payload = ByteString.copyFrom(p.bytes) it.payload = ByteString.copyFrom(p.bytes)
}.build() }.build()
} }
@ -596,26 +596,34 @@ class MeshService : Service(), Logging {
dataPacket.status = MessageStatus.RECEIVED dataPacket.status = MessageStatus.RECEIVED
rememberDataPacket(dataPacket) rememberDataPacket(dataPacket)
when (data.typValue) { when (data.portnumValue) {
MeshProtos.Data.Type.CLEAR_TEXT_VALUE -> { Portnums.PortNum.TEXT_MESSAGE_APP_VALUE -> {
debug("Received CLEAR_TEXT from $fromId") debug("Received CLEAR_TEXT from $fromId")
recentReceivedTextPacket = dataPacket recentReceivedTextPacket = dataPacket
updateNotification() updateNotification()
serviceBroadcasts.broadcastReceivedData(dataPacket)
} }
MeshProtos.Data.Type.CLEAR_READACK_VALUE -> // Handle new style position info
warn( Portnums.PortNum.POSITION_APP_VALUE -> {
"TODO ignoring CLEAR_READACK from $fromId" val rxTime = if (packet.rxTime != 0) packet.rxTime else currentSecond()
) val u = MeshProtos.Position.parseFrom(data.payload)
handleReceivedPosition(packet.from, u, rxTime)
MeshProtos.Data.Type.OPAQUE_VALUE ->
serviceBroadcasts.broadcastReceivedData(dataPacket)
else -> TODO()
} }
// Handle new style user info
Portnums.PortNum.NODEINFO_APP_VALUE -> {
val u = MeshProtos.User.parseFrom(data.payload)
handleReceivedUser(packet.from, u)
}
else -> {
debug("Received other data packet")
}}
// We always tell other apps when new data packets arrive
serviceBroadcasts.broadcastReceivedData(dataPacket)
GeeksvilleApplication.analytics.track( GeeksvilleApplication.analytics.track(
"num_data_receive", "num_data_receive",
DataPair(1) DataPair(1)
@ -624,7 +632,7 @@ class MeshService : Service(), Logging {
GeeksvilleApplication.analytics.track( GeeksvilleApplication.analytics.track(
"data_receive", "data_receive",
DataPair("num_bytes", bytes.size), DataPair("num_bytes", bytes.size),
DataPair("type", data.typValue) DataPair("type", data.portnumValue)
) )
} }
} }

@ -1 +1 @@
Subproject commit a36b31a43c53cab8e62ba04dfbb1fdcc9ecfe821 Subproject commit aac0044b2dcca5daa86c6532c1d8c43475956d31

@ -1 +1 @@
Subproject commit af1a758b0d4ed0b98e412d0aa03195d30f95127a Subproject commit 534f0e192bbbaaa6c32a981534b00451ed708ddc