From 27c6e3d860aed41f6ed44997b1410b229f2bd53f Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Thu, 1 Dec 2016 17:59:08 +0100 Subject: [PATCH] C-Netz: Add code documentation... --- src/cnetz/cnetz.c | 26 +++++++++++++++++++++++++- src/cnetz/fsk_fm_demod.c | 6 ++++++ src/cnetz/fsk_fm_demod.h | 1 + 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/cnetz/cnetz.c b/src/cnetz/cnetz.c index 7519241..b177f65 100644 --- a/src/cnetz/cnetz.c +++ b/src/cnetz/cnetz.c @@ -75,6 +75,30 @@ * read also in the C-Netz specs. */ +/* + * Notes on switching from OgK to SpK + * + * Upon transmission of TRANS_VAG and TRANS_VAK, the SpK channel is allocated, + * set to busy, scheduled to switch to SpK mode after two frames. The trans- + * action is relinked from OgK to SpK. + * + * In case of a combined OgK+SpK, the channel stays the same, but will change. + * + * See below for detailled processing. + */ + +/* + * Notes on database (subscriber) + * + * If a subscriber registers (transaction is created), an instance of the + * subscriber database is created. A timer is running for each instance, so + * the subscriber is paged to check availability of the phone. If the paging + * fails, a retry counter is decreased until the subscriber is removed from + * database. + * + * See database.c for more information. + */ + /* * Notes on the combined channel hack: * @@ -899,7 +923,7 @@ wbn: } else { PDEBUG(DCNETZ, DEBUG_INFO, "Assigning phone to traffic channel %d\n", spk->sender.kanal); /* sync RX time to current OgK time */ - spk->fsk_demod.bit_time = cnetz->fsk_demod.bit_time; + fsk_copy_sync(&spk->fsk_demod, &cnetz->fsk_demod); } /* set channel */ telegramm.frequenz_nr = spk->sender.kanal; diff --git a/src/cnetz/fsk_fm_demod.c b/src/cnetz/fsk_fm_demod.c index a7247f0..f4008f4 100644 --- a/src/cnetz/fsk_fm_demod.c +++ b/src/cnetz/fsk_fm_demod.c @@ -456,6 +456,12 @@ void fsk_correct_sync(fsk_fm_demod_t *fsk, double offset) fsk->bit_time = fmod(fsk->bit_time - offset + BITS_PER_SUPERFRAME, BITS_PER_SUPERFRAME); } +/* copy sync from one instance to another (used to sync RX of SpK to OgK */ +void fsk_copy_sync(fsk_fm_demod_t *fsk_to, fsk_fm_demod_t *fsk_from) +{ + fsk_to->bit_time = fsk_from->bit_time; +} + void fsk_demod_reset(fsk_fm_demod_t *fsk) { fsk->sync = FSK_SYNC_NONE; diff --git a/src/cnetz/fsk_fm_demod.h b/src/cnetz/fsk_fm_demod.h index 0c51e70..b1889bd 100644 --- a/src/cnetz/fsk_fm_demod.h +++ b/src/cnetz/fsk_fm_demod.h @@ -53,5 +53,6 @@ typedef struct fsk_fm_demod { int fsk_fm_init(fsk_fm_demod_t *fsk, cnetz_t *cnetz, int samplerate, double bitrate); void fsk_fm_demod(fsk_fm_demod_t *fsk, int16_t *samples, int length); void fsk_correct_sync(fsk_fm_demod_t *fsk, double offset); +void fsk_copy_sync(fsk_fm_demod_t *fsk_to, fsk_fm_demod_t *fsk_from); void fsk_demod_reset(fsk_fm_demod_t *fsk);