diff options
author | Andreas Eversberg <jolly@eversberg.eu> | 2024-01-14 19:16:41 +0100 |
---|---|---|
committer | Andreas Eversberg <jolly@eversberg.eu> | 2024-02-18 16:23:30 +0100 |
commit | c844fcc1f67b6e2941a54c003059e0ee065ba077 (patch) | |
tree | d5e11602137a65331ef00bfd541884a19a29cd6b /src | |
parent | 7e5663a709eee8fdafa422d03aed802561957131 (diff) |
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.)
Diffstat (limited to 'src')
-rw-r--r-- | src/amps/amps.c | 2 | ||||
-rw-r--r-- | src/cnetz/cnetz.c | 3 | ||||
-rwxr-xr-x | src/fuvst/fuvst.c | 11 | ||||
-rw-r--r-- | src/libmobile/call.c | 1 | ||||
-rwxr-xr-x | src/libmobile/console.c | 15 | ||||
-rw-r--r-- | src/libmobile/console.h | 6 | ||||
-rw-r--r-- | src/libmobile/main_mobile.c | 1 | ||||
-rwxr-xr-x | src/mpt1327/mpt1327.c | 7 | ||||
-rw-r--r-- | src/nmt/nmt.c | 2 | ||||
-rw-r--r-- | src/r2000/r2000.c | 2 |
10 files changed, 45 insertions, 5 deletions
diff --git a/src/amps/amps.c b/src/amps/amps.c index 9872da9..7af7539 100644 --- a/src/amps/amps.c +++ b/src/amps/amps.c @@ -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)); diff --git a/src/cnetz/cnetz.c b/src/cnetz/cnetz.c index 704d965..0d959a9 100644 --- a/src/cnetz/cnetz.c +++ b/src/cnetz/cnetz.c @@ -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"); diff --git a/src/fuvst/fuvst.c b/src/fuvst/fuvst.c index 0871116..bf6c60f 100755 --- a/src/fuvst/fuvst.c +++ b/src/fuvst/fuvst.c @@ -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; diff --git a/src/libmobile/call.c b/src/libmobile/call.c index d12e5ca..e848881 100644 --- a/src/libmobile/call.c +++ b/src/libmobile/call.c @@ -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 diff --git a/src/libmobile/console.c b/src/libmobile/console.c index a21f3fa..7dd0fdf 100755 --- a/src/libmobile/console.c +++ b/src/libmobile/console.c @@ -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; +} + diff --git a/src/libmobile/console.h b/src/libmobile/console.h index 20b5a44..53fc1fd 100644 --- a/src/libmobile/console.h +++ b/src/libmobile/console.h @@ -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); diff --git a/src/libmobile/main_mobile.c b/src/libmobile/main_mobile.c index 9df29e8..888e514 100644 --- a/src/libmobile/main_mobile.c +++ b/src/libmobile/main_mobile.c @@ -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> diff --git a/src/mpt1327/mpt1327.c b/src/mpt1327/mpt1327.c index 7b0e303..5161e1a 100755 --- a/src/mpt1327/mpt1327.c +++ b/src/mpt1327/mpt1327.c @@ -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); diff --git a/src/nmt/nmt.c b/src/nmt/nmt.c index ece75cc..e8f9174 100644 --- a/src/nmt/nmt.c +++ b/src/nmt/nmt.c @@ -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)); diff --git a/src/r2000/r2000.c b/src/r2000/r2000.c index a0193ae..cad6916 100644 --- a/src/r2000/r2000.c +++ b/src/r2000/r2000.c @@ -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: |