Add option to handle pulses from Swedish rotary phones correctly

One pulse represents '0', two pulses respresent '1', ect...
master
Andreas Eversberg 3 months ago
parent 0365aa0edc
commit 90913f6570

@ -36,6 +36,7 @@ int num_kanal = 1;
#define SUBSCRIBER_MAX 16
static char law = 'a';
static int sweden = 0;
static int serving_location = 1; /* private network serving local user */
static const char *socketname = NULL;
static const char *name = "pstn";
@ -123,6 +124,9 @@ static void print_help()
printf(" Use U-LAW for b-channel coding instead of alaw.\n");
printf(" --serving-location (see Q.931)\n");
printf(" 0 = user, 1 = private network serving local user (default=%d)\n", serving_location);
printf(" --sweden\n");
printf(" Translate pulses from Swedish rotary phone into digits. One pulse is\n");
printf(" digit '0', two pulses are digit '1', and so on.\n");
printf(" -r --realtime <prio>\n");
printf(" Set prio: 0 to disable, 99 for maximum (default = %d)\n", rt_prio);
printf(" -C --cc \"<osmo-cc arg>\" [--cc ...]\n");
@ -158,6 +162,7 @@ static void print_recall()
#define OPT_TX_RING_H 264
#define OPT_ULAW 265
#define OPT_SERVING 266
#define OPT_SWEDEN 267
static void add_options(void)
{
@ -179,6 +184,7 @@ static void add_options(void)
option_add('T', "local-tones", 0);
option_add(OPT_ULAW, "ulaw", 0);
option_add(OPT_SERVING, "serving-location", 1);
option_add(OPT_SWEDEN, "sweden", 0);
option_add('r', "realtime", 1);
option_add('C', "cc", 1);
}
@ -287,6 +293,9 @@ static int handle_options(int short_option, int argi, char **argv)
case OPT_SERVING:
serving_location = atoi(argv[argi]);;
break;
case OPT_SWEDEN:
sweden = 1;
break;
case 'r':
rt_prio = atoi(argv[argi]);
break;
@ -362,7 +371,7 @@ int main(int argc, char *argv[])
if (!pstn_ep)
goto error;
rc = pstn_init(pstn_ep, name, socketname, subscribers, subscriber_num, serving_location, tx_delay, clip, cid_bell, cid_dtmf, clip_date, enblock, recall, ringing_types_incoming, ringing_type_hold, tones_type, law);
rc = pstn_init(pstn_ep, name, socketname, subscribers, subscriber_num, serving_location, tx_delay, clip, cid_bell, cid_dtmf, clip_date, enblock, recall, ringing_types_incoming, ringing_type_hold, tones_type, law, sweden);
if (rc) {
PDEBUG(DTEL, DEBUG_ERROR, "Endpoint initializing failed!\n");
goto error;

@ -417,7 +417,7 @@ static void pstn_new_state(pstn_t *pstn, enum pstn_state state)
}
/* initialization and configuration of interface instance */
int pstn_init(pstn_t *pstn, const char *name, const char *socketname, const char **subscribers, int subscriber_num, uint8_t serving_location, int tx_delay, enum pstn_cid_method clip, int cid_bell, int cid_dtmf, int clip_date, int enblock, int recall, int *ringing_types_incoming, int ringing_type_hold, enum tones_type tones_type, char law)
int pstn_init(pstn_t *pstn, const char *name, const char *socketname, const char **subscribers, int subscriber_num, uint8_t serving_location, int tx_delay, enum pstn_cid_method clip, int cid_bell, int cid_dtmf, int clip_date, int enblock, int recall, int *ringing_types_incoming, int ringing_type_hold, enum tones_type tones_type, char law, int sweden)
{
int i;
int rc;
@ -437,6 +437,7 @@ int pstn_init(pstn_t *pstn, const char *name, const char *socketname, const char
pstn->ringing_types_incoming = ringing_types_incoming;
pstn->ringing_type_hold = ringing_type_hold;
pstn->tones_type = tones_type;
pstn->sweden = sweden;
/* init DTMF detector */
rc = dtmf_decode_init(&pstn->dtmf_dec, pstn, recv_dtmf, 8000, db2level(6.0), db2level(-30.0));
@ -1606,9 +1607,6 @@ static void v5_sig_ind(pstn_t *pstn, uint8_t *data, int len)
case 0:
PDEBUG(DTEL, DEBUG_ERROR, "Received 0 pulses, ignoring!\n");
break;
case 10:
called[0] = '0';
break;
case 11:
called[0] = '*';
break;
@ -1625,7 +1623,10 @@ static void v5_sig_ind(pstn_t *pstn, uint8_t *data, int len)
called[0] = 'c';
break;
default:
called[0] = '0' + (data[2] & 0x0f);
if (pstn->sweden)
called[0] = '0' + (((data[2] & 0x0f) + 9) % 10);
else
called[0] = '0' + ((data[2] & 0x0f) % 10);
}
/* if we are receiving digits en block */
if (pstn->call[PSTN_CALL_ACTIVE]->state == CALL_STATE_ENBLOCK) {

@ -131,6 +131,7 @@ typedef struct pstn {
int *ringing_types_incoming;/* cadenced rining on incoming call */
int ringing_type_hold; /* cadenced rining on waiting call */
enum tones_type tones_type; /* what tone set to use */
int sweden; /* swedish rotary phone */
/* states */
enum pstn_state state;
@ -165,6 +166,6 @@ int add_dial_hint(const char *arg);
void purge_dial_hints(void);
void pstn_destroy(pstn_t *pstn_ep);
pstn_t *pstn_create(void);
int pstn_init(pstn_t *pstn, const char *name, const char *socketname, const char **subscribers, int subscriber_num, uint8_t serving_location, int tx_delay, enum pstn_cid_method clip, int cid_bell, int cid_dtmf, int clip_date, int enblock, int recall, int *ringing_types_incoming, int ringing_type_hold, enum tones_type tones_type, char law);
int pstn_init(pstn_t *pstn, const char *name, const char *socketname, const char **subscribers, int subscriber_num, uint8_t serving_location, int tx_delay, enum pstn_cid_method clip, int cid_bell, int cid_dtmf, int clip_date, int enblock, int recall, int *ringing_types_incoming, int ringing_type_hold, enum tones_type tones_type, char law, int sweden);
void cc_message(osmo_cc_endpoint_t *ep, uint32_t callref, osmo_cc_msg_t *msg);
void rtp_work(pstn_t *pstn_ep);

Loading…
Cancel
Save