C-Netz: --ms-power defines power level (not P-bits)

Also the level 8 can be selected. Actually level 6 is selected, but
reduced to 8 when making a call.
pull/1/head
Andreas Eversberg 3 years ago
parent 5c8919a78b
commit 4cd9cb787e
  1. 32
      src/cnetz/cnetz.c
  2. 13
      src/cnetz/main.c

@ -181,6 +181,26 @@ double cnetz_kanal2freq(int kanal, int unterband)
return freq * 1e6;
}
/* convert power level to P-bits by selecting next higher level */
static uint8_t cnetz_power2bits(int power)
{
switch (power) {
case 1:
return 3;
case 2:
case 3:
return 2;
case 4:
case 5:
return 1;
case 6:
case 7:
case 8:
default:
return 0;
}
}
const char *cnetz_state_name(enum cnetz_state state)
{
static char invalid[16];
@ -941,7 +961,7 @@ const telegramm_t *cnetz_transmit_telegramm_rufblock(cnetz_t *cnetz)
memset(&telegramm, 0, sizeof(telegramm));
telegramm.opcode = OPCODE_LR_R;
telegramm.max_sendeleistung = cnetz->ms_power;
telegramm.max_sendeleistung = cnetz_power2bits(cnetz->ms_power);
telegramm.bedingte_genauigkeit_der_fufst = si.genauigkeit;
telegramm.zeitschlitz_nr = cnetz->sched_ts;
telegramm.grenzwert_fuer_einbuchen_und_umbuchen = si.grenz_einbuchen;
@ -1082,7 +1102,7 @@ const telegramm_t *cnetz_transmit_telegramm_meldeblock(cnetz_t *cnetz)
memset(&telegramm, 0, sizeof(telegramm));
telegramm.opcode = OPCODE_MLR_M;
telegramm.max_sendeleistung = cnetz->ms_power;
telegramm.max_sendeleistung = cnetz_power2bits(cnetz->ms_power);
telegramm.ogk_verkehrsanteil = 0; /* must be 0 or phone might not respond to messages in different slot */
telegramm.teilnehmergruppensperre = si.teilnehmergruppensperre;
telegramm.anzahl_gesperrter_teilnehmergruppen = si.anzahl_gesperrter_teilnehmergruppen;
@ -1270,8 +1290,8 @@ const telegramm_t *cnetz_transmit_telegramm_spk_k(cnetz_t *cnetz)
if (!trans)
return &telegramm;
telegramm.max_sendeleistung = cnetz->ms_power;
telegramm.sendeleistungsanpassung = 1;
telegramm.max_sendeleistung = cnetz_power2bits(cnetz->ms_power);
telegramm.sendeleistungsanpassung = (cnetz->ms_power < 8) ? 1 : 0;
telegramm.entfernung = si.entfernung;
telegramm.fuz_nationalitaet = si.fuz_nat;
telegramm.fuz_fuvst_nr = si.fuz_fuvst;
@ -1600,8 +1620,8 @@ const telegramm_t *cnetz_transmit_telegramm_spk_v(cnetz_t *cnetz)
meter = (now - trans->call_start) / (double)cnetz->metering + 1;
}
telegramm.max_sendeleistung = cnetz->ms_power;
telegramm.sendeleistungsanpassung = 1;
telegramm.max_sendeleistung = cnetz_power2bits(cnetz->ms_power);
telegramm.sendeleistungsanpassung = (cnetz->ms_power < 8) ? 1 : 0;
telegramm.ankuendigung_gespraechsende = 0;
telegramm.gebuehren_stand = meter;
telegramm.fuz_nationalitaet = si.fuz_nat;

@ -45,7 +45,7 @@ int measure_speed = 0;
double clock_speed[2] = { 0.0, 0.0 };
int set_clock_speed = 0;
const char *flip_polarity = "auto";
int ms_power = 0; /* 0..3 */
int ms_power = 6; /* 1..8 */
int warteschlange = 1;
int challenge_valid;
uint64_t challenge;
@ -97,8 +97,9 @@ void print_help(const char *arg0)
printf(" (default = %s)\n", flip_polarity);
printf(" Note: This has no effect with SDR.\n");
printf(" -P --ms-power <power level>\n");
printf(" Give power level of the mobile station 0..3. (default = '%d')\n", ms_power);
printf(" 0 = 50-125 mW; 1 = 0.5-1 W; 2 = 4-8 W; 3 = 10-20 W\n");
printf(" Give power level of the mobile station: 1, 2, 4, 6, 8 (default = '%d')\n", ms_power);
printf(" 1 = 7.5-20 W; 2 = 4-8 W; 4 = 0.5-1 W; 6 = 50-125 mW; 8 = 2-10 mW\n");
printf(" Power level 8 starts with level 6 and is then reduced on SpK.\n");
printf(" -A --authentication <challenge>\n");
printf(" Enable authorization flag on the base station and use given challenge\n");
printf(" as autorization random. Depending on the key inside the card you will\n");
@ -307,7 +308,11 @@ static int handle_options(int short_option, int argi, char **argv)
}
break;
case 'P':
ms_power = atoi_limit(argv[argi], 0, 3);
ms_power = atoi_limit(argv[argi], 0, 9);
if (ms_power < 1 || ms_power == 3 || ms_power == 5 || ms_power == 7 || ms_power > 8) {
fprintf(stderr, "Given power level '%s' is illegal, use '-h' for help!\n", argv[argi]);
return -EINVAL;
}
break;
case 'A':
authentifikationsbit = 1;

Loading…
Cancel
Save