diff --git a/src/mesh/Channels.cpp b/src/mesh/Channels.cpp index 9ae211e6e..e7f1cb3ed 100644 --- a/src/mesh/Channels.cpp +++ b/src/mesh/Channels.cpp @@ -196,6 +196,17 @@ Channel &Channels::getByIndex(ChannelIndex chIndex) return *ch; } +Channel &Channels::getByName(const char* chName) +{ + for (ChannelIndex i = 0; i < getNumChannels(); i++) { + if (strcasecmp(channelFile.channels[i].settings.name, chName) == 0) { + return channelFile.channels[i]; + } + } + + return getByIndex(getPrimaryIndex()); +} + void Channels::setChannel(const Channel &c) { Channel &old = getByIndex(c.index); diff --git a/src/mesh/Channels.h b/src/mesh/Channels.h index ebf08d32c..f66848577 100644 --- a/src/mesh/Channels.h +++ b/src/mesh/Channels.h @@ -40,6 +40,9 @@ class Channels /** Return the Channel for a specified index */ Channel &getByIndex(ChannelIndex chIndex); + /** Return the Channel for a specified name, return primary if not found */ + Channel &getByName(const char* chName); + /** Using the index inside the channel, update the specified channel's settings and role. If this channel is being promoted * to be primary, force all other channels to be secondary. */ diff --git a/src/modules/SerialModule.cpp b/src/modules/SerialModule.cpp index aaaf3b144..116690d74 100644 --- a/src/modules/SerialModule.cpp +++ b/src/modules/SerialModule.cpp @@ -221,8 +221,12 @@ MeshPacket *SerialModuleRadio::allocReply() void SerialModuleRadio::sendPayload(NodeNum dest, bool wantReplies) { + Channel *ch = (boundChannel != NULL) ? &channels.getByName(boundChannel) : NULL; MeshPacket *p = allocReply(); p->to = dest; + if (ch != NULL) { + p->channel = ch->index; + } p->decoded.want_response = wantReplies; p->want_ack = ACK;