kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
pass pack exceptions via RemoteExceptions
rodzic
0cca88575d
commit
a306c4466d
|
@ -3,22 +3,22 @@ package com.geeksville.mesh;
|
|||
|
||||
// Declare any non-default types here with import statements
|
||||
|
||||
/**
|
||||
* Note - these calls might throw RemoteException to indicate mesh error states
|
||||
*/
|
||||
interface IMeshService {
|
||||
/**
|
||||
* Set the ID info for this node
|
||||
|
||||
@return null for success, or an error message for failure
|
||||
*/
|
||||
String setOwner(String myId, String longName, String shortName);
|
||||
void setOwner(String myId, String longName, String shortName);
|
||||
|
||||
/*
|
||||
Send an opaque packet to a specified node name
|
||||
|
||||
typ is defined in mesh.proto Data.Type. For now juse use 0 to mean opaque bytes.
|
||||
|
||||
@return null for success, or an error message for failure
|
||||
*/
|
||||
String sendData(String destId, in byte[] payload, int typ);
|
||||
void sendData(String destId, in byte[] payload, int typ);
|
||||
|
||||
/**
|
||||
Get the IDs of everyone on the mesh. You should also subscribe for NODE_CHANGE broadcasts.
|
||||
|
|
|
@ -9,9 +9,8 @@ import android.os.IBinder
|
|||
import com.geeksville.android.Logging
|
||||
import com.geeksville.mesh.MeshProtos.MeshPacket
|
||||
import com.geeksville.mesh.MeshProtos.ToRadio
|
||||
import com.geeksville.util.exceptionReporter
|
||||
import com.geeksville.util.exceptionsToStrings
|
||||
import com.geeksville.util.toOneLineString
|
||||
import com.geeksville.util.toRemoteExceptions
|
||||
import com.google.protobuf.ByteString
|
||||
import java.nio.charset.Charset
|
||||
|
||||
|
@ -292,7 +291,7 @@ class MeshService : Service(), Logging {
|
|||
// per https://blog.classycode.com/dealing-with-exceptions-in-aidl-9ba904c6d63
|
||||
|
||||
override fun setOwner(myId: String, longName: String, shortName: String) =
|
||||
exceptionsToStrings {
|
||||
toRemoteExceptions {
|
||||
error("TODO setOwner $myId : $longName : $shortName")
|
||||
|
||||
val user = MeshProtos.User.newBuilder().also {
|
||||
|
@ -312,7 +311,7 @@ class MeshService : Service(), Logging {
|
|||
}
|
||||
|
||||
override fun sendData(destId: String, payloadIn: ByteArray, typ: Int) =
|
||||
exceptionsToStrings {
|
||||
toRemoteExceptions {
|
||||
info("sendData $destId <- ${payloadIn.size} bytes")
|
||||
|
||||
// encapsulate our payload in the proper protobufs and fire it off
|
||||
|
@ -328,14 +327,14 @@ class MeshService : Service(), Logging {
|
|||
})
|
||||
}
|
||||
|
||||
override fun getOnline(): Array<String> = exceptionReporter {
|
||||
override fun getOnline(): Array<String> = toRemoteExceptions {
|
||||
val r = nodeDBbyID.keys.toTypedArray()
|
||||
info("in getOnline, count=${r.size}")
|
||||
// return arrayOf("+16508675309")
|
||||
r
|
||||
}
|
||||
|
||||
override fun isConnected(): Boolean = exceptionReporter {
|
||||
override fun isConnected(): Boolean = toRemoteExceptions {
|
||||
val r = this@MeshService.isConnected
|
||||
info("in isConnected=r")
|
||||
r
|
||||
|
|
Ładowanie…
Reference in New Issue