we now send owner at boot

1.2-legacy
geeksville 2020-02-06 10:58:19 -08:00
rodzic 241e262f5c
commit 2792e2148f
5 zmienionych plików z 44 dodań i 7 usunięć

17
TODO.md
Wyświetl plik

@ -1,7 +1,6 @@
# High priority
* have meshservice periodically send location data on mesh (if device has a GPS)
* implement getCurrentTime() - set based off gps but then updated locally
* send our owner info at boot, reply if we see anyone send theirs
* implement regen owner and radio prefs
* confirm second device receives that gps message and updates device db
@ -41,8 +40,17 @@
* do lowest sleep level possible where BT still works during normal sleeping, make sure cpu stays in that mode unless lora rx packet happens, bt rx packet happens or button press happens
* optionally do lora messaging only during special scheduled intervals (unless nodes are told to go to low latency mode), then deep sleep except during those intervals - before implementing calculate what battery life would be with this feature
# dynamic nodenum assignment tasks
we currently do the following crap solution:
hardwire nodenums based on macaddr. when node boots it broadcasts its Owner info (which includes our macaddr). If any node receives Owner messages, the other nodes reply with their owner info.
Really should instead do something like: new node sends its owner info as a provisional request. If any other node shows that nodenum in use by a different macaddr, they reply with NodeDeny.
If the node doesn't get denied within X seconds it then sends the info as a non provisional message (and other nodes update their node db)
But fixme, think about this and look for standard solutions - it will have problems when meshes separate change and then rejoin.
# Pre-beta priority
* cope with nodes that have 0xff or 0x00 as the last byte of their mac
* use variable length arduino Strings in protobufs (instead of current fixed buffers)
* don't even power on bluetooth until we have some data to send to the android phone. Most of the time we should be sleeping in a lowpower "listening for lora" only mode. Once we have some packets for the phone, then power on bluetooth
until the phone pulls those packets. Ever so often power on bluetooth just so we can see if the phone wants to send some packets. Possibly might need ULP processor to help with this wake process.
@ -78,4 +86,7 @@ until the phone pulls those packets. Ever so often power on bluetooth just so w
* implement new ble characteristics
* have MeshService keep a node DB by sniffing user messages
* have a state machine return the correct FromRadio packet to the phone, it isn't always going to be a MeshPacket. Do a notify on fromnum to force the radio to read our state machine generated packets
* send my_node_num when phone sends WantsNodes
* send my_node_num when phone sends WantsNodes
* have meshservice periodically send location data on mesh (if device has a GPS)
* implement getCurrentTime() - set based off gps but then updated locally
* make default owner record have valid usernames

Wyświetl plik

@ -68,7 +68,7 @@ bool MeshRadio::init()
ErrorCode MeshRadio::send(MeshPacket *p)
{
DEBUG_MSG("enquing packet for sending on mesh\n");
DEBUG_MSG("enquing packet for send from=%d, to=%d\n", p->from, p->to);
return txQueue.enqueue(p, 0); // nowait
}

Wyświetl plik

@ -43,6 +43,18 @@ void MeshService::init()
DEBUG_MSG("radio init failed\n");
gps.addObserver(this);
sendOurOwner();
}
void MeshService::sendOurOwner(NodeNum dest)
{
MeshPacket *p = allocForSending();
p->to = dest;
p->payload.which_variant = SubPacket_user_tag;
User &u = p->payload.variant.user;
u = owner;
sendToMesh(p);
}
/// Do idle processing (mostly processing messages which have been queued from the radio)
@ -89,13 +101,20 @@ void MeshService::sendToMesh(MeshPacket *p)
assert(radio.send(p) == pdTRUE);
}
void MeshService::onGPSChanged()
MeshPacket *MeshService::allocForSending()
{
MeshPacket *p = packetPool.allocZeroed();
p->has_payload = true;
p->from = nodeDB.getNodeNum();
p->to = NODENUM_BROADCAST;
return p;
}
void MeshService::onGPSChanged()
{
MeshPacket *p = allocForSending();
p->payload.which_variant = SubPacket_position_tag;
Position &pos = p->payload.variant.position;
if (gps.altitude.isValid())

Wyświetl plik

@ -57,6 +57,11 @@ public:
/// The owner User record just got updated, update our node DB and broadcast the info into the mesh
void reloadOwner() { DEBUG_MSG("FIXME implement reloadOwner\n"); }
/// Allocate and return a meshpacket which defaults as send to broadcast from the current node.
MeshPacket *allocForSending();
/// Send our owner info to a particular node
void sendOurOwner(NodeNum dest = NODENUM_BROADCAST);
private:
/// Send a packet into the mesh - note p must have been allocated from packetPool. We will return it to that pool after sending.

Wyświetl plik

@ -31,7 +31,7 @@ static NodeNum getDesiredNodeNum()
// FIXME not the right way to guess node numes
uint8_t r = ourMacAddr[5];
assert(r != 0xff); // It better not be the broadcast address
assert(r != 0xff && r != 0); // It better not be the broadcast address or zero
return r;
}
@ -50,6 +50,8 @@ void NodeDB::init() {
ourMacAddr[1], ourMacAddr[2], ourMacAddr[3], ourMacAddr[4], ourMacAddr[5]);
memcpy(owner.macaddr, ourMacAddr, sizeof(owner.macaddr));
sprintf(owner.long_name, "Unknown %02x%02x", ourMacAddr[4], ourMacAddr[5]);
sprintf(owner.short_name, "?%02X", ourMacAddr[5]);
// FIXME, read owner info from flash
// Include our owner in the node db under our nodenum
@ -74,7 +76,7 @@ void NodeDB::updateFrom(const MeshPacket &mp)
if (mp.has_payload)
{
const SubPacket &p = mp.payload;
DEBUG_MSG("Update DB node %x for %d\n", mp.from, p.which_variant);
DEBUG_MSG("Update DB node %x for variant %d\n", mp.from, p.which_variant);
if (p.which_variant != SubPacket_want_node_tag) // we don't create nodeinfo records for someone that is just trying to claim a nodenum
{
int oldNumNodes = numNodes;