properly route messages to phone again

pull/706/head
Kevin Hester 2021-02-23 14:35:34 +08:00
rodzic aa8b86c6b2
commit f8d8dc25c0
7 zmienionych plików z 31 dodań i 14 usunięć

Wyświetl plik

@ -15,11 +15,14 @@ You probably don't care about this section - skip to the next one.
* DONE enable remote setttings access by moving settings operations into a regular plugin (move settings ops out of PhoneAPI) * DONE enable remote setttings access by moving settings operations into a regular plugin (move settings ops out of PhoneAPI)
* DONE move portnum up? * DONE move portnum up?
* DONE remove region specific builds from the firmware * DONE remove region specific builds from the firmware
* test single channel without python * DONE test single channel without python
* test single channel with python * DONE Use "default" for name if name is empty
* implement 'get channels' Admin operation * DONE fix python data packet receiving (nothing showing in log?)
* implement 'get channels' Admin plugin operation
* use get-channels from python * use get-channels from python
* use set-channel from python * use set-channel from python
* make python tests more exhaustive
* document the relationship between want_response (indicating remote node received it) and want_ack (indicating that this message should be sent reliably - and also get acks from the first rx node and naks if it is never delivered)
* test multi channel * test multi channel
* pick default random admin key * pick default random admin key
* restrict gpio & serial & settings operations to the admin channel (unless local to the current node) * restrict gpio & serial & settings operations to the admin channel (unless local to the current node)

Wyświetl plik

@ -28,9 +28,8 @@ int16_t Channels::generateHash(ChannelIndex channelNum)
if (k.length < 0) if (k.length < 0)
return -1; // invalid return -1; // invalid
else { else {
Channel &c = getByIndex(channelNum); const char *name = getName(channelNum);
uint8_t h = xorHash((const uint8_t *) name, strlen(name));
uint8_t h = xorHash((const uint8_t *)c.settings.name, strlen(c.settings.name));
h ^= xorHash(k.bytes, k.length); h ^= xorHash(k.bytes, k.length);
@ -253,7 +252,7 @@ const char *Channels::getPrimaryName()
static char buf[32]; static char buf[32];
char suffix; char suffix;
auto channelSettings = getPrimary(); // auto channelSettings = getPrimary();
// if (channelSettings.psk.size != 1) { // if (channelSettings.psk.size != 1) {
// We have a standard PSK, so generate a letter based hash. // We have a standard PSK, so generate a letter based hash.
uint8_t code = getHash(primaryIndex); uint8_t code = getHash(primaryIndex);
@ -263,7 +262,7 @@ const char *Channels::getPrimaryName()
suffix = '0' + channelSettings.psk.bytes[0]; suffix = '0' + channelSettings.psk.bytes[0];
} */ } */
snprintf(buf, sizeof(buf), "#%s-%c", channelSettings.name, suffix); snprintf(buf, sizeof(buf), "#%s-%c", getName(primaryIndex), suffix);
return buf; return buf;
} }

Wyświetl plik

@ -41,6 +41,7 @@ void MeshPlugin::callPlugins(const MeshPacket &mp)
// We only call plugins that are interested in the packet (and the message is destined to us or we are promiscious) // We only call plugins that are interested in the packet (and the message is destined to us or we are promiscious)
bool wantsPacket = (pi.isPromiscuous || toUs) && pi.wantPacket(&mp); bool wantsPacket = (pi.isPromiscuous || toUs) && pi.wantPacket(&mp);
// DEBUG_MSG("Plugin %s wantsPacket=%d\n", pi.name, wantsPacket);
if (wantsPacket) { if (wantsPacket) {
pluginFound = true; pluginFound = true;
@ -79,7 +80,8 @@ void MeshPlugin::sendResponse(const MeshPacket &req) {
service.sendToMesh(r); service.sendToMesh(r);
} }
else { else {
DEBUG_MSG("WARNING: Client requested response but this plugin did not provide\n"); // Ignore - this is now expected behavior for routing plugin (because it ignores some replies)
// DEBUG_MSG("WARNING: Client requested response but this plugin did not provide\n");
} }
} }

Wyświetl plik

