allow to globally switch of the sending of NMEA2000 data
This commit is contained in:
parent
966ef0c4fb
commit
9f6e41a598
25
src/main.cpp
25
src/main.cpp
|
@ -109,6 +109,7 @@ GwWifi gwWifi(&config,&logger,fixedApPass);
|
||||||
GwChannelList channels(&logger,&config);
|
GwChannelList channels(&logger,&config);
|
||||||
GwBoatData boatData(&logger);
|
GwBoatData boatData(&logger);
|
||||||
GwXDRMappings xdrMappings(&logger,&config);
|
GwXDRMappings xdrMappings(&logger,&config);
|
||||||
|
bool sendOutN2k=true;
|
||||||
|
|
||||||
|
|
||||||
int NodeAddress; // To store last Node Address
|
int NodeAddress; // To store last Node Address
|
||||||
|
@ -205,7 +206,7 @@ void handleN2kMessage(const tN2kMsg &n2kMsg,int sourceId, bool isConverted=false
|
||||||
if (! isConverted){
|
if (! isConverted){
|
||||||
nmea0183Converter->HandleMsg(n2kMsg,sourceId);
|
nmea0183Converter->HandleMsg(n2kMsg,sourceId);
|
||||||
}
|
}
|
||||||
if (sourceId != N2K_CHANNEL_ID){
|
if (sourceId != N2K_CHANNEL_ID && sendOutN2k){
|
||||||
countNMEA2KOut.add(n2kMsg.PGN);
|
countNMEA2KOut.add(n2kMsg.PGN);
|
||||||
NMEA2000.SendMsg(n2kMsg);
|
NMEA2000.SendMsg(n2kMsg);
|
||||||
}
|
}
|
||||||
|
@ -603,6 +604,8 @@ void setup() {
|
||||||
//maybe the user code changed the level
|
//maybe the user code changed the level
|
||||||
level=config.getInt(config.logLevel,LOGLEVEL);
|
level=config.getInt(config.logLevel,LOGLEVEL);
|
||||||
logger.setLevel(level);
|
logger.setLevel(level);
|
||||||
|
sendOutN2k=config.getBool(config.sendN2k,true);
|
||||||
|
logger.logDebug(GwLog::LOG,"send N2k=%s",(sendOutN2k?"true":"false"));
|
||||||
gwWifi.setup();
|
gwWifi.setup();
|
||||||
MDNS.begin(config.getConfigItem(config.systemName)->asCString());
|
MDNS.begin(config.getConfigItem(config.systemName)->asCString());
|
||||||
channels.begin(fallbackSerial);
|
channels.begin(fallbackSerial);
|
||||||
|
@ -711,17 +714,19 @@ void setup() {
|
||||||
logger.flush();
|
logger.flush();
|
||||||
NMEA2000.SetMode(tNMEA2000::N2km_ListenAndNode, NodeAddress);
|
NMEA2000.SetMode(tNMEA2000::N2km_ListenAndNode, NodeAddress);
|
||||||
NMEA2000.SetForwardOwnMessages(false);
|
NMEA2000.SetForwardOwnMessages(false);
|
||||||
// Set the information for other bus devices, which messages we support
|
if (sendOutN2k){
|
||||||
unsigned long *pgns=toN2KConverter->handledPgns();
|
// Set the information for other bus devices, which messages we support
|
||||||
if (logger.isActive(GwLog::DEBUG)){
|
unsigned long *pgns=toN2KConverter->handledPgns();
|
||||||
unsigned long *op=pgns;
|
if (logger.isActive(GwLog::DEBUG)){
|
||||||
while (*op != 0){
|
unsigned long *op=pgns;
|
||||||
logger.logDebug(GwLog::DEBUG,"add transmit pgn %ld",(long)(*op));
|
while (*op != 0){
|
||||||
logger.flush();
|
logger.logDebug(GwLog::DEBUG,"add transmit pgn %ld",(long)(*op));
|
||||||
op++;
|
logger.flush();
|
||||||
|
op++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
NMEA2000.ExtendTransmitMessages(pgns);
|
||||||
}
|
}
|
||||||
NMEA2000.ExtendTransmitMessages(pgns);
|
|
||||||
NMEA2000.ExtendReceiveMessages(nmea0183Converter->handledPgns());
|
NMEA2000.ExtendReceiveMessages(nmea0183Converter->handledPgns());
|
||||||
NMEA2000.SetMsgHandler([](const tN2kMsg &n2kMsg){
|
NMEA2000.SetMsgHandler([](const tN2kMsg &n2kMsg){
|
||||||
handleN2kMessage(n2kMsg,N2K_CHANNEL_ID);
|
handleN2kMessage(n2kMsg,N2K_CHANNEL_ID);
|
||||||
|
|
|
@ -175,6 +175,14 @@
|
||||||
"description": "min interval in ms between 2 NMEA 2000 records with the same PGN and the same source (> 5)",
|
"description": "min interval in ms between 2 NMEA 2000 records with the same PGN and the same source (> 5)",
|
||||||
"category": "converter"
|
"category": "converter"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name":"sendN2k",
|
||||||
|
"label":"NMEA2000 out",
|
||||||
|
"type":"boolean",
|
||||||
|
"default":"true",
|
||||||
|
"description":"send out the converted data on the NMEA2000 bus",
|
||||||
|
"category":"converter"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "usbActisense",
|
"name": "usbActisense",
|
||||||
"label": "USB mode",
|
"label": "USB mode",
|
||||||
|
|
Loading…
Reference in New Issue