mirror of
https://github.com/meshtastic/firmware.git
synced 2026-01-13 18:11:39 -05:00
Finish config transition
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
#include "configuration.h"
|
||||
#ifndef NO_SCREEN
|
||||
#include "CannedMessageModule.h"
|
||||
#include "PowerFSM.h" // neede for button bypass
|
||||
#include "MeshService.h"
|
||||
#include "FSCommon.h"
|
||||
#include "MeshService.h"
|
||||
#include "PowerFSM.h" // neede for button bypass
|
||||
#include "mesh/generated/cannedmessages.pb.h"
|
||||
|
||||
// TODO: reuse defined from Screen.cpp
|
||||
@@ -22,22 +22,18 @@ CannedMessageModule *cannedMessageModule;
|
||||
|
||||
// TODO: move it into NodeDB.h!
|
||||
extern bool loadProto(const char *filename, size_t protoSize, size_t objSize, const pb_msgdesc_t *fields, void *dest_struct);
|
||||
extern bool saveProto(const char *filename, size_t protoSize, size_t objSize, const pb_msgdesc_t *fields, const void *dest_struct);
|
||||
extern bool saveProto(const char *filename, size_t protoSize, size_t objSize, const pb_msgdesc_t *fields,
|
||||
const void *dest_struct);
|
||||
|
||||
CannedMessageModule::CannedMessageModule()
|
||||
: SinglePortModule("canned", PortNum_TEXT_MESSAGE_APP),
|
||||
concurrency::OSThread("CannedMessageModule")
|
||||
: SinglePortModule("canned", PortNum_TEXT_MESSAGE_APP), concurrency::OSThread("CannedMessageModule")
|
||||
{
|
||||
if (radioConfig.preferences.canned_message_module_enabled)
|
||||
{
|
||||
if (moduleConfig.payloadVariant.canned_message.enabled) {
|
||||
this->loadProtoForModule();
|
||||
if(this->splitConfiguredMessages() <= 0)
|
||||
{
|
||||
if (this->splitConfiguredMessages() <= 0) {
|
||||
DEBUG_MSG("CannedMessageModule: No messages are configured. Module is disabled\n");
|
||||
this->runState = CANNED_MESSAGE_RUN_STATE_DISABLED;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
DEBUG_MSG("CannedMessageModule is enabled\n");
|
||||
this->inputObserver.observe(inputBroker);
|
||||
}
|
||||
@@ -56,57 +52,38 @@ int CannedMessageModule::splitConfiguredMessages()
|
||||
int i = 0;
|
||||
|
||||
// collect all the message parts
|
||||
strcpy(
|
||||
this->messageStore,
|
||||
cannedMessageModuleConfig.messagesPart1);
|
||||
strcat(
|
||||
this->messageStore,
|
||||
cannedMessageModuleConfig.messagesPart2);
|
||||
strcat(
|
||||
this->messageStore,
|
||||
cannedMessageModuleConfig.messagesPart3);
|
||||
strcat(
|
||||
this->messageStore,
|
||||
cannedMessageModuleConfig.messagesPart4);
|
||||
strcpy(this->messageStore, cannedMessageModuleConfig.messagesPart1);
|
||||
strcat(this->messageStore, cannedMessageModuleConfig.messagesPart2);
|
||||
strcat(this->messageStore, cannedMessageModuleConfig.messagesPart3);
|
||||
strcat(this->messageStore, cannedMessageModuleConfig.messagesPart4);
|
||||
|
||||
// The first message points to the beginning of the store.
|
||||
this->messages[messageIndex++] =
|
||||
this->messageStore;
|
||||
int upTo =
|
||||
strlen(this->messageStore) - 1;
|
||||
this->messages[messageIndex++] = this->messageStore;
|
||||
int upTo = strlen(this->messageStore) - 1;
|
||||
|
||||
while (i < upTo)
|
||||
{
|
||||
if (this->messageStore[i] == '|')
|
||||
{
|
||||
while (i < upTo) {
|
||||
if (this->messageStore[i] == '|') {
|
||||
// Message ending found, replace it with string-end character.
|
||||
this->messageStore[i] = '\0';
|
||||
DEBUG_MSG("CannedMessage %d is: '%s'\n",
|
||||
messageIndex-1, this->messages[messageIndex-1]);
|
||||
DEBUG_MSG("CannedMessage %d is: '%s'\n", messageIndex - 1, this->messages[messageIndex - 1]);
|
||||
|
||||
// hit our max messages, bail
|
||||
if (messageIndex >= CANNED_MESSAGE_MODULE_MESSAGE_MAX_COUNT)
|
||||
{
|
||||
if (messageIndex >= CANNED_MESSAGE_MODULE_MESSAGE_MAX_COUNT) {
|
||||
this->messagesCount = messageIndex;
|
||||
return this->messagesCount;
|
||||
}
|
||||
|
||||
// Next message starts after pipe (|) just found.
|
||||
this->messages[messageIndex++] =
|
||||
(this->messageStore + i + 1);
|
||||
this->messages[messageIndex++] = (this->messageStore + i + 1);
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
if (strlen(this->messages[messageIndex-1]) > 0)
|
||||
{
|
||||
if (strlen(this->messages[messageIndex - 1]) > 0) {
|
||||
// We have a last message.
|
||||
DEBUG_MSG("CannedMessage %d is: '%s'\n",
|
||||
messageIndex-1, this->messages[messageIndex-1]);
|
||||
DEBUG_MSG("CannedMessage %d is: '%s'\n", messageIndex - 1, this->messages[messageIndex - 1]);
|
||||
this->messagesCount = messageIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->messagesCount = messageIndex-1;
|
||||
} else {
|
||||
this->messagesCount = messageIndex - 1;
|
||||
}
|
||||
|
||||
return this->messagesCount;
|
||||
@@ -114,11 +91,9 @@ int CannedMessageModule::splitConfiguredMessages()
|
||||
|
||||
int CannedMessageModule::handleInputEvent(const InputEvent *event)
|
||||
{
|
||||
if (
|
||||
(strlen(radioConfig.preferences.canned_message_module_allow_input_source) > 0) &&
|
||||
(strcmp(radioConfig.preferences.canned_message_module_allow_input_source, event->source) != 0) &&
|
||||
(strcmp(radioConfig.preferences.canned_message_module_allow_input_source, "_any") != 0))
|
||||
{
|
||||
if ((strlen(moduleConfig.payloadVariant.canned_message.allow_input_source) > 0) &&
|
||||
(strcmp(moduleConfig.payloadVariant.canned_message.allow_input_source, event->source) != 0) &&
|
||||
(strcmp(moduleConfig.payloadVariant.canned_message.allow_input_source, "_any") != 0)) {
|
||||
// Event source is not accepted.
|
||||
// Event only accepted if source matches the configured one, or
|
||||
// the configured one is "_any" (or if there is no configured
|
||||
@@ -127,32 +102,28 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event)
|
||||
}
|
||||
|
||||
bool validEvent = false;
|
||||
if (event->inputEvent == static_cast<char>(InputEventChar_KEY_UP))
|
||||
{
|
||||
if (event->inputEvent == static_cast<char>(ModuleConfig_CannedMessageConfig_InputEventChar_KEY_UP)) {
|
||||
DEBUG_MSG("Canned message event UP\n");
|
||||
this->runState = CANNED_MESSAGE_RUN_STATE_ACTION_UP;
|
||||
validEvent = true;
|
||||
}
|
||||
if (event->inputEvent == static_cast<char>(InputEventChar_KEY_DOWN))
|
||||
{
|
||||
if (event->inputEvent == static_cast<char>(ModuleConfig_CannedMessageConfig_InputEventChar_KEY_DOWN)) {
|
||||
DEBUG_MSG("Canned message event DOWN\n");
|
||||
this->runState = CANNED_MESSAGE_RUN_STATE_ACTION_DOWN;
|
||||
validEvent = true;
|
||||
}
|
||||
if (event->inputEvent == static_cast<char>(InputEventChar_KEY_SELECT))
|
||||
{
|
||||
if (event->inputEvent == static_cast<char>(ModuleConfig_CannedMessageConfig_InputEventChar_KEY_SELECT)) {
|
||||
DEBUG_MSG("Canned message event Select\n");
|
||||
// when inactive, call the onebutton shortpress instead. Activate Module only on up/down
|
||||
if ((this->runState == CANNED_MESSAGE_RUN_STATE_INACTIVE) || (this->runState == CANNED_MESSAGE_RUN_STATE_DISABLED)) {
|
||||
powerFSM.trigger(EVENT_PRESS);
|
||||
}else{
|
||||
} else {
|
||||
this->runState = CANNED_MESSAGE_RUN_STATE_ACTION_SELECT;
|
||||
validEvent = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (validEvent)
|
||||
{
|
||||
if (validEvent) {
|
||||
// Let runOnce to be called immediately.
|
||||
setIntervalFromNow(0);
|
||||
}
|
||||
@@ -160,90 +131,67 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CannedMessageModule::sendText(NodeNum dest,
|
||||
const char* message,
|
||||
bool wantReplies)
|
||||
void CannedMessageModule::sendText(NodeNum dest, const char *message, bool wantReplies)
|
||||
{
|
||||
MeshPacket *p = allocDataPacket();
|
||||
p->to = dest;
|
||||
p->want_ack = true;
|
||||
p->decoded.payload.size = strlen(message);
|
||||
memcpy(p->decoded.payload.bytes, message, p->decoded.payload.size);
|
||||
if (radioConfig.preferences.canned_message_module_send_bell)
|
||||
{
|
||||
p->decoded.payload.bytes[p->decoded.payload.size-1] = 7; // Bell character
|
||||
p->decoded.payload.bytes[p->decoded.payload.size] = '\0'; // Bell character
|
||||
if (moduleConfig.payloadVariant.canned_message.send_bell) {
|
||||
p->decoded.payload.bytes[p->decoded.payload.size - 1] = 7; // Bell character
|
||||
p->decoded.payload.bytes[p->decoded.payload.size] = '\0'; // Bell character
|
||||
p->decoded.payload.size++;
|
||||
}
|
||||
|
||||
DEBUG_MSG("Sending message id=%d, msg=%.*s\n",
|
||||
p->id, p->decoded.payload.size, p->decoded.payload.bytes);
|
||||
DEBUG_MSG("Sending message id=%d, msg=%.*s\n", p->id, p->decoded.payload.size, p->decoded.payload.bytes);
|
||||
|
||||
service.sendToMesh(p);
|
||||
}
|
||||
|
||||
int32_t CannedMessageModule::runOnce()
|
||||
{
|
||||
if ((!radioConfig.preferences.canned_message_module_enabled)
|
||||
|| (this->runState == CANNED_MESSAGE_RUN_STATE_DISABLED)
|
||||
|| (this->runState == CANNED_MESSAGE_RUN_STATE_INACTIVE))
|
||||
{
|
||||
if ((!moduleConfig.payloadVariant.canned_message.enabled) || (this->runState == CANNED_MESSAGE_RUN_STATE_DISABLED) ||
|
||||
(this->runState == CANNED_MESSAGE_RUN_STATE_INACTIVE)) {
|
||||
return 30000; // TODO: should return MAX_VAL
|
||||
}
|
||||
DEBUG_MSG("Check status\n");
|
||||
UIFrameEvent e = {false, true};
|
||||
if (this->runState == CANNED_MESSAGE_RUN_STATE_SENDING_ACTIVE)
|
||||
{
|
||||
if (this->runState == CANNED_MESSAGE_RUN_STATE_SENDING_ACTIVE) {
|
||||
// TODO: might have some feedback of sendig state
|
||||
this->runState = CANNED_MESSAGE_RUN_STATE_INACTIVE;
|
||||
e.frameChanged = true;
|
||||
this->currentMessageIndex = -1;
|
||||
this->notifyObservers(&e);
|
||||
}
|
||||
else if (
|
||||
(this->runState == CANNED_MESSAGE_RUN_STATE_ACTIVE)
|
||||
&& (millis() - this->lastTouchMillis) > INACTIVATE_AFTER_MS)
|
||||
{
|
||||
} else if ((this->runState == CANNED_MESSAGE_RUN_STATE_ACTIVE) && (millis() - this->lastTouchMillis) > INACTIVATE_AFTER_MS) {
|
||||
// Reset module
|
||||
DEBUG_MSG("Reset due the lack of activity.\n");
|
||||
e.frameChanged = true;
|
||||
this->currentMessageIndex = -1;
|
||||
this->runState = CANNED_MESSAGE_RUN_STATE_INACTIVE;
|
||||
this->notifyObservers(&e);
|
||||
}
|
||||
else if (this->currentMessageIndex == -1)
|
||||
{
|
||||
} else if (this->currentMessageIndex == -1) {
|
||||
this->currentMessageIndex = 0;
|
||||
DEBUG_MSG("First touch (%d):%s\n", this->currentMessageIndex, this->getCurrentMessage());
|
||||
e.frameChanged = true;
|
||||
this->runState = CANNED_MESSAGE_RUN_STATE_ACTIVE;
|
||||
}
|
||||
else if (this->runState == CANNED_MESSAGE_RUN_STATE_ACTION_SELECT)
|
||||
{
|
||||
sendText(
|
||||
NODENUM_BROADCAST,
|
||||
this->messages[this->currentMessageIndex],
|
||||
true);
|
||||
} else if (this->runState == CANNED_MESSAGE_RUN_STATE_ACTION_SELECT) {
|
||||
sendText(NODENUM_BROADCAST, this->messages[this->currentMessageIndex], true);
|
||||
this->runState = CANNED_MESSAGE_RUN_STATE_SENDING_ACTIVE;
|
||||
this->currentMessageIndex = -1;
|
||||
this->notifyObservers(&e);
|
||||
return 2000;
|
||||
}
|
||||
else if (this->runState == CANNED_MESSAGE_RUN_STATE_ACTION_UP)
|
||||
{
|
||||
} else if (this->runState == CANNED_MESSAGE_RUN_STATE_ACTION_UP) {
|
||||
this->currentMessageIndex = getPrevIndex();
|
||||
this->runState = CANNED_MESSAGE_RUN_STATE_ACTIVE;
|
||||
DEBUG_MSG("MOVE UP (%d):%s\n", this->currentMessageIndex, this->getCurrentMessage());
|
||||
}
|
||||
else if (this->runState == CANNED_MESSAGE_RUN_STATE_ACTION_DOWN)
|
||||
{
|
||||
} else if (this->runState == CANNED_MESSAGE_RUN_STATE_ACTION_DOWN) {
|
||||
this->currentMessageIndex = this->getNextIndex();
|
||||
this->runState = CANNED_MESSAGE_RUN_STATE_ACTIVE;
|
||||
DEBUG_MSG("MOVE DOWN (%d):%s\n", this->currentMessageIndex, this->getCurrentMessage());
|
||||
}
|
||||
|
||||
if (this->runState == CANNED_MESSAGE_RUN_STATE_ACTIVE)
|
||||
{
|
||||
if (this->runState == CANNED_MESSAGE_RUN_STATE_ACTIVE) {
|
||||
this->lastTouchMillis = millis();
|
||||
this->notifyObservers(&e);
|
||||
return INACTIVATE_AFTER_MS;
|
||||
@@ -252,22 +200,21 @@ int32_t CannedMessageModule::runOnce()
|
||||
return 30000; // TODO: should return MAX_VAL
|
||||
}
|
||||
|
||||
const char* CannedMessageModule::getCurrentMessage()
|
||||
const char *CannedMessageModule::getCurrentMessage()
|
||||
{
|
||||
return this->messages[this->currentMessageIndex];
|
||||
}
|
||||
const char* CannedMessageModule::getPrevMessage()
|
||||
const char *CannedMessageModule::getPrevMessage()
|
||||
{
|
||||
return this->messages[this->getPrevIndex()];
|
||||
}
|
||||
const char* CannedMessageModule::getNextMessage()
|
||||
const char *CannedMessageModule::getNextMessage()
|
||||
{
|
||||
return this->messages[this->getNextIndex()];
|
||||
}
|
||||
bool CannedMessageModule::shouldDraw()
|
||||
{
|
||||
if (!radioConfig.preferences.canned_message_module_enabled)
|
||||
{
|
||||
if (!moduleConfig.payloadVariant.canned_message.enabled) {
|
||||
return false;
|
||||
}
|
||||
return (currentMessageIndex != -1) || (this->runState != CANNED_MESSAGE_RUN_STATE_INACTIVE);
|
||||
@@ -275,47 +222,35 @@ bool CannedMessageModule::shouldDraw()
|
||||
|
||||
int CannedMessageModule::getNextIndex()
|
||||
{
|
||||
if (this->currentMessageIndex >= (this->messagesCount -1))
|
||||
{
|
||||
if (this->currentMessageIndex >= (this->messagesCount - 1)) {
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return this->currentMessageIndex + 1;
|
||||
}
|
||||
}
|
||||
|
||||
int CannedMessageModule::getPrevIndex()
|
||||
{
|
||||
if (this->currentMessageIndex <= 0)
|
||||
{
|
||||
if (this->currentMessageIndex <= 0) {
|
||||
return this->messagesCount - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return this->currentMessageIndex - 1;
|
||||
}
|
||||
}
|
||||
|
||||
void CannedMessageModule::drawFrame(
|
||||
OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
||||
void CannedMessageModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
||||
{
|
||||
displayedNodeNum = 0; // Not currently showing a node pane
|
||||
|
||||
if (cannedMessageModule->runState == CANNED_MESSAGE_RUN_STATE_SENDING_ACTIVE)
|
||||
{
|
||||
if (cannedMessageModule->runState == CANNED_MESSAGE_RUN_STATE_SENDING_ACTIVE) {
|
||||
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
||||
display->setFont(FONT_MEDIUM);
|
||||
display->drawString(display->getWidth()/2 + x, 0 + y + 12, "Sending...");
|
||||
}
|
||||
else if (cannedMessageModule->runState == CANNED_MESSAGE_RUN_STATE_DISABLED)
|
||||
{
|
||||
display->drawString(display->getWidth() / 2 + x, 0 + y + 12, "Sending...");
|
||||
} else if (cannedMessageModule->runState == CANNED_MESSAGE_RUN_STATE_DISABLED) {
|
||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||
display->setFont(FONT_SMALL);
|
||||
display->drawString(10 + x, 0 + y + 16, "Canned Message\nModule disabled.");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||
display->setFont(FONT_SMALL);
|
||||
display->drawString(0 + x, 0 + y, cannedMessageModule->getPrevMessage());
|
||||
@@ -328,7 +263,8 @@ void CannedMessageModule::drawFrame(
|
||||
|
||||
void CannedMessageModule::loadProtoForModule()
|
||||
{
|
||||
if (!loadProto(cannedMessagesConfigFile, CannedMessageModuleConfig_size, sizeof(cannedMessagesConfigFile), CannedMessageModuleConfig_fields, &cannedMessageModuleConfig)) {
|
||||
if (!loadProto(cannedMessagesConfigFile, CannedMessageModuleConfig_size, sizeof(cannedMessagesConfigFile),
|
||||
CannedMessageModuleConfig_fields, &cannedMessageModuleConfig)) {
|
||||
installDefaultCannedMessageModuleConfig();
|
||||
}
|
||||
}
|
||||
@@ -347,7 +283,8 @@ bool CannedMessageModule::saveProtoForModule()
|
||||
FS.mkdir("/prefs");
|
||||
#endif
|
||||
|
||||
okay &= saveProto(cannedMessagesConfigFile, CannedMessageModuleConfig_size, sizeof(CannedMessageModuleConfig), CannedMessageModuleConfig_fields, &cannedMessageModuleConfig);
|
||||
okay &= saveProto(cannedMessagesConfigFile, CannedMessageModuleConfig_size, sizeof(CannedMessageModuleConfig),
|
||||
CannedMessageModuleConfig_fields, &cannedMessageModuleConfig);
|
||||
|
||||
return okay;
|
||||
}
|
||||
@@ -372,8 +309,8 @@ void CannedMessageModule::installDefaultCannedMessageModuleConfig()
|
||||
* @return AdminMessageHandleResult HANDLED if message was handled
|
||||
* HANDLED_WITH_RESULT if a result is also prepared.
|
||||
*/
|
||||
AdminMessageHandleResult CannedMessageModule::handleAdminMessageForModule(
|
||||
const MeshPacket &mp, AdminMessage *request, AdminMessage *response)
|
||||
AdminMessageHandleResult CannedMessageModule::handleAdminMessageForModule(const MeshPacket &mp, AdminMessage *request,
|
||||
AdminMessage *response)
|
||||
{
|
||||
AdminMessageHandleResult result;
|
||||
|
||||
@@ -404,29 +341,25 @@ AdminMessageHandleResult CannedMessageModule::handleAdminMessageForModule(
|
||||
|
||||
case AdminMessage_set_canned_message_module_part1_tag:
|
||||
DEBUG_MSG("Client is setting radio canned message part 1\n");
|
||||
this->handleSetCannedMessageModulePart1(
|
||||
request->set_canned_message_module_part1);
|
||||
this->handleSetCannedMessageModulePart1(request->set_canned_message_module_part1);
|
||||
result = AdminMessageHandleResult::HANDLED;
|
||||
break;
|
||||
|
||||
case AdminMessage_set_canned_message_module_part2_tag:
|
||||
DEBUG_MSG("Client is setting radio canned message part 2\n");
|
||||
this->handleSetCannedMessageModulePart2(
|
||||
request->set_canned_message_module_part2);
|
||||
this->handleSetCannedMessageModulePart2(request->set_canned_message_module_part2);
|
||||
result = AdminMessageHandleResult::HANDLED;
|
||||
break;
|
||||
|
||||
case AdminMessage_set_canned_message_module_part3_tag:
|
||||
DEBUG_MSG("Client is setting radio canned message part 3\n");
|
||||
this->handleSetCannedMessageModulePart3(
|
||||
request->set_canned_message_module_part3);
|
||||
this->handleSetCannedMessageModulePart3(request->set_canned_message_module_part3);
|
||||
result = AdminMessageHandleResult::HANDLED;
|
||||
break;
|
||||
|
||||
case AdminMessage_set_canned_message_module_part4_tag:
|
||||
DEBUG_MSG("Client is setting radio canned message part 4\n");
|
||||
this->handleSetCannedMessageModulePart4(
|
||||
request->set_canned_message_module_part4);
|
||||
this->handleSetCannedMessageModulePart4(request->set_canned_message_module_part4);
|
||||
result = AdminMessageHandleResult::HANDLED;
|
||||
break;
|
||||
|
||||
@@ -437,67 +370,53 @@ AdminMessageHandleResult CannedMessageModule::handleAdminMessageForModule(
|
||||
return result;
|
||||
}
|
||||
|
||||
void CannedMessageModule::handleGetCannedMessageModulePart1(
|
||||
const MeshPacket &req, AdminMessage *response)
|
||||
void CannedMessageModule::handleGetCannedMessageModulePart1(const MeshPacket &req, AdminMessage *response)
|
||||
{
|
||||
DEBUG_MSG("*** handleGetCannedMessageModulePart1\n");
|
||||
assert(req.decoded.want_response);
|
||||
|
||||
response->which_variant = AdminMessage_get_canned_message_module_part1_response_tag;
|
||||
strcpy(
|
||||
response->get_canned_message_module_part1_response,
|
||||
cannedMessageModuleConfig.messagesPart1);
|
||||
strcpy(response->get_canned_message_module_part1_response, cannedMessageModuleConfig.messagesPart1);
|
||||
}
|
||||
|
||||
void CannedMessageModule::handleGetCannedMessageModulePart2(
|
||||
const MeshPacket &req, AdminMessage *response)
|
||||
void CannedMessageModule::handleGetCannedMessageModulePart2(const MeshPacket &req, AdminMessage *response)
|
||||
{
|
||||
DEBUG_MSG("*** handleGetCannedMessageModulePart2\n");
|
||||
assert(req.decoded.want_response);
|
||||
|
||||
response->which_variant = AdminMessage_get_canned_message_module_part2_response_tag;
|
||||
strcpy(
|
||||
response->get_canned_message_module_part2_response,
|
||||
cannedMessageModuleConfig.messagesPart2);
|
||||
strcpy(response->get_canned_message_module_part2_response, cannedMessageModuleConfig.messagesPart2);
|
||||
}
|
||||
|
||||
void CannedMessageModule::handleGetCannedMessageModulePart3(
|
||||
const MeshPacket &req, AdminMessage *response)
|
||||
void CannedMessageModule::handleGetCannedMessageModulePart3(const MeshPacket &req, AdminMessage *response)
|
||||
{
|
||||
DEBUG_MSG("*** handleGetCannedMessageModulePart3\n");
|
||||
assert(req.decoded.want_response);
|
||||
|
||||
response->which_variant = AdminMessage_get_canned_message_module_part3_response_tag;
|
||||
strcpy(
|
||||
response->get_canned_message_module_part3_response,
|
||||
cannedMessageModuleConfig.messagesPart3);
|
||||
strcpy(response->get_canned_message_module_part3_response, cannedMessageModuleConfig.messagesPart3);
|
||||
}
|
||||
|
||||
void CannedMessageModule::handleGetCannedMessageModulePart4(
|
||||
const MeshPacket &req, AdminMessage *response)
|
||||
void CannedMessageModule::handleGetCannedMessageModulePart4(const MeshPacket &req, AdminMessage *response)
|
||||
{
|
||||
DEBUG_MSG("*** handleGetCannedMessageModulePart4\n");
|
||||
assert(req.decoded.want_response);
|
||||
|
||||
response->which_variant = AdminMessage_get_canned_message_module_part4_response_tag;
|
||||
strcpy(
|
||||
response->get_canned_message_module_part4_response,
|
||||
cannedMessageModuleConfig.messagesPart4);
|
||||
strcpy(response->get_canned_message_module_part4_response, cannedMessageModuleConfig.messagesPart4);
|
||||
}
|
||||
|
||||
void CannedMessageModule::handleSetCannedMessageModulePart1(const char *from_msg)
|
||||
{
|
||||
int changed = 0;
|
||||
|
||||
if (*from_msg)
|
||||
{
|
||||
if (*from_msg) {
|
||||
changed |= strcmp(cannedMessageModuleConfig.messagesPart1, from_msg);
|
||||
strcpy(cannedMessageModuleConfig.messagesPart1, from_msg);
|
||||
DEBUG_MSG("*** from_msg.text:%s\n", from_msg);
|
||||
}
|
||||
|
||||
if (changed)
|
||||
{
|
||||
if (changed) {
|
||||
this->saveProtoForModule();
|
||||
}
|
||||
}
|
||||
@@ -506,14 +425,12 @@ void CannedMessageModule::handleSetCannedMessageModulePart2(const char *from_msg
|
||||
{
|
||||
int changed = 0;
|
||||
|
||||
if (*from_msg)
|
||||
{
|
||||
if (*from_msg) {
|
||||
changed |= strcmp(cannedMessageModuleConfig.messagesPart2, from_msg);
|
||||
strcpy(cannedMessageModuleConfig.messagesPart2, from_msg);
|
||||
}
|
||||
|
||||
if (changed)
|
||||
{
|
||||
if (changed) {
|
||||
this->saveProtoForModule();
|
||||
}
|
||||
}
|
||||
@@ -522,14 +439,12 @@ void CannedMessageModule::handleSetCannedMessageModulePart3(const char *from_msg
|
||||
{
|
||||
int changed = 0;
|
||||
|
||||
if (*from_msg)
|
||||
{
|
||||
if (*from_msg) {
|
||||
changed |= strcmp(cannedMessageModuleConfig.messagesPart3, from_msg);
|
||||
strcpy(cannedMessageModuleConfig.messagesPart3, from_msg);
|
||||
}
|
||||
|
||||
if (changed)
|
||||
{
|
||||
if (changed) {
|
||||
this->saveProtoForModule();
|
||||
}
|
||||
}
|
||||
@@ -538,14 +453,12 @@ void CannedMessageModule::handleSetCannedMessageModulePart4(const char *from_msg
|
||||
{
|
||||
int changed = 0;
|
||||
|
||||
if (*from_msg)
|
||||
{
|
||||
if (*from_msg) {
|
||||
changed |= strcmp(cannedMessageModuleConfig.messagesPart4, from_msg);
|
||||
strcpy(cannedMessageModuleConfig.messagesPart4, from_msg);
|
||||
}
|
||||
|
||||
if (changed)
|
||||
{
|
||||
if (changed) {
|
||||
this->saveProtoForModule();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user