From 6adfcf74664a30021f12cc84e00a7cd471ee81a1 Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Thu, 25 May 2017 18:43:54 +0200 Subject: Status display Alows to show status of current channels and users --- src/nmt/nmt.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'src/nmt') diff --git a/src/nmt/nmt.c b/src/nmt/nmt.c index b7a5f74..7a92608 100644 --- a/src/nmt/nmt.c +++ b/src/nmt/nmt.c @@ -110,12 +110,28 @@ const char *nmt_state_name(enum nmt_state state) return invalid; } +void nmt_display_status(void) +{ + sender_t *sender; + nmt_t *nmt; + + display_status_start(); + for (sender = sender_head; sender; sender = sender->next) { + nmt = (nmt_t *) sender; + display_status_channel(nmt->sender.kanal, chan_type_short_name(nmt->sysinfo.chan_type), nmt_state_name(nmt->state)); + if (nmt->trans) + display_status_subscriber(nmt->trans->subscriber.number, NULL); + } + display_status_end(); +} + static void nmt_new_state(nmt_t *nmt, enum nmt_state new_state) { if (nmt->state == new_state) return; PDEBUG_CHAN(DNMT, DEBUG_DEBUG, "State change: %s -> %s\n", nmt_state_name(nmt->state), nmt_state_name(new_state)); nmt->state = new_state; + nmt_display_status(); } static struct nmt_channels { @@ -438,8 +454,8 @@ void nmt_go_idle(nmt_t *nmt) sms_reset(nmt); PDEBUG_CHAN(DNMT, DEBUG_INFO, "Entering IDLE state, sending idle frames on %s.\n", chan_type_long_name(nmt->sysinfo.chan_type)); + nmt->trans = NULL; /* remove transaction before state change, so status is shown correctly */ nmt_new_state(nmt, STATE_IDLE); - nmt->trans = NULL; nmt_set_dsp_mode(nmt, DSP_MODE_FRAME); memset(&nmt->dialing, 0, sizeof(nmt->dialing)); @@ -488,8 +504,8 @@ static void nmt_page(transaction_t *trans, int try) if (nmt->state != STATE_IDLE && nmt->trans != trans) continue; PDEBUG(DNMT, DEBUG_INFO, "Paging on channel %d.\n", sender->kanal); + nmt->trans = trans; /* add transaction before state change, so status is shown correctly */ nmt_new_state(nmt, STATE_MT_PAGING); - nmt->trans = trans; nmt_set_dsp_mode(nmt, DSP_MODE_FRAME); nmt->tx_frame_count = 0; } @@ -711,8 +727,8 @@ static void rx_idle(nmt_t *nmt, frame_t *frame) PDEBUG_CHAN(DNMT, DEBUG_INFO, "Received roaming seizure from subscriber %c,%s\n", subscr.country, subscr.number); /* change state */ + nmt->trans = trans; /* add transaction before state change, so status is shown correctly */ nmt_new_state(nmt, STATE_ROAMING_IDENT); - nmt->trans = trans; trans->nmt = nmt; nmt->rx_frame_count = 0; nmt->tx_frame_count = 0; @@ -737,8 +753,8 @@ static void rx_idle(nmt_t *nmt, frame_t *frame) PDEBUG_CHAN(DNMT, DEBUG_INFO, "Received call from subscriber %c,%s%s\n", subscr.country, subscr.number, (subscr.coinbox) ? " (coinbox)" : ""); /* change state */ + nmt->trans = trans; /* add transaction before state change, so status is shown correctly */ nmt_new_state(nmt, STATE_MO_IDENT); - nmt->trans = trans; trans->nmt = nmt; nmt->rx_frame_count = 0; nmt->tx_frame_count = 0; -- cgit v1.2.3