basic working
This commit is contained in:
+7
-9
@@ -88,8 +88,8 @@ class MeshtasticMQTTClient {
|
||||
try {
|
||||
const { from, to, channel, id, sender } = payload;
|
||||
|
||||
// Extract node ID (convert to hex string if it's a number)
|
||||
const fromNode = sender || (from ? `!${from.toString(16).padStart(8, '0')}` : null);
|
||||
// Extract node ID (convert to hex string if it's a number, fallback to sender if none
|
||||
const fromNode = from ? `!${from.toString(16).padStart(8, '0')}` : sender;
|
||||
const toNode = to ? `!${to.toString(16).padStart(8, '0')}` : null;
|
||||
|
||||
// Handle different message types based on actual JSON structure
|
||||
@@ -344,18 +344,16 @@ class MeshtasticMQTTClient {
|
||||
}
|
||||
|
||||
// Send a text message
|
||||
async sendTextMessage(text, channel = 0) {
|
||||
async sendTextMessage(from, text) {
|
||||
try {
|
||||
const message = JSON.stringify({
|
||||
type: 'text',
|
||||
text,
|
||||
channel,
|
||||
timestamp: Date.now()
|
||||
from: from,
|
||||
type: 'sendtext',
|
||||
payload: text
|
||||
});
|
||||
|
||||
// Publish to the appropriate topic
|
||||
const baseTopic = config.mqtt.topic.replace('/#', '');
|
||||
await this.publish(`${baseTopic}/2/json/mqtt`, message);
|
||||
await this.publish(config.mqtt.pubTopic, message);
|
||||
|
||||
return true;
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user