mirror of
https://github.com/meshtastic/firmware.git
synced 2026-01-27 04:02:05 +00:00
Don't send to public channel (#5310)
* Don't send to public channel `p->to` wasn't set and had the same value as broadcast, it's now set to our own NodeNum. * Trunk * Update DetectionSensorModule.cpp Take 3 * Revert NodeNum()
This commit is contained in:
@@ -58,7 +58,7 @@ int32_t DetectionSensorModule::runOnce()
|
|||||||
// moduleConfig.detection_sensor.minimum_broadcast_secs = 30;
|
// moduleConfig.detection_sensor.minimum_broadcast_secs = 30;
|
||||||
// moduleConfig.detection_sensor.state_broadcast_secs = 120;
|
// moduleConfig.detection_sensor.state_broadcast_secs = 120;
|
||||||
// moduleConfig.detection_sensor.detection_trigger_type =
|
// moduleConfig.detection_sensor.detection_trigger_type =
|
||||||
// meshtastic_ModuleConfig_DetectionSensorConfig_TriggerType_LOGIC_HIGH;
|
// meshtastic_ModuleConfig_DetectionSensorConfig_TriggerType_LOGIC_HIGH;
|
||||||
// strcpy(moduleConfig.detection_sensor.name, "Motion");
|
// strcpy(moduleConfig.detection_sensor.name, "Motion");
|
||||||
|
|
||||||
if (moduleConfig.detection_sensor.enabled == false)
|
if (moduleConfig.detection_sensor.enabled == false)
|
||||||
@@ -130,9 +130,12 @@ void DetectionSensorModule::sendDetectionMessage()
|
|||||||
p->decoded.payload.bytes[p->decoded.payload.size + 1] = '\0'; // Bell character
|
p->decoded.payload.bytes[p->decoded.payload.size + 1] = '\0'; // Bell character
|
||||||
p->decoded.payload.size++;
|
p->decoded.payload.size++;
|
||||||
}
|
}
|
||||||
LOG_INFO("Send message id=%d, dest=%x, msg=%.*s", p->id, p->to, p->decoded.payload.size, p->decoded.payload.bytes);
|
|
||||||
lastSentToMesh = millis();
|
lastSentToMesh = millis();
|
||||||
service->sendToMesh(p);
|
if (!channels.isDefaultChannel(0)) {
|
||||||
|
LOG_INFO("Send message id=%d, dest=%x, msg=%.*s", p->id, p->to, p->decoded.payload.size, p->decoded.payload.bytes);
|
||||||
|
service->sendToMesh(p);
|
||||||
|
} else
|
||||||
|
LOG_ERROR("Message not allow on Public channel");
|
||||||
delete[] message;
|
delete[] message;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,14 +143,16 @@ void DetectionSensorModule::sendCurrentStateMessage(bool state)
|
|||||||
{
|
{
|
||||||
char *message = new char[40];
|
char *message = new char[40];
|
||||||
sprintf(message, "%s state: %i", moduleConfig.detection_sensor.name, state);
|
sprintf(message, "%s state: %i", moduleConfig.detection_sensor.name, state);
|
||||||
|
|
||||||
meshtastic_MeshPacket *p = allocDataPacket();
|
meshtastic_MeshPacket *p = allocDataPacket();
|
||||||
p->want_ack = false;
|
p->want_ack = false;
|
||||||
p->decoded.payload.size = strlen(message);
|
p->decoded.payload.size = strlen(message);
|
||||||
memcpy(p->decoded.payload.bytes, message, p->decoded.payload.size);
|
memcpy(p->decoded.payload.bytes, message, p->decoded.payload.size);
|
||||||
LOG_INFO("Send message id=%d, dest=%x, msg=%.*s", p->id, p->to, p->decoded.payload.size, p->decoded.payload.bytes);
|
|
||||||
lastSentToMesh = millis();
|
lastSentToMesh = millis();
|
||||||
service->sendToMesh(p);
|
if (!channels.isDefaultChannel(0)) {
|
||||||
|
LOG_INFO("Send message id=%d, dest=%x, msg=%.*s", p->id, p->to, p->decoded.payload.size, p->decoded.payload.bytes);
|
||||||
|
service->sendToMesh(p);
|
||||||
|
} else
|
||||||
|
LOG_ERROR("Message not allow on Public channel");
|
||||||
delete[] message;
|
delete[] message;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,4 +161,4 @@ bool DetectionSensorModule::hasDetectionEvent()
|
|||||||
bool currentState = digitalRead(moduleConfig.detection_sensor.monitor_pin);
|
bool currentState = digitalRead(moduleConfig.detection_sensor.monitor_pin);
|
||||||
// LOG_DEBUG("Detection Sensor Module: Current state: %i", currentState);
|
// LOG_DEBUG("Detection Sensor Module: Current state: %i", currentState);
|
||||||
return (moduleConfig.detection_sensor.detection_trigger_type & 1) ? currentState : !currentState;
|
return (moduleConfig.detection_sensor.detection_trigger_type & 1) ? currentState : !currentState;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user