[modules][serial] fix simple module ability to send

This commit is contained in:
Mykhailo Lesyk 2022-12-21 01:35:19 -08:00
parent af9d4328eb
commit 4de557b4db
3 changed files with 18 additions and 0 deletions

View File

@ -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);

View File

@ -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.
*/

View File

@ -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;