If a mobile inscribes, show station ID on the console

If the console's station ID is not set, it will be automatically set
when a call is made from the mobile phone or when it performs
inscription to the network. (Only works for cellular networks with
inscription support.)
This commit is contained in:
Andreas Eversberg 2024-01-14 19:16:41 +01:00
parent 7e5663a709
commit c844fcc1f6
10 changed files with 45 additions and 5 deletions

View File

@ -46,6 +46,7 @@
#include "../liblogging/logging.h"
#include "../libmobile/call.h"
#include "../libmobile/cause.h"
#include "../libmobile/console.h"
#include <osmocom/cc/message.h>
#include "amps.h"
#include "dsp.h"
@ -862,6 +863,7 @@ _register:
LOGP(DAMPS, LOGL_ERROR, "Failed to create transaction\n");
return;
}
console_inscription(callerid);
} else
if (order == 13 && ordq == 3 && msg_type == 1) {
LOGP_CHAN(DAMPS, LOGL_INFO, "Registration - Power Down %s (ESN = %s, %s, %s)\n", callerid, esn_to_string(esn), amps_scm(scm), amps_mpci(mpci));

View File

@ -147,6 +147,7 @@
#include "../libmobile/call.h"
#include "../libmobile/cause.h"
#include "../libmobile/get_time.h"
#include "../libmobile/console.h"
#include <osmocom/cc/message.h>
#include "cnetz.h"
#include "database.h"
@ -1190,6 +1191,7 @@ void cnetz_receive_telegramm_ogk(cnetz_t *cnetz, telegramm_t *telegramm, int blo
LOGP(DCNETZ, LOGL_NOTICE, "Ignoring Attachment from subscriber '%s', because we are busy becoming SpK.\n", rufnummer);
break;
}
console_inscription(rufnummer);
trans = create_transaction(cnetz, TRANS_EM, telegramm->futln_nationalitaet, telegramm->futln_heimat_fuvst_nr, telegramm->futln_rest_nr, telegramm->chipkarten_futelg_bit, telegramm->erweitertes_frequenzbandbit, cnetz->rf_level_db);
if (!trans) {
LOGP(DCNETZ, LOGL_ERROR, "Failed to create transaction\n");
@ -1212,6 +1214,7 @@ void cnetz_receive_telegramm_ogk(cnetz_t *cnetz, telegramm_t *telegramm, int blo
LOGP(DCNETZ, LOGL_NOTICE, "Ignoring Roaming from subscriber '%s', because we are busy becoming SpK.\n", rufnummer);
break;
}
console_inscription(rufnummer);
trans = create_transaction(cnetz, TRANS_UM, telegramm->futln_nationalitaet, telegramm->futln_heimat_fuvst_nr, telegramm->futln_rest_nr, telegramm->chipkarten_futelg_bit, telegramm->erweitertes_frequenzbandbit, cnetz->rf_level_db);
if (!trans) {
LOGP(DCNETZ, LOGL_ERROR, "Failed to create transaction\n");

View File

@ -40,6 +40,7 @@
#include "../libmobile/call.h"
#include "../libmobile/cause.h"
#include "../libmobile/get_time.h"
#include "../libmobile/console.h"
#include <osmocom/core/timer.h>
#include <osmocom/core/utils.h>
#include <osmocom/cc/message.h>
@ -432,15 +433,20 @@ typedef struct transaction {
transaction_t *trans_list = NULL;
const char *transaction2rufnummer(transaction_t *trans)
static const char *nut2rufnummer(uint8_t futln_nat, uint8_t futln_fuvst, uint16_t futln_rest)
{
static char rufnummer[32]; /* make GCC happy (overflow check) */
sprintf(rufnummer, "%d%d%05d", trans->futln_nat, trans->futln_fuvst, trans->futln_rest);
sprintf(rufnummer, "%d%d%05d", futln_nat, futln_fuvst, futln_rest);
return rufnummer;
}
static const char *transaction2rufnummer(transaction_t *trans)
{
return nut2rufnummer(trans->futln_nat, trans->futln_fuvst, trans->futln_rest);
}
const char *state_name(enum call_state state)
{
static char invalid[16];
@ -925,6 +931,7 @@ static void message_receive(fuvst_t *zzk, uint8_t ident, uint8_t opcode, uint8_t
case OPCODE_EBAF: /* enter BS (inscription) */
decode_ebaf(data, len, &T, &U, &N, &s, &u, &b, &l);
add_db(N, U, T, l);
console_inscription(nut2rufnummer(N, U, T));
len = encode_ebpqu(&opcode, &data);
message_send(ident, opcode, data, len);
break;

View File

@ -36,7 +36,6 @@
#include "cause.h"
#include "sender.h"
#include "call.h"
#include "main_mobile.h"
#include "console.h"
#define DISC_TIMEOUT 30, 0

View File

@ -35,7 +35,6 @@
#include <osmocom/cc/helper.h>
#include <osmocom/cc/rtp.h>
#include "testton.h"
#include "../libmobile/main_mobile.h"
#include "console.h"
#include "cause.h"
#include "../libmobile/call.h"
@ -629,3 +628,17 @@ void process_console(int c)
#endif
}
/* Call this for every inscription. If the console's dial string is empty, it is set to the number that has been inscribed. */
int console_inscription(const char *station_id)
{
if (console.loopback || !console.number_max_length)
return -EINVAL;
if (console.station_id[0])
return 1;
strncpy(console.station_id, station_id, sizeof(console.station_id) - 1);
process_ui(-1);
return 0;
}

View File

@ -1,4 +1,9 @@
#include <osmocom/core/timer.h>
#include <osmocom/core/select.h>
#include <osmocom/cc/endpoint.h>
#include "main_mobile.h"
void console_msg(osmo_cc_call_t *call, osmo_cc_msg_t *msg);
int console_init(const char *audiodev, int samplerate, int buffer, int loopback, int echo_test, const char *digits, const struct number_lengths *lengths, const char *station_id);
void console_cleanup(void);
@ -6,4 +11,5 @@ int console_open_audio(int buffer_size, double interval);
int console_start_audio(void);
void console_process(int c);
void process_console(int c);
int console_inscription(const char *station_id);

View File

@ -28,7 +28,6 @@
#include <termios.h>
#include <errno.h>
#include "../libsample/sample.h"
#include "main_mobile.h"
#include "../liblogging/logging.h"
#include "sender.h"
#include <osmocom/core/timer.h>

View File

@ -75,6 +75,7 @@
#include <osmocom/core/timer.h>
#include "../libmobile/call.h"
#include "../libmobile/cause.h"
#include "../libmobile/console.h"
#include <osmocom/cc/message.h>
#include "mpt1327.h"
#include "dsp.h"
@ -1139,11 +1140,17 @@ void mpt1327_receive_codeword_control(mpt1327_t *mpt1327, mpt1327_codeword_t *co
{
mpt1327_unit_t *unit;
mpt1327_t *tc;
char station_id[8];
switch (codeword->type) {
case MPT_RQR: /* register */
mpt1327_reset_sync(mpt1327); /* message complete */
unit = get_unit(codeword->params[MPT_PFIX], codeword->params[MPT_IDENT1]);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-truncation"
snprintf(station_id, sizeof(station_id), "%03d%04d", unit->prefix, unit->ident);
#pragma GCC diagnostic pop
console_inscription(station_id);
LOGP_CHAN(DMPT1327, LOGL_INFO, "Radio Unit (Prefix:%d Ident:%d) registers\n", unit->prefix, unit->ident);
if (unit->tc)
_cancel_pending_call(mpt1327, unit);

View File

@ -29,6 +29,7 @@
#include "../liblogging/logging.h"
#include "../libmobile/cause.h"
#include "../libmobile/get_time.h"
#include "../libmobile/console.h"
#include <osmocom/cc/message.h>
#include "nmt.h"
#include "transaction.h"
@ -782,6 +783,7 @@ static void rx_roaming_ident(nmt_t *nmt, frame_t *frame)
LOGP_CHAN(DNMT, LOGL_INFO, "Received identity confirm (password %s).\n", trans->subscriber.password);
nmt_new_state(nmt, STATE_ROAMING_CONFIRM);
nmt->tx_frame_count = 0;
console_inscription(&trans->subscriber.country);
break;
default:
LOGP_CHAN(DNMT, LOGL_DEBUG, "Dropping message %s in state %s\n", nmt_frame_name(frame->mt), nmt_state_name(nmt->state));

View File

@ -28,6 +28,7 @@
#include "../libsample/sample.h"
#include "../liblogging/logging.h"
#include "../libmobile/cause.h"
#include "../libmobile/console.h"
#include <osmocom/cc/message.h>
#include "r2000.h"
//#include "transaction.h"
@ -657,6 +658,7 @@ static void rx_idle(r2000_t *r2000, frame_t *frame)
LOGP_CHAN(DR2000, LOGL_INFO, " -> Mobile ID: %d'\n", r2000->subscriber.mor);
LOGP_CHAN(DR2000, LOGL_INFO, " (Use '%s' as dial string to call the station mobile.)'\n", subscriber2string(&r2000->subscriber));
console_inscription(subscriber2string(&r2000->subscriber));
r2000_new_state(r2000, STATE_INSCRIPTION);
break;
case 1: