Communication Module Technicals
Overview
DroneEngage Communication (DE Comm) is a Linux-based distributed communication system for monitoring and controlling drones via Internet. It serves as a communication broker that runs on vehicles, coordinating between various modules (Mavlink, Video, etc.) and the Andruav Server/WebClients. This module is part of the Ardupilot Cloud Eco System and provides a C++ alternative to the Android-based Andruav application.
Tech Stack
Language: C++17
Build System: CMake 3.10+
Core Libraries:
Boost 1.74.0+ (coroutine, context, thread, system, chrono)
libcurl4-openssl-dev
OpenSSL
Architecture: Plugin-Broker pattern with UDP communication
Package Management: Debian (.deb) packages via CPack
Logging: plog (3rdparty library)
Architecture Summary
Plugin-Broker Pattern
The system consists of two main components communicating via UDP:
Plugin Side (de_comm library)
CModule- Main interface for plugins (singleton pattern)CUDPClient- UDP communication with chunking supportCFacade_Base- High-level API wrapperCAndruavMessageParserBase- Message parsing
Broker Side (de_comm broker module)
CUavosModulesManager- Central module managerCUDPCommunicator- UDP server for modulesCMessageBuffer- Thread-safe message queue
Message Routing Types
CMD_TYPE_INTERMODULE- Plugin-to-plugin communication onlyCMD_COMM_SYSTEM- Plugin-to-broker system commandsCMD_COMM_GROUP/CMD_COMM_INDIVIDUAL- Messages forwarded to external DroneEngage server
Module Classes
MODULE_CLASS_FCB- Flight Control BoardMODULE_CLASS_VIDEO- Camera modulesMODULE_CLASS_P2P- Peer-to-Peer communicationMODULE_CLASS_GPIO- GPIO controlMODULE_CLASS_TRACKING- Object trackingMODULE_CLASS_A_RECOGNITION- AI recognitionMODULE_CLASS_SDR- Software Defined RadioMODULE_CLASS_SOUND- Audio processing
Key Files and Directories
Root Configuration
CMakeLists.txt- Main build configuration with auto-versioning (x.y.z.build format)de_comm.config.module.json- Module configuration (IP, ports, authentication)template.json- Configuration templateroot.crt- SSL certificate for authenticationbuild.sh/build_release.sh/build_ddebug.sh- Build scripts
Source Structure (src/)
main.cpp- Entry point for broker moduleglobal.hpp- Global definitions and constantsmessages.hpp- Message type definitionsstatus.hpp- System status definitionsversion.h- Auto-generated version headerconfigFile.cpp/hpp- Configuration file handlinglocalConfigFile.cpp/hpp- Local configuration overrides
Core Components
comm_server/- Andruav communication server implementationandruav_auth.cpp/hpp- Authentication logicandruav_comm_server.cpp/hpp- Main communication serverandruav_facade.cpp/hpp- Facade pattern implementationandruav_parser.cpp/hpp- Message parser
de_broker/- Broker implementationandruav_message.cpp/hpp- Message structuresandruav_message_buffer.cpp/hpp- Thread-safe message queuede_modules_manager.cpp- Module lifecycle management
de_general_mission_planner/- Mission planning functionalityhelpers/- Utility functionshal//hal_linux/- Hardware abstraction layernotification_module/- Notification system
Build Output
Binary:
bin/de_commDebian package:
build/de-communicator-pro-x.y.z-Linux.debInstallation path:
$HOME/drone_engage/de_comm/
Build Instructions
Prerequisites
sudo apt install git cmake build-essential
sudo apt install libcurl4-openssl-dev libssl-dev
sudo apt install libboost-all-dev # or build Boost 1.74+ from source
Build Process
rm -rf ./build
mkdir build && cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON ../
make -j$(nproc)
cpack -G DEB # Generate Debian package
Build Types
DEBUG- Debug symbols, additional loggingRELEASE- Optimized, auto-increments build versionDDEBUG=ON- Detailed debug output (add to cmake command)
Installation
sudo dpkg -i de-communicator-pro-*.deb
Version Management
Format:
MAJOR.MINOR.BUGFIX.BUILD(e.g., 3.12.0.5)Major/Minor/Bugfix: Manually set in CMakeLists.txt
Build: Auto-incremented on RELEASE builds
Version stored in
.versionfile (gitignored)
Coding Standards
C++ Standards
C++17 compliance required
Strict compiler warnings enabled (
-Werror=unused-variable,-Werror=unused-result)Debug builds:
-g3 -Og -ggdbRelease builds:
-O2 -Werror=parentheses
Architecture Patterns
Singleton Pattern: Used for
CModule(plugin side)Facade Pattern:
CFacade_Baseprovides high-level APIThread-Safe Design: Mutex protection for shared data structures
Chunked UDP: Large messages split into chunks (2-byte header + data)
Callback Pattern: Message handling via user-defined callbacks
Message Protocol
JSON-based messages with compact field names (e.g., “ty” for type, “ms” for message)
Module identification messages exchanged during registration
Routing determined by “ty” field
Chunk structure:
[2 bytes: chunk number] [chunk data](0xFFFF = last chunk)
Thread Architecture
Plugin Side:
Main thread: Application logic
UDP receiver thread:
CUDPClient::InternalReceiverEntry()ID sender thread:
CUDPClient::InternelSenderIDEntry()(1-second intervals)
Broker Side:
Main thread: Module management, routing decisions
UDP receiver thread:
CUDPCommunicator::InternalReceiverEntry()Consumer thread:
CUavosModulesManager::consumerThreadFunc()
Configuration
Module Configuration (de_comm.config.module.json)
Key settings:
module_id- Module identifiers2s_udp_listening_ip/port- UDP server settingsauth_ip/port- Authentication serveruserName/accessCode- Authentication credentialsunitID/groupID- Unit identificationping_server_rate_in_ms- Keep-alive intervalmax_offline_count- Max reconnection attempts before exit
Network Configuration
Plugin connects to broker via UDP
Broker connects to Andruav server via WebSocket (SSL optional)
Default broker port: 60000
Default auth port: 19408
Security & Licensing
License validation via hardware serial and type
SSL/TLS support for server communication
Module key uniqueness enforced
Hardware types:
HARDWARE_TYPE_CPU,HARDWARE_TYPE_UNDEFINED
Common Patterns
Plugin Registration
CModule::defineModule(class, id, key, version, filter);
CModule::init(targetIP, broadcastPort, host, listenPort, chunkSize);
CModule::createJSONID(true); // Request reply
Message Sending
CModule::sendJMSG(json_message); // JSON message
CModule::sendBMSG(binary_data); // Binary message
Message Receiving
CModule::setMessageOnReceive(callback_function);
void callback(const char* message, int len);
Debugging
Colored console output for different log levels
_INFO_CONSOLE_TEXT,_SUCCESS_CONSOLE_TEXT,_ERROR_CONSOLE_TEXT,_LOG_CONSOLE_TEXTEnable
DDEBUGfor detailed debug outputCheck UDP port conflicts (ensure unique ports per module)
Verify module key uniqueness
Monitor module health via periodic ID broadcasts
Integration Points
Mavlink Module:
de_mavlinkrepositoryServer Module:
droneengage_serverrepositoryWeb Client:
andruav_webclientrepositoryAuthenticator:
droneegnage_authenticatorrepository
Important Notes
Conda/Anaconda environments: System Boost libraries preferred to avoid static initialization issues
In-source builds not allowed (must use build directory)
Debian packages install to
$HOME/drone_engage/de_comm/Scripts in
scripts/directory copied to installationThread-safe message buffering for high-throughput scenarios
When Working on This Codebase
Read
wiki/DE_Comm_Architecture.mdfirst - Complete architecture overviewUnderstand the plugin-broker UDP communication pattern
Be aware of chunked message protocol for large UDP packets
Use thread-safe data structures in broker code
Follow existing message routing patterns (inter-module vs. external)
Test with both DEBUG and RELEASE builds
Verify module registration flow when adding new module types
Check license validation logic for hardware-based modules