kopia lustrzana https://github.com/meshtastic/firmware
properly route messages to phone again
rodzic
aa8b86c6b2
commit
f8d8dc25c0
|
@ -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 move portnum up?
|
||||
* DONE remove region specific builds from the firmware
|
||||
* test single channel without python
|
||||
* test single channel with python
|
||||
* implement 'get channels' Admin operation
|
||||
* DONE test single channel without python
|
||||
* DONE Use "default" for name if name is empty
|
||||
* DONE fix python data packet receiving (nothing showing in log?)
|
||||
* implement 'get channels' Admin plugin operation
|
||||
* use get-channels 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
|
||||
* pick default random admin key
|
||||
* restrict gpio & serial & settings operations to the admin channel (unless local to the current node)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -9,6 +9,7 @@ RoutingPlugin *routingPlugin;
|
|||
|
||||
bool RoutingPlugin::handleReceivedProtobuf(const MeshPacket &mp, const Routing *r)
|
||||
{
|
||||
DEBUG_MSG("Routing sniffing", &mp);
|
||||
router->sniffReceived(&mp, r);
|
||||
|
||||
// FIXME - move this to a non promsicious PhoneAPI plugin?
|
||||
|
@ -23,8 +24,13 @@ bool RoutingPlugin::handleReceivedProtobuf(const MeshPacket &mp, const Routing *
|
|||
|
||||
MeshPacket *RoutingPlugin::allocReply()
|
||||
{
|
||||
assert(currentRequest);
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,9 @@ class RoutingPlugin : public ProtobufPlugin<Routing>
|
|||
* so that subclasses can (optionally) send a response back to the original sender. */
|
||||
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);
|
||||
};
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue