Merge branch 'master' into lora-type

This commit is contained in:
Ben Meadors 2023-11-01 04:56:52 -05:00 committed by GitHub
commit 6e3b71d5fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 47 additions and 56 deletions

View File

@ -267,14 +267,22 @@ void MeshService::sendNetworkPing(NodeNum dest, bool wantReplies)
void MeshService::sendToPhone(meshtastic_MeshPacket *p) void MeshService::sendToPhone(meshtastic_MeshPacket *p)
{ {
perhapsDecode(p);
if (toPhoneQueue.numFree() == 0) { if (toPhoneQueue.numFree() == 0) {
LOG_WARN("ToPhone queue is full, discarding oldest\n"); if (p->decoded.portnum == meshtastic_PortNum_TEXT_MESSAGE_APP ||
meshtastic_MeshPacket *d = toPhoneQueue.dequeuePtr(0); p->decoded.portnum == meshtastic_PortNum_RANGE_TEST_APP) {
if (d) LOG_WARN("ToPhone queue is full, discarding oldest\n");
releaseToPool(d); meshtastic_MeshPacket *d = toPhoneQueue.dequeuePtr(0);
if (d)
releaseToPool(d);
} else {
LOG_WARN("ToPhone queue is full, dropping packet.\n");
releaseToPool(p);
return;
}
} }
perhapsDecode(p);
assert(toPhoneQueue.enqueue(p, 0)); assert(toPhoneQueue.enqueue(p, 0));
fromNum++; fromNum++;
} }

View File

@ -254,6 +254,8 @@ void NodeDB::installDefaultModuleConfig()
strncpy(moduleConfig.mqtt.address, default_mqtt_address, sizeof(moduleConfig.mqtt.address)); strncpy(moduleConfig.mqtt.address, default_mqtt_address, sizeof(moduleConfig.mqtt.address));
strncpy(moduleConfig.mqtt.username, default_mqtt_username, sizeof(moduleConfig.mqtt.username)); strncpy(moduleConfig.mqtt.username, default_mqtt_username, sizeof(moduleConfig.mqtt.username));
strncpy(moduleConfig.mqtt.password, default_mqtt_password, sizeof(moduleConfig.mqtt.password)); strncpy(moduleConfig.mqtt.password, default_mqtt_password, sizeof(moduleConfig.mqtt.password));
strncpy(moduleConfig.mqtt.root, default_mqtt_root, sizeof(moduleConfig.mqtt.root));
moduleConfig.mqtt.encryption_enabled = true;
moduleConfig.has_neighbor_info = true; moduleConfig.has_neighbor_info = true;
moduleConfig.neighbor_info.enabled = false; moduleConfig.neighbor_info.enabled = false;

View File

@ -204,6 +204,7 @@ extern NodeDB nodeDB;
#define default_mqtt_address "mqtt.meshtastic.org" #define default_mqtt_address "mqtt.meshtastic.org"
#define default_mqtt_username "meshdev" #define default_mqtt_username "meshdev"
#define default_mqtt_password "large4cats" #define default_mqtt_password "large4cats"
#define default_mqtt_root "msh"
inline uint32_t getConfiguredOrDefaultMs(uint32_t configuredInterval) inline uint32_t getConfiguredOrDefaultMs(uint32_t configuredInterval)
{ {

View File

@ -249,29 +249,12 @@ ErrorCode Router::send(meshtastic_MeshPacket *p)
if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) { if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) {
ChannelIndex chIndex = p->channel; // keep as a local because we are about to change it ChannelIndex chIndex = p->channel; // keep as a local because we are about to change it
bool shouldActuallyEncrypt = true;
if (moduleConfig.mqtt.enabled) { if (moduleConfig.mqtt.enabled) {
// check if we should send decrypted packets to mqtt
// truth table: LOG_INFO("Should encrypt MQTT?: %d\n", moduleConfig.mqtt.encryption_enabled);
/* mqtt_server mqtt_encryption_enabled should_encrypt
* not set 0 1
* not set 1 1
* set 0 0
* set 1 1
*
* => so we only decrypt mqtt if they have a custom mqtt server AND mqtt_encryption_enabled is FALSE
*/
if (*moduleConfig.mqtt.address && !moduleConfig.mqtt.encryption_enabled) {
shouldActuallyEncrypt = false;
}
LOG_INFO("Should encrypt MQTT?: %d\n", shouldActuallyEncrypt);
// the packet is currently in a decrypted state. send it now if they want decrypted packets // the packet is currently in a decrypted state. send it now if they want decrypted packets
if (mqtt && !shouldActuallyEncrypt) if (mqtt && !moduleConfig.mqtt.encryption_enabled)
mqtt->onSend(*p, chIndex); mqtt->onSend(*p, chIndex);
} }
@ -284,7 +267,7 @@ ErrorCode Router::send(meshtastic_MeshPacket *p)
if (moduleConfig.mqtt.enabled) { if (moduleConfig.mqtt.enabled) {
// the packet is now encrypted. // the packet is now encrypted.
// check if we should send encrypted packets to mqtt // check if we should send encrypted packets to mqtt
if (mqtt && shouldActuallyEncrypt) if (mqtt && moduleConfig.mqtt.encryption_enabled)
mqtt->onSend(*p, chIndex); mqtt->onSend(*p, chIndex);
} }
} }

View File

@ -676,7 +676,7 @@ void AdminModule::handleSetHamMode(const meshtastic_HamParameters &p)
channels.onConfigChanged(); channels.onConfigChanged();
service.reloadOwner(false); service.reloadOwner(false);
service.reloadConfig(SEGMENT_CONFIG | SEGMENT_DEVICESTATE | SEGMENT_CHANNELS); saveChanges(SEGMENT_CONFIG | SEGMENT_DEVICESTATE | SEGMENT_CHANNELS);
} }
AdminModule::AdminModule() : ProtobufModule("Admin", meshtastic_PortNum_ADMIN_APP, &meshtastic_AdminMessage_msg) AdminModule::AdminModule() : ProtobufModule("Admin", meshtastic_PortNum_ADMIN_APP, &meshtastic_AdminMessage_msg)

View File

@ -692,6 +692,10 @@ std::string MQTT::meshPacketToJson(meshtastic_MeshPacket *mp)
jsonObj["channel"] = new JSONValue((uint)mp->channel); jsonObj["channel"] = new JSONValue((uint)mp->channel);
jsonObj["type"] = new JSONValue(msgType.c_str()); jsonObj["type"] = new JSONValue(msgType.c_str());
jsonObj["sender"] = new JSONValue(owner.id); jsonObj["sender"] = new JSONValue(owner.id);
if (mp->rx_rssi != 0)
jsonObj["rssi"] = new JSONValue((int)mp->rx_rssi);
if (mp->rx_snr != 0)
jsonObj["snr"] = new JSONValue((float)mp->rx_snr);
// serialize and write it to the stream // serialize and write it to the stream
JSONValue *value = new JSONValue(jsonObj); JSONValue *value = new JSONValue(jsonObj);

View File

@ -2,13 +2,11 @@
#define I2C_SDA 21 #define I2C_SDA 21
#define I2C_SCL 22 #define I2C_SCL 22
// GPS // For GPS, 'undef's not needed
#undef GPS_RX_PIN
#undef GPS_TX_PIN
#define GPS_RX_PIN 12
#define GPS_TX_PIN 15 #define GPS_TX_PIN 15
#define GPS_UBLOX #define GPS_RX_PIN 12
#define PIN_GPS_EN 4 #define PIN_GPS_EN 4
#define GPS_POWER_TOGGLE // Moved definition from platformio.ini to here
#define BUTTON_PIN 39 // The middle button GPIO on the T-Beam #define BUTTON_PIN 39 // The middle button GPIO on the T-Beam
#define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage #define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage
@ -18,28 +16,25 @@
#define EXT_NOTIFY_OUT 12 // Overridden default pin to use for Ext Notify Module (#975). #define EXT_NOTIFY_OUT 12 // Overridden default pin to use for Ext Notify Module (#975).
#define LED_PIN 2 // add status LED (compatible with core-pcb and DIY targets) #define LED_PIN 2 // add status LED (compatible with core-pcb and DIY targets)
#define LORA_DIO0 26 // a No connect on the SX1262/SX1268 module // Radio
#define LORA_RESET 23 // RST for SX1276, and for SX1262/SX1268 #define USE_SX1262 // E22-900M30S uses SX1262
#define LORA_DIO1 33 // IRQ for SX1262/SX1268 #define SX126X_MAX_POWER \
#define LORA_DIO2 32 // BUSY for SX1262/SX1268 22 // Outputting 22dBm from SX1262 results in ~30dBm E22-900M30S output (module only uses last stage of the YP2233W PA)
#define LORA_DIO3 // Not connected on PCB, but internally on the TTGO SX1262/SX1268, if DIO3 is high the TXCO is enabled #define SX126X_DIO3_TCXO_VOLTAGE 1.8 // E22 series TCXO reference voltage is 1.8V
#define RF95_SCK 5 #define SX126X_CS 18 // EBYTE module's NSS pin
#define RF95_MISO 19 #define SX126X_SCK 5 // EBYTE module's SCK pin
#define RF95_MOSI 27 #define SX126X_MOSI 27 // EBYTE module's MOSI pin
#define RF95_NSS 18 #define SX126X_MISO 19 // EBYTE module's MISO pin
#define SX126X_RESET 23 // EBYTE module's NRST pin
#define SX126X_BUSY 32 // EBYTE module's BUSY pin
#define SX126X_DIO1 33 // EBYTE module's DIO1 pin
#define USE_SX1262 #define SX126X_TXEN 13 // Schematic connects EBYTE module's TXEN pin to MCU
#define SX126X_RXEN 14 // Schematic connects EBYTE module's RXEN pin to MCU
#define SX126X_CS 18 // NSS for SX126X #define RF95_NSS SX126X_CS // Compatibility with variant file configuration structure
#define SX126X_DIO1 LORA_DIO1 #define RF95_SCK SX126X_SCK // Compatibility with variant file configuration structure
#define SX126X_BUSY LORA_DIO2 #define RF95_MOSI SX126X_MOSI // Compatibility with variant file configuration structure
#define SX126X_RESET LORA_RESET #define RF95_MISO SX126X_MISO // Compatibility with variant file configuration structure
#define SX126X_RXEN 14 #define LORA_DIO1 SX126X_DIO1 // Compatibility with variant file configuration structure
#define SX126X_TXEN RADIOLIB_NC
#define SX126X_DIO2_AS_RF_SWITCH
// Set lora.tx_power to 13 for Hydra or other E22 900M30S target due to PA
#define SX126X_MAX_POWER 13
#define SX126X_DIO3_TCXO_VOLTAGE 1.8

View File

@ -43,6 +43,4 @@ board_level = extra
build_flags = build_flags =
${esp32_base.build_flags} ${esp32_base.build_flags}
-D DIY_V1 -D DIY_V1
-D EBYTE_E22
-D GPS_POWER_TOGGLE
-I variants/diy/hydra -I variants/diy/hydra

View File

@ -1,4 +1,4 @@
[VERSION] [VERSION]
major = 2 major = 2
minor = 2 minor = 2
build = 12 build = 13