diff --git a/Log.cpp b/Log.cpp index 8d093de..7adfdfd 100644 --- a/Log.cpp +++ b/Log.cpp @@ -149,6 +149,12 @@ void LogFinalise() { if (m_fpLog != NULL) ::fclose(m_fpLog); + + if (m_mqtt != NULL) { + m_mqtt->close(); + delete m_mqtt; + m_mqtt = NULL; + } } void Log(unsigned int level, const char* fmt, ...) diff --git a/M17Control.cpp b/M17Control.cpp index 9beff31..99cd768 100644 --- a/M17Control.cpp +++ b/M17Control.cpp @@ -683,6 +683,7 @@ bool CM17Control::processRFHeader(bool lateEntry) if (type != M17_ENCRYPTION_TYPE_NONE) { LogMessage("M17, access attempt with encryption from %s to %s", m_source.c_str(), m_dest.c_str()); m_rfState = RS_RF_REJECTED; + writeJSON("rejected", RS_RF_AUDIO, m_source, m_dest); return true; } } @@ -692,6 +693,7 @@ bool CM17Control::processRFHeader(bool lateEntry) if (!ret) { LogMessage("M17, invalid access attempt from %s to %s", m_source.c_str(), m_dest.c_str()); m_rfState = RS_RF_REJECTED; + writeJSON("rejected", RS_RF_AUDIO, m_source, m_dest); return true; } } diff --git a/MQTTPublisher.cpp b/MQTTPublisher.cpp index bc4f37a..ccd2082 100644 --- a/MQTTPublisher.cpp +++ b/MQTTPublisher.cpp @@ -66,6 +66,7 @@ bool CMQTTPublisher::open() rc = ::mosquitto_loop_start(m_mosq); if (rc != MOSQ_ERR_SUCCESS) { + ::mosquitto_disconnect(m_mosq); ::mosquitto_destroy(m_mosq); m_mosq = NULL; ::fprintf(stderr, "MQTT Error loop starting: %s\n", ::mosquitto_strerror(rc)); @@ -97,9 +98,11 @@ bool CMQTTPublisher::publish(const char* topic, const char* text) void CMQTTPublisher::close() { - ::mosquitto_disconnect(m_mosq); - ::mosquitto_destroy(m_mosq); - m_mosq = NULL; + if (m_mosq != NULL) { + ::mosquitto_disconnect(m_mosq); + ::mosquitto_destroy(m_mosq); + m_mosq = NULL; + } } void CMQTTPublisher::onConnect(mosquitto* mosq, void* obj, int rc) diff --git a/schema.json b/schema.json index 0db9afd..38714f6 100644 --- a/schema.json +++ b/schema.json @@ -1,6 +1,6 @@ { "$defs": { - "mmdvm_state": {"enum": ["lockout", "idle", "d-star", "dmr", "ysf", "nxdn", "pocsag", "fm", "ax,25", "m17"]}, + "mmdvm_state": {"type": "string", "enum": ["lockout", "idle", "d-star", "dmr", "ysf", "nxdn", "pocsag", "fm", "ax,25", "m17"]}, "dstar_callsign": {"type": "string", "minLength": 8, "maxLength": 8}, "dstar_extension": {"type": "string", "minLength": 4, "maxLength": 4}, "ysf_callsign": {"type": "string", "minLength": 10, "maxLength": 10}, @@ -10,17 +10,17 @@ "p25_id": {"type": "integer", "minimum": 1, "maximum": 65535}, "nxdn_id": {"type": "integer", "minimum": 1, "maximum": 65535}, "pocsag_ric": {"type": "integer"}, - "id_type": {"enum": ["group", "individual"]}, - "ysf_mode": {"enum": ["v/d_1", "v/d_2", "voice_fr", "data_fr"]}, - "ax25_type": {"enum": ["sabm", "disc", "ui", "ua", "rr", "rnr", "rej", "frmr", "i"]}, - "dmr_slot": {"enum": [1, 2]}, - "source": {"enum": ["rf", "network"]}, - "fm_state": {"enum": ["waiting_rf", "waiting_network"]}, - "m17_traffic_type": {"enum": ["audio", "audio_data", "data"]}, + "id_type": {"type": "string", "enum": ["group", "individual"]}, + "ysf_mode": {"type": "string", "enum": ["v/d_1", "v/d_2", "voice_fr", "data_fr"]}, + "ax25_type": {"type": "string", "enum": ["sabm", "disc", "ui", "ua", "rr", "rnr", "rej", "frmr", "i"]}, + "dmr_slot": {"type": "integer", "enum": [1, 2]}, + "source": {"type": "string", "enum": ["rf", "network"]}, + "fm_state": {"type": "string", "enum": ["waiting_rf", "waiting_network"]}, + "m17_traffic_type": {"type": "string", "enum": ["audio", "audio_data", "data"]}, "ax25_pid": {"type": "string"}, - "pocsag_source": {"enum": ["local", "network"]}, - "pocsag_function": {"enum": ["numeric", "alphanumeric", "alert_1", "alert_2"]}, - "action": {"enum": ["invalid", "rejected", "header", "late_entry", "end", "lost"]}, + "pocsag_source": {"type": "string", "enum": ["local", "network"]}, + "pocsag_function": {"type": "string", "enum": ["numeric", "alphanumeric", "alert_1", "alert_2"]}, + "action": {"type": "string", "enum": ["invalid", "rejected", "header", "late_entry", "end", "lost"]}, "duration": {"type": "number", "minimum": 0.0}, "loss": {"type": "number", "minimum": 0.0}, "ber": {"type": "number", "minimum": 0.0},