TACS support (variations added to AMPS code)
These are: - Bandwidth only 25 KHz, so lower deviations - Data rate only 8000 KHz - SID is called AID (Area ID) - MIN1 coding is different
This commit is contained in:
parent
d52f4cd29d
commit
3788b3e8a5
|
@ -25,7 +25,9 @@ src/anetz/anetz
|
|||
src/bnetz/bnetz
|
||||
src/cnetz/cnetz
|
||||
src/nmt/nmt
|
||||
src/amps/libamps.a
|
||||
src/amps/amps
|
||||
src/tacs/tacs
|
||||
sim/cnetz_sim
|
||||
src/test/test_filter
|
||||
src/test/test_compandor
|
||||
|
|
3
README
3
README
|
@ -8,6 +8,7 @@ and from mobile phone. Currently supported networks:
|
|||
* C-Netz
|
||||
* NMT 450 (Nordic Mobile Telephone)
|
||||
* AMPS (Advanced Mobile Phone System)
|
||||
* TACS (Total Access Communication System)
|
||||
|
||||
|
||||
USE AT YOUR OWN RISK!
|
||||
|
@ -45,3 +46,5 @@ Association."
|
|||
Eric from Smart Card World and Karsten Niehusen from cardomatic.de for
|
||||
providing memory cards to be programmed for older C-Netz phone.
|
||||
|
||||
Dieter Spaar prividing TACS recordings to verify and debug TACS support.
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ AC_OUTPUT(
|
|||
src/cnetz/Makefile
|
||||
src/nmt/Makefile
|
||||
src/amps/Makefile
|
||||
src/tacs/Makefile
|
||||
src/test/Makefile
|
||||
src/Makefile
|
||||
sim/Makefile
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
AUTOMAKE_OPTIONS = foreign
|
||||
SUBDIRS = common anetz bnetz cnetz nmt amps test
|
||||
SUBDIRS = common anetz bnetz cnetz nmt amps tacs test
|
||||
|
||||
|
|
|
@ -1,24 +1,31 @@
|
|||
AM_CPPFLAGS = -Wall -Wextra -g $(all_includes)
|
||||
|
||||
noinst_LIBRARIES = libamps.a
|
||||
|
||||
bin_PROGRAMS = \
|
||||
amps
|
||||
|
||||
amps_SOURCES = \
|
||||
libamps_a_SOURCES = \
|
||||
amps_tacs_main.c \
|
||||
amps.c \
|
||||
transaction.c \
|
||||
frame.c \
|
||||
dsp.c \
|
||||
sysinfo.c \
|
||||
image.c \
|
||||
sysinfo.c
|
||||
|
||||
amps_SOURCES = \
|
||||
tones.c \
|
||||
noanswer.c \
|
||||
outoforder.c \
|
||||
invalidnumber.c \
|
||||
congestion.c \
|
||||
stations.c \
|
||||
image.c \
|
||||
main.c
|
||||
|
||||
amps_LDADD = \
|
||||
$(COMMON_LA) \
|
||||
libamps.a \
|
||||
$(top_builddir)/src/common/libcommon.a \
|
||||
$(ALSA_LIBS) \
|
||||
$(UHD_LIBS) \
|
||||
|
|
164
src/amps/amps.c
164
src/amps/amps.c
|
@ -50,6 +50,8 @@
|
|||
#include "amps.h"
|
||||
#include "dsp.h"
|
||||
#include "frame.h"
|
||||
#include "stations.h"
|
||||
#include "main.h"
|
||||
|
||||
/* Uncomment this to test SAT via loopback */
|
||||
//#define DEBUG_VC
|
||||
|
@ -72,14 +74,22 @@ double amps_channel2freq(int channel, int uplink)
|
|||
{
|
||||
double freq;
|
||||
|
||||
/* 832 channels, 990 not used, see TIA/EIA-136-110 */
|
||||
if (channel < 1 || channel > 1023 || (channel > 799 && channel < 991))
|
||||
return 0;
|
||||
if (!tacs) {
|
||||
/* 832 channels, 990 not used, see TIA/EIA-136-110 */
|
||||
if (channel < 1 || channel > 1023 || (channel > 799 && channel < 991))
|
||||
return 0;
|
||||
|
||||
if (channel >= 990) // 990 is not used
|
||||
channel -= 1023;
|
||||
if (channel >= 990) // 990 is not used
|
||||
channel -= 1023;
|
||||
|
||||
freq = 870.030 + (channel - 1) * 0.030;
|
||||
freq = 870.030 + (channel - 1) * 0.030;
|
||||
} else {
|
||||
/* 600 channels */
|
||||
if (channel < 1 || channel > 600)
|
||||
return 0;
|
||||
|
||||
freq = 935.0125 + (channel - 1) * 0.025;
|
||||
}
|
||||
|
||||
if (uplink)
|
||||
freq -= 45.000;
|
||||
|
@ -89,24 +99,38 @@ double amps_channel2freq(int channel, int uplink)
|
|||
|
||||
enum amps_chan_type amps_channel2type(int channel)
|
||||
{
|
||||
if (channel >= 313 && channel <= 354)
|
||||
return CHAN_TYPE_CC;
|
||||
if (!tacs) {
|
||||
if (channel >= 313 && channel <= 354)
|
||||
return CHAN_TYPE_CC;
|
||||
} else {
|
||||
if (channel >= 23 && channel <= 43)
|
||||
return CHAN_TYPE_CC;
|
||||
if (channel >= 323 && channel <= 343)
|
||||
return CHAN_TYPE_CC;
|
||||
}
|
||||
|
||||
return CHAN_TYPE_VC;
|
||||
}
|
||||
|
||||
const char *amps_channel2band(int channel)
|
||||
{
|
||||
if (channel >= 991 && channel <= 1023)
|
||||
return "A''";
|
||||
if (channel >= 1 && channel <= 333)
|
||||
return "A";
|
||||
if (channel >= 334 && channel <= 666)
|
||||
return "B";
|
||||
if (channel >= 667 && channel <= 716)
|
||||
return "A'";
|
||||
if (channel >= 717 && channel <= 799)
|
||||
return "B'";
|
||||
if (!tacs) {
|
||||
if (channel >= 991 && channel <= 1023)
|
||||
return "A''";
|
||||
if (channel >= 1 && channel <= 333)
|
||||
return "A";
|
||||
if (channel >= 334 && channel <= 666)
|
||||
return "B";
|
||||
if (channel >= 667 && channel <= 716)
|
||||
return "A'";
|
||||
if (channel >= 717 && channel <= 799)
|
||||
return "B'";
|
||||
} else {
|
||||
if (channel >= 1 && channel <= 300)
|
||||
return "A";
|
||||
if (channel >= 301 && channel <= 600)
|
||||
return "B";
|
||||
}
|
||||
|
||||
return "<invalid>";
|
||||
}
|
||||
|
@ -125,11 +149,15 @@ static inline int binary2digit(int binary)
|
|||
return binary + '0';
|
||||
}
|
||||
|
||||
/* convert NPA-NXX-XXXX to MIN1 and MIN2
|
||||
/* AMPS: convert NPA-NXX-XXXX to MIN1 and MIN2
|
||||
* NPA = numbering plan area (MIN2)
|
||||
* NXX = mobile exchange code
|
||||
* XXXX = telephone number within the exchange
|
||||
*/
|
||||
/* TACS: convert AREA-XXXXXX to MIN1 and MIN2
|
||||
* AREA = 3 + 1 Digits
|
||||
* XXXXXX = telephone number
|
||||
*/
|
||||
void amps_number2min(const char *number, uint32_t *min1, uint16_t *min2)
|
||||
{
|
||||
int nlen = strlen(number);
|
||||
|
@ -154,13 +182,22 @@ void amps_number2min(const char *number, uint32_t *min1, uint16_t *min2)
|
|||
nlen -= 3;
|
||||
}
|
||||
|
||||
/* MIN1 */
|
||||
*min1 = ((uint32_t)(digit2binary(number[0]) * 100 + digit2binary(number[1]) * 10 + digit2binary(number[2]) - 111)) << 14;
|
||||
*min1 |= digit2binary(number[3]) << 10;
|
||||
*min1 |= digit2binary(number[4]) * 100 + digit2binary(number[5]) * 10 + digit2binary(number[6]) - 111;
|
||||
if (!tacs) {
|
||||
/* MIN1 */
|
||||
*min1 = ((uint32_t)(digit2binary(number[0]) * 100 + digit2binary(number[1]) * 10 + digit2binary(number[2]) - 111)) << 14;
|
||||
*min1 |= digit2binary(number[3]) << 10;
|
||||
*min1 |= digit2binary(number[4]) * 100 + digit2binary(number[5]) * 10 + digit2binary(number[6]) - 111;
|
||||
} else {
|
||||
/* MIN1 */
|
||||
*min1 = (number[0] - '0') << 20;
|
||||
*min1 |= (digit2binary(number[1]) * 100 + digit2binary(number[2]) * 10 + digit2binary(number[3]) - 111) << 10;
|
||||
*min1 |= digit2binary(number[4]) * 100 + digit2binary(number[5]) * 10 + digit2binary(number[6]) - 111;
|
||||
}
|
||||
}
|
||||
|
||||
/* convert MIN1 and MIN2 to NPA-NXX-XXXX
|
||||
/* AMPS: convert MIN1 and MIN2 to NPA-NXX-XXXX
|
||||
*/
|
||||
/* TACS: convert MIN1 and MIN2 to AREA-XXXXXXX
|
||||
*/
|
||||
const char *amps_min22number(uint16_t min2)
|
||||
{
|
||||
|
@ -183,24 +220,46 @@ const char *amps_min12number(uint32_t min1)
|
|||
{
|
||||
static char number[8];
|
||||
|
||||
/* MIN1 */
|
||||
if ((min1 >> 14) > 999)
|
||||
strcpy(number, "???");
|
||||
else {
|
||||
number[0] = binary2digit(((min1 >> 14) / 100) + 1);
|
||||
number[1] = binary2digit((((min1 >> 14) / 10) % 10) + 1);
|
||||
number[2] = binary2digit(((min1 >> 14) % 10) + 1);
|
||||
}
|
||||
if (((min1 >> 10) & 0xf) < 1 || ((min1 >> 10) & 0xf) > 10)
|
||||
number[3] = '?';
|
||||
else
|
||||
number[3] = binary2digit((min1 >> 10) & 0xf);
|
||||
if ((min1 & 0x3ff) > 999)
|
||||
strcpy(number + 4, "???");
|
||||
else {
|
||||
number[4] = binary2digit(((min1 & 0x3ff) / 100) + 1);
|
||||
number[5] = binary2digit((((min1 & 0x3ff) / 10) % 10) + 1);
|
||||
number[6] = binary2digit(((min1 & 0x3ff) % 10) + 1);
|
||||
if (!tacs) {
|
||||
/* MIN1 */
|
||||
if ((min1 >> 14) > 999)
|
||||
strcpy(number, "???");
|
||||
else {
|
||||
number[0] = binary2digit(((min1 >> 14) / 100) + 1);
|
||||
number[1] = binary2digit((((min1 >> 14) / 10) % 10) + 1);
|
||||
number[2] = binary2digit(((min1 >> 14) % 10) + 1);
|
||||
}
|
||||
if (((min1 >> 10) & 0xf) < 1 || ((min1 >> 10) & 0xf) > 10)
|
||||
number[3] = '?';
|
||||
else
|
||||
number[3] = binary2digit((min1 >> 10) & 0xf);
|
||||
if ((min1 & 0x3ff) > 999)
|
||||
strcpy(number + 4, "???");
|
||||
else {
|
||||
number[4] = binary2digit(((min1 & 0x3ff) / 100) + 1);
|
||||
number[5] = binary2digit((((min1 & 0x3ff) / 10) % 10) + 1);
|
||||
number[6] = binary2digit(((min1 & 0x3ff) % 10) + 1);
|
||||
}
|
||||
} else {
|
||||
/* MIN1 */
|
||||
if ((min1 >> 20) > 9)
|
||||
number[0] = '?';
|
||||
else
|
||||
number[0] = '0' + (min1 >> 20);
|
||||
if (((min1 >> 10) & 0x3ff) > 999)
|
||||
strcpy(number + 1, "???");
|
||||
else {
|
||||
number[1] = binary2digit((((min1 >> 10) & 0x3ff) / 100) + 1);
|
||||
number[2] = binary2digit(((((min1 >> 10) & 0x3ff) / 10) % 10) + 1);
|
||||
number[3] = binary2digit((((min1 >> 10) & 0x3ff) % 10) + 1);
|
||||
}
|
||||
if ((min1 & 0x3ff) > 999)
|
||||
strcpy(number + 4, "???");
|
||||
else {
|
||||
number[4] = binary2digit(((min1 & 0x3ff) / 100) + 1);
|
||||
number[5] = binary2digit((((min1 & 0x3ff) / 10) % 10) + 1);
|
||||
number[6] = binary2digit(((min1 & 0x3ff) % 10) + 1);
|
||||
}
|
||||
}
|
||||
number[7] = '\0';
|
||||
|
||||
|
@ -424,7 +483,7 @@ int amps_create(int channel, enum amps_chan_type chan_type, const char *audiodev
|
|||
const char *band;
|
||||
|
||||
/* check for channel number */
|
||||
if (channel < 1 || (channel > 799 && channel < 991) || channel > 1023) {
|
||||
if (amps_channel2freq(channel, 0) == 0) {
|
||||
PDEBUG(DAMPS, DEBUG_ERROR, "Channel number %d invalid.\n", channel);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -459,11 +518,11 @@ int amps_create(int channel, enum amps_chan_type chan_type, const char *audiodev
|
|||
/* check if sid machtes channel band */
|
||||
band = amps_channel2band(channel);
|
||||
if (band[0] == 'A' && (sid & 1) == 0 && chan_type != CHAN_TYPE_VC) {
|
||||
PDEBUG(DAMPS, DEBUG_ERROR, "Channel number %d belongs to system A, but your SID %d is even and belongs to system B. Please give odd SID.\n", channel, sid);
|
||||
PDEBUG(DAMPS, DEBUG_ERROR, "Channel number %d belongs to system A, but your %s %d is even and belongs to system B. Please give odd %s.\n", channel, (!tacs) ? "SID" : "AID", sid, (!tacs) ? "SID" : "AID");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (band[0] == 'B' && (sid & 1) == 1 && chan_type != CHAN_TYPE_VC) {
|
||||
PDEBUG(DAMPS, DEBUG_ERROR, "Channel number %d belongs to system B, but your SID %d is odd and belongs to system A. Please give even SID.\n", channel, sid);
|
||||
PDEBUG(DAMPS, DEBUG_ERROR, "Channel number %d belongs to system B, but your %s %d is odd and belongs to system A. Please give even %s.\n", channel, (!tacs) ? "SID" : "AID", sid, (!tacs) ? "SID" : "AID");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -722,6 +781,7 @@ void amps_rx_recc(amps_t *amps, uint8_t scm, uint8_t mpci, uint32_t esn, uint32_
|
|||
amps_t *vc;
|
||||
transaction_t *trans;
|
||||
const char *callerid = amps_min2number(min1, min2);
|
||||
const char *carrier = NULL, *country = NULL, *national_number = NULL;
|
||||
|
||||
/* check if we are busy, so we ignore all signaling */
|
||||
if (amps->state == STATE_BUSY) {
|
||||
|
@ -731,6 +791,14 @@ void amps_rx_recc(amps_t *amps, uint8_t scm, uint8_t mpci, uint32_t esn, uint32_
|
|||
|
||||
if (order == 13 && (ordq == 0 || ordq == 1 || ordq == 2 || ordq == 3) && msg_type == 0) {
|
||||
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Registration %s (ESN = %08x, %s, %s)\n", callerid, esn, amps_scm(scm), amps_mpci(mpci));
|
||||
_register:
|
||||
numbering(callerid, &carrier, &country, &national_number);
|
||||
if (carrier)
|
||||
PDEBUG_CHAN(DAMPS, DEBUG_INFO, " -> Home carrier: %s\n", carrier);
|
||||
if (country)
|
||||
PDEBUG_CHAN(DAMPS, DEBUG_INFO, " -> Home country: %s\n", country);
|
||||
if (national_number)
|
||||
PDEBUG_CHAN(DAMPS, DEBUG_INFO, " -> Home number: %s\n", national_number);
|
||||
trans = create_transaction(amps, TRANS_REGISTER_ACK, min1, min2, msg_type, ordq, order, 0);
|
||||
if (!trans) {
|
||||
PDEBUG(DAMPS, DEBUG_ERROR, "Failed to create transaction\n");
|
||||
|
@ -739,11 +807,7 @@ void amps_rx_recc(amps_t *amps, uint8_t scm, uint8_t mpci, uint32_t esn, uint32_
|
|||
} else
|
||||
if (order == 13 && ordq == 3 && msg_type == 1) {
|
||||
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Registration - Power Down %s (ESN = %08x, %s, %s)\n", callerid, esn, amps_scm(scm), amps_mpci(mpci));
|
||||
trans = create_transaction(amps, TRANS_REGISTER_ACK, min1, min2, msg_type, ordq, order, 0);
|
||||
if (!trans) {
|
||||
PDEBUG(DAMPS, DEBUG_ERROR, "Failed to create transaction\n");
|
||||
return;
|
||||
}
|
||||
goto _register;
|
||||
} else
|
||||
if (order == 0 && ordq == 0 && msg_type == 0) {
|
||||
if (!dialing)
|
||||
|
|
|
@ -0,0 +1,417 @@
|
|||
/* AMPS main
|
||||
*
|
||||
* (C) 2016 by Andreas Eversberg <jolly@eversberg.eu>
|
||||
* All Rights Reserved
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <getopt.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "../common/sample.h"
|
||||
#include "../common/main.h"
|
||||
#include "../common/debug.h"
|
||||
#include "../common/timer.h"
|
||||
#include "../common/call.h"
|
||||
#include "../common/mncc_sock.h"
|
||||
#include "amps.h"
|
||||
#include "dsp.h"
|
||||
#include "frame.h"
|
||||
#include "image.h"
|
||||
#include "stations.h"
|
||||
#include "main.h"
|
||||
|
||||
/* settings */
|
||||
int num_chan_type = 0;
|
||||
enum amps_chan_type chan_type[MAX_SENDER] = { CHAN_TYPE_CC_PC_VC };
|
||||
const char *flip_polarity = "";
|
||||
int ms_power = 4, dtx = 0, dcc = 0, scc = 0, sid = 0, regh = 1, regr = 1, pureg = 0, pdreg = 0, locaid = -1, regincr = 300, bis = 0;
|
||||
int tolerant = 0;
|
||||
|
||||
void print_help(const char *arg0)
|
||||
{
|
||||
if (!tacs)
|
||||
print_help_common(arg0, "-p -d -F yes | no [-S sid=<sid>] ");
|
||||
else
|
||||
print_help_common(arg0, "-p -d -F yes | no [-S aid=<aid>] ");
|
||||
/* - - */
|
||||
printf(" -T --channel-type <channel type> | list\n");
|
||||
printf(" Give channel type, use 'list' to get a list. (default = '%s')\n", chan_type_short_name(chan_type[0]));
|
||||
printf(" -F --flip-polarity no | yes\n");
|
||||
printf(" Flip polarity of transmitted FSK signal. If yes, the sound card\n");
|
||||
printf(" generates a negative signal rather than a positive one. Be sure that\n");
|
||||
printf(" a positive signal causes a positive deviation on your transmitter.\n");
|
||||
printf(" If the phone shows 'NoSrv', try the other way.\n");
|
||||
printf(" -P --ms-power <power level>\n");
|
||||
printf(" Give power level of the mobile station 0..7. (default = '%d')\n", ms_power);
|
||||
if (!tacs) {
|
||||
printf(" 0 = 4 W; 1 = 1.6 W; 2 = 630 mW; 3 = 250 mW;\n");
|
||||
printf(" 4 = 100 mW; 5 = 40 mW; 6 = 16 mW; 7 = 6.3 mW\n");
|
||||
} else {
|
||||
printf(" 0 = 2.82 W; 1 = 1.12 W; 2 = 447 mW; 3 = 178 mW;\n");
|
||||
printf(" 4 = 70.8 mW; 5 = 28.2 mW; 6 = 11.2 mW; 7 = 4.5 mW\n");
|
||||
}
|
||||
printf(" -D --dtx <parameter>\n");
|
||||
printf(" Give DTX parameter for Discontinuous Transmission. (default = '%d')\n", dtx);
|
||||
printf(" 0 = disable DTX; 1 = reserved;\n");
|
||||
printf(" 2 = 8 dB attenuation in low state; 3 = transmitter off\n");
|
||||
if (!tacs) {
|
||||
printf(" -S --sysinfo sid=<System ID> | sid=list\n");
|
||||
printf(" Give system ID of cell broadcast\n");
|
||||
printf(" If it changes, phone re-registers. Use 'sid=list' to get a full list.\n");
|
||||
} else {
|
||||
printf(" -S --sysinfo aid=<System ID> | aid=list\n");
|
||||
printf(" Give area ID of cell broadcast (default = '%d')\n", sid);
|
||||
printf(" If it changes, phone re-registers. Use 'aid=list' to get a full list.\n");
|
||||
}
|
||||
printf(" -S --sysinfo dcc=<digital color code>\n");
|
||||
printf(" Give digital color code 0..3 (default = '%d')\n", dcc);
|
||||
printf(" -S --sysinfo scc=<SAT color code>\n");
|
||||
printf(" Give supervisor tone color code 0..2 (default = '%d')\n", scc);
|
||||
printf(" -S --sysinfo regincr\n");
|
||||
printf(" Amount to add to REGID after successful registration (default = '%d')\n", regincr);
|
||||
printf(" Since REGID is incremented every second, this value define after how\n");
|
||||
printf(" many second the phone waits before it re-registers.\n");
|
||||
printf(" -S --sysinfo pureg=0 | pureg=1\n");
|
||||
printf(" If 1, phone registers on every power on (default = '%d')\n", pureg);
|
||||
printf(" Warning: Older phones may not like this and show 'No Service'!\n");
|
||||
printf(" -S --sysinfo pdreg=0 | pdreg=1\n");
|
||||
printf(" If 1, phone de-registers on every power down (default = '%d')\n", pureg);
|
||||
printf(" Warning: Older phones may not like this and show 'No Service'!\n");
|
||||
printf(" -S --sysinfo locaid=<location area ID > | locaid=-1 to disable\n");
|
||||
printf(" (default = '%d')\n", locaid);
|
||||
printf(" If it changes, phone re-registers.\n");
|
||||
printf(" Warning: Older phones may not like this and show 'No Service'!\n");
|
||||
printf(" -S --sysinfo regh=0 | regh=1\n");
|
||||
printf(" If 1, phone registers only if System ID matches (default = '%d')\n", regh);
|
||||
printf(" -S --sysinfo regr=0 | regr=1\n");
|
||||
printf(" If 1, phone registers only if System ID is different (default = '%d')\n", regr);
|
||||
printf(" -S --sysinfo bis=0 | bis=1\n");
|
||||
printf(" If 0, phone ignores BUSY/IDLE bit on FOCC (default = '%d')\n", bis);
|
||||
printf(" If 1, be sure to have a round-trip delay (latency) not more than 5 ms\n");
|
||||
printf(" -O --tolerant\n");
|
||||
printf(" Be more tolerant when hunting for sync sequence\n");
|
||||
printf("\nstation-id: Give 10 digit station-id, you don't need to enter it for every\n");
|
||||
printf(" start of this program.\n");
|
||||
print_hotkeys_common();
|
||||
}
|
||||
|
||||
static int handle_options(int argc, char **argv)
|
||||
{
|
||||
const char *p;
|
||||
int skip_args = 0;
|
||||
int rc;
|
||||
|
||||
static struct option long_options_special[] = {
|
||||
{"channel-type", 1, 0, 'T'},
|
||||
{"flip-polarity", 1, 0, 'F'},
|
||||
{"ms-power", 1, 0, 'P'},
|
||||
{"dtx", 1, 0, 'D'},
|
||||
{"sysinfo", 1, 0, 'S'},
|
||||
{"tolerant", 0, 0, 'O'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
set_options_common("T:F:P:D:S:O", long_options_special);
|
||||
|
||||
while (1) {
|
||||
int option_index = 0, c;
|
||||
|
||||
c = getopt_long(argc, argv, optstring, long_options, &option_index);
|
||||
|
||||
if (c == -1)
|
||||
break;
|
||||
|
||||
switch (c) {
|
||||
case 'T':
|
||||
if (!strcmp(optarg, "list")) {
|
||||
amps_channel_list();
|
||||
exit(0);
|
||||
}
|
||||
rc = amps_channel_by_short_name(optarg);
|
||||
if (rc < 0) {
|
||||
fprintf(stderr, "Error, channel type '%s' unknown. Please use '-t list' to get a list. I suggest to use the default.\n", optarg);
|
||||
exit(0);
|
||||
}
|
||||
OPT_ARRAY(num_chan_type, chan_type, rc)
|
||||
skip_args += 2;
|
||||
break;
|
||||
case 'F':
|
||||
if (!strcasecmp(optarg, "no"))
|
||||
flip_polarity = "no";
|
||||
else if (!strcasecmp(optarg, "yes"))
|
||||
flip_polarity = "yes";
|
||||
else {
|
||||
fprintf(stderr, "Given polarity '%s' is illegal, see help!\n", optarg);
|
||||
exit(0);
|
||||
}
|
||||
skip_args += 2;
|
||||
break;
|
||||
case 'P':
|
||||
ms_power = atoi(optarg);
|
||||
if (ms_power > 7)
|
||||
ms_power = 7;
|
||||
if (ms_power < 0)
|
||||
ms_power = 0;
|
||||
skip_args += 2;
|
||||
break;
|
||||
case 'D':
|
||||
dtx = atoi(optarg);
|
||||
if (dtx > 3)
|
||||
dtx = 3;
|
||||
if (dtx < 0)
|
||||
dtx = 0;
|
||||
skip_args += 2;
|
||||
break;
|
||||
case 'S':
|
||||
p = strchr(optarg, '=');
|
||||
if (!p) {
|
||||
fprintf(stderr, "Given sysinfo parameter '%s' requires '=' character to set value, see help!\n", optarg);
|
||||
exit(0);
|
||||
}
|
||||
p++;
|
||||
if (!strncasecmp(optarg, "sid=", p - optarg)
|
||||
|| !strncasecmp(optarg, "aid=", p - optarg)) {
|
||||
if (!strcasecmp(p, "list")) {
|
||||
list_stations();
|
||||
exit(0);
|
||||
}
|
||||
sid = atoi(p);
|
||||
if (sid > 32767)
|
||||
sid = 32767;
|
||||
if (sid < 0)
|
||||
sid = 0;
|
||||
} else
|
||||
if (!strncasecmp(optarg, "dcc=", p - optarg)) {
|
||||
dcc = atoi(p);
|
||||
if (dcc > 3)
|
||||
dcc = 3;
|
||||
if (dcc < 0)
|
||||
dcc = 0;
|
||||
} else
|
||||
if (!strncasecmp(optarg, "scc=", p - optarg)) {
|
||||
scc = atoi(p);
|
||||
if (scc > 2)
|
||||
scc = 2;
|
||||
if (scc < 0)
|
||||
scc = 0;
|
||||
} else
|
||||
if (!strncasecmp(optarg, "regincr=", p - optarg)) {
|
||||
regincr = atoi(p);
|
||||
} else
|
||||
if (!strncasecmp(optarg, "pureg=", p - optarg)) {
|
||||
pureg = atoi(p) & 1;
|
||||
} else
|
||||
if (!strncasecmp(optarg, "pdreg=", p - optarg)) {
|
||||
pdreg = atoi(p) & 1;
|
||||
} else
|
||||
if (!strncasecmp(optarg, "locaid=", p - optarg)) {
|
||||
locaid = atoi(p);
|
||||
if (locaid > 4095)
|
||||
locaid = 4095;
|
||||
} else
|
||||
if (!strncasecmp(optarg, "regh=", p - optarg)) {
|
||||
regh = atoi(p) & 1;
|
||||
} else
|
||||
if (!strncasecmp(optarg, "regr=", p - optarg)) {
|
||||
regr = atoi(p) & 1;
|
||||
} else
|
||||
if (!strncasecmp(optarg, "bis=", p - optarg)) {
|
||||
bis = atoi(p) & 1;
|
||||
} else {
|
||||
fprintf(stderr, "Given sysinfo parameter '%s' unknown, see help!\n", optarg);
|
||||
exit(0);
|
||||
}
|
||||
skip_args += 2;
|
||||
break;
|
||||
case 'O':
|
||||
tolerant = 1;
|
||||
skip_args += 1;
|
||||
break;
|
||||
default:
|
||||
opt_switch_common(c, argv[0], &skip_args);
|
||||
}
|
||||
}
|
||||
|
||||
free(long_options);
|
||||
|
||||
return skip_args;
|
||||
}
|
||||
|
||||
int main_amps_tacs(int argc, char *argv[])
|
||||
{
|
||||
int rc;
|
||||
int skip_args;
|
||||
const char *station_id = "";
|
||||
int polarity;
|
||||
int i;
|
||||
|
||||
/* override default */
|
||||
samplerate = 96000;
|
||||
|
||||
skip_args = handle_options(argc, argv);
|
||||
argc -= skip_args;
|
||||
argv += skip_args;
|
||||
|
||||
if (argc > 1) {
|
||||
station_id = argv[1];
|
||||
if (strlen(station_id) != 10) {
|
||||
printf("Given station ID '%s' does not have 10 digits\n", station_id);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!num_kanal) {
|
||||
printf("No channel (\"Kanal\") is specified, I suggest channel %d.\n\n", (!tacs) ? 334 : 323);
|
||||
print_help(argv[-skip_args]);
|
||||
return 0;
|
||||
}
|
||||
if (use_sdr) {
|
||||
/* set audiodev */
|
||||
for (i = 0; i < num_kanal; i++)
|
||||
audiodev[i] = "sdr";
|
||||
num_audiodev = num_kanal;
|
||||
/* set channel types for more than 1 channel */
|
||||
if (num_kanal > 1 && num_chan_type == 0) {
|
||||
chan_type[0] = CHAN_TYPE_CC_PC;
|
||||
for (i = 1; i < num_kanal; i++)
|
||||
chan_type[i] = CHAN_TYPE_VC;
|
||||
num_chan_type = num_kanal;
|
||||
}
|
||||
}
|
||||
if (num_kanal == 1 && num_audiodev == 0)
|
||||
num_audiodev = 1; /* use default */
|
||||
if (num_kanal != num_audiodev) {
|
||||
fprintf(stderr, "You need to specify as many sound devices as you have channels.\n");
|
||||
exit(0);
|
||||
}
|
||||
if (num_kanal == 1 && num_chan_type == 0)
|
||||
num_chan_type = 1; /* use default */
|
||||
if (num_kanal != num_chan_type) {
|
||||
fprintf(stderr, "You need to specify as many channel types as you have channels.\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/* check for mandatory CC */
|
||||
for (i = 0; i < num_kanal; i++) {
|
||||
if (chan_type[i] == CHAN_TYPE_CC || chan_type[i] == CHAN_TYPE_CC_PC || chan_type[i] == CHAN_TYPE_CC_PC_VC)
|
||||
break;
|
||||
}
|
||||
if (i == num_kanal) {
|
||||
fprintf(stderr, "You must define at least one CC (control) or combined channel type. Quitting!\n");
|
||||
goto fail;
|
||||
}
|
||||
// NOTE: Variable 'i' from above is used here:
|
||||
/* default SID/AID, depending on system */
|
||||
if (!sid) {
|
||||
if (amps_channel2band(kanal[i])[0] == 'A') {
|
||||
if (!tacs)
|
||||
sid = 1; /* Chicago */
|
||||
else
|
||||
sid = 2051; /* UK Vodafone */
|
||||
} else {
|
||||
if (!tacs)
|
||||
sid = 40; /* Frisco */
|
||||
else
|
||||
sid = 3600; /* UK Cellnet */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (bis && latency > 5) {
|
||||
fprintf(stderr, "If you use BUSY/IDLE bit, you need to lower the round-trip delay to 5 ms (--latency 5).\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (!loopback)
|
||||
print_image();
|
||||
sid_stations(sid);
|
||||
|
||||
/* init functions */
|
||||
dsp_init();
|
||||
init_frame();
|
||||
|
||||
/* check for mandatory PC */
|
||||
for (i = 0; i < num_kanal; i++) {
|
||||
if (chan_type[i] == CHAN_TYPE_CC_PC || chan_type[i] == CHAN_TYPE_CC_PC_VC)
|
||||
break;
|
||||
}
|
||||
if (i == num_kanal) {
|
||||
fprintf(stderr, "You must define at least one PC (paging) or combined channel type. Quitting!\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* check for mandatory VC */
|
||||
for (i = 0; i < num_kanal; i++) {
|
||||
if (chan_type[i] == CHAN_TYPE_VC || chan_type[i] == CHAN_TYPE_CC_PC_VC)
|
||||
break;
|
||||
}
|
||||
if (i == num_kanal)
|
||||
fprintf(stderr, "You did not define any VC (voice) channel. You will not be able to make any call.\n");
|
||||
|
||||
/* SDR always requires emphasis */
|
||||
if (use_sdr) {
|
||||
do_pre_emphasis = 1;
|
||||
do_de_emphasis = 1;
|
||||
}
|
||||
|
||||
if (!do_pre_emphasis || !do_de_emphasis) {
|
||||
fprintf(stderr, "*******************************************************************************\n");
|
||||
fprintf(stderr, "I strongly suggest to let me do pre- and de-emphasis (options -p -d)!\n");
|
||||
fprintf(stderr, "Use a transmitter/receiver without emphasis and let me do that!\n");
|
||||
fprintf(stderr, "Because carrier FSK signaling does not use emphasis, I like to control\n");
|
||||
fprintf(stderr, "emphasis by myself for best results.\n");
|
||||
fprintf(stderr, "*******************************************************************************\n");
|
||||
}
|
||||
|
||||
if (!strcmp(flip_polarity, "no"))
|
||||
polarity = 1; /* positive */
|
||||
else if (!strcmp(flip_polarity, "yes"))
|
||||
polarity = -1; /* negative */
|
||||
else if (use_sdr)
|
||||
polarity = 1; /* SDR is always positive */
|
||||
else {
|
||||
fprintf(stderr, "You must define, if the the TX deviation polarity has to be flipped. (-F yes | no) See help.\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/* create transceiver instance */
|
||||
for (i = 0; i < num_kanal; i++) {
|
||||
amps_si si;
|
||||
|
||||
init_sysinfo(&si, ms_power, ms_power, dtx, dcc, sid >> 1, regh, regr, pureg, pdreg, locaid, regincr, bis);
|
||||
rc = amps_create(kanal[i], chan_type[i], audiodev[i], use_sdr, samplerate, rx_gain, do_pre_emphasis, do_de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, &si, sid, scc, polarity, tolerant, loopback);
|
||||
if (rc < 0) {
|
||||
fprintf(stderr, "Failed to create \"Sender\" instance. Quitting!\n");
|
||||
goto fail;
|
||||
}
|
||||
if (!tacs)
|
||||
printf("Base station on channel %d ready (%s), please tune transmitter to %.3f MHz and receiver to %.3f MHz.\n", kanal[i], chan_type_long_name(chan_type[i]), amps_channel2freq(kanal[i], 0) / 1e6, amps_channel2freq(kanal[i], 1) / 1e6);
|
||||
else
|
||||
printf("Base station on channel %d ready (%s), please tune transmitter to %.4f MHz and receiver to %.4f MHz.\n", kanal[i], chan_type_long_name(chan_type[i]), amps_channel2freq(kanal[i], 0) / 1e6, amps_channel2freq(kanal[i], 1) / 1e6);
|
||||
}
|
||||
|
||||
main_common(&quit, latency, interval, NULL, station_id, 10);
|
||||
|
||||
fail:
|
||||
/* destroy transceiver instance */
|
||||
while (sender_head)
|
||||
amps_destroy(sender_head);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -88,6 +88,7 @@
|
|||
#include "amps.h"
|
||||
#include "frame.h"
|
||||
#include "dsp.h"
|
||||
#include "main.h"
|
||||
|
||||
#define CHAN amps->sender.kanal
|
||||
|
||||
|
@ -99,14 +100,22 @@
|
|||
|
||||
#define PI M_PI
|
||||
|
||||
#define MAX_DEVIATION 8000.0
|
||||
#define MAX_MODULATION 10000.0
|
||||
#define DBM0_DEVIATION 2900.0 /* deviation of dBm0 at 1 kHz */
|
||||
#define COMPANDOR_0DB 1.0 /* A level of 0dBm (1.0) shall be unaccected */
|
||||
#define FSK_DEVIATION (8000.0 / DBM0_DEVIATION) /* no emphasis */
|
||||
#define SAT_DEVIATION (2000.0 / DBM0_DEVIATION) /* no emphasis */
|
||||
#define MAX_DISPLAY (8000.0 / DBM0_DEVIATION) /* no emphasis */
|
||||
#define BITRATE 10000
|
||||
#define AMPS_MAX_DEVIATION 8000.0
|
||||
#define AMPS_MAX_MODULATION 10000.0
|
||||
#define AMPS_DBM0_DEVIATION 2900.0 /* deviation of dBm0 at 1 kHz */
|
||||
#define AMPS_FSK_DEVIATION (8000.0 / AMPS_DBM0_DEVIATION) /* no emphasis */
|
||||
#define AMPS_SAT_DEVIATION (2000.0 / AMPS_DBM0_DEVIATION) /* no emphasis */
|
||||
#define AMPS_MAX_DISPLAY (8000.0 / AMPS_DBM0_DEVIATION) /* no emphasis */
|
||||
#define AMPS_BITRATE 10000
|
||||
/* for some reason, 4000 Hz deviation works better */
|
||||
#define TACS_DBM0_DEVIATION 4000.0 /* 2300 Hz deviation at 1 kHz (according to panasonic manual) */
|
||||
#define TACS_MAX_DEVIATION 6400.0 /* (according to texas intruments and other sources) */
|
||||
#define TACS_MAX_MODULATION 9500.0 /* (according to panasonic manual) */
|
||||
#define TACS_FSK_DEVIATION (6400.0 / TACS_DBM0_DEVIATION) /* no emphasis */
|
||||
#define TACS_SAT_DEVIATION (1700.0 / TACS_DBM0_DEVIATION) /* no emphasis (panasonic / TI) */
|
||||
#define TACS_MAX_DISPLAY (6400.0 / TACS_DBM0_DEVIATION) /* no emphasis */
|
||||
#define TACS_BITRATE 8000
|
||||
#define SAT_DURATION 0.05 /* duration of SAT signal measurement */
|
||||
#define SAT_QUALITY 0.85 /* quality needed to detect SAT signal */
|
||||
#define DTX_LEVEL 0.50 /* SAT level needed to mute/unmute */
|
||||
|
@ -121,12 +130,11 @@
|
|||
|
||||
static sample_t ramp_up[256], ramp_down[256];
|
||||
|
||||
static double sat_freq[5] = {
|
||||
static double sat_freq[4] = {
|
||||
5970.0,
|
||||
6000.0,
|
||||
6030.0,
|
||||
5800.0, /* noise level to check against */
|
||||
10000.0, /* signaling tone */
|
||||
};
|
||||
|
||||
static sample_t dsp_sine_sat[65536];
|
||||
|
@ -143,8 +151,8 @@ void dsp_init(void)
|
|||
PDEBUG(DDSP, DEBUG_DEBUG, "Generating sine table for SAT signal.\n");
|
||||
for (i = 0; i < 65536; i++) {
|
||||
s = sin((double)i / 65536.0 * 2.0 * PI);
|
||||
dsp_sine_sat[i] = s * SAT_DEVIATION;
|
||||
dsp_sine_test[i] = s * FSK_DEVIATION;
|
||||
dsp_sine_sat[i] = s * ((!tacs) ? AMPS_SAT_DEVIATION : TACS_SAT_DEVIATION);
|
||||
dsp_sine_test[i] = s * ((!tacs) ? AMPS_FSK_DEVIATION : TACS_FSK_DEVIATION);
|
||||
}
|
||||
|
||||
/* sync checker */
|
||||
|
@ -194,14 +202,18 @@ int dsp_init_sender(amps_t *amps, int tolerant)
|
|||
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Init DSP for transceiver.\n");
|
||||
|
||||
/* set modulation parameters */
|
||||
sender_set_fm(&s->sender, MAX_DEVIATION, MAX_MODULATION, DBM0_DEVIATION, MAX_DISPLAY);
|
||||
sender_set_fm(&s->sender,
|
||||
(!tacs) ? AMPS_MAX_DEVIATION : TACS_MAX_DEVIATION,
|
||||
(!tacs) ? AMPS_MAX_MODULATION : TACS_MAX_MODULATION,
|
||||
(!tacs) ? AMPS_DBM0_DEVIATION : TACS_DBM0_DEVIATION,
|
||||
(!tacs) ? AMPS_MAX_DISPLAY : TACS_MAX_DISPLAY);
|
||||
|
||||
if (amps->sender.samplerate < 96000) {
|
||||
PDEBUG(DDSP, DEBUG_ERROR, "Sample rate must be at least 96000 Hz to process FSK and SAT signals.\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
amps->fsk_bitduration = (double)amps->sender.samplerate / (double)BITRATE;
|
||||
amps->fsk_bitduration = (double)amps->sender.samplerate / (double)((!tacs) ? AMPS_BITRATE : TACS_BITRATE);
|
||||
amps->fsk_bitstep = 1.0 / amps->fsk_bitduration;
|
||||
PDEBUG(DDSP, DEBUG_DEBUG, "Use %.4f samples for full bit duration @ %d.\n", amps->fsk_bitduration, amps->sender.samplerate);
|
||||
|
||||
|
@ -231,7 +243,7 @@ int dsp_init_sender(amps_t *amps, int tolerant)
|
|||
amps->fsk_rx_window = spl;
|
||||
|
||||
/* create devation and ramp */
|
||||
amps->fsk_deviation = FSK_DEVIATION;
|
||||
amps->fsk_deviation = (!tacs) ? AMPS_FSK_DEVIATION : TACS_FSK_DEVIATION;
|
||||
dsp_init_ramp(amps);
|
||||
|
||||
/* allocate ring buffer for SAT signal detection */
|
||||
|
@ -244,13 +256,15 @@ int dsp_init_sender(amps_t *amps, int tolerant)
|
|||
amps->sat_filter_spl = spl;
|
||||
|
||||
/* count SAT tones */
|
||||
for (i = 0; i < 5; i++) {
|
||||
for (i = 0; i < 4; i++) {
|
||||
audio_goertzel_init(&s->sat_goertzel[i], sat_freq[i], amps->sender.samplerate);
|
||||
if (i < 3) {
|
||||
amps->sat_phaseshift65536[i] = 65536.0 / ((double)amps->sender.samplerate / sat_freq[i]);
|
||||
PDEBUG(DDSP, DEBUG_DEBUG, "sat_phaseshift65536[%d] = %.4f\n", i, amps->sat_phaseshift65536[i]);
|
||||
}
|
||||
}
|
||||
/* signaling tone */
|
||||
audio_goertzel_init(&s->sat_goertzel[4], (!tacs) ? 10000.0 : 8000.0, amps->sender.samplerate);
|
||||
sat_reset(amps, "Initial state");
|
||||
|
||||
/* test tone */
|
||||
|
@ -568,7 +582,7 @@ prepare_frame:
|
|||
amps->fsk_rx_frame_quality = 0.0;
|
||||
amps->fsk_rx_frame_level = 0.0;
|
||||
amps->fsk_rx_sync_register = 0x555;
|
||||
amps->when_received = get_time() - (21.0 / (double)BITRATE);
|
||||
amps->when_received = get_time() - (21.0 / (double)((!tacs) ? AMPS_BITRATE : TACS_BITRATE));
|
||||
return;
|
||||
case 0x81:
|
||||
if (!amps->fsk_rx_sync_tolerant)
|
||||
|
@ -594,11 +608,11 @@ prepare_frame:
|
|||
}
|
||||
|
||||
/* count level and quality */
|
||||
amps->fsk_rx_frame_level += (double)(max - min) / (double)FSK_DEVIATION / 2.0;
|
||||
amps->fsk_rx_frame_level += (double)(max - min) / (double)((!tacs) ? AMPS_FSK_DEVIATION : TACS_FSK_DEVIATION) / 2.0;
|
||||
if (bit)
|
||||
amps->fsk_rx_frame_quality += (double)(second - first) / (double)FSK_DEVIATION / 2.0 / BEST_QUALITY;
|
||||
amps->fsk_rx_frame_quality += (double)(second - first) / (double)((!tacs) ? AMPS_FSK_DEVIATION : TACS_FSK_DEVIATION) / 2.0 / BEST_QUALITY;
|
||||
else
|
||||
amps->fsk_rx_frame_quality += (double)(first - second) / (double)FSK_DEVIATION / 2.0 / BEST_QUALITY;
|
||||
amps->fsk_rx_frame_quality += (double)(first - second) / (double)((!tacs) ? AMPS_FSK_DEVIATION : TACS_FSK_DEVIATION) / 2.0 / BEST_QUALITY;
|
||||
|
||||
/* invert bit if negative sync was detected */
|
||||
if (amps->fsk_rx_sync == FSK_SYNC_NEGATIVE)
|
||||
|
@ -745,11 +759,11 @@ static void sat_decode(amps_t *amps, sample_t *samples, int length)
|
|||
if (quality[1] < 0)
|
||||
quality[1] = 0;
|
||||
|
||||
PDEBUG_CHAN(DDSP, DEBUG_NOTICE, "SAT level %.2f%% quality %.0f%%\n", result[0] / SAT_DEVIATION / 0.63662 * 100.0, quality[0] * 100.0);
|
||||
PDEBUG_CHAN(DDSP, DEBUG_NOTICE, "SAT level %.2f%% quality %.0f%%\n", result[0] / ((!tacs) ? AMPS_SAT_DEVIATION : TACS_SAT_DEVIATION) / 0.63662 * 100.0, quality[0] * 100.0);
|
||||
if (amps->sender.loopback || debuglevel == DEBUG_DEBUG) {
|
||||
PDEBUG_CHAN(DDSP, debuglevel, "Signaling Tone level %.2f%% quality %.0f%%\n", result[2] / FSK_DEVIATION / 0.63662 * 100.0, quality[1] * 100.0);
|
||||
PDEBUG_CHAN(DDSP, debuglevel, "Signaling Tone level %.2f%% quality %.0f%%\n", result[2] / ((!tacs) ? AMPS_FSK_DEVIATION : TACS_FSK_DEVIATION) / 0.63662 * 100.0, quality[1] * 100.0);
|
||||
}
|
||||
if (quality[0] > SAT_QUALITY && result[0] / SAT_DEVIATION / 0.63662 > DTX_LEVEL)
|
||||
if (quality[0] > SAT_QUALITY && result[0] / ((!tacs) ? AMPS_SAT_DEVIATION : TACS_SAT_DEVIATION) / 0.63662 > DTX_LEVEL)
|
||||
amps->dtx_state = 1;
|
||||
else
|
||||
amps->dtx_state = 0;
|
||||
|
|
103
src/amps/frame.c
103
src/amps/frame.c
|
@ -32,6 +32,7 @@
|
|||
#include "amps.h"
|
||||
#include "dsp.h"
|
||||
#include "frame.h"
|
||||
#include "main.h"
|
||||
|
||||
/* uncomment this to debug bits */
|
||||
//#define BIT_DEBUGGING
|
||||
|
@ -317,7 +318,7 @@ static struct def_word word5_third_ssd_update_order_word = {
|
|||
|
||||
/* FOCC - System Parameter Overhead Message */
|
||||
|
||||
static struct def_word word1_system_parameter_overhead = {
|
||||
static struct def_word amps_word1_system_parameter_overhead = {
|
||||
"Word 1 - System Parameter Overhead",
|
||||
{
|
||||
{ "T1T2", 2, 0 },
|
||||
|
@ -333,6 +334,21 @@ static struct def_word word1_system_parameter_overhead = {
|
|||
}
|
||||
};
|
||||
|
||||
static struct def_word tacs_word1_system_parameter_overhead = {
|
||||
"Word 1 - System Parameter Overhead",
|
||||
{
|
||||
{ "T1T2", 2, 0 },
|
||||
{ "DCC", 2, 0 },
|
||||
{ "AID1", 14, 0 },
|
||||
{ "EP", 1, 0 },
|
||||
{ "AUTH", 1, 0 },
|
||||
{ "PCI", 1, 0 },
|
||||
{ "NAWC", 4, 0 },
|
||||
{ "OHD", 3, 0 },
|
||||
{ "P", 12, 0 },
|
||||
{ NULL, 0, 0 }
|
||||
}
|
||||
};
|
||||
|
||||
static struct def_word word2_system_parameter_overhead = {
|
||||
"Word 2 - System Parameter Overhead",
|
||||
|
@ -612,7 +628,8 @@ static struct def_message_set focc_words = {
|
|||
&word4_second_ssd_update_order_word,
|
||||
&word5_third_ssd_update_order_word,
|
||||
|
||||
&word1_system_parameter_overhead,
|
||||
&s_word1_system_parameter_overhead,
|
||||
&tacs_word1_system_parameter_overhead,
|
||||
&word2_system_parameter_overhead,
|
||||
&rescan_global_action,
|
||||
®istration_increment_global_action,
|
||||
|
@ -1711,23 +1728,43 @@ static const char *ie_chan(uint64_t value)
|
|||
|
||||
static const char *ie_cmac(uint64_t value)
|
||||
{
|
||||
switch (value) {
|
||||
case 0:
|
||||
return "6 dbW (4 Watts)";
|
||||
case 1:
|
||||
return "2 dbW (1.6 Watts)";
|
||||
case 2:
|
||||
return "-2 dbW (630 Milliwatts)";
|
||||
case 3:
|
||||
return "-6 dbW (250 Milliwatts)";
|
||||
case 4:
|
||||
return "-10 dbW (100 Milliwatts)";
|
||||
case 5:
|
||||
return "-14 dbW (40 Milliwatts)";
|
||||
case 6:
|
||||
return "-18 dbW (16 Milliwatts)";
|
||||
if (!tacs) {
|
||||
switch (value) {
|
||||
case 0:
|
||||
return "6 dbW (4 Watts)";
|
||||
case 1:
|
||||
return "2 dbW (1.6 Watts)";
|
||||
case 2:
|
||||
return "-2 dbW (630 Milliwatts)";
|
||||
case 3:
|
||||
return "-6 dbW (250 Milliwatts)";
|
||||
case 4:
|
||||
return "-10 dbW (100 Milliwatts)";
|
||||
case 5:
|
||||
return "-14 dbW (40 Milliwatts)";
|
||||
case 6:
|
||||
return "-18 dbW (16 Milliwatts)";
|
||||
}
|
||||
return "-22 dbW (6.3 Milliwatts)";
|
||||
} else {
|
||||
switch (value) {
|
||||
case 0:
|
||||
return "4.5 dbW (2.82 Watts)";
|
||||
case 1:
|
||||
return "0.5 dbW (1.12 Watts)";
|
||||
case 2:
|
||||
return "-3.5 dbW (447 Milliwatts)";
|
||||
case 3:
|
||||
return "-7.5 dbW (178 Milliwatts)";
|
||||
case 4:
|
||||
return "-11.5 dbW (70.8 Milliwatts)";
|
||||
case 5:
|
||||
return "-15.5 dbW (28.2 Milliwatts)";
|
||||
case 6:
|
||||
return "-19.5 dbW (11.2 Milliwatts)";
|
||||
}
|
||||
return "-23.5 dbW (4.5 Milliwatts)";
|
||||
}
|
||||
return "-22 dbW (6.3 Milliwatts)";
|
||||
}
|
||||
|
||||
static const char *ie_cmax(uint64_t value)
|
||||
|
@ -2113,6 +2150,7 @@ struct amps_ie_desc amps_ie_desc[] = {
|
|||
{ AMPS_IE_11, "11", "bit combination 3", NULL },
|
||||
{ AMPS_IE_1111, "1111", "bit combination 15", NULL },
|
||||
{ AMPS_IE_ACT, "ACT", "Global action field", ie_act },
|
||||
{ AMPS_IE_AID1, "AID1", "First part of the area identification field", NULL },
|
||||
{ AMPS_IE_AUTH, "AUTH", "Support of authentication procedures described in TIA/EIA-136-510", ie_yes },
|
||||
{ AMPS_IE_AUTHBS, "AUTHBS", "Output response of the authentication algorithm initiated by the Base Station Challenge Order", ie_hex },
|
||||
{ AMPS_IE_AUTHR, "AUTHR", "Output response of the authentication algorithm", ie_hex },
|
||||
|
@ -2763,7 +2801,23 @@ uint64_t amps_encode_word1_system(uint8_t dcc, uint16_t sid1, uint8_t ep, uint8_
|
|||
frame.ie[AMPS_IE_PCI] = pci;
|
||||
frame.ie[AMPS_IE_NAWC] = nawc;
|
||||
frame.ie[AMPS_IE_OHD] = 6;
|
||||
return amps_encode_word(&frame, &word1_system_parameter_overhead, -1);
|
||||
return amps_encode_word(&frame, &s_word1_system_parameter_overhead, -1);
|
||||
}
|
||||
|
||||
uint64_t tacs_encode_word1_system(uint8_t dcc, uint16_t aid1, uint8_t ep, uint8_t auth, uint8_t pci, uint8_t nawc)
|
||||
{
|
||||
frame_t frame;
|
||||
|
||||
memset(&frame, 0, sizeof(frame));
|
||||
frame.ie[AMPS_IE_T1T2] = 3;
|
||||
frame.ie[AMPS_IE_DCC] = dcc;
|
||||
frame.ie[AMPS_IE_AID1] = aid1;
|
||||
frame.ie[AMPS_IE_EP] = ep;
|
||||
frame.ie[AMPS_IE_AUTH] = auth;
|
||||
frame.ie[AMPS_IE_PCI] = pci;
|
||||
frame.ie[AMPS_IE_NAWC] = nawc;
|
||||
frame.ie[AMPS_IE_OHD] = 6;
|
||||
return amps_encode_word(&frame, &tacs_word1_system_parameter_overhead, -1);
|
||||
}
|
||||
|
||||
uint64_t amps_encode_word2_system(uint8_t dcc, uint8_t s, uint8_t e, uint8_t regh, uint8_t regr, uint8_t dtx, uint8_t n_1, uint8_t rcf, uint8_t cpa, uint8_t cmax_1, uint8_t end)
|
||||
|
@ -3061,7 +3115,10 @@ static void amps_decode_word_focc(amps_t *amps, uint64_t word)
|
|||
ohd = (word >> 12) & 7;
|
||||
switch (ohd) {
|
||||
case 6:
|
||||
w = &word1_system_parameter_overhead;
|
||||
if (!tacs)
|
||||
w = &s_word1_system_parameter_overhead;
|
||||
else
|
||||
w = &tacs_word1_system_parameter_overhead;
|
||||
break;
|
||||
case 7:
|
||||
w = &word2_system_parameter_overhead;
|
||||
|
@ -3385,7 +3442,7 @@ int amps_encode_frame_focc(amps_t *amps, char *bits)
|
|||
/* send overhead train */
|
||||
if (amps->si.num) {
|
||||
word = get_sysinfo(&s->si);
|
||||
if (++amps->tx_focc_frame_count >= 17)
|
||||
if (++amps->tx_focc_frame_count >= amps->si.overhead_repeat)
|
||||
amps->tx_focc_frame_count = 0;
|
||||
goto send;
|
||||
}
|
||||
|
@ -3427,7 +3484,7 @@ int amps_encode_frame_focc(amps_t *amps, char *bits)
|
|||
amps->tx_focc_word_repeat = 0;
|
||||
amps->tx_focc_send = 0;
|
||||
/* now we may wrap */
|
||||
if (amps->tx_focc_frame_count >= 17)
|
||||
if (amps->tx_focc_frame_count >= amps->si.overhead_repeat)
|
||||
amps->tx_focc_frame_count = 0;
|
||||
}
|
||||
}
|
||||
|
@ -3436,7 +3493,7 @@ int amps_encode_frame_focc(amps_t *amps, char *bits)
|
|||
|
||||
/* send filler */
|
||||
word = amps_encode_control_filler(amps, amps->si.dcc, amps->si.filler.cmac, amps->si.filler.sdcc1, amps->si.filler.sdcc2, amps->si.filler.wfom);
|
||||
if (++amps->tx_focc_frame_count >= 17)
|
||||
if (++amps->tx_focc_frame_count >= amps->si.overhead_repeat)
|
||||
amps->tx_focc_frame_count = 0;
|
||||
|
||||
send:
|
||||
|
|
|
@ -5,6 +5,7 @@ enum amps_ie {
|
|||
AMPS_IE_11,
|
||||
AMPS_IE_1111,
|
||||
AMPS_IE_ACT,
|
||||
AMPS_IE_AID1,
|
||||
AMPS_IE_AUTH,
|
||||
AMPS_IE_AUTHBS,
|
||||
AMPS_IE_AUTHR,
|
||||
|
@ -211,6 +212,7 @@ typedef struct amps_frame {
|
|||
|
||||
void init_frame(void);
|
||||
uint64_t amps_encode_word1_system(uint8_t dcc, uint16_t sid1, uint8_t ep, uint8_t auth, uint8_t pci, uint8_t nawc);
|
||||
uint64_t tacs_encode_word1_system(uint8_t dcc, uint16_t aid1, uint8_t ep, uint8_t auth, uint8_t pci, uint8_t nawc);
|
||||
uint64_t amps_encode_word2_system(uint8_t dcc, uint8_t s, uint8_t e, uint8_t regh, uint8_t regr, uint8_t dtx, uint8_t n_1, uint8_t rcf, uint8_t cpa, uint8_t cmax_1, uint8_t end);
|
||||
uint64_t amps_encode_registration_id(uint8_t dcc, uint32_t regid, uint8_t end);
|
||||
uint64_t amps_encode_registration_increment(uint8_t dcc, uint16_t regincr, uint8_t end);
|
||||
|
|
382
src/amps/main.c
382
src/amps/main.c
|
@ -1,394 +1,20 @@
|
|||
/* AMPS main
|
||||
*
|
||||
* (C) 2016 by Andreas Eversberg <jolly@eversberg.eu>
|
||||
* All Rights Reserved
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <getopt.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "../common/sample.h"
|
||||
#include "../common/main.h"
|
||||
#include "../common/debug.h"
|
||||
#include "../common/timer.h"
|
||||
#include "../common/call.h"
|
||||
#include "../common/mncc_sock.h"
|
||||
#include "amps.h"
|
||||
#include "dsp.h"
|
||||
#include "frame.h"
|
||||
#include "image.h"
|
||||
#include "main.h"
|
||||
#include "tones.h"
|
||||
#include "noanswer.h"
|
||||
#include "outoforder.h"
|
||||
#include "invalidnumber.h"
|
||||
#include "congestion.h"
|
||||
#include "stations.h"
|
||||
|
||||
/* settings */
|
||||
int num_chan_type = 0;
|
||||
enum amps_chan_type chan_type[MAX_SENDER] = { CHAN_TYPE_CC_PC_VC };
|
||||
const char *flip_polarity = "";
|
||||
int ms_power = 4, dtx = 0, dcc = 0, scc = 0, sid = 40, regh = 1, regr = 1, pureg = 1, pdreg = 1, locaid = -1, regincr = 300, bis = 0;
|
||||
int tolerant = 0;
|
||||
|
||||
void print_help(const char *arg0)
|
||||
{
|
||||
print_help_common(arg0, "-p -d -F yes | no [-S sid=<sid>] ");
|
||||
/* - - */
|
||||
printf(" -T --channel-type <channel type> | list\n");
|
||||
printf(" Give channel type, use 'list' to get a list. (default = '%s')\n", chan_type_short_name(chan_type[0]));
|
||||
printf(" -F --flip-polarity no | yes\n");
|
||||
printf(" Flip polarity of transmitted FSK signal. If yes, the sound card\n");
|
||||
printf(" generates a negative signal rather than a positive one. Be sure that\n");
|
||||
printf(" a positive signal causes a positive deviation on your transmitter.\n");
|
||||
printf(" If the phone shows 'NoSrv', try the other way.\n");
|
||||
printf(" -P --ms-power <power level>\n");
|
||||
printf(" Give power level of the mobile station 0..7. (default = '%d')\n", ms_power);
|
||||
printf(" 0 = 4 W; 1 = 1.6 W; 2 = 630 mW; 3 = 250 mW;\n");
|
||||
printf(" 4 = 100 mW; 5 = 40 mW; 6 = 16 mW; 7 = 6.3 mW\n");
|
||||
printf(" -D --dtx <parameter>\n");
|
||||
printf(" Give DTX parameter for Discontinuous Transmission. (default = '%d')\n", dtx);
|
||||
printf(" 0 = disable DTX; 1 = reserved;\n");
|
||||
printf(" 2 = 8 dB attenuation in low state; 3 = transmitter off\n");
|
||||
printf(" -S --sysinfo sid=<System ID> | sid=list\n");
|
||||
printf(" Give system ID of cell broadcast (default = '%d')\n", sid);
|
||||
printf(" If it changes, phone re-registers. Use 'sid=list' to get a full list.\n");
|
||||
printf(" -S --sysinfo dcc=<digital color code>\n");
|
||||
printf(" Give digital color code 0..3 (default = '%d')\n", dcc);
|
||||
printf(" -S --sysinfo scc=<SAT color code>\n");
|
||||
printf(" Give supervisor tone color code 0..2 (default = '%d')\n", scc);
|
||||
printf(" -S --sysinfo regincr\n");
|
||||
printf(" Amount to add to REGID after successful registration (default = '%d')\n", regincr);
|
||||
printf(" Since REGID is incremented every second, this value define after how\n");
|
||||
printf(" many second the phone waits before it re-registers.\n");
|
||||
printf(" -S --sysinfo pureg=0 | pureg=1\n");
|
||||
printf(" If 1, phone registers on every power on (default = '%d')\n", pureg);
|
||||
printf(" (Not supported by older phones.)\n");
|
||||
printf(" -S --sysinfo pdreg=0 | pdreg=1\n");
|
||||
printf(" If 1, phone de-registers on every power down (default = '%d')\n", pureg);
|
||||
printf(" (Not supported by older phones.)\n");
|
||||
printf(" -S --sysinfo locaid=<location area ID > | locaid=-1 to disable\n");
|
||||
printf(" (default = '%d')\n", locaid);
|
||||
printf(" If it changes, phone re-registers.\n");
|
||||
printf(" (Not supported by older phones.)\n");
|
||||
printf(" -S --sysinfo regh=0 | regh=1\n");
|
||||
printf(" If 1, phone registers only if System ID matches (default = '%d')\n", regh);
|
||||
printf(" -S --sysinfo regr=0 | regr=1\n");
|
||||
printf(" If 1, phone registers only if System ID is different (default = '%d')\n", regr);
|
||||
printf(" -S --sysinfo bis=0 | bis=1\n");
|
||||
printf(" If 0, phone ignores BUSY/IDLE bit on FOCC (default = '%d')\n", bis);
|
||||
printf(" If 1, be sure to have a round-trip delay (latency) not more than 5 ms\n");
|
||||
printf(" -O --tolerant\n");
|
||||
printf(" Be more tolerant when hunting for sync sequence\n");
|
||||
printf("\nstation-id: Give 10 digit station-id, you don't need to enter it for every\n");
|
||||
printf(" start of this program.\n");
|
||||
print_hotkeys_common();
|
||||
}
|
||||
|
||||
static int handle_options(int argc, char **argv)
|
||||
{
|
||||
const char *p;
|
||||
int skip_args = 0;
|
||||
int rc;
|
||||
|
||||
static struct option long_options_special[] = {
|
||||
{"channel-type", 1, 0, 'T'},
|
||||
{"flip-polarity", 1, 0, 'F'},
|
||||
{"ms-power", 1, 0, 'P'},
|
||||
{"dtx", 1, 0, 'D'},
|
||||
{"sysinfo", 1, 0, 'S'},
|
||||
{"tolerant", 0, 0, 'O'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
set_options_common("T:F:P:D:S:O", long_options_special);
|
||||
|
||||
while (1) {
|
||||
int option_index = 0, c;
|
||||
|
||||
c = getopt_long(argc, argv, optstring, long_options, &option_index);
|
||||
|
||||
if (c == -1)
|
||||
break;
|
||||
|
||||
switch (c) {
|
||||
case 'T':
|
||||
if (!strcmp(optarg, "list")) {
|
||||
amps_channel_list();
|
||||
exit(0);
|
||||
}
|
||||
rc = amps_channel_by_short_name(optarg);
|
||||
if (rc < 0) {
|
||||
fprintf(stderr, "Error, channel type '%s' unknown. Please use '-t list' to get a list. I suggest to use the default.\n", optarg);
|
||||
exit(0);
|
||||
}
|
||||
OPT_ARRAY(num_chan_type, chan_type, rc)
|
||||
skip_args += 2;
|
||||
break;
|
||||
case 'F':
|
||||
if (!strcasecmp(optarg, "no"))
|
||||
flip_polarity = "no";
|
||||
else if (!strcasecmp(optarg, "yes"))
|
||||
flip_polarity = "yes";
|
||||
else {
|
||||
fprintf(stderr, "Given polarity '%s' is illegal, see help!\n", optarg);
|
||||
exit(0);
|
||||
}
|
||||
skip_args += 2;
|
||||
break;
|
||||
case 'P':
|
||||
ms_power = atoi(optarg);
|
||||
if (ms_power > 3)
|
||||
ms_power = 3;
|
||||
if (ms_power < 0)
|
||||
ms_power = 0;
|
||||
skip_args += 2;
|
||||
break;
|
||||
case 'D':
|
||||
dtx = atoi(optarg);
|
||||
if (dtx > 3)
|
||||
dtx = 3;
|
||||
if (dtx < 0)
|
||||
dtx = 0;
|
||||
skip_args += 2;
|
||||
break;
|
||||
case 'S':
|
||||
p = strchr(optarg, '=');
|
||||
if (!p) {
|
||||
fprintf(stderr, "Given sysinfo parameter '%s' requires '=' character to set value, see help!\n", optarg);
|
||||
exit(0);
|
||||
}
|
||||
p++;
|
||||
if (!strncasecmp(optarg, "sid=", p - optarg)) {
|
||||
if (!strcasecmp(p, "list")) {
|
||||
list_stations();
|
||||
exit(0);
|
||||
}
|
||||
sid = atoi(p);
|
||||
if (sid > 32767)
|
||||
sid = 32767;
|
||||
if (sid < 0)
|
||||
sid = 0;
|
||||
} else
|
||||
if (!strncasecmp(optarg, "dcc=", p - optarg)) {
|
||||
dcc = atoi(p);
|
||||
if (dcc > 3)
|
||||
dcc = 3;
|
||||
if (dcc < 0)
|
||||
dcc = 0;
|
||||
} else
|
||||
if (!strncasecmp(optarg, "scc=", p - optarg)) {
|
||||
scc = atoi(p);
|
||||
if (scc > 2)
|
||||
scc = 2;
|
||||
if (scc < 0)
|
||||
scc = 0;
|
||||
} else
|
||||
if (!strncasecmp(optarg, "regincr=", p - optarg)) {
|
||||
regincr = atoi(p);
|
||||
} else
|
||||
if (!strncasecmp(optarg, "pureg=", p - optarg)) {
|
||||
pureg = atoi(p) & 1;
|
||||
} else
|
||||
if (!strncasecmp(optarg, "pdreg=", p - optarg)) {
|
||||
pdreg = atoi(p) & 1;
|
||||
} else
|
||||
if (!strncasecmp(optarg, "locaid=", p - optarg)) {
|
||||
locaid = atoi(p);
|
||||
if (locaid > 4095)
|
||||
locaid = 4095;
|
||||
} else
|
||||
if (!strncasecmp(optarg, "regh=", p - optarg)) {
|
||||
regh = atoi(p) & 1;
|
||||
} else
|
||||
if (!strncasecmp(optarg, "regr=", p - optarg)) {
|
||||
regr = atoi(p) & 1;
|
||||
} else
|
||||
if (!strncasecmp(optarg, "bis=", p - optarg)) {
|
||||
bis = atoi(p) & 1;
|
||||
} else {
|
||||
fprintf(stderr, "Given sysinfo parameter '%s' unknown, see help!\n", optarg);
|
||||
exit(0);
|
||||
}
|
||||
skip_args += 2;
|
||||
break;
|
||||
case 'O':
|
||||
tolerant = 1;
|
||||
skip_args += 1;
|
||||
break;
|
||||
default:
|
||||
opt_switch_common(c, argv[0], &skip_args);
|
||||
}
|
||||
}
|
||||
|
||||
free(long_options);
|
||||
|
||||
return skip_args;
|
||||
}
|
||||
const int tacs = 0;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int rc;
|
||||
int skip_args;
|
||||
const char *station_id = "";
|
||||
int polarity;
|
||||
int i;
|
||||
|
||||
/* override default */
|
||||
samplerate = 96000;
|
||||
|
||||
/* init common tones */
|
||||
init_tones();
|
||||
init_noanswer();
|
||||
init_outoforder();
|
||||
init_noanswer();
|
||||
init_invalidnumber();
|
||||
init_congestion();
|
||||
|
||||
skip_args = handle_options(argc, argv);
|
||||
argc -= skip_args;
|
||||
argv += skip_args;
|
||||
|
||||
if (argc > 1) {
|
||||
station_id = argv[1];
|
||||
if (strlen(station_id) != 10) {
|
||||
printf("Given station ID '%s' does not have 10 digits\n", station_id);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!num_kanal) {
|
||||
printf("No channel (\"Kanal\") is specified, I suggest channel 334.\n\n");
|
||||
print_help(argv[-skip_args]);
|
||||
return 0;
|
||||
}
|
||||
if (use_sdr) {
|
||||
/* set audiodev */
|
||||
for (i = 0; i < num_kanal; i++)
|
||||
audiodev[i] = "sdr";
|
||||
num_audiodev = num_kanal;
|
||||
/* set channel types for more than 1 channel */
|
||||
if (num_kanal > 1 && num_chan_type == 0) {
|
||||
chan_type[0] = CHAN_TYPE_CC_PC;
|
||||
for (i = 1; i < num_kanal; i++)
|
||||
chan_type[i] = CHAN_TYPE_VC;
|
||||
num_chan_type = num_kanal;
|
||||
}
|
||||
}
|
||||
if (num_kanal == 1 && num_audiodev == 0)
|
||||
num_audiodev = 1; /* use default */
|
||||
if (num_kanal != num_audiodev) {
|
||||
fprintf(stderr, "You need to specify as many sound devices as you have channels.\n");
|
||||
exit(0);
|
||||
}
|
||||
if (num_kanal == 1 && num_chan_type == 0)
|
||||
num_chan_type = 1; /* use default */
|
||||
if (num_kanal != num_chan_type) {
|
||||
fprintf(stderr, "You need to specify as many channel types as you have channels.\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (bis && latency > 5) {
|
||||
fprintf(stderr, "If you use BUSY/IDLE bit, you need to lower the round-trip delay to 5 ms (--latenc 5).\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (!loopback)
|
||||
print_image();
|
||||
sid_stations(sid);
|
||||
|
||||
/* init functions */
|
||||
dsp_init();
|
||||
init_frame();
|
||||
|
||||
/* check for mandatory CC */
|
||||
for (i = 0; i < num_kanal; i++) {
|
||||
if (chan_type[i] == CHAN_TYPE_CC || chan_type[i] == CHAN_TYPE_CC_PC || chan_type[i] == CHAN_TYPE_CC_PC_VC)
|
||||
break;
|
||||
}
|
||||
if (i == num_kanal) {
|
||||
fprintf(stderr, "You must define at least one CC (control) or combined channel type. Quitting!\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* check for mandatory PC */
|
||||
for (i = 0; i < num_kanal; i++) {
|
||||
if (chan_type[i] == CHAN_TYPE_CC_PC || chan_type[i] == CHAN_TYPE_CC_PC_VC)
|
||||
break;
|
||||
}
|
||||
if (i == num_kanal) {
|
||||
fprintf(stderr, "You must define at least one PC (paging) or combined channel type. Quitting!\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* check for mandatory VC */
|
||||
for (i = 0; i < num_kanal; i++) {
|
||||
if (chan_type[i] == CHAN_TYPE_VC || chan_type[i] == CHAN_TYPE_CC_PC_VC)
|
||||
break;
|
||||
}
|
||||
if (i == num_kanal)
|
||||
fprintf(stderr, "You did not define any VC (voice) channel. You will not be able to make any call.\n");
|
||||
|
||||
/* SDR always requires emphasis */
|
||||
if (use_sdr) {
|
||||
do_pre_emphasis = 1;
|
||||
do_de_emphasis = 1;
|
||||
}
|
||||
|
||||
if (!do_pre_emphasis || !do_de_emphasis) {
|
||||
fprintf(stderr, "*******************************************************************************\n");
|
||||
fprintf(stderr, "I strongly suggest to let me do pre- and de-emphasis (options -p -d)!\n");
|
||||
fprintf(stderr, "Use a transmitter/receiver without emphasis and let me do that!\n");
|
||||
fprintf(stderr, "Because carrier FSK signaling does not use emphasis, I like to control\n");
|
||||
fprintf(stderr, "emphasis by myself for best results.\n");
|
||||
fprintf(stderr, "*******************************************************************************\n");
|
||||
}
|
||||
|
||||
if (!strcmp(flip_polarity, "no"))
|
||||
polarity = 1; /* positive */
|
||||
else if (!strcmp(flip_polarity, "yes"))
|
||||
polarity = -1; /* negative */
|
||||
else if (use_sdr)
|
||||
polarity = 1; /* SDR is always positive */
|
||||
else {
|
||||
fprintf(stderr, "You must define, if the the TX deviation polarity has to be flipped. (-F yes | no) See help.\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/* create transceiver instance */
|
||||
for (i = 0; i < num_kanal; i++) {
|
||||
amps_si si;
|
||||
|
||||
init_sysinfo(&si, ms_power, ms_power, dtx, dcc, sid >> 1, regh, regr, pureg, pdreg, locaid, regincr, bis);
|
||||
rc = amps_create(kanal[i], chan_type[i], audiodev[i], use_sdr, samplerate, rx_gain, do_pre_emphasis, do_de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, &si, sid, scc, polarity, tolerant, loopback);
|
||||
if (rc < 0) {
|
||||
fprintf(stderr, "Failed to create \"Sender\" instance. Quitting!\n");
|
||||
goto fail;
|
||||
}
|
||||
printf("Base station on channel %d ready (%s), please tune transmitter to %.3f MHz and receiver to %.3f MHz.\n", kanal[i], chan_type_long_name(chan_type[i]), amps_channel2freq(kanal[i], 0) / 1e6, amps_channel2freq(kanal[i], 1) / 1e6);
|
||||
}
|
||||
|
||||
main_common(&quit, latency, interval, NULL, station_id, 10);
|
||||
|
||||
fail:
|
||||
/* destroy transceiver instance */
|
||||
while (sender_head)
|
||||
amps_destroy(sender_head);
|
||||
|
||||
return 0;
|
||||
return main_amps_tacs(argc, argv);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
|
||||
extern const int tacs;
|
||||
|
||||
int main_amps_tacs(int argc, char *argv[]);
|
||||
|
|
@ -1,6 +1,17 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "stations.h"
|
||||
|
||||
void numbering(const char *number, const char __attribute__((unused)) **carrier, const char **country, const char **national_number)
|
||||
{
|
||||
static char digits[64];
|
||||
|
||||
*country = "USA";
|
||||
strcpy(digits, "1");
|
||||
strcat(digits, number);
|
||||
*national_number = number;
|
||||
}
|
||||
|
||||
/*
|
||||
1: the SID, system Identification number
|
||||
2: the BID, the billing identification number, or 0= if same as the SID
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
|
||||
void numbering(const char *number, const char **carrier, const char **country, const char **national_number);
|
||||
void list_stations(void);
|
||||
void sid_stations(int sid);
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "../common/timer.h"
|
||||
#include "amps.h"
|
||||
#include "frame.h"
|
||||
#include "main.h"
|
||||
|
||||
static struct sysinfo_reg_incr default_reg_incr = {
|
||||
450,
|
||||
|
@ -48,6 +49,12 @@ void init_sysinfo(amps_si *si, int cmac, int vmac, int dtx, int dcc, int sid1, i
|
|||
|
||||
memset(si, 0, sizeof(*si));
|
||||
|
||||
/* how oftern to repeat the overhead train */
|
||||
if (!tacs)
|
||||
si->overhead_repeat = 17;
|
||||
else
|
||||
si->overhead_repeat = 14;
|
||||
|
||||
/* all words */
|
||||
si->dcc = dcc;
|
||||
/* VC assginment */
|
||||
|
@ -159,7 +166,10 @@ uint64_t get_sysinfo(amps_si *si)
|
|||
switch (si->type[count]) {
|
||||
case SYSINFO_WORD1:
|
||||
nawc = si->num - 1;
|
||||
return amps_encode_word1_system(si->dcc, si->word1.sid1, si->word1.ep, si->word1.auth, si->word1.pci, nawc);
|
||||
if (!tacs)
|
||||
return amps_encode_word1_system(si->dcc, si->word1.sid1, si->word1.ep, si->word1.auth, si->word1.pci, nawc);
|
||||
else
|
||||
return tacs_encode_word1_system(si->dcc, si->word1.sid1, si->word1.ep, si->word1.auth, si->word1.pci, nawc);
|
||||
case SYSINFO_WORD2:
|
||||
return amps_encode_word2_system(si->dcc, si->word2.s, si->word2.e, si->word2.regh, si->word2.regr, si->word2.dtx, si->word2.n_1, si->word2.rcf, si->word2.cpa, si->word2.cmax_1, end);
|
||||
case SYSINFO_REG_ID:
|
||||
|
|
|
@ -86,6 +86,8 @@ struct sysinfo_reg_id {
|
|||
};
|
||||
|
||||
typedef struct system_information {
|
||||
/* how ofter repeat overhead train (in frames) */
|
||||
int overhead_repeat;
|
||||
/* all words */
|
||||
uint8_t dcc;
|
||||
/* VC assginment */
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
AM_CPPFLAGS = -Wall -Wextra -g $(all_includes)
|
||||
|
||||
bin_PROGRAMS = \
|
||||
tacs
|
||||
|
||||
tacs_SOURCES = \
|
||||
tones.c \
|
||||
outoforder.c \
|
||||
stations.c \
|
||||
image.c \
|
||||
main.c
|
||||
|
||||
tacs_LDADD = \
|
||||
$(COMMON_LA) \
|
||||
../amps/libamps.a \
|
||||
$(top_builddir)/src/common/libcommon.a \
|
||||
$(ALSA_LIBS) \
|
||||
$(UHD_LIBS) \
|
||||
$(SOAPY_LIBS) \
|
||||
-lm
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "image.h"
|
||||
|
||||
const char *image[] = {
|
||||
" @B(@g#@B)",
|
||||
" @g#",
|
||||
" #",
|
||||
" #",
|
||||
" # @R_____",
|
||||
" _@g#@R--- _._ ---__",
|
||||
" |_____(_|_)_____|",
|
||||
" | @WTELEPHONE@R |",
|
||||
" |###############|",
|
||||
" |###############|",
|
||||
" |## | | ##|",
|
||||
" |## @B1@R | @B2@R | @B3@R ##|",
|
||||
" |##___|___|___##| @WTACS@R",
|
||||
" |## | | ##|",
|
||||
" |## @B4@R | @B5@R | @B6@R ##|",
|
||||
" |##___|___|___##|",
|
||||
" |## | | ##|",
|
||||
" |## @B7@R | @B8@R | @B9@R ##|",
|
||||
" |##___|___|___##|",
|
||||
" |## | | ##|",
|
||||
" |## @B*@R | @B0@R | @B#@R ##|",
|
||||
" |##___|___|___##|",
|
||||
" |###############|",
|
||||
" |##+---------+##|",
|
||||
" |##+---------+##|",
|
||||
" |###############|",
|
||||
" @g+++++++++++++++++",
|
||||
"@W",
|
||||
NULL
|
||||
};
|
||||
|
||||
void print_image(void)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
for (i = 0; image[i]; i++) {
|
||||
for (j = 0; j < (int)strlen(image[i]); j++) {
|
||||
if (image[i][j] == '@') {
|
||||
j++;
|
||||
switch(image[i][j]) {
|
||||
case 'R': /* red */
|
||||
printf("\033[1;31m");
|
||||
break;
|
||||
case 'g': /* gray */
|
||||
printf("\033[0;37m");
|
||||
break;
|
||||
case 'W': /* white */
|
||||
printf("\033[1;37m");
|
||||
break;
|
||||
case 'B': /* blue */
|
||||
printf("\033[1;34m");
|
||||
break;
|
||||
}
|
||||
} else
|
||||
printf("%c", image[i][j]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
printf("\033[0;39m");
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
|
||||
void print_image(void);
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
#include "../amps/main.h"
|
||||
#include "../amps/tones.h"
|
||||
#include "../amps/outoforder.h"
|
||||
|
||||
const int tacs = 1;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
/* init common tones */
|
||||
init_tones();
|
||||
init_outoforder();
|
||||
|
||||
return main_amps_tacs(argc, argv);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,89 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "../amps/stations.h"
|
||||
|
||||
/* area codes */
|
||||
static struct tacs_areas {
|
||||
const char *number; /* country code (first 3 digits of subscriber number) + area code */
|
||||
const char *carrier; /* name of carrier */
|
||||
const char *country; /* name of country */
|
||||
const char *national_prefix; /* digits to dial inside country */
|
||||
} tacs_areas[] = {
|
||||
{ "2220", "Telecom Italia Mobile", "Italy", "0336" },
|
||||
{ "2222", "Telecom Italia Mobile", "Italy", "0337" },
|
||||
{ "2224", "Telecom Italia Mobile", "Italy", "0330" },
|
||||
{ "2225", "Telecom Italia Mobile", "Italy", "0360" },
|
||||
{ "2226", "Telecom Italia Mobile", "Italy", "0368" },
|
||||
{ "2340", "Vodafone", "United Kingdom", "0836" },
|
||||
{ "2341", "Vodafone", "United Kingdom", "0421" },
|
||||
{ "2342", "CellNet", "United Kingdom", "0860" },
|
||||
{ "2343", "Vodafone", "United Kingdom", "0378" },
|
||||
{ "2344", "Vodafone", "United Kingdom", "0831" },
|
||||
{ "2345", "Vodafone", "United Kingdom", "0374" },
|
||||
{ "2346", "CellNet", "United Kingdom", "0850" },
|
||||
{ "2347", "CellNet", "United Kingdom", "0589" },
|
||||
{ "2348", "CellNet", "United Kingdom", "0402" },
|
||||
{ "2349", "CellNet", "United Kingdom", "0585" },
|
||||
{ NULL, NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
void numbering(const char *number, const char **carrier, const char **country, const char **national_number)
|
||||
{
|
||||
int i;
|
||||
static char digits[64];
|
||||
|
||||
for (i = 0; tacs_areas[i].carrier; i++) {
|
||||
if (!strncmp(number, tacs_areas[i].number, 4)) {
|
||||
*carrier = tacs_areas[i].carrier;
|
||||
*country = tacs_areas[i].country;
|
||||
if (tacs_areas[i].national_prefix) {
|
||||
strcpy(digits, tacs_areas[i].national_prefix);
|
||||
strcat(digits, number + 4);
|
||||
*national_number = digits;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
1: the AID, system Identification number
|
||||
2: the telephone company name
|
||||
3: the country
|
||||
*/
|
||||
static struct tacs_stations {
|
||||
int aid;
|
||||
const char *carrier, *country;
|
||||
} tacs_stations[] = {
|
||||
{ -1, "Telecom Italia Mobile", "Italy" },
|
||||
{ 3600, "CellNet", "United Kingdom" },
|
||||
{ 2051, "VodaFone", "United Kingdom" },
|
||||
{ 0, NULL, NULL }
|
||||
};
|
||||
|
||||
void list_stations(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; tacs_stations[i].carrier; i++) {
|
||||
if (tacs_stations[i].aid >= 0)
|
||||
printf("AID:%5d", tacs_stations[i].aid);
|
||||
else
|
||||
printf("AID: ???");
|
||||
printf(" Carrier: %s, %s\n", tacs_stations[i].carrier, tacs_stations[i].country);
|
||||
}
|
||||
}
|
||||
|
||||
void sid_stations(int aid)
|
||||
{
|
||||
int i, first = 1;
|
||||
|
||||
for (i = 0; tacs_stations[i].carrier; i++) {
|
||||
if (aid == tacs_stations[i].aid) {
|
||||
if (first)
|
||||
printf("Selected Area ID (AID) %d belongs to:\n", tacs_stations[i].aid);
|
||||
first = 0;
|
||||
printf("\t%s, %s\n", tacs_stations[i].carrier, tacs_stations[i].country);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue