changes for dynamic nodenum assignment

pull/8/head
geeksville 2020-02-08 12:44:56 -08:00
rodzic 11ce60eb6d
commit 4af51e88c7
2 zmienionych plików z 21 dodań i 29 usunięć

Wyświetl plik

@ -359,14 +359,6 @@ class MeshService : Service(), Logging {
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")
}
}

Wyświetl plik

@ -85,8 +85,25 @@ message Data {
bytes payload = 2; // required
}
/* Broadcast when a newly powered mesh node wants to find a node num it can use
// Sent from the phone over bluetooth to set the user id for the owner of this node.
// Also sent from nodes to each other when a new node signs on (so all clients can have this info)
The algorithm is as follows:
* when a node starts up, it broadcasts their user and the normal flow is for all other nodes to reply with their User as well (so the new node can build its node db)
* If a node ever receives a User (not just the first broadcast) message where the sender node number equals our node number, that indicates a collision has occurred and the following steps should happen:
If the receiving node (that was already in the mesh)'s macaddr is LOWER than the new User who just tried to sign in: it gets to keep its nodenum. We send a broadcast message
of OUR User (we use a broadcast so that the other node can receive our message, considering we have the same id - it also serves to let observers correct their nodedb) - this case is rare so it should be okay.
If any node receives a User where the macaddr is GTE than their local macaddr, they have been vetoed and should pick a new random nodenum (filtering against whatever it knows about the nodedb) and
rebroadcast their User.
A few nodenums are reserved and will never be requested:
0xff - broadcast
0 through 3 - for future use
*/
message User {
string id = 1; // a globally unique ID string for this user. In the case of Signal that would mean +16504442323
string long_name = 2; // A full name for this user, i.e. "Kevin Hester"
@ -94,21 +111,6 @@ message User {
bytes macaddr = 4; // This is the addr of the radio. Not populated by the phone, but added by the esp32 when broadcasting
}
// Broadcast when a newly powered mesh node wants to find a node num it can use (see document for more
// details)
// FIXME in the initial proof of concept we just skip the entire want/deny flow and just hand pick node numbers at first.
message WantNodeNum {
uint32 desired_nodenum = 1; // The node number we want (note: these WantNodeNum packets are sent from a few special 'unassigned' nodenumbers)
bytes macaddr = 2; // the unique ID of my node, so that others can descriminate between anyone else who is also accidentially using the same unassigned node number
}
// Sent to a node which has requested a nodenum when it is told it can't have it
// FIXME, should denials be sent as a broadcast also?
// FIXME, how do we handle someone missing the denial and assuming it has the nodenum?
message DenyNodeNum {
bytes 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)
}
// 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 {
@ -119,8 +121,6 @@ message SubPacket {
uint64 time = 2; // msecs since 1970
Data data = 3;
User user = 4;
WantNodeNum want_node = 5;
DenyNodeNum deny_node = 6;
}
}
@ -251,16 +251,16 @@ message DeviceState {
enum Version {
option allow_alias = true;
/// default value for old files before we added version.
Unset = 0;
Unset = 0;
/// We bump up the integer values in this enum to indicate minimum levels of encodings for saved files
/// if your file is below the Minimum you should discard it.
Minimum = 1;
Minimum = 2;
/// The current value we are using for saved files
Current = 1;
Current = 2;
};
Version version = 6;