diff --git a/TODO.md b/TODO.md index 66fe9c63e..43c5d39f4 100644 --- a/TODO.md +++ b/TODO.md @@ -41,6 +41,7 @@ nanopb binaries available here: https://jpa.kapsi.fi/nanopb/download/ use nanopb Don't leave device discoverable. Don't let unpaired users do things with device * remove example code boilerplate from the service * switch from protobuf-java to protobuf-javalite - much faster and smaller, just no JSON debug printing +* if the rxpacket queue on the device overflows (because android hasn't connected in a while) send a special packet to android which means 'X packets have been dropped because you were offline' -drop oldest packets first # Low priority diff --git a/app/src/main/java/com/geeksville/mesh/MeshService.kt b/app/src/main/java/com/geeksville/mesh/MeshService.kt index 1aa5a6e18..b04f9ba18 100644 --- a/app/src/main/java/com/geeksville/mesh/MeshService.kt +++ b/app/src/main/java/com/geeksville/mesh/MeshService.kt @@ -223,10 +223,8 @@ class MeshService : Service(), Logging { destId: String, initFn: MeshProtos.SubPacket.Builder.() -> Unit ): MeshPacket = newMeshPacketTo(destId).apply { - payload = MeshProtos.MeshPayload.newBuilder().apply { - addSubPackets(MeshProtos.SubPacket.newBuilder().also { - initFn(it) - }.build()) + payload = MeshProtos.SubPacket.newBuilder().also { + initFn(it) }.build() }.build() @@ -280,36 +278,34 @@ class MeshService : Service(), Logging { // decided to pass through to us (except for broadcast packets) val toNum = packet.to - val payload = packet.payload - payload.subPacketsList.forEach { p -> - when (p.variantCase.number) { - MeshProtos.SubPacket.POSITION_FIELD_NUMBER -> - updateNodeInfo(fromNum) { - it.position = Position( - p.position.latitude, - p.position.longitude, - p.position.altitude - ) - } - MeshProtos.SubPacket.TIME_FIELD_NUMBER -> - updateNodeInfo(fromNum) { - it.lastSeen = p.time.msecs - } - MeshProtos.SubPacket.DATA_FIELD_NUMBER -> - handleReceivedData(fromNum, p.data) + val p = packet.payload + when (p.variantCase.number) { + MeshProtos.SubPacket.POSITION_FIELD_NUMBER -> + updateNodeInfo(fromNum) { + it.position = Position( + p.position.latitude, + p.position.longitude, + p.position.altitude + ) + } + MeshProtos.SubPacket.TIME_FIELD_NUMBER -> + updateNodeInfo(fromNum) { + it.lastSeen = p.time.msecs + } + MeshProtos.SubPacket.DATA_FIELD_NUMBER -> + handleReceivedData(fromNum, p.data) - MeshProtos.SubPacket.USER_FIELD_NUMBER -> - handleReceivedUser(fromNum, p.user) - MeshProtos.SubPacket.WANT_NODE_FIELD_NUMBER -> { - // This is managed by the radio on its own - debug("Ignoring WANT_NODE from $fromNum") - } - MeshProtos.SubPacket.DENY_NODE_FIELD_NUMBER -> { - // This is managed by the radio on its own - debug("Ignoring DENY_NODE from $fromNum to $toNum") - } - else -> TODO("Unexpected SubPacket variant") + MeshProtos.SubPacket.USER_FIELD_NUMBER -> + handleReceivedUser(fromNum, p.user) + MeshProtos.SubPacket.WANT_NODE_FIELD_NUMBER -> { + // This is managed by the radio on its own + debug("Ignoring WANT_NODE from $fromNum") } + MeshProtos.SubPacket.DENY_NODE_FIELD_NUMBER -> { + // This is managed by the radio on its own + debug("Ignoring DENY_NODE from $fromNum to $toNum") + } + else -> TODO("Unexpected SubPacket variant") } } diff --git a/app/src/main/proto/mesh.proto b/app/src/main/proto/mesh.proto index 8482a14dc..4b7b975cd 100644 --- a/app/src/main/proto/mesh.proto +++ b/app/src/main/proto/mesh.proto @@ -103,7 +103,7 @@ message DenyNodeNum { string macaddr = 1; // the macaddr of the node we are sending this denial to (so that the recipient can be sure the packet really as desined to them) } -// A single packet might have a series of SubPacket included +// The payload portion fo a packet, this is the actual bytes that are sent inside a radio packet (because from/to are broken out by the comms library) message SubPacket { oneof variant { Position position = 1; @@ -115,18 +115,23 @@ message SubPacket { } } +// Note: For simplicity reasons (and that we want to keep over the radio packets very small, we now assume that there is only _one_ +// SubPacket in each MeshPacket). That might change in the far future, but for now that's the case. // A packet sent over our mesh. // NOTE: this raw payload does not include the from and to addresses, which are stripped off // and passed into the mesh library code separately. -message MeshPayload { - repeated SubPacket subPackets = 3; -} +//message MeshPayload { +// repeated SubPacket subPackets = 3; +//} // A full packet sent/received over the mesh message MeshPacket { int32 from = 1; int32 to = 2; - MeshPayload payload = 3; + + // See note above: + // MeshPayload payloads = 4; + SubPacket payload = 3; } // Full settings (center freq, spread factor, pre-shared secret key etc...) needed to configure a radio