080e47efc0
AR_electronics — AR-Autopilot Project Tarea #3 — firmware/ar_bno085_node_v1/ Nodo compacto ESP32+CAN lee heading y yaw rate del BNO085 via I2C y los publica en el backbone NMEA 2000 como PGN 127250+127251 a 10 Hz. Tarea #4 — firmware/ar_concentrador_v1/ Gateway NMEA2000<->NMEA0183 con 4 puertos OUT (UART1 TX broadcast) y 4 puertos IN (UART2 RX comandos). Parsea sentencias $PARP, gestiona autoridad de mando entre estaciones con timeout 10s y override del puente. Reenvía comandos autopilot como PGN 127237 al backbone. Tarea #5 — nmea2000_consumer (ar_autopilot_v1) Listener PGN 127237 entrante desde concentrador: HeadingControlSnapshot, HandleHeadingControl() con filtro source address, nmea2000_htc() publico, ventana stale 3s para comandos externos.
46 lines
1.7 KiB
C++
46 lines
1.7 KiB
C++
// =============================================================================
|
|
// protocols/n2k_bridge.h -- NMEA 2000 <-> NMEA 0183 conversion
|
|
// =============================================================================
|
|
//
|
|
// Outbound (NMEA 2000 → NMEA 0183 for USB-OUT ports):
|
|
// Receives PGNs from the backbone and formats standard/proprietary sentences.
|
|
//
|
|
// Inbound (NMEA 0183 → NMEA 2000 for $PARP commands from USB-IN ports):
|
|
// Converts parsed ParpCommand structs into NMEA 2000 PGN 127237.
|
|
// =============================================================================
|
|
|
|
#pragma once
|
|
|
|
#include "nmea0183_parser.h"
|
|
#include <N2kMessages.h>
|
|
#include <Stream.h>
|
|
|
|
namespace arconcentrador::protocols {
|
|
|
|
/// Initialise the NMEA 2000 stack and register PGN handlers.
|
|
void n2k_bridge_init();
|
|
|
|
/// Process one incoming NMEA 2000 message.
|
|
/// Formats the corresponding NMEA 0183 sentence into out_buf.
|
|
/// Returns true if a sentence was written.
|
|
bool n2k_to_0183(const tN2kMsg& msg, char* out_buf, size_t out_len);
|
|
|
|
/// Convert a parsed $PARP command into a NMEA 2000 PGN 127237 and send it.
|
|
/// Returns true if a PGN was sent.
|
|
bool parp_to_n2k(const ParpCommand& cmd, float current_heading_deg);
|
|
|
|
/// Latest vessel heading received from backbone (degrees, for status broadcasts).
|
|
float n2k_latest_heading_deg();
|
|
|
|
/// Latest autopilot status received from backbone (PGN 127237 from autopilot).
|
|
struct ApStatus {
|
|
float heading_deg; ///< actual vessel heading
|
|
float commanded_deg; ///< heading setpoint
|
|
float rudder_deg; ///< rudder angle
|
|
uint8_t mode; ///< 0=STANDBY 1=HEADING_HOLD 2=TRACK
|
|
bool valid;
|
|
};
|
|
ApStatus n2k_ap_status();
|
|
|
|
} // namespace arconcentrador::protocols
|