Fix Serial Plugin name

This commit is contained in:
Sacha Weatherstone 2022-03-09 18:37:41 +11:00
parent f5369c3f1b
commit 46b8b61b7f
3 changed files with 51 additions and 51 deletions

2
proto

@ -1 +1 @@
Subproject commit f6ba3722be8a51c3c0c1446bb08e730a0be568e0 Subproject commit 11eb13439235f926420c817f3ff2f35be7db063d

View File

@ -148,12 +148,12 @@ typedef struct _RadioConfig_UserPreferences {
bool debug_log_enabled; bool debug_log_enabled;
pb_size_t ignore_incoming_count; pb_size_t ignore_incoming_count;
uint32_t ignore_incoming[3]; uint32_t ignore_incoming[3];
bool serialmodule_enabled; bool serial_module_enabled;
bool serialmodule_echo; bool serial_module_echo;
uint32_t serialmodule_rxd; uint32_t serial_module_rxd;
uint32_t serialmodule_txd; uint32_t serial_module_txd;
uint32_t serialmodule_timeout; uint32_t serial_module_timeout;
uint32_t serialmodule_mode; uint32_t serial_module_mode;
bool ext_notification_module_enabled; bool ext_notification_module_enabled;
uint32_t ext_notification_module_output_ms; uint32_t ext_notification_module_output_ms;
uint32_t ext_notification_module_output; uint32_t ext_notification_module_output;
@ -197,7 +197,7 @@ typedef struct _RadioConfig_UserPreferences {
bool canned_message_module_send_bell; bool canned_message_module_send_bell;
bool mqtt_encryption_enabled; bool mqtt_encryption_enabled;
float adc_multiplier_override; float adc_multiplier_override;
uint32_t serialmodule_baud; uint32_t serial_module_baud;
} RadioConfig_UserPreferences; } RadioConfig_UserPreferences;
typedef struct _RadioConfig { typedef struct _RadioConfig {
@ -289,12 +289,12 @@ extern "C" {
#define RadioConfig_UserPreferences_factory_reset_tag 100 #define RadioConfig_UserPreferences_factory_reset_tag 100
#define RadioConfig_UserPreferences_debug_log_enabled_tag 101 #define RadioConfig_UserPreferences_debug_log_enabled_tag 101
#define RadioConfig_UserPreferences_ignore_incoming_tag 103 #define RadioConfig_UserPreferences_ignore_incoming_tag 103
#define RadioConfig_UserPreferences_serialmodule_enabled_tag 120 #define RadioConfig_UserPreferences_serial_module_enabled_tag 120
#define RadioConfig_UserPreferences_serialmodule_echo_tag 121 #define RadioConfig_UserPreferences_serial_module_echo_tag 121
#define RadioConfig_UserPreferences_serialmodule_rxd_tag 122 #define RadioConfig_UserPreferences_serial_module_rxd_tag 122
#define RadioConfig_UserPreferences_serialmodule_txd_tag 123 #define RadioConfig_UserPreferences_serial_module_txd_tag 123
#define RadioConfig_UserPreferences_serialmodule_timeout_tag 124 #define RadioConfig_UserPreferences_serial_module_timeout_tag 124
#define RadioConfig_UserPreferences_serialmodule_mode_tag 125 #define RadioConfig_UserPreferences_serial_module_mode_tag 125
#define RadioConfig_UserPreferences_ext_notification_module_enabled_tag 126 #define RadioConfig_UserPreferences_ext_notification_module_enabled_tag 126
#define RadioConfig_UserPreferences_ext_notification_module_output_ms_tag 127 #define RadioConfig_UserPreferences_ext_notification_module_output_ms_tag 127
#define RadioConfig_UserPreferences_ext_notification_module_output_tag 128 #define RadioConfig_UserPreferences_ext_notification_module_output_tag 128
@ -338,7 +338,7 @@ extern "C" {
#define RadioConfig_UserPreferences_canned_message_module_send_bell_tag 173 #define RadioConfig_UserPreferences_canned_message_module_send_bell_tag 173
#define RadioConfig_UserPreferences_mqtt_encryption_enabled_tag 174 #define RadioConfig_UserPreferences_mqtt_encryption_enabled_tag 174
#define RadioConfig_UserPreferences_adc_multiplier_override_tag 175 #define RadioConfig_UserPreferences_adc_multiplier_override_tag 175
#define RadioConfig_UserPreferences_serialmodule_baud_tag 176 #define RadioConfig_UserPreferences_serial_module_baud_tag 176
#define RadioConfig_preferences_tag 1 #define RadioConfig_preferences_tag 1
/* Struct field encoding specification for nanopb */ /* Struct field encoding specification for nanopb */
@ -383,12 +383,12 @@ X(a, STATIC, SINGULAR, UINT32, gps_max_dop, 46) \
X(a, STATIC, SINGULAR, BOOL, factory_reset, 100) \ X(a, STATIC, SINGULAR, BOOL, factory_reset, 100) \
X(a, STATIC, SINGULAR, BOOL, debug_log_enabled, 101) \ X(a, STATIC, SINGULAR, BOOL, debug_log_enabled, 101) \
X(a, STATIC, REPEATED, UINT32, ignore_incoming, 103) \ X(a, STATIC, REPEATED, UINT32, ignore_incoming, 103) \
X(a, STATIC, SINGULAR, BOOL, serialmodule_enabled, 120) \ X(a, STATIC, SINGULAR, BOOL, serial_module_enabled, 120) \
X(a, STATIC, SINGULAR, BOOL, serialmodule_echo, 121) \ X(a, STATIC, SINGULAR, BOOL, serial_module_echo, 121) \
X(a, STATIC, SINGULAR, UINT32, serialmodule_rxd, 122) \ X(a, STATIC, SINGULAR, UINT32, serial_module_rxd, 122) \
X(a, STATIC, SINGULAR, UINT32, serialmodule_txd, 123) \ X(a, STATIC, SINGULAR, UINT32, serial_module_txd, 123) \
X(a, STATIC, SINGULAR, UINT32, serialmodule_timeout, 124) \ X(a, STATIC, SINGULAR, UINT32, serial_module_timeout, 124) \
X(a, STATIC, SINGULAR, UINT32, serialmodule_mode, 125) \ X(a, STATIC, SINGULAR, UINT32, serial_module_mode, 125) \
X(a, STATIC, SINGULAR, BOOL, ext_notification_module_enabled, 126) \ X(a, STATIC, SINGULAR, BOOL, ext_notification_module_enabled, 126) \
X(a, STATIC, SINGULAR, UINT32, ext_notification_module_output_ms, 127) \ X(a, STATIC, SINGULAR, UINT32, ext_notification_module_output_ms, 127) \
X(a, STATIC, SINGULAR, UINT32, ext_notification_module_output, 128) \ X(a, STATIC, SINGULAR, UINT32, ext_notification_module_output, 128) \
@ -432,7 +432,7 @@ X(a, STATIC, SINGULAR, STRING, canned_message_module_allow_input_source, 171
X(a, STATIC, SINGULAR, BOOL, canned_message_module_send_bell, 173) \ X(a, STATIC, SINGULAR, BOOL, canned_message_module_send_bell, 173) \
X(a, STATIC, SINGULAR, BOOL, mqtt_encryption_enabled, 174) \ X(a, STATIC, SINGULAR, BOOL, mqtt_encryption_enabled, 174) \
X(a, STATIC, SINGULAR, FLOAT, adc_multiplier_override, 175) \ X(a, STATIC, SINGULAR, FLOAT, adc_multiplier_override, 175) \
X(a, STATIC, SINGULAR, UINT32, serialmodule_baud, 176) X(a, STATIC, SINGULAR, UINT32, serial_module_baud, 176)
#define RadioConfig_UserPreferences_CALLBACK NULL #define RadioConfig_UserPreferences_CALLBACK NULL
#define RadioConfig_UserPreferences_DEFAULT NULL #define RadioConfig_UserPreferences_DEFAULT NULL

View File

@ -20,18 +20,18 @@
Basic Usage: Basic Usage:
1) Enable the module by setting serialmodule_enabled to 1. 1) Enable the module by setting serial_module_enabled to 1.
2) Set the pins (serialmodule_rxd / serialmodule_rxd) for your preferred RX and TX GPIO pins. 2) Set the pins (serial_module_rxd / serial_module_rxd) for your preferred RX and TX GPIO pins.
On tbeam, recommend to use: On tbeam, recommend to use:
RXD 35 RXD 35
TXD 15 TXD 15
3) Set serialmodule_timeout to the amount of time to wait before we consider 3) Set serial_module_timeout to the amount of time to wait before we consider
your packet as "done". your packet as "done".
4) (Optional) In SerialModule.h set the port to PortNum_TEXT_MESSAGE_APP if you want to 4) (Optional) In SerialModule.h set the port to PortNum_TEXT_MESSAGE_APP if you want to
send messages to/from the general text message channel. send messages to/from the general text message channel.
5) Connect to your device over the serial interface at 38400 8N1. 5) Connect to your device over the serial interface at 38400 8N1.
6) Send a packet up to 240 bytes in length. This will get relayed over the mesh network. 6) Send a packet up to 240 bytes in length. This will get relayed over the mesh network.
7) (Optional) Set serialmodule_echo to 1 and any message you send out will be echoed back 7) (Optional) Set serial_module_echo to 1 and any message you send out will be echoed back
to your device. to your device.
TODO (in this order): TODO (in this order):
@ -48,11 +48,11 @@
#define RXD2 16 #define RXD2 16
#define TXD2 17 #define TXD2 17
#define SERIALMODULE_RX_BUFFER 128 #define SERIAL_MODULE_RX_BUFFER 128
#define SERIALMODULE_STRING_MAX Constants_DATA_PAYLOAD_LEN #define SERIAL_MODULE_STRING_MAX Constants_DATA_PAYLOAD_LEN
#define SERIALMODULE_TIMEOUT 250 #define SERIAL_MODULE_TIMEOUT 250
#define SERIALMODULE_BAUD 38400 #define SERIAL_MODULE_BAUD 38400
#define SERIALMODULE_ACK 1 #define SERIAL_MODULE_ACK 1
SerialModule *serialModule; SerialModule *serialModule;
SerialModuleRadio *serialModuleRadio; SerialModuleRadio *serialModuleRadio;
@ -76,36 +76,36 @@ int32_t SerialModule::runOnce()
without having to configure it from the PythonAPI or WebUI. without having to configure it from the PythonAPI or WebUI.
*/ */
// radioConfig.preferences.serialmodule_enabled = 1; // radioConfig.preferences.serial_module_enabled = 1;
// radioConfig.preferences.serialmodule_rxd = 35; // radioConfig.preferences.serial_module_rxd = 35;
// radioConfig.preferences.serialmodule_txd = 15; // radioConfig.preferences.serial_module_txd = 15;
// radioConfig.preferences.serialmodule_timeout = 1000; // radioConfig.preferences.serial_module_timeout = 1000;
// radioConfig.preferences.serialmodule_echo = 1; // radioConfig.preferences.serial_module_echo = 1;
if (radioConfig.preferences.serialmodule_enabled) { if (radioConfig.preferences.serial_module_enabled) {
if (firstTime) { if (firstTime) {
// Interface with the serial peripheral from in here. // Interface with the serial peripheral from in here.
DEBUG_MSG("Initializing serial peripheral interface\n"); DEBUG_MSG("Initializing serial peripheral interface\n");
if (radioConfig.preferences.serialmodule_rxd && radioConfig.preferences.serialmodule_txd) { if (radioConfig.preferences.serial_module_rxd && radioConfig.preferences.serial_module_txd) {
Serial2.begin(SERIALMODULE_BAUD, SERIAL_8N1, radioConfig.preferences.serialmodule_rxd, Serial2.begin(SERIAL_MODULE_BAUD, SERIAL_8N1, radioConfig.preferences.serial_module_rxd,
radioConfig.preferences.serialmodule_txd); radioConfig.preferences.serial_module_txd);
} else { } else {
Serial2.begin(SERIALMODULE_BAUD, SERIAL_8N1, RXD2, TXD2); Serial2.begin(SERIAL_MODULE_BAUD, SERIAL_8N1, RXD2, TXD2);
} }
if (radioConfig.preferences.serialmodule_timeout) { if (radioConfig.preferences.serial_module_timeout) {
Serial2.setTimeout( Serial2.setTimeout(
radioConfig.preferences.serialmodule_timeout); // Number of MS to wait to set the timeout for the string. radioConfig.preferences.serial_module_timeout); // Number of MS to wait to set the timeout for the string.
} else { } else {
Serial2.setTimeout(SERIALMODULE_TIMEOUT); // Number of MS to wait to set the timeout for the string. Serial2.setTimeout(SERIAL_MODULE_TIMEOUT); // Number of MS to wait to set the timeout for the string.
} }
Serial2.setRxBufferSize(SERIALMODULE_RX_BUFFER); Serial2.setRxBufferSize(SERIAL_MODULE_RX_BUFFER);
serialModuleRadio = new SerialModuleRadio(); serialModuleRadio = new SerialModuleRadio();
@ -149,7 +149,7 @@ void SerialModuleRadio::sendPayload(NodeNum dest, bool wantReplies)
p->to = dest; p->to = dest;
p->decoded.want_response = wantReplies; p->decoded.want_response = wantReplies;
p->want_ack = SERIALMODULE_ACK; p->want_ack = SERIAL_MODULE_ACK;
p->decoded.payload.size = strlen(serialStringChar); // You must specify how many bytes are in the reply p->decoded.payload.size = strlen(serialStringChar); // You must specify how many bytes are in the reply
memcpy(p->decoded.payload.bytes, serialStringChar, p->decoded.payload.size); memcpy(p->decoded.payload.bytes, serialStringChar, p->decoded.payload.size);
@ -161,7 +161,7 @@ ProcessMessage SerialModuleRadio::handleReceived(const MeshPacket &mp)
{ {
#ifndef NO_ESP32 #ifndef NO_ESP32
if (radioConfig.preferences.serialmodule_enabled) { if (radioConfig.preferences.serial_module_enabled) {
auto &p = mp.decoded; auto &p = mp.decoded;
// DEBUG_MSG("Received text msg self=0x%0x, from=0x%0x, to=0x%0x, id=%d, msg=%.*s\n", // DEBUG_MSG("Received text msg self=0x%0x, from=0x%0x, to=0x%0x, id=%d, msg=%.*s\n",
@ -170,10 +170,10 @@ ProcessMessage SerialModuleRadio::handleReceived(const MeshPacket &mp)
if (getFrom(&mp) == nodeDB.getNodeNum()) { if (getFrom(&mp) == nodeDB.getNodeNum()) {
/* /*
* If radioConfig.preferences.serialmodule_echo is true, then echo the packets that are sent out back to the TX * If radioConfig.preferences.serial_module_echo is true, then echo the packets that are sent out back to the TX
* of the serial interface. * of the serial interface.
*/ */
if (radioConfig.preferences.serialmodule_echo) { if (radioConfig.preferences.serial_module_echo) {
// For some reason, we get the packet back twice when we send out of the radio. // For some reason, we get the packet back twice when we send out of the radio.
// TODO: need to find out why. // TODO: need to find out why.
@ -187,12 +187,12 @@ ProcessMessage SerialModuleRadio::handleReceived(const MeshPacket &mp)
} else { } else {
if (radioConfig.preferences.serialmodule_mode == 0 || radioConfig.preferences.serialmodule_mode == 1) { if (radioConfig.preferences.serial_module_mode == 0 || radioConfig.preferences.serial_module_mode == 1) {
// DEBUG_MSG("* * Message came from the mesh\n"); // DEBUG_MSG("* * Message came from the mesh\n");
// Serial2.println("* * Message came from the mesh"); // Serial2.println("* * Message came from the mesh");
Serial2.printf("%s", p.payload.bytes); Serial2.printf("%s", p.payload.bytes);
} else if (radioConfig.preferences.serialmodule_mode == 10) { } else if (radioConfig.preferences.serial_module_mode == 10) {
/* /*
@jobionekabnoi @jobionekabnoi
Add code here to handle what gets sent out to the serial interface. Add code here to handle what gets sent out to the serial interface.