mirror of
https://github.com/meshtastic/firmware.git
synced 2026-01-09 11:27:29 +00:00
properly route messages to phone again
This commit is contained in:
@@ -28,9 +28,8 @@ int16_t Channels::generateHash(ChannelIndex channelNum)
|
||||
if (k.length < 0)
|
||||
return -1; // invalid
|
||||
else {
|
||||
Channel &c = getByIndex(channelNum);
|
||||
|
||||
uint8_t h = xorHash((const uint8_t *)c.settings.name, strlen(c.settings.name));
|
||||
const char *name = getName(channelNum);
|
||||
uint8_t h = xorHash((const uint8_t *) name, strlen(name));
|
||||
|
||||
h ^= xorHash(k.bytes, k.length);
|
||||
|
||||
@@ -253,7 +252,7 @@ const char *Channels::getPrimaryName()
|
||||
static char buf[32];
|
||||
|
||||
char suffix;
|
||||
auto channelSettings = getPrimary();
|
||||
// auto channelSettings = getPrimary();
|
||||
// if (channelSettings.psk.size != 1) {
|
||||
// We have a standard PSK, so generate a letter based hash.
|
||||
uint8_t code = getHash(primaryIndex);
|
||||
@@ -263,7 +262,7 @@ const char *Channels::getPrimaryName()
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
bool wantsPacket = (pi.isPromiscuous || toUs) && pi.wantPacket(&mp);
|
||||
// DEBUG_MSG("Plugin %s wantsPacket=%d\n", pi.name, wantsPacket);
|
||||
if (wantsPacket) {
|
||||
pluginFound = true;
|
||||
|
||||
@@ -79,7 +80,8 @@ void MeshPlugin::sendResponse(const MeshPacket &req) {
|
||||
service.sendToMesh(r);
|
||||
}
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -119,8 +119,8 @@ uint32_t RadioInterface::getTxDelayMsec()
|
||||
|
||||
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,
|
||||
p->hop_limit);
|
||||
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->channel);
|
||||
if (p->which_payloadVariant == MeshPacket_decoded_tag) {
|
||||
auto &s = p->decoded;
|
||||
|
||||
|
||||
@@ -232,6 +232,7 @@ bool Router::perhapsDecode(MeshPacket *p)
|
||||
} else {
|
||||
// parsing was successful
|
||||
p->channel = chIndex; // change to store the index instead of the hash
|
||||
// printPacket("decoded message", p);
|
||||
p->which_payloadVariant = MeshPacket_decoded_tag;
|
||||
return true;
|
||||
}
|
||||
@@ -257,7 +258,10 @@ void Router::handleReceived(MeshPacket *p)
|
||||
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
|
||||
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
|
||||
|
||||
// call any promiscious plugins here, make a (non promisiocous) plugin for forwarding messages to phone api
|
||||
|
||||
Reference in New Issue
Block a user