mirror of
https://github.com/g4klx/MMDVMHost
synced 2025-12-24 01:25:41 +08:00
Add MMDVM status JSON messages.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015-2022 by Jonathan Naylor G4KLX
|
* Copyright (C) 2015-2023 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -34,6 +34,7 @@
|
|||||||
#include "StopWatch.h"
|
#include "StopWatch.h"
|
||||||
#include "Defines.h"
|
#include "Defines.h"
|
||||||
#include "Thread.h"
|
#include "Thread.h"
|
||||||
|
#include "Utils.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "GitVersion.h"
|
#include "GitVersion.h"
|
||||||
|
|
||||||
@@ -2025,6 +2026,7 @@ void CMMDVMHost::setMode(unsigned char mode)
|
|||||||
m_modeTimer.start();
|
m_modeTimer.start();
|
||||||
m_cwIdTimer.stop();
|
m_cwIdTimer.stop();
|
||||||
createLockFile("D-Star");
|
createLockFile("D-Star");
|
||||||
|
writeJSON("D-Star");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MODE_DMR:
|
case MODE_DMR:
|
||||||
@@ -2073,6 +2075,7 @@ void CMMDVMHost::setMode(unsigned char mode)
|
|||||||
m_modeTimer.start();
|
m_modeTimer.start();
|
||||||
m_cwIdTimer.stop();
|
m_cwIdTimer.stop();
|
||||||
createLockFile("DMR");
|
createLockFile("DMR");
|
||||||
|
writeJSON("DMR");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MODE_YSF:
|
case MODE_YSF:
|
||||||
@@ -2117,6 +2120,7 @@ void CMMDVMHost::setMode(unsigned char mode)
|
|||||||
m_modeTimer.start();
|
m_modeTimer.start();
|
||||||
m_cwIdTimer.stop();
|
m_cwIdTimer.stop();
|
||||||
createLockFile("System Fusion");
|
createLockFile("System Fusion");
|
||||||
|
writeJSON("YSF");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MODE_P25:
|
case MODE_P25:
|
||||||
@@ -2161,6 +2165,7 @@ void CMMDVMHost::setMode(unsigned char mode)
|
|||||||
m_modeTimer.start();
|
m_modeTimer.start();
|
||||||
m_cwIdTimer.stop();
|
m_cwIdTimer.stop();
|
||||||
createLockFile("P25");
|
createLockFile("P25");
|
||||||
|
writeJSON("P25");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MODE_NXDN:
|
case MODE_NXDN:
|
||||||
@@ -2205,6 +2210,7 @@ void CMMDVMHost::setMode(unsigned char mode)
|
|||||||
m_modeTimer.start();
|
m_modeTimer.start();
|
||||||
m_cwIdTimer.stop();
|
m_cwIdTimer.stop();
|
||||||
createLockFile("NXDN");
|
createLockFile("NXDN");
|
||||||
|
writeJSON("NXDN");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MODE_M17:
|
case MODE_M17:
|
||||||
@@ -2249,6 +2255,7 @@ void CMMDVMHost::setMode(unsigned char mode)
|
|||||||
m_modeTimer.start();
|
m_modeTimer.start();
|
||||||
m_cwIdTimer.stop();
|
m_cwIdTimer.stop();
|
||||||
createLockFile("M17");
|
createLockFile("M17");
|
||||||
|
writeJSON("M17");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MODE_POCSAG:
|
case MODE_POCSAG:
|
||||||
@@ -2293,6 +2300,7 @@ void CMMDVMHost::setMode(unsigned char mode)
|
|||||||
m_modeTimer.start();
|
m_modeTimer.start();
|
||||||
m_cwIdTimer.stop();
|
m_cwIdTimer.stop();
|
||||||
createLockFile("POCSAG");
|
createLockFile("POCSAG");
|
||||||
|
writeJSON("POCSAG");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MODE_FM:
|
case MODE_FM:
|
||||||
@@ -2342,6 +2350,7 @@ void CMMDVMHost::setMode(unsigned char mode)
|
|||||||
m_modeTimer.start();
|
m_modeTimer.start();
|
||||||
m_cwIdTimer.stop();
|
m_cwIdTimer.stop();
|
||||||
createLockFile("FM");
|
createLockFile("FM");
|
||||||
|
writeJSON("FM");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MODE_LOCKOUT:
|
case MODE_LOCKOUT:
|
||||||
@@ -2391,6 +2400,7 @@ void CMMDVMHost::setMode(unsigned char mode)
|
|||||||
m_modeTimer.stop();
|
m_modeTimer.stop();
|
||||||
m_cwIdTimer.stop();
|
m_cwIdTimer.stop();
|
||||||
removeLockFile();
|
removeLockFile();
|
||||||
|
writeJSON("lockout");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MODE_ERROR:
|
case MODE_ERROR:
|
||||||
@@ -2440,6 +2450,7 @@ void CMMDVMHost::setMode(unsigned char mode)
|
|||||||
m_modeTimer.stop();
|
m_modeTimer.stop();
|
||||||
m_cwIdTimer.stop();
|
m_cwIdTimer.stop();
|
||||||
removeLockFile();
|
removeLockFile();
|
||||||
|
writeJSON("error");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -2498,6 +2509,7 @@ void CMMDVMHost::setMode(unsigned char mode)
|
|||||||
m_mode = MODE_IDLE;
|
m_mode = MODE_IDLE;
|
||||||
m_modeTimer.stop();
|
m_modeTimer.stop();
|
||||||
removeLockFile();
|
removeLockFile();
|
||||||
|
writeJSON("idle");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2787,3 +2799,14 @@ void CMMDVMHost::buildNetworkHostsString(std::string &str)
|
|||||||
str += std::string(" m17:\"") + ((m_m17Enabled && (m_m17Network != NULL)) ? m_conf.getM17GatewayAddress() : "NONE") + "\"";
|
str += std::string(" m17:\"") + ((m_m17Enabled && (m_m17Network != NULL)) ? m_conf.getM17GatewayAddress() : "NONE") + "\"";
|
||||||
str += std::string(" fm:\"") + ((m_fmEnabled && (m_fmNetwork != NULL)) ? m_conf.getFMGatewayAddress() : "NONE") + "\"";
|
str += std::string(" fm:\"") + ((m_fmEnabled && (m_fmNetwork != NULL)) ? m_conf.getFMGatewayAddress() : "NONE") + "\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CMMDVMHost::writeJSON(const std::string& mode)
|
||||||
|
{
|
||||||
|
nlohmann::json json;
|
||||||
|
|
||||||
|
json["timestamp"] = CUtils::createTimestamp();
|
||||||
|
json["mode"] = mode;
|
||||||
|
|
||||||
|
WriteJSON("MMDVM", json);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015-2021 by Jonathan Naylor G4KLX
|
* Copyright (C) 2015-2021,2023 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -142,6 +142,8 @@ private:
|
|||||||
|
|
||||||
void createLockFile(const char* mode) const;
|
void createLockFile(const char* mode) const;
|
||||||
void removeLockFile() const;
|
void removeLockFile() const;
|
||||||
|
|
||||||
|
void writeJSON(const std::string& mode);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"$defs": {
|
"$defs": {
|
||||||
"mmdvm_state": {"type": "string", "enum": ["lockout", "idle", "d-star", "dmr", "ysf", "nxdn", "pocsag", "fm", "ax,25", "m17"]},
|
"mmdvm_mode": {"type": "string", "enum": ["lockout", "idle", "error", "D-Star", "DMR", "YSF", "NXDN", "POCSAG", "FM", "M17"]},
|
||||||
"dstar_callsign": {"type": "string", "minLength": 8, "maxLength": 8},
|
"dstar_callsign": {"type": "string", "minLength": 8, "maxLength": 8},
|
||||||
"dstar_extension": {"type": "string", "minLength": 4, "maxLength": 4},
|
"dstar_extension": {"type": "string", "minLength": 4, "maxLength": 4},
|
||||||
"ysf_callsign": {"type": "string", "minLength": 10, "maxLength": 10},
|
"ysf_callsign": {"type": "string", "minLength": 10, "maxLength": 10},
|
||||||
@@ -32,8 +32,8 @@
|
|||||||
"MMDVM": {
|
"MMDVM": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"timestamp": {"$ref": "#/$defs/timestamp"},
|
"timestamp": {"$ref": "#/$defs/timestamp"},
|
||||||
"state": {"$ref": "#/$defs/mmdvm_state"},
|
"mode": {"$ref": "#/$defs/mmdvm_mode"},
|
||||||
"required": ["timestamp"]
|
"required": ["timestamp", "mode"]
|
||||||
},
|
},
|
||||||
|
|
||||||
"D-Star": {
|
"D-Star": {
|
||||||
|
|||||||
Reference in New Issue
Block a user