Files
firmware/src/modules/Modules.cpp

137 lines
4.7 KiB
C++
Raw Normal View History

#include "configuration.h"
2022-01-13 14:06:10 +01:00
#include "input/InputBroker.h"
#include "input/RotaryEncoderInterruptImpl1.h"
#include "input/TrackballInterruptImpl1.h"
#include "input/UpDownInterruptImpl1.h"
#include "input/cardKbI2cImpl.h"
2023-08-07 19:34:42 +02:00
#include "input/kbMatrixImpl.h"
#include "modules/AdminModule.h"
#include "modules/CannedMessageModule.h"
#include "modules/DetectionSensorModule.h"
#include "modules/NeighborInfoModule.h"
#include "modules/NodeInfoModule.h"
#include "modules/PositionModule.h"
#include "modules/RemoteHardwareModule.h"
#include "modules/ReplyModule.h"
#include "modules/RoutingModule.h"
#include "modules/TextMessageModule.h"
2022-12-05 20:38:06 +01:00
#include "modules/TraceRouteModule.h"
#include "modules/WaypointModule.h"
#if ARCH_PORTDUINO
#include "input/LinuxInputImpl.h"
#endif
#if HAS_TELEMETRY
#include "modules/Telemetry/DeviceTelemetry.h"
#endif
#if HAS_SENSOR
#include "modules/Telemetry/AirQualityTelemetry.h"
2023-02-11 11:46:54 +01:00
#include "modules/Telemetry/EnvironmentTelemetry.h"
#endif
#if HAS_TELEMETRY && !defined(ARCH_PORTDUINO)
#include "modules/Telemetry/PowerTelemetry.h"
#endif
#ifdef ARCH_ESP32
2023-12-17 16:00:57 +01:00
#ifdef USE_SX1280
2023-01-21 14:34:29 +01:00
#include "modules/esp32/AudioModule.h"
2023-12-17 16:00:57 +01:00
#endif
#include "modules/esp32/PaxcounterModule.h"
2022-02-27 01:27:17 -08:00
#include "modules/esp32/StoreForwardModule.h"
#endif
#if defined(ARCH_ESP32) || defined(ARCH_NRF52) || defined(ARCH_RP2040)
#include "modules/ExternalNotificationModule.h"
#include "modules/RangeTestModule.h"
#if (defined(ARCH_ESP32) || defined(ARCH_NRF52) || defined(ARCH_RP2040)) && !defined(CONFIG_IDF_TARGET_ESP32S2)
2022-09-12 10:08:32 +02:00
#include "modules/SerialModule.h"
#endif
2022-09-12 10:53:11 +02:00
#endif
/**
* Create module instances here. If you are adding a new module, you must 'new' it here (or somewhere else)
*/
2022-02-27 01:49:24 -08:00
void setupModules()
{
2023-01-28 09:18:06 -06:00
if (config.device.role != meshtastic_Config_DeviceConfig_Role_REPEATER) {
#if HAS_BUTTON || ARCH_PORTDUINO
2023-01-28 09:18:06 -06:00
inputBroker = new InputBroker();
#endif
2023-01-28 09:18:06 -06:00
adminModule = new AdminModule();
nodeInfoModule = new NodeInfoModule();
positionModule = new PositionModule();
waypointModule = new WaypointModule();
textMessageModule = new TextMessageModule();
traceRouteModule = new TraceRouteModule();
neighborInfoModule = new NeighborInfoModule();
detectionSensorModule = new DetectionSensorModule();
2023-01-21 14:34:29 +01:00
2023-01-28 09:18:06 -06:00
// Note: if the rest of meshtastic doesn't need to explicitly use your module, you do not need to assign the instance
// to a global variable.
2023-01-28 09:18:06 -06:00
new RemoteHardwareModule();
new ReplyModule();
#if HAS_BUTTON || ARCH_PORTDUINO
2023-01-28 09:18:06 -06:00
rotaryEncoderInterruptImpl1 = new RotaryEncoderInterruptImpl1();
if (!rotaryEncoderInterruptImpl1->init()) {
delete rotaryEncoderInterruptImpl1;
rotaryEncoderInterruptImpl1 = nullptr;
}
2023-01-28 09:18:06 -06:00
upDownInterruptImpl1 = new UpDownInterruptImpl1();
if (!upDownInterruptImpl1->init()) {
delete upDownInterruptImpl1;
upDownInterruptImpl1 = nullptr;
}
2023-01-28 09:18:06 -06:00
cardKbI2cImpl = new CardKbI2cImpl();
cardKbI2cImpl->init();
2023-08-07 19:57:47 +02:00
#ifdef INPUTBROKER_MATRIX_TYPE
2023-08-07 19:34:42 +02:00
kbMatrixImpl = new KbMatrixImpl();
kbMatrixImpl->init();
2023-08-07 19:57:47 +02:00
#endif // INPUTBROKER_MATRIX_TYPE
#endif // HAS_BUTTON
#if ARCH_PORTDUINO
aLinuxInputImpl = new LinuxInputImpl();
aLinuxInputImpl->init();
#endif
#if HAS_TRACKBALL
trackballInterruptImpl1 = new TrackballInterruptImpl1();
trackballInterruptImpl1->init();
#endif
#if HAS_SCREEN
2023-01-28 09:18:06 -06:00
cannedMessageModule = new CannedMessageModule();
2022-05-06 15:41:37 +02:00
#endif
#if HAS_TELEMETRY
2023-01-28 09:18:06 -06:00
new DeviceTelemetryModule();
#endif
#if HAS_SENSOR
2023-01-28 09:18:06 -06:00
new EnvironmentTelemetryModule();
if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_PMSA003I].first > 0) {
2023-02-04 13:07:14 -06:00
new AirQualityTelemetryModule();
}
#endif
#if HAS_TELEMETRY && !defined(ARCH_PORTDUINO)
new PowerTelemetryModule();
#endif
#if (defined(ARCH_ESP32) || defined(ARCH_NRF52) || defined(ARCH_RP2040)) && !defined(CONFIG_IDF_TARGET_ESP32S2) && \
!defined(CONFIG_IDF_TARGET_ESP32C3)
2023-01-28 09:18:06 -06:00
new SerialModule();
#endif
#ifdef ARCH_ESP32
2023-01-28 09:18:06 -06:00
// Only run on an esp32 based device.
2023-12-17 16:00:57 +01:00
#ifdef USE_SX1280
2023-01-28 09:18:06 -06:00
audioModule = new AudioModule();
2023-12-17 16:00:57 +01:00
#endif
2023-01-28 09:18:06 -06:00
storeForwardModule = new StoreForwardModule();
2023-12-17 16:00:57 +01:00
paxcounterModule = new PaxcounterModule();
#endif
#if defined(ARCH_ESP32) || defined(ARCH_NRF52) || defined(ARCH_RP2040)
2023-01-28 09:18:06 -06:00
externalNotificationModule = new ExternalNotificationModule();
new RangeTestModule();
#endif
2023-01-28 09:18:06 -06:00
} else {
adminModule = new AdminModule();
#if HAS_TELEMETRY
new DeviceTelemetryModule();
#endif
2023-01-29 16:37:02 +01:00
traceRouteModule = new TraceRouteModule();
2023-01-28 09:18:06 -06:00
}
2023-01-29 16:37:02 +01:00
// NOTE! This module must be added LAST because it likes to check for replies from other modules and avoid sending extra
// acks
2023-01-28 09:18:06 -06:00
routingModule = new RoutingModule();
}