@ -119,8 +119,8 @@ uint32_t RadioInterface::getTxDelayMsec()
void printPacket(const char *prefix, const MeshPacket *p) void printPacket(const char *prefix, const MeshPacket *p)
{ {
DEBUG_MSG("%s (id=0x%08x Fr0x%02x To0x%02x, WantAck%d, HopLim%d", prefix, p->id, p->from & 0xff, p->to & 0xff, p->want_ack, DEBUG_MSG("%s (id=0x%08x Fr0x%02x To0x%02x, WantAck%d, HopLim%d Ch0x%x", prefix, p->id, p->from & 0xff, p->to & 0xff, p->want_ack,
p->hop_limit); p->hop_limit, p->channel);
if (p->which_payloadVariant == MeshPacket_decoded_tag) { if (p->which_payloadVariant == MeshPacket_decoded_tag) {
auto &s = p->decoded; auto &s = p->decoded;

Wyświetl plik

@ -232,6 +232,7 @@ bool Router::perhapsDecode(MeshPacket *p)
} else { } else {
// parsing was successful // parsing was successful
p->channel = chIndex; // change to store the index instead of the hash p->channel = chIndex; // change to store the index instead of the hash
// printPacket("decoded message", p);
p->which_payloadVariant = MeshPacket_decoded_tag; p->which_payloadVariant = MeshPacket_decoded_tag;
return true; return true;
} }
@ -257,7 +258,10 @@ void Router::handleReceived(MeshPacket *p)
p->rx_time = getValidTime(RTCQualityFromNet); // store the arrival timestamp for the phone p->rx_time = getValidTime(RTCQualityFromNet); // store the arrival timestamp for the phone
// Take those raw bytes and convert them back into a well structured protobuf we can understand // Take those raw bytes and convert them back into a well structured protobuf we can understand
if (perhapsDecode(p)) { bool decoded = perhapsDecode(p);
printPacket("handleReceived", p);
DEBUG_MSG("decoded=%d\n", decoded);
if (decoded) {
// parsing was successful, queue for our recipient // parsing was successful, queue for our recipient
// call any promiscious plugins here, make a (non promisiocous) plugin for forwarding messages to phone api // call any promiscious plugins here, make a (non promisiocous) plugin for forwarding messages to phone api

Wyświetl plik

@ -9,6 +9,7 @@ RoutingPlugin *routingPlugin;
bool RoutingPlugin::handleReceivedProtobuf(const MeshPacket &mp, const Routing *r) bool RoutingPlugin::handleReceivedProtobuf(const MeshPacket &mp, const Routing *r)
{ {
DEBUG_MSG("Routing sniffing", &mp);
router->sniffReceived(&mp, r); router->sniffReceived(&mp, r);
// FIXME - move this to a non promsicious PhoneAPI plugin? // FIXME - move this to a non promsicious PhoneAPI plugin?
@ -23,8 +24,13 @@ bool RoutingPlugin::handleReceivedProtobuf(const MeshPacket &mp, const Routing *
MeshPacket *RoutingPlugin::allocReply() MeshPacket *RoutingPlugin::allocReply()
{ {
assert(0); // 1.2 refactoring fixme, Not sure if anything needs this yet? assert(currentRequest);
// return allocDataProtobuf(u);
// We only consider making replies if the request was a legit routing packet (not just something we were sniffing)
if(currentRequest->decoded.portnum == PortNum_ROUTING_APP) {
assert(0); // 1.2 refactoring fixme, Not sure if anything needs this yet?
// return allocDataProtobuf(u);
}
return NULL; return NULL;
} }

Wyświetl plik

@ -25,6 +25,9 @@ class RoutingPlugin : public ProtobufPlugin<Routing>
* so that subclasses can (optionally) send a response back to the original sender. */ * so that subclasses can (optionally) send a response back to the original sender. */
virtual MeshPacket *allocReply(); virtual MeshPacket *allocReply();
/// Override wantPacket to say we want to see all packets, not just those for our port number
virtual bool wantPacket(const MeshPacket *p) { return true; }
void sendAckNak(Routing_Error err, NodeNum to, PacketId idFrom); void sendAckNak(Routing_Error err, NodeNum to, PacketId idFrom);
}; };