diff --git a/src/mesh/Channels.h b/src/mesh/Channels.h index bbd767fa0..eb8422cb5 100644 --- a/src/mesh/Channels.h +++ b/src/mesh/Channels.h @@ -29,7 +29,6 @@ class Channels int16_t hashes[MAX_NUM_CHANNELS]; public: - /// Well known channel names static const char *adminChannel, *gpioChannel, *serialChannel; @@ -43,8 +42,15 @@ class Channels */ void setChannel(const Channel &c); + /** Return a human friendly name for this channel (and expand any short strings as needed) + */ const char *getName(size_t chIndex); + /** + * Return a globally unique channel ID usable with MQTT. + */ + const char *getGlobalId(size_t chIndex) { return getName(chIndex); } // FIXME, not correct + /** The index of the primary channel */ ChannelIndex getPrimaryIndex() const { return primaryIndex; } diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index 92da5509b..e6f38f8e8 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -109,11 +109,11 @@ int32_t MQTT::runOnce() void MQTT::onSend(const MeshPacket &mp, ChannelIndex chIndex) { - // don't bother sending if not connected... - if (pubSub.connected()) { - // FIXME - check uplink enabled + auto &ch = channels.getByIndex(chIndex); - const char *channelId = channels.getName(chIndex); // FIXME, for now we just use the human name for the channel + // don't bother sending if not connected... + if (pubSub.connected() && ch.settings.uplink_enabled) { + const char *channelId = channels.getGlobalId(chIndex); // FIXME, for now we just use the human name for the channel ServiceEnvelope env = ServiceEnvelope_init_default; env.channel_id = (char *)channelId;