Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Yes, you can retrieve the channel information without modifying the library by adding a callback for processing text messages in your program. Here's how you can do it:
Define a callback for processing text messages:
Configure the library to use this callback:
set_text_message_callback
to record your callback.Use the callback to store the index of the last channel:
Here is an example illustrating this approach:
Modification of the callback function in the library
You need to slightly modify the
set_text_message_callback
callback function in the “mt_protocol.cpp” library to pass the channel index to the user callback. It might look like this:Modification of the callback function in the library:
Modified
handle_mesh_packet
to include channel:With these changes, your
my_text_message_callback
callback will receive the channel index every time a text message is received, and you will be able to use this information in your main program without touching the library further.Don’t forget to also modify “meshtastic.h”
Line 75
// Set the callback function that gets called when the node receives a text message.
void set_text_message_callback(void (callback)(uint32_t from, const char text, uint8_t channel));