kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
WIP for new protobufs
rodzic
663ac774de
commit
cc2b99fdfc
|
@ -30,8 +30,8 @@ android {
|
|||
applicationId "com.geeksville.mesh"
|
||||
minSdkVersion 21 // The oldest emulator image I have tried is 22 (though 21 probably works)
|
||||
targetSdkVersion 29
|
||||
versionCode 20109 // format is Mmmss (where M is 1+the numeric major number
|
||||
versionName "1.1.9"
|
||||
versionCode 20120 // format is Mmmss (where M is 1+the numeric major number
|
||||
versionName "1.1.20"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
buildTypes {
|
||||
|
@ -166,7 +166,7 @@ dependencies {
|
|||
implementation 'com.google.android.gms:play-services-auth:19.0.0'
|
||||
|
||||
// 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
|
||||
// implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3"
|
||||
|
|
|
@ -133,7 +133,7 @@
|
|||
<!-- The QR codes to share channel settings are shared as meshtastic URLS
|
||||
|
||||
an approximate example:
|
||||
http://www.meshtastic.org/s/YXNkZnF3ZXJhc2RmcXdlcmFzZGZxd2Vy
|
||||
http://www.meshtastic.org/c/YXNkZnF3ZXJhc2RmcXdlcmFzZGZxd2Vy
|
||||
-->
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ enum class MessageStatus : Parcelable {
|
|||
data class DataPacket(
|
||||
var to: String? = ID_BROADCAST, // a nodeID string, or ID_BROADCAST for broadcast
|
||||
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 time: Long = System.currentTimeMillis(), // msecs since 1970
|
||||
var id: Int = 0, // 0 means unassigned
|
||||
|
@ -39,14 +39,14 @@ data class DataPacket(
|
|||
*/
|
||||
constructor(to: String? = ID_BROADCAST, text: String) : this(
|
||||
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
|
||||
*/
|
||||
val text: String?
|
||||
get() = if (dataType == MeshProtos.Data.Type.CLEAR_TEXT_VALUE)
|
||||
get() = if (dataType == Portnums.PortNum.TEXT_MESSAGE_APP_VALUE)
|
||||
bytes?.toString(utf8)
|
||||
else
|
||||
null
|
||||
|
|
|
@ -324,14 +324,14 @@ class MainActivity : AppCompatActivity(), Logging,
|
|||
DataPacket(
|
||||
"+16508675310",
|
||||
testPayload,
|
||||
MeshProtos.Data.Type.OPAQUE_VALUE
|
||||
Portnums.PortNum.PRIVATE_APP_VALUE
|
||||
)
|
||||
)
|
||||
m.send(
|
||||
DataPacket(
|
||||
"+16508675310",
|
||||
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)!!
|
||||
|
||||
when (payload.dataType) {
|
||||
MeshProtos.Data.Type.CLEAR_TEXT_VALUE -> {
|
||||
Portnums.PortNum.TEXT_MESSAGE_APP_VALUE -> {
|
||||
model.messagesState.addMessage(payload)
|
||||
}
|
||||
else ->
|
||||
|
|
|
@ -547,7 +547,7 @@ class MeshService : Service(), Logging {
|
|||
to = toId,
|
||||
time = rxTime * 1000L,
|
||||
id = packet.id,
|
||||
dataType = data.typValue,
|
||||
dataType = data.portnumValue,
|
||||
bytes = bytes
|
||||
)
|
||||
}
|
||||
|
@ -558,7 +558,7 @@ class MeshService : Service(), Logging {
|
|||
private fun toMeshPacket(p: DataPacket): MeshPacket {
|
||||
return buildMeshPacket(p.to!!, id = p.id, wantAck = true) {
|
||||
data = MeshProtos.Data.newBuilder().also {
|
||||
it.typ = MeshProtos.Data.Type.forNumber(p.dataType)
|
||||
it.portnumValue = p.dataType
|
||||
it.payload = ByteString.copyFrom(p.bytes)
|
||||
}.build()
|
||||
}
|
||||
|
@ -596,25 +596,33 @@ class MeshService : Service(), Logging {
|
|||
dataPacket.status = MessageStatus.RECEIVED
|
||||
rememberDataPacket(dataPacket)
|
||||
|
||||
when (data.typValue) {
|
||||
MeshProtos.Data.Type.CLEAR_TEXT_VALUE -> {
|
||||
when (data.portnumValue) {
|
||||
Portnums.PortNum.TEXT_MESSAGE_APP_VALUE -> {
|
||||
debug("Received CLEAR_TEXT from $fromId")
|
||||
|
||||
recentReceivedTextPacket = dataPacket
|
||||
updateNotification()
|
||||
serviceBroadcasts.broadcastReceivedData(dataPacket)
|
||||
}
|
||||
|
||||
MeshProtos.Data.Type.CLEAR_READACK_VALUE ->
|
||||
warn(
|
||||
"TODO ignoring CLEAR_READACK from $fromId"
|
||||
)
|
||||
// Handle new style position info
|
||||
Portnums.PortNum.POSITION_APP_VALUE -> {
|
||||
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)
|
||||
// Handle new style user info
|
||||
Portnums.PortNum.NODEINFO_APP_VALUE -> {
|
||||
val u = MeshProtos.User.parseFrom(data.payload)
|
||||
handleReceivedUser(packet.from, u)
|
||||
}
|
||||
|
||||
else -> TODO()
|
||||
}
|
||||
else -> {
|
||||
debug("Received other data packet")
|
||||
}}
|
||||
|
||||
// We always tell other apps when new data packets arrive
|
||||
serviceBroadcasts.broadcastReceivedData(dataPacket)
|
||||
|
||||
GeeksvilleApplication.analytics.track(
|
||||
"num_data_receive",
|
||||
|
@ -624,7 +632,7 @@ class MeshService : Service(), Logging {
|
|||
GeeksvilleApplication.analytics.track(
|
||||
"data_receive",
|
||||
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
|
Ładowanie…
Reference in New Issue