C-Netz: Cleanup OgK slot allocation and polarity detection

Now you can select between 1 and 8 slots per frame.
pull/6/head
Andreas Eversberg 6 months ago
parent 4930da8e0c
commit 26f4b3f711
  1. 8
      src/cnetz/cnetz.c
  2. 16
      src/cnetz/dsp.c
  3. 31
      src/cnetz/main.c
  4. 4
      src/cnetz/sysinfo.h

@ -559,7 +559,7 @@ void cnetz_go_idle(cnetz_t *cnetz)
PDEBUG(DCNETZ, DEBUG_NOTICE, "Now channel is available for queued subscriber '%s'.\n", transaction2rufnummer(trans));
trans_new_state(trans, (trans->state == TRANS_MT_QUEUE) ? TRANS_MT_DELAY : TRANS_MO_DELAY);
timer_stop(&trans->timer);
timer_start(&trans->timer, 2.0);
timer_start(&trans->timer, 3.0);
}
}
@ -1121,7 +1121,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_power2bits(cnetz->ms_power);
telegramm.ogk_verkehrsanteil = 0; /* must be 0 or phone might not respond to messages in different slot */
telegramm.ogk_verkehrsanteil = 0; /* must be 0 or some phone might not respond to messages in different slots */
telegramm.teilnehmergruppensperre = si.teilnehmergruppensperre;
telegramm.anzahl_gesperrter_teilnehmergruppen = si.anzahl_gesperrter_teilnehmergruppen;
if (ogk_list_count) {
@ -1143,7 +1143,7 @@ const telegramm_t *cnetz_transmit_telegramm_meldeblock(cnetz_t *cnetz)
telegramm.futln_heimat_fuvst_nr = trans->futln_fuvst;
telegramm.futln_rest_nr = trans->futln_rest;
trans_new_state(trans, TRANS_WAF);
timer_start(&trans->timer, 1.0); /* Wait two slot cycles until resending */
timer_start(&trans->timer, 3.0); /* Wait at least two frame cycles until resending */
break;
case TRANS_MA:
PDEBUG_CHAN(DCNETZ, DEBUG_INFO, "Sending keepalive request 'Meldeaufruf'\n");
@ -1152,7 +1152,7 @@ const telegramm_t *cnetz_transmit_telegramm_meldeblock(cnetz_t *cnetz)
telegramm.futln_heimat_fuvst_nr = trans->futln_fuvst;
telegramm.futln_rest_nr = trans->futln_rest;
trans_new_state(trans, TRANS_MFT);
timer_start(&trans->timer, 1.0); /* Wait two slot cycles until timeout */
timer_start(&trans->timer, 3.0); /* Wait at least two frame cycles until timeout */
break;
default:
; /* MLR */

@ -670,19 +670,11 @@ again:
switch (cnetz->dsp_mode) {
case DSP_MODE_OGK:
/* if automatic polarity selection is used, toggle between
* two polarities (every 4 slots) until a response is received
* then continue to use the time slots of that polarity
*/
if (cnetz->auto_polarity)
cnetz->negative_polarity = (cnetz->sched_ts & 7) >> 2;
/* send on timeslots depending on the polarity:
* positive polarity: ts, ts+8, ts+16, ts+24
* negative polarity: ts+4, ts+12, ts+20, ts+28
*/
if (((cnetz->sched_ts & 7) == (si.timeslot & 7) && cnetz->negative_polarity == 0)
|| ((cnetz->sched_ts & 7) == ((si.timeslot + 4) & 7) && cnetz->negative_polarity == 1)) {
if (((si.timeslots >> cnetz->sched_ts) & 1)) {
if (cnetz->sched_r_m == 0) {
/* if automatic polarity selection is used, toggle between two polarities (every transmitted slot) until a response is received then continue to use the time slots of that polarity */
if (cnetz->auto_polarity)
cnetz->negative_polarity = (cnetz->sched_ts & 7) >> 2;
/* set last time slot, so we know to which time slot the message from mobile station belongs to */
cnetz->sched_last_ts = cnetz->sched_ts;
bits = cnetz_encode_telegramm(cnetz);

@ -44,14 +44,14 @@ enum cnetz_chan_type chan_type[MAX_SENDER] = { CHAN_TYPE_OGK_SPK };
int measure_speed = 0;
double clock_speed[2] = { 0.0, 0.0 };
int set_clock_speed = 0;
const char *flip_polarity = "auto";
const char *flip_polarity = "";
int ms_power = 6; /* 1..8 */
int warteschlange = 1;
int challenge_valid;
uint64_t challenge;
int response_valid;
uint64_t response;
uint8_t timeslot = 0;
uint32_t timeslots = 4; /* 1 up to 8 */
uint8_t fuz_nat = 1;
uint8_t fuz_fuvst = 4;
uint8_t fuz_rest = 66;
@ -99,8 +99,8 @@ void print_help(const char *arg0)
printf(" generates a negative signal rather than a positive one. If auto, the\n");
printf(" base station uses double time slots with alternating polarity.\n");
printf(" Once a mobile registers, the correct polarity is selected and used.\n");
printf(" (default = %s)\n", flip_polarity);
printf(" Note: This has no effect with SDR.\n");
printf(" (default = %s)\n", (flip_polarity[0]) ? flip_polarity : "auto");
printf(" Note: Correct polarity is selected for SDR by default.\n");
printf(" -P --ms-power <power level>\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");
@ -125,11 +125,10 @@ void print_help(const char *arg0)
printf(" It is unclear what the actual voice deviation is. Please decrease, if\n");
printf(" mobile's microphone is too loud and speaker is too quiet.\n");
printf(" (default = %.0f)\n", speech_deviation);
printf(" -S --sysinfo timeslot=<0..31>\n");
printf(" Set time slot of OgK broadcast. There are 32 time slots, but every 8th\n");
printf(" slot is used. This means if you select time slot 0, also slots 8, 16\n");
printf(" and 24 will be used. If you select slot 14, also slots 6, 22 and 30\n");
printf(" will be used. (default = %d)\n", timeslot);
printf(" -S --sysinfo timeslots=1|2|4|8\n");
printf(" Set number of timeslots of OgK broadcast. There are 32 time slots per\n");
printf(" frame, but only up to 8 slots can be used, because of processing\n");
printf(" delay. (default = %d)\n", timeslots);
printf(" -S --sysinfo fuz-nat=<nat>\n");
printf(" Set country ID of base station. All IDs were used inside Germany only.\n");
printf(" (default = %d)\n", fuz_nat);
@ -350,8 +349,8 @@ static int handle_options(int short_option, int argi, char **argv)
return -EINVAL;
}
p++;
if (!strncasecmp(argv[argi], "timeslot=", p - argv[argi])) {
timeslot = atoi_limit(p, 0, 31);
if (!strncasecmp(argv[argi], "timeslots=", p - argv[argi])) {
timeslots = atoi_limit(p, 1, 8);
} else
if (!strncasecmp(argv[argi], "fuz-nat=", p - argv[argi])) {
fuz_nat = atoi_limit(p, 0, 7);
@ -579,7 +578,13 @@ int main(int argc, char *argv[])
}
if (anzahl_gesperrter_teilnehmergruppen)
printf("Blocked subscriber with number's last 4 bits from 0x%x to 0x%x\n", teilnehmergruppensperre, (teilnehmergruppensperre + anzahl_gesperrter_teilnehmergruppen - 1) & 0xf);
init_sysinfo(timeslot, fuz_nat, fuz_fuvst, fuz_rest, kennung_fufst, authentifikationsbit, ws_kennung, fuvst_sperren, grenz_einbuchen, grenz_umschalten, grenz_ausloesen, mittel_umschalten, mittel_ausloesen, genauigkeit, bewertung, entfernung, reduzierung, nachbar_prio, teilnehmergruppensperre, anzahl_gesperrter_teilnehmergruppen);
switch(timeslots) {
case 1: timeslots=0x00000001; break;
case 2: timeslots=0x00010001; break;
case 4: timeslots=0x01010101; break;
default: timeslots=0x11111111;
}
init_sysinfo(timeslots, fuz_nat, fuz_fuvst, fuz_rest, kennung_fufst, authentifikationsbit, ws_kennung, fuvst_sperren, grenz_einbuchen, grenz_umschalten, grenz_ausloesen, mittel_umschalten, mittel_ausloesen, genauigkeit, bewertung, entfernung, reduzierung, nachbar_prio, teilnehmergruppensperre, anzahl_gesperrter_teilnehmergruppen);
dsp_init();
rc = init_telegramm();
if (rc < 0) {
@ -633,7 +638,7 @@ int main(int argc, char *argv[])
polarity = 1; /* positive */
if (!strcmp(flip_polarity, "yes"))
polarity = -1; /* negative */
if (use_sdr && polarity == 0)
if (use_sdr && !flip_polarity[0])
polarity = 1; /* SDR is always positive */
/* demodulation algorithm */

@ -1,6 +1,6 @@
typedef struct system_information {
uint8_t timeslot; /* timeslot to use */
uint32_t timeslots; /* timeslot map to use */
uint8_t fuz_nat; /* national network ID */
uint8_t fuz_fuvst; /* id of switching center */
uint8_t fuz_rest; /* rest of base station id */
@ -24,5 +24,5 @@ typedef struct system_information {
extern cnetz_si si;
void init_sysinfo(uint8_t timeslot, uint8_t fuz_nat, uint8_t fuz_fuvst, uint8_t fuz_rest, uint8_t kennung_fufst, uint8_t authentifikationsbit, uint8_t ws_kennung, uint8_t vermittlungstechnische_sperren, uint8_t grenz_einbuchen, uint8_t grenz_umschalten, uint8_t grenz_ausloesen, uint8_t mittel_umschalten, uint8_t mittel_ausloesen, uint8_t genauigkeit, uint8_t bewertung, uint8_t entfernung, uint8_t reduzierung, uint8_t nachbar_prio, int8_t teilnehmergruppensperre, uint8_t anzahl_gesperrter_teilnehmergruppen);
void init_sysinfo(uint32_t timeslots, uint8_t fuz_nat, uint8_t fuz_fuvst, uint8_t fuz_rest, uint8_t kennung_fufst, uint8_t authentifikationsbit, uint8_t ws_kennung, uint8_t vermittlungstechnische_sperren, uint8_t grenz_einbuchen, uint8_t grenz_umschalten, uint8_t grenz_ausloesen, uint8_t mittel_umschalten, uint8_t mittel_ausloesen, uint8_t genauigkeit, uint8_t bewertung, uint8_t entfernung, uint8_t reduzierung, uint8_t nachbar_prio, int8_t teilnehmergruppensperre, uint8_t anzahl_gesperrter_teilnehmergruppen);

Loading…
Cancel
Save