Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Commit

Permalink
[dmr-handle] modified loglevels
Browse files Browse the repository at this point in the history
  • Loading branch information
nonoo committed Sep 15, 2015
1 parent dfb5fe1 commit bbf5430
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 45 deletions.
2 changes: 2 additions & 0 deletions libs/base/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ void command_process(char *input_buffer) {
loglevel.flags.ipsc = !loglevel.flags.ipsc;
else if (strcmp(tok, "comm-ip") == 0)
loglevel.flags.comm_ip = !loglevel.flags.comm_ip;
else if (strcmp(tok, "dmr") == 0)
loglevel.flags.dmr = !loglevel.flags.dmr;
else if (strcmp(tok, "dmrdata") == 0)
loglevel.flags.dmrdata = !loglevel.flags.dmrdata;
else if (strcmp(tok, "snmp") == 0)
Expand Down
25 changes: 19 additions & 6 deletions libs/base/dmr-handle.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ void dmr_handle_voicecall_end(struct ip *ip_packet, ipscpacket_t *ipscpacket, re

voicestreams_process_call_end(repeater->slot[ipscpacket->timeslot-1].voicestream, repeater);

console_log(LOGLEVEL_IPSC "ipsc [%s", repeaters_get_display_string_for_ip(&ip_packet->ip_src));
console_log(LOGLEVEL_IPSC "->%s]: %s call end on ts %u src id %u dst id %u\n",
console_log(LOGLEVEL_DMR "dmr [%s", repeaters_get_display_string_for_ip(&ip_packet->ip_src));
console_log(LOGLEVEL_DMR "->%s]: %s call end on ts %u src id %u dst id %u\n",
repeaters_get_display_string_for_ip(&ip_packet->ip_dst), dmr_get_readable_call_type(repeater->slot[ipscpacket->timeslot-1].call_type),
ipscpacket->timeslot, repeater->slot[ipscpacket->timeslot-1].src_id, repeater->slot[ipscpacket->timeslot-1].dst_id);
repeaters_state_change(repeater, ipscpacket->timeslot-1, REPEATER_SLOT_STATE_IDLE);
Expand All @@ -44,8 +44,8 @@ void dmr_handle_voicecall_start(struct ip *ip_packet, ipscpacket_t *ipscpacket,
if (repeater->slot[ipscpacket->timeslot-1].state == REPEATER_SLOT_STATE_CALL_RUNNING)
dmr_handle_voicecall_end(ip_packet, ipscpacket, repeater);

console_log(LOGLEVEL_IPSC "ipsc [%s", repeaters_get_display_string_for_ip(&ip_packet->ip_src));
console_log(LOGLEVEL_IPSC "->%s]: %s call start on ts %u src id %u dst id %u\n",
console_log(LOGLEVEL_DMR "dmr [%s", repeaters_get_display_string_for_ip(&ip_packet->ip_src));
console_log(LOGLEVEL_DMR "->%s]: %s call start on ts %u src id %u dst id %u\n",
repeaters_get_display_string_for_ip(&ip_packet->ip_dst), dmr_get_readable_call_type(ipscpacket->call_type), ipscpacket->timeslot, ipscpacket->src_id, ipscpacket->dst_id);
repeaters_state_change(repeater, ipscpacket->timeslot-1, REPEATER_SLOT_STATE_CALL_RUNNING);
repeater->slot[ipscpacket->timeslot-1].call_started_at = time(NULL);
Expand All @@ -56,12 +56,25 @@ void dmr_handle_voicecall_start(struct ip *ip_packet, ipscpacket_t *ipscpacket,
repeater->slot[ipscpacket->timeslot-1].rssi = repeater->slot[ipscpacket->timeslot-1].avg_rssi = 0;

if (repeater->auto_rssi_update_enabled_at == 0 && !repeater->snmpignored) {
console_log(LOGLEVEL_IPSC "ipsc [%s", repeaters_get_display_string_for_ip(&ip_packet->ip_src));
console_log(LOGLEVEL_IPSC "->%s]: starting auto snmp rssi update\n", repeaters_get_display_string_for_ip(&ip_packet->ip_dst));
console_log(LOGLEVEL_SNMP "snmp [%s", repeaters_get_display_string_for_ip(&ip_packet->ip_src));
console_log(LOGLEVEL_SNMP "->%s]: starting auto rssi update\n", repeaters_get_display_string_for_ip(&ip_packet->ip_dst));
repeater->auto_rssi_update_enabled_at = time(NULL)+1; // +1 - lets add a little delay to let the repeater read the correct RSSI.
}

voicestreams_process_call_start(repeater->slot[ipscpacket->timeslot-1].voicestream, repeater);

remotedb_update(repeater);
}

void dmr_handle_voicecall_timeout(repeater_t *repeater, dmr_timeslot_t ts) {
console_log(LOGLEVEL_DMR "dmr [%s]: call timeout on ts%u\n", repeaters_get_display_string_for_ip(&repeater->ipaddr), ts+1);
repeaters_state_change(repeater, ts, REPEATER_SLOT_STATE_IDLE);
repeater->slot[ts].call_ended_at = time(NULL);
remotedb_update(repeater);
remotedb_update_stats_callend(repeater, ts+1);
}

void dmr_handle_data_timeout(repeater_t *repeater, dmr_timeslot_t ts) {
console_log(LOGLEVEL_DMR "dmr [%s]: data timeout on ts%u\n", repeaters_get_display_string_for_ip(&repeater->ipaddr), ts);
repeaters_state_change(repeater, ts, REPEATER_SLOT_STATE_IDLE);
}
5 changes: 5 additions & 0 deletions libs/base/dmr-handle.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,17 @@
#ifndef DMR_HANDLE_H_
#define DMR_HANDLE_H_

#include "dmr.h"

#include <libs/comm/ipscpacket.h>
#include <libs/comm/repeaters.h>

#include <netinet/ip.h>

void dmr_handle_voicecall_end(struct ip *ip_packet, ipscpacket_t *ipscpacket, repeater_t *repeater);
void dmr_handle_voicecall_start(struct ip *ip_packet, ipscpacket_t *ipscpacket, repeater_t *repeater);
void dmr_handle_voicecall_timeout(repeater_t *repeater, dmr_timeslot_t ts);

void dmr_handle_data_timeout(repeater_t *repeater, dmr_timeslot_t ts);

#endif
6 changes: 6 additions & 0 deletions libs/base/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ void log_loglevel(loglevel_t *loglevel) {
else
console_log("off\n");

console_log(" dmr ");
if (loglevel->flags.dmr)
console_log("on\n");
else
console_log("off\n");

console_log(" dmrdata ");
if (loglevel->flags.dmrdata)
console_log("on\n");
Expand Down
34 changes: 9 additions & 25 deletions libs/comm/repeaters.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <libs/daemon/daemon-poll.h>
#include <libs/config/config.h>
#include <libs/remotedb/remotedb.h>
#include <libs/base/dmr-handle.h>

#include <string.h>
#include <sys/time.h>
Expand Down Expand Up @@ -229,23 +230,11 @@ void repeaters_process(void) {
repeater->last_repeaterinfo_request_time = time(NULL);
}

// TODO
if (repeater->slot[0].state == REPEATER_SLOT_STATE_CALL_RUNNING && time(NULL)-repeater->slot[0].last_packet_received_at > config_get_calltimeoutinsec()) {
console_log(LOGLEVEL_IPSC "repeaters [%s]: call timeout on ts1\n", repeaters_get_display_string_for_ip(&repeater->ipaddr));
repeaters_state_change(repeater, 0, REPEATER_SLOT_STATE_IDLE);
repeater->slot[0].call_ended_at = time(NULL);
remotedb_update(repeater);
remotedb_update_stats_callend(repeater, 1);
}
if (repeater->slot[0].state == REPEATER_SLOT_STATE_CALL_RUNNING && time(NULL)-repeater->slot[0].last_packet_received_at > config_get_calltimeoutinsec())
dmr_handle_voicecall_timeout(repeater, 0);

// TODO
if (repeater->slot[1].state == REPEATER_SLOT_STATE_CALL_RUNNING && time(NULL)-repeater->slot[1].last_packet_received_at > config_get_calltimeoutinsec()) {
console_log(LOGLEVEL_IPSC "repeaters [%s]: call timeout on ts2\n", repeaters_get_display_string_for_ip(&repeater->ipaddr));
repeaters_state_change(repeater, 1, REPEATER_SLOT_STATE_IDLE);
repeater->slot[1].call_ended_at = time(NULL);
remotedb_update(repeater);
remotedb_update_stats_callend(repeater, 2);
}
if (repeater->slot[1].state == REPEATER_SLOT_STATE_CALL_RUNNING && time(NULL)-repeater->slot[1].last_packet_received_at > config_get_calltimeoutinsec())
dmr_handle_voicecall_timeout(repeater, 0);

if (repeater->auto_rssi_update_enabled_at > 0 && repeater->auto_rssi_update_enabled_at <= time(NULL)) {
if (config_get_rssiupdateduringcallinmsec() > 0) {
Expand All @@ -258,16 +247,11 @@ void repeaters_process(void) {
}
}

// TODO
if (repeater->slot[0].state == REPEATER_SLOT_STATE_DATA_RECEIVE_RUNNING && time(NULL)-repeater->slot[0].data_header_received_at > config_get_datatimeoutinsec()) {
console_log(LOGLEVEL_IPSC "repeaters [%s]: data timeout on ts1\n", repeaters_get_display_string_for_ip(&repeater->ipaddr));
repeaters_state_change(repeaters, 0, REPEATER_SLOT_STATE_IDLE);
}
if (repeater->slot[0].state == REPEATER_SLOT_STATE_DATA_RECEIVE_RUNNING && time(NULL)-repeater->slot[0].data_header_received_at > config_get_datatimeoutinsec())
dmr_handle_data_timeout(repeater, 0);

if (repeater->slot[1].state == REPEATER_SLOT_STATE_DATA_RECEIVE_RUNNING && time(NULL)-repeater->slot[1].data_header_received_at > config_get_datatimeoutinsec()) {
console_log(LOGLEVEL_IPSC "repeaters [%s]: data timeout on ts2\n", repeaters_get_display_string_for_ip(&repeater->ipaddr));
repeaters_state_change(repeater, 1, REPEATER_SLOT_STATE_IDLE);
}
if (repeater->slot[1].state == REPEATER_SLOT_STATE_DATA_RECEIVE_RUNNING && time(NULL)-repeater->slot[1].data_header_received_at > config_get_datatimeoutinsec())
dmr_handle_data_timeout(repeater, 1);

repeater = repeater->next;
}
Expand Down
2 changes: 2 additions & 0 deletions libs/daemon/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ static flag_t console_isallowedtodisplay(char loglevel_char) {
case LOGLEVEL_DEBUG_VAL: return loglevel.flags.debug;
case LOGLEVEL_IPSC_VAL: return loglevel.flags.ipsc;
case LOGLEVEL_COMM_IP_VAL: return loglevel.flags.comm_ip;
case LOGLEVEL_DMR_VAL: return loglevel.flags.dmr;
case LOGLEVEL_DMRDATA_VAL: return loglevel.flags.dmrdata;
case LOGLEVEL_SNMP_VAL: return loglevel.flags.snmp;
case LOGLEVEL_REPEATERS_VAL: return loglevel.flags.repeaters;
Expand All @@ -202,6 +203,7 @@ static flag_t console_isloglevelchar(char loglevel_char) {
case LOGLEVEL_DEBUG_VAL:
case LOGLEVEL_IPSC_VAL:
case LOGLEVEL_COMM_IP_VAL:
case LOGLEVEL_DMR_VAL:
case LOGLEVEL_DMRDATA_VAL:
case LOGLEVEL_SNMP_VAL:
case LOGLEVEL_REPEATERS_VAL:
Expand Down
31 changes: 17 additions & 14 deletions libs/daemon/console.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,22 @@
#define LOGLEVEL_IPSC_VAL 0x02
#define LOGLEVEL_COMM_IP "\x03"
#define LOGLEVEL_COMM_IP_VAL 0x03
#define LOGLEVEL_DMRDATA "\x04"
#define LOGLEVEL_DMRDATA_VAL 0x04
#define LOGLEVEL_SNMP "\x05"
#define LOGLEVEL_SNMP_VAL 0x05
#define LOGLEVEL_REPEATERS "\x06"
#define LOGLEVEL_REPEATERS_VAL 0x06
#define LOGLEVEL_HEARTBEAT "\x07"
#define LOGLEVEL_HEARTBEAT_VAL 0x07
#define LOGLEVEL_REMOTEDB "\x08"
#define LOGLEVEL_REMOTEDB_VAL 0x08
#define LOGLEVEL_VOICESTREAMS "\x09"
#define LOGLEVEL_VOICESTREAMS_VAL 0x09
#define LOGLEVEL_CODING "\x0b"
#define LOGLEVEL_CODING_VAL 0x0b
#define LOGLEVEL_DMR "\x04"
#define LOGLEVEL_DMR_VAL 0x04
#define LOGLEVEL_DMRDATA "\x05"
#define LOGLEVEL_DMRDATA_VAL 0x05
#define LOGLEVEL_SNMP "\x06"
#define LOGLEVEL_SNMP_VAL 0x06
#define LOGLEVEL_REPEATERS "\x07"
#define LOGLEVEL_REPEATERS_VAL 0x07
#define LOGLEVEL_HEARTBEAT "\x08"
#define LOGLEVEL_HEARTBEAT_VAL 0x08
#define LOGLEVEL_REMOTEDB "\x09"
#define LOGLEVEL_REMOTEDB_VAL 0x09
#define LOGLEVEL_VOICESTREAMS "\x0b"
#define LOGLEVEL_VOICESTREAMS_VAL 0x0b
#define LOGLEVEL_CODING "\x0c"
#define LOGLEVEL_CODING_VAL 0x0c

// Don't forget to add new loglevels to the log command handler in command.c,
// and to the loglevel display list in log.c!
Expand All @@ -48,6 +50,7 @@ typedef union __attribute__((packed)) {
uint8_t debug : 1;
uint8_t ipsc : 1;
uint8_t comm_ip : 1;
uint8_t dmr : 1;
uint8_t dmrdata : 1;
uint8_t snmp : 1;
uint8_t repeaters : 1;
Expand Down

0 comments on commit bbf5430

Please sign in to comment.