MessagePasser
A real-time messaging application that periodically sends timestamped messages to a remote server via HTTP POST requests.
Overview
MessagePasser is an embedded C++ application designed to communicate with a remote web service. The application continuously sends JSON-formatted messages containing device identification, uptime information, and timestamped messages to a specified HTTP endpoint.
Features
- Automatic Device Identification: Uses the device's MAC address as a unique identifier
- Real-time Communication: Sends HTTP POST requests with JSON payloads
- Uptime Tracking: Reports system uptime with each message
- Network Integration: Waits for active network connection (DHCP) before operation
- Periodic Messaging: Sends messages every 10 seconds automatically
- JSON Response Handling: Processes server responses and displays success status
Application Flow
- Initialization: System initialization and diagnostics enablement
- Network Setup: Waits up to 5 seconds for active network connection
- Message Loop: Continuous loop that:
- Creates timestamped messages
- Sends JSON data to remote server
- Processes server responses
- Waits 10 seconds before next iteration
Message Format
The application sends JSON messages with the following structure:
{
"DEVICEID": "AABBCCDDEEFF",
"UPTIME": 12345,
"MESSAGE": "At the tone the time will be: 12345"
}
Where:
DEVICEID: 12-character hexadecimal string representing the device MAC address
UPTIME: Current system uptime in seconds
MESSAGE: Timestamped message string
Server Endpoints
The application is configured to communicate with:
Implementation Details
Key Functions
- **
SendRxMessage(const char *msg)**: Modern JSON object-based message sending
- **
SendManualRxMessage(const char *msg)**: Manual JSON string formatting (alternative implementation)
- **
UserMain(void *pd)**: Main application entry point and message loop
Dependencies
The application requires several system libraries:
Network Requirements
- Active network interface with DHCP configuration
- Internet connectivity to reach the remote server
- HTTP POST capability
Configuration
Timing Parameters
- Network Wait: 5 seconds maximum for DHCP address acquisition
- Message Interval: 10 seconds between transmissions
- HTTP Timeout: 10 seconds for server response
Customization Options
- Server URL can be modified by changing the
Url constant
- Message content can be customized in the
UserMain function
- Timing intervals can be adjusted by modifying the
OSTimeDly parameters
Output
The application provides console output including:
- Application startup confirmation
- Success/failure status for each HTTP request
- Server response messages
- Error notifications for failed requests
Use Cases
This application is suitable for:
- IoT device monitoring and reporting
- Remote system status updates
- Periodic data collection from embedded devices
- Network connectivity testing and validation
Technical Notes
- Built for embedded systems with real-time OS capabilities
- Uses system ticks for timing (
TICKS_PER_SECOND)
- Implements proper JSON object building and parsing
- Includes system diagnostics for development/debugging