mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-08-03 02:36:11 +00:00
fix(live-share): name the sender in DM position shares
A channel [LOC] broadcast already carries the sender (sendGroupMessage prepends "<name>: "), but the DM path sent a bare "[LOC]<lat>,<lon>" with no name in it. Embed the node name as a trailing token after the coordinate so a DM share is self-describing in any chat client; parseLocShare ignores the trailing text, so receivers are unaffected. Verified: WioTrackerL1_companion_solo_dual builds clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
df894eba16
commit
f49b7dd8bd
@@ -2338,17 +2338,24 @@ void UITask::onSharedLocation(const uint8_t* pub_key, const char* name,
|
|||||||
|
|
||||||
bool UITask::sendLocationShare(int32_t lat, int32_t lon) {
|
bool UITask::sendLocationShare(int32_t lat, int32_t lon) {
|
||||||
if (!_node_prefs) return false;
|
if (!_node_prefs) return false;
|
||||||
char text[40];
|
char text[80];
|
||||||
snprintf(text, sizeof(text), LOCATION_MSG_TAG "%.5f,%.5f", lat / 1e6, lon / 1e6);
|
|
||||||
if (_node_prefs->loc_share_target_type == 0) {
|
if (_node_prefs->loc_share_target_type == 0) {
|
||||||
|
// Channel: sendGroupMessage prepends "<name>: ", so the payload already
|
||||||
|
// names the sender — keep the [LOC] text bare.
|
||||||
|
snprintf(text, sizeof(text), LOCATION_MSG_TAG "%.5f,%.5f", lat / 1e6, lon / 1e6);
|
||||||
ChannelDetails ch;
|
ChannelDetails ch;
|
||||||
if (!the_mesh.getChannel(_node_prefs->loc_share_channel_idx, ch)) return false;
|
if (!the_mesh.getChannel(_node_prefs->loc_share_channel_idx, ch)) return false;
|
||||||
return the_mesh.sendGroupMessage(rtc_clock.getCurrentTime(), ch.channel,
|
return the_mesh.sendGroupMessage(rtc_clock.getCurrentTime(), ch.channel,
|
||||||
the_mesh.getNodeName(), text, strlen(text));
|
the_mesh.getNodeName(), text, strlen(text));
|
||||||
}
|
}
|
||||||
|
// DM carries no per-message sender prefix, so embed the name in the text — the
|
||||||
|
// share is then self-describing in any chat client (a trailing token after the
|
||||||
|
// coordinate, which parseLocShare ignores on the receiving side).
|
||||||
ContactInfo* c = the_mesh.lookupContactByPubKey(_node_prefs->loc_share_dm_prefix,
|
ContactInfo* c = the_mesh.lookupContactByPubKey(_node_prefs->loc_share_dm_prefix,
|
||||||
NodePrefs::FAVOURITE_PREFIX_LEN);
|
NodePrefs::FAVOURITE_PREFIX_LEN);
|
||||||
if (!c) return false;
|
if (!c) return false;
|
||||||
|
snprintf(text, sizeof(text), LOCATION_MSG_TAG "%.5f,%.5f %s",
|
||||||
|
lat / 1e6, lon / 1e6, the_mesh.getNodeName());
|
||||||
uint32_t expected_ack = 0, est_timeout = 0;
|
uint32_t expected_ack = 0, est_timeout = 0;
|
||||||
return the_mesh.sendMessage(*c, rtc_clock.getCurrentTime(), 0, text, expected_ack, est_timeout) > 0;
|
return the_mesh.sendMessage(*c, rtc_clock.getCurrentTime(), 0, text, expected_ack, est_timeout) > 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user