mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
feat(example): Add packet log and UI improvements (#4455)
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
parent
c44d2f3268
commit
f1520eb383
6 changed files with 258 additions and 97 deletions
|
|
@ -24,7 +24,7 @@ import okio.ByteString.Companion.toByteString
|
|||
|
||||
@Suppress("unused") // These are extension functions meant to be imported elsewhere
|
||||
fun <T : Message<T, *>> ProtoAdapter<T>.decodeOrNull(bytes: ByteString?, logger: Logger? = null): T? {
|
||||
if (bytes == null || bytes.size == 0) return null
|
||||
if (bytes == null) return null
|
||||
return runCatching { decode(bytes) }
|
||||
.onFailure { exception -> logger?.e(exception) { "Failed to decode proto message" } }
|
||||
.getOrNull()
|
||||
|
|
@ -40,7 +40,7 @@ fun <T : Message<T, *>> ProtoAdapter<T>.decodeOrNull(bytes: ByteString?, logger:
|
|||
* @return The decoded message, or null if bytes is null or decoding fails
|
||||
*/
|
||||
fun <T : Message<T, *>> ProtoAdapter<T>.decodeOrNull(bytes: ByteArray?, logger: Logger? = null): T? {
|
||||
if (bytes == null || bytes.isEmpty()) return null
|
||||
if (bytes == null) return null
|
||||
return decodeOrNull(bytes.toByteString(), logger)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue