Merge remote-tracking branch 'origin/master' into 2.2-working-changes

This commit is contained in:
Ben Meadors
2023-08-07 13:24:10 -05:00
36 changed files with 497 additions and 60 deletions

View File

@@ -18,7 +18,9 @@
#include "graphics/fonts/OLEDDisplayFontsUA.h"
#endif
#if defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS) || defined(ST7789_CS)
#if (defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS) || defined(ST7789_CS)) && \
!defined(DISPLAY_FORCE_SMALL_FONTS)
// The screen is bigger so use bigger fonts
#define FONT_SMALL ArialMT_Plain_16
#define FONT_MEDIUM ArialMT_Plain_24
@@ -59,7 +61,8 @@ CannedMessageModule::CannedMessageModule()
{
if (moduleConfig.canned_message.enabled) {
this->loadProtoForModule();
if ((this->splitConfiguredMessages() <= 0) && (cardkb_found.address != CARDKB_ADDR)) {
if ((this->splitConfiguredMessages() <= 0) && (cardkb_found.address != CARDKB_ADDR) &&
(cardkb_found.address != TDECK_KB_ADDR)) {
LOG_INFO("CannedMessageModule: No messages are configured. Module is disabled\n");
this->runState = CANNED_MESSAGE_RUN_STATE_DISABLED;
disable();

View File

@@ -1,3 +1,18 @@
/**
* @file ExternalNotificationModule.cpp
* @brief Implementation of the ExternalNotificationModule class.
*
* This file contains the implementation of the ExternalNotificationModule class, which is responsible for handling external
* notifications such as vibration, buzzer, and LED lights. The class provides methods to turn on and off the external
* notification outputs and to play ringtones using PWM buzzer. It also includes default configurations and a runOnce() method to
* handle the module's behavior.
*
* Documentation:
* https://meshtastic.org/docs/settings/moduleconfig/external-notification
*
* @author Jm Casler & Meshtastic Team
* @date [Insert Date]
*/
#include "ExternalNotificationModule.h"
#include "MeshService.h"
#include "NodeDB.h"
@@ -113,6 +128,11 @@ int32_t ExternalNotificationModule::runOnce()
}
}
/**
* Sets the external notification on for the specified index.
*
* @param index The index of the external notification to turn on.
*/
void ExternalNotificationModule::setExternalOn(uint8_t index)
{
externalCurrentState[index] = 1;

View File

@@ -1,3 +1,13 @@
/**
* @file RangeTestModule.cpp
* @brief Implementation of the RangeTestModule class and RangeTestModuleRadio class.
*
* As a sender, this module sends packets every n seconds with an incremented PacketID.
* As a receiver, this module receives packets from multiple senders and saves them to the Filesystem.
*
* The RangeTestModule class is an OSThread that runs the module.
* The RangeTestModuleRadio class handles sending and receiving packets.
*/
#include "RangeTestModule.h"
#include "FSCommon.h"
#include "MeshService.h"
@@ -10,11 +20,6 @@
#include "gps/GeoCoord.h"
#include <Arduino.h>
/*
As a sender, I can send packets every n seconds. These packets include an incremented PacketID.
As a receiver, I can receive packets from multiple senders. These packets can be saved to the Filesystem.
*/
RangeTestModule *rangeTestModule;
RangeTestModuleRadio *rangeTestModuleRadio;
@@ -97,6 +102,12 @@ int32_t RangeTestModule::runOnce()
return disable();
}
/**
* Sends a payload to a specified destination node.
*
* @param dest The destination node number.
* @param wantReplies Whether or not to request replies from the destination node.
*/
void RangeTestModuleRadio::sendPayload(NodeNum dest, bool wantReplies)
{
meshtastic_MeshPacket *p = allocDataPacket();

View File

@@ -86,7 +86,13 @@ SerialModuleRadio::SerialModuleRadio() : MeshModule("SerialModuleRadio")
}
}
// For the serial2 port we can't really detect if any client is on the other side, so instead just look for recent messages
/**
* @brief Checks if the serial connection is established.
*
* @return true if the serial connection is established, false otherwise.
*
* For the serial2 port we can't really detect if any client is on the other side, so instead just look for recent messages
*/
bool SerialModule::checkIsConnected()
{
uint32_t now = millis();
@@ -191,6 +197,11 @@ int32_t SerialModule::runOnce()
}
}
/**
* Allocates a new mesh packet for use as a reply to a received packet.
*
* @return A pointer to the newly allocated mesh packet.
*/
meshtastic_MeshPacket *SerialModuleRadio::allocReply()
{
auto reply = allocDataPacket(); // Allocate a packet for sending
@@ -198,6 +209,12 @@ meshtastic_MeshPacket *SerialModuleRadio::allocReply()
return reply;
}
/**
* Sends a payload to a specified destination node.
*
* @param dest The destination node number.
* @param wantReplies Whether or not to request replies from the destination node.
*/
void SerialModuleRadio::sendPayload(NodeNum dest, bool wantReplies)
{
meshtastic_Channel *ch = (boundChannel != NULL) ? &channels.getByName(boundChannel) : NULL;
@@ -216,6 +233,12 @@ void SerialModuleRadio::sendPayload(NodeNum dest, bool wantReplies)
service.sendToMesh(p);
}
/**
* Handle a received mesh packet.
*
* @param mp The received mesh packet.
* @return The processed message.
*/
ProcessMessage SerialModuleRadio::handleReceived(const meshtastic_MeshPacket &mp)
{
if (moduleConfig.serial.enabled) {
@@ -277,6 +300,11 @@ ProcessMessage SerialModuleRadio::handleReceived(const meshtastic_MeshPacket &mp
return ProcessMessage::CONTINUE; // Let others look at this message also if they want
}
/**
* @brief Returns the baud rate of the serial module from the module configuration.
*
* @return uint32_t The baud rate of the serial module.
*/
uint32_t SerialModule::getBaudRate()
{
if (moduleConfig.serial.baud == meshtastic_ModuleConfig_SerialConfig_Serial_Baud_BAUD_110) {

View File

@@ -31,7 +31,9 @@ SHT31Sensor sht31Sensor;
#define FAILED_STATE_SENSOR_READ_MULTIPLIER 10
#define DISPLAY_RECEIVEID_MEASUREMENTS_ON_SCREEN true
#ifdef USE_EINK
#if (defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS) || defined(ST7789_CS)) && \
!defined(DISPLAY_FORCE_SMALL_FONTS)
// The screen is bigger so use bigger fonts
#define FONT_SMALL ArialMT_Plain_16
#define FONT_MEDIUM ArialMT_Plain_24

View File

@@ -48,7 +48,9 @@ AudioModule *audioModule;
#define YIELD_FROM_ISR(x) portYIELD_FROM_ISR(x)
#endif
#if defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS)
#if (defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS) || defined(ST7789_CS)) && \
!defined(DISPLAY_FORCE_SMALL_FONTS)
// The screen is bigger so use bigger fonts
#define FONT_SMALL ArialMT_Plain_16
#define FONT_MEDIUM ArialMT_Plain_24

View File

@@ -1,3 +1,17 @@
/**
* @file StoreForwardModule.cpp
* @brief Implementation of the StoreForwardModule class.
*
* This file contains the implementation of the StoreForwardModule class, which is responsible for managing the store and forward
* functionality of the Meshtastic device. The class provides methods for sending and receiving messages, as well as managing the
* message history queue. It also initializes and manages the data structures used for storing the message history.
*
* The StoreForwardModule class is used by the MeshService class to provide store and forward functionality to the Meshtastic
* device.
*
* @author Jm Casler
* @date [Insert Date]
*/
#include "StoreForwardModule.h"
#include "MeshService.h"
#include "NodeDB.h"
@@ -52,9 +66,9 @@ int32_t StoreForwardModule::runOnce()
return disable();
}
/*
Create our data structure in the PSRAM.
*/
/**
* Populates the PSRAM with data to be sent later when a device is out of range.
*/
void StoreForwardModule::populatePSRAM()
{
/*
@@ -82,6 +96,12 @@ void StoreForwardModule::populatePSRAM()
LOG_DEBUG("*** numberOfPackets for packetHistory - %u\n", numberOfPackets);
}
/**
* Sends messages from the message history to the specified recipient.
*
* @param msAgo The number of milliseconds ago from which to start sending messages.
* @param to The recipient ID to send the messages to.
*/
void StoreForwardModule::historySend(uint32_t msAgo, uint32_t to)
{
uint32_t queueSize = storeForwardModule->historyQueueCreate(msAgo, to);
@@ -101,6 +121,13 @@ void StoreForwardModule::historySend(uint32_t msAgo, uint32_t to)
storeForwardModule->sendMessage(to, sf);
}
/**
* Creates a new history queue with messages that were received within the specified time frame.
*
* @param msAgo The number of milliseconds ago to start the history queue.
* @param to The maximum number of messages to include in the history queue.
* @return The ID of the newly created history queue.
*/
uint32_t StoreForwardModule::historyQueueCreate(uint32_t msAgo, uint32_t to)
{
@@ -141,6 +168,11 @@ uint32_t StoreForwardModule::historyQueueCreate(uint32_t msAgo, uint32_t to)
return this->packetHistoryTXQueue_size;
}
/**
* Adds a mesh packet to the history buffer for store-and-forward functionality.
*
* @param mp The mesh packet to add to the history buffer.
*/
void StoreForwardModule::historyAdd(const meshtastic_MeshPacket &mp)
{
const auto &p = mp.decoded;
@@ -162,6 +194,12 @@ meshtastic_MeshPacket *StoreForwardModule::allocReply()
return reply;
}
/**
* Sends a payload to a specified destination node using the store and forward mechanism.
*
* @param dest The destination node number.
* @param packetHistory_index The index of the packet in the packet history buffer.
*/
void StoreForwardModule::sendPayload(NodeNum dest, uint32_t packetHistory_index)
{
LOG_INFO("*** Sending S&F Payload\n");
@@ -183,6 +221,12 @@ void StoreForwardModule::sendPayload(NodeNum dest, uint32_t packetHistory_index)
service.sendToMesh(p);
}
/**
* Sends a message to a specified destination node using the store and forward protocol.
*
* @param dest The destination node number.
* @param payload The message payload to be sent.
*/
void StoreForwardModule::sendMessage(NodeNum dest, meshtastic_StoreAndForward &payload)
{
meshtastic_MeshPacket *p = allocDataProtobuf(payload);
@@ -203,6 +247,12 @@ void StoreForwardModule::sendMessage(NodeNum dest, meshtastic_StoreAndForward &p
service.sendToMesh(p);
}
/**
* Sends a store-and-forward message to the specified destination node.
*
* @param dest The destination node number.
* @param rr The store-and-forward request/response message to send.
*/
void StoreForwardModule::sendMessage(NodeNum dest, meshtastic_StoreAndForward_RequestResponse rr)
{
// Craft an empty response, save some bytes in flash
@@ -211,6 +261,11 @@ void StoreForwardModule::sendMessage(NodeNum dest, meshtastic_StoreAndForward_Re
storeForwardModule->sendMessage(dest, sf);
}
/**
* Sends statistics about the store and forward module to the specified node.
*
* @param to The node ID to send the statistics to.
*/
void StoreForwardModule::statsSend(uint32_t to)
{
meshtastic_StoreAndForward sf = meshtastic_StoreAndForward_init_zero;
@@ -231,6 +286,12 @@ void StoreForwardModule::statsSend(uint32_t to)
storeForwardModule->sendMessage(to, sf);
}
/**
* Handles a received mesh packet, potentially storing it for later forwarding.
*
* @param mp The received mesh packet.
* @return A `ProcessMessage` indicating whether the packet was successfully handled.
*/
ProcessMessage StoreForwardModule::handleReceived(const meshtastic_MeshPacket &mp)
{
#ifdef ARCH_ESP32
@@ -287,6 +348,13 @@ ProcessMessage StoreForwardModule::handleReceived(const meshtastic_MeshPacket &m
return ProcessMessage::CONTINUE; // Let others look at this message also if they want
}
/**
* Handles a received protobuf message for the Store and Forward module.
*
* @param mp The received MeshPacket to handle.
* @param p A pointer to the StoreAndForward object.
* @return True if the message was successfully handled, false otherwise.
*/
bool StoreForwardModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_StoreAndForward *p)
{
if (!moduleConfig.store_forward.enabled) {
@@ -488,4 +556,4 @@ StoreForwardModule::StoreForwardModule()
disable();
}
#endif
}
}