mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-20 09:43:03 +00:00
stub encryptor seems nicely backwards compatible with old devices and apps
This commit is contained in:
@@ -92,9 +92,9 @@ void MeshService::sendOurOwner(NodeNum dest, bool wantReplies)
|
||||
{
|
||||
MeshPacket *p = allocForSending();
|
||||
p->to = dest;
|
||||
p->payload.want_response = wantReplies;
|
||||
p->payload.has_user = true;
|
||||
User &u = p->payload.user;
|
||||
p->decoded.want_response = wantReplies;
|
||||
p->decoded.has_user = true;
|
||||
User &u = p->decoded.user;
|
||||
u = owner;
|
||||
DEBUG_MSG("sending owner %s/%s/%s\n", u.id, u.long_name, u.short_name);
|
||||
|
||||
@@ -108,7 +108,7 @@ const MeshPacket *MeshService::handleFromRadioUser(const MeshPacket *mp)
|
||||
bool isCollision = mp->from == myNodeInfo.my_node_num;
|
||||
|
||||
// we win if we have a lower macaddr
|
||||
bool weWin = memcmp(&owner.macaddr, &mp->payload.user.macaddr, sizeof(owner.macaddr)) < 0;
|
||||
bool weWin = memcmp(&owner.macaddr, &mp->decoded.user.macaddr, sizeof(owner.macaddr)) < 0;
|
||||
|
||||
if (isCollision) {
|
||||
if (weWin) {
|
||||
@@ -134,7 +134,7 @@ const MeshPacket *MeshService::handleFromRadioUser(const MeshPacket *mp)
|
||||
|
||||
sendOurOwner(mp->from);
|
||||
|
||||
String lcd = String("Joined: ") + mp->payload.user.long_name + "\n";
|
||||
String lcd = String("Joined: ") + mp->decoded.user.long_name + "\n";
|
||||
screen.print(lcd.c_str());
|
||||
}
|
||||
|
||||
@@ -143,12 +143,12 @@ const MeshPacket *MeshService::handleFromRadioUser(const MeshPacket *mp)
|
||||
|
||||
void MeshService::handleIncomingPosition(const MeshPacket *mp)
|
||||
{
|
||||
if (mp->has_payload && mp->payload.has_position) {
|
||||
DEBUG_MSG("handled incoming position time=%u\n", mp->payload.position.time);
|
||||
if (mp->which_payload == MeshPacket_decoded_tag && mp->decoded.has_position) {
|
||||
DEBUG_MSG("handled incoming position time=%u\n", mp->decoded.position.time);
|
||||
|
||||
if (mp->payload.position.time) {
|
||||
if (mp->decoded.position.time) {
|
||||
struct timeval tv;
|
||||
uint32_t secs = mp->payload.position.time;
|
||||
uint32_t secs = mp->decoded.position.time;
|
||||
|
||||
tv.tv_sec = secs;
|
||||
tv.tv_usec = 0;
|
||||
@@ -171,7 +171,7 @@ int MeshService::handleFromRadio(const MeshPacket *mp)
|
||||
DEBUG_MSG("Ignoring incoming time, because we have a GPS\n");
|
||||
}
|
||||
|
||||
if (mp->has_payload && mp->payload.has_user) {
|
||||
if (mp->which_payload == MeshPacket_decoded_tag && mp->decoded.has_user) {
|
||||
mp = handleFromRadioUser(mp);
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ int MeshService::handleFromRadio(const MeshPacket *mp)
|
||||
MeshPacket *copied = packetPool.allocCopy(*mp);
|
||||
assert(toPhoneQueue.enqueue(copied, 0)); // FIXME, instead of failing for full queue, delete the oldest mssages
|
||||
|
||||
if (mp->payload.want_response)
|
||||
if (mp->decoded.want_response)
|
||||
sendNetworkPing(mp->from);
|
||||
} else {
|
||||
DEBUG_MSG("Not delivering vetoed User message\n");
|
||||
@@ -257,12 +257,12 @@ void MeshService::sendToMesh(MeshPacket *p)
|
||||
// Strip out any time information before sending packets to other nodes - to keep the wire size small (and because other
|
||||
// nodes shouldn't trust it anyways) Note: for now, we allow a device with a local GPS to include the time, so that gpsless
|
||||
// devices can get time.
|
||||
if (p->has_payload && p->payload.has_position) {
|
||||
if (p->which_payload == MeshPacket_decoded_tag && p->decoded.has_position) {
|
||||
if (!gps->isConnected) {
|
||||
DEBUG_MSG("Stripping time %u from position send\n", p->payload.position.time);
|
||||
p->payload.position.time = 0;
|
||||
DEBUG_MSG("Stripping time %u from position send\n", p->decoded.position.time);
|
||||
p->decoded.position.time = 0;
|
||||
} else
|
||||
DEBUG_MSG("Providing time to mesh %u\n", p->payload.position.time);
|
||||
DEBUG_MSG("Providing time to mesh %u\n", p->decoded.position.time);
|
||||
}
|
||||
|
||||
// If the phone sent a packet just to us, don't send it out into the network
|
||||
@@ -282,7 +282,7 @@ MeshPacket *MeshService::allocForSending()
|
||||
{
|
||||
MeshPacket *p = packetPool.allocZeroed();
|
||||
|
||||
p->has_payload = true;
|
||||
p->which_payload = MeshPacket_decoded_tag; // Assume payload is decoded at start.
|
||||
p->from = nodeDB.getNodeNum();
|
||||
p->to = NODENUM_BROADCAST;
|
||||
p->id = generatePacketId();
|
||||
@@ -312,10 +312,10 @@ void MeshService::sendOurPosition(NodeNum dest, bool wantReplies)
|
||||
// Update our local node info with our position (even if we don't decide to update anyone else)
|
||||
MeshPacket *p = allocForSending();
|
||||
p->to = dest;
|
||||
p->payload.has_position = true;
|
||||
p->payload.position = node->position;
|
||||
p->payload.want_response = wantReplies;
|
||||
p->payload.position.time = getValidTime(); // This nodedb timestamp might be stale, so update it if our clock is valid.
|
||||
p->decoded.has_position = true;
|
||||
p->decoded.position = node->position;
|
||||
p->decoded.want_response = wantReplies;
|
||||
p->decoded.position.time = getValidTime(); // This nodedb timestamp might be stale, so update it if our clock is valid.
|
||||
sendToMesh(p);
|
||||
}
|
||||
|
||||
@@ -325,9 +325,9 @@ int MeshService::onGPSChanged(void *unused)
|
||||
|
||||
// Update our local node info with our position (even if we don't decide to update anyone else)
|
||||
MeshPacket *p = allocForSending();
|
||||
p->payload.has_position = true;
|
||||
p->decoded.has_position = true;
|
||||
|
||||
Position &pos = p->payload.position;
|
||||
Position &pos = p->decoded.position;
|
||||
// !zero or !zero lat/long means valid
|
||||
if (gps->latitude != 0 || gps->longitude != 0) {
|
||||
if (gps->altitude != 0)
|
||||
|
||||
Reference in New Issue
Block a user