aboutsummaryrefslogtreecommitdiffstats
path: root/src/amps/frame.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/amps/frame.c')
-rw-r--r--src/amps/frame.c233
1 files changed, 150 insertions, 83 deletions
diff --git a/src/amps/frame.c b/src/amps/frame.c
index 7c99c85..14bd856 100644
--- a/src/amps/frame.c
+++ b/src/amps/frame.c
@@ -27,7 +27,8 @@
#include <math.h>
#include <inttypes.h>
#include "../libsample/sample.h"
-#include "../libdebug/debug.h"
+#include "../liblogging/logging.h"
+#include "../libmobile/get_time.h"
#include "amps.h"
#include "dsp.h"
#include "frame.h"
@@ -1717,7 +1718,7 @@ static const char *ie_bspc(uint64_t value)
static const char *ie_chan(uint64_t value)
{
- static char string[32];
+ static char string[64];
if (value == 0)
return "No channel";
@@ -2707,7 +2708,7 @@ static uint64_t amps_encode_word(frame_t *frame, struct def_word *w, int debug)
int i, t4 = 0;
#ifdef DEBUG_ALL_MESSAGES
- debug=1;
+ debug = 1;
#endif
memset(spaces, ' ', ie_desc_max_len);
@@ -2718,7 +2719,8 @@ static uint64_t amps_encode_word(frame_t *frame, struct def_word *w, int debug)
for (i = 0; w->ie[i].name; i++)
sum_bits += w->ie[i].bits;
- PDEBUG(DFRAME, (debug >= 0) ? DEBUG_INFO : DEBUG_DEBUG, "Transmit: %s\n", w->name);
+ if (debug)
+ LOGP(DFRAME, LOGL_INFO, "Transmit: %s\n", w->name);
word = 0;
for (i = 0; w->ie[i].name; i++) {
bits = w->ie[i].bits;
@@ -2727,26 +2729,26 @@ static uint64_t amps_encode_word(frame_t *frame, struct def_word *w, int debug)
else
value = frame->ie[w->ie[i].ie];
word = (word << bits) | (value & cut_bits[bits]);
- if (debug >= 0) {
+ if (debug) {
if (amps_ie_desc[w->ie[i].ie].decoder)
- PDEBUG(DFRAME, DEBUG_DEBUG, " %s%s: %" PRIu64 " = %s (%s)\n", spaces + strlen(w->ie[i].name), w->ie[i].name, value, amps_ie_desc[w->ie[i].ie].decoder(value), amps_ie_desc[w->ie[i].ie].desc);
+ LOGP(DFRAME, LOGL_DEBUG, " %s%s: %" PRIu64 " = %s (%s)\n", spaces + strlen(w->ie[i].name), w->ie[i].name, value, amps_ie_desc[w->ie[i].ie].decoder(value), amps_ie_desc[w->ie[i].ie].desc);
else
- PDEBUG(DFRAME, DEBUG_DEBUG, " %s%s: %" PRIu64 " (%s)\n", spaces + strlen(w->ie[i].name), w->ie[i].name, value, amps_ie_desc[w->ie[i].ie].desc);
+ LOGP(DFRAME, LOGL_DEBUG, " %s%s: %" PRIu64 " (%s)\n", spaces + strlen(w->ie[i].name), w->ie[i].name, value, amps_ie_desc[w->ie[i].ie].desc);
}
/* show result for 3 IEs of table 4 */
if (w->ie[i].ie == AMPS_IE_LOCAL_MSG_TYPE || w->ie[i].ie == AMPS_IE_ORDQ || w->ie[i].ie == AMPS_IE_ORDER)
t4++;
if (t4 == 3) {
t4 = 0;
- if (debug >= 0)
- PDEBUG(DFRAME, DEBUG_DEBUG, " %s--> %s\n", spaces, amps_table4_name(frame->ie[AMPS_IE_LOCAL_MSG_TYPE], frame->ie[AMPS_IE_ORDQ], frame->ie[AMPS_IE_ORDER]));
+ if (debug)
+ LOGP(DFRAME, LOGL_DEBUG, " %s--> %s\n", spaces, amps_table4_name(frame->ie[AMPS_IE_LOCAL_MSG_TYPE], frame->ie[AMPS_IE_ORDQ], frame->ie[AMPS_IE_ORDER]));
}
}
return word;
}
-static uint64_t amps_encode_control_filler(amps_t *amps, uint8_t dcc, uint8_t cmac, uint8_t sdcc1, uint8_t sdcc2, uint8_t wfom)
+static uint64_t amps_encode_control_filler(amps_t *amps, uint8_t dcc, uint8_t cmac, uint8_t sdcc1, uint8_t sdcc2, uint8_t wfom, int debug)
{
frame_t frame;
@@ -2767,10 +2769,10 @@ static uint64_t amps_encode_control_filler(amps_t *amps, uint8_t dcc, uint8_t cm
} else
frame.ie[AMPS_IE_1111] = 15;
frame.ie[AMPS_IE_OHD] = 1;
- return amps_encode_word(&frame, &control_filler, -1);
+ return amps_encode_word(&frame, &control_filler, debug);
}
-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 amps_encode_word1_system(uint8_t dcc, uint16_t sid1, uint8_t ep, uint8_t auth, uint8_t pci, uint8_t nawc, int debug)
{
frame_t frame;
@@ -2783,10 +2785,10 @@ 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, &amps_word1_system_parameter_overhead, -1);
+ return amps_encode_word(&frame, &amps_word1_system_parameter_overhead, debug);
}
-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 tacs_encode_word1_system(uint8_t dcc, uint16_t aid1, uint8_t ep, uint8_t auth, uint8_t pci, uint8_t nawc, int debug)
{
frame_t frame;
@@ -2799,10 +2801,10 @@ uint64_t tacs_encode_word1_system(uint8_t dcc, uint16_t aid1, 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, &tacs_word1_system_parameter_overhead, -1);
+ return amps_encode_word(&frame, &tacs_word1_system_parameter_overhead, debug);
}
-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_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, int debug)
{
frame_t frame;
@@ -2820,10 +2822,10 @@ uint64_t amps_encode_word2_system(uint8_t dcc, uint8_t s, uint8_t e, uint8_t reg
frame.ie[AMPS_IE_CMAX_1] = cmax_1;
frame.ie[AMPS_IE_END] = end;
frame.ie[AMPS_IE_OHD] = 7;
- return amps_encode_word(&frame, &word2_system_parameter_overhead, -1);
+ return amps_encode_word(&frame, &word2_system_parameter_overhead, debug);
}
-uint64_t amps_encode_registration_id(uint8_t dcc, uint32_t regid, uint8_t end)
+uint64_t amps_encode_registration_id(uint8_t dcc, uint32_t regid, uint8_t end, int debug)
{
frame_t frame;
@@ -2833,10 +2835,10 @@ uint64_t amps_encode_registration_id(uint8_t dcc, uint32_t regid, uint8_t end)
frame.ie[AMPS_IE_REGID] = regid;
frame.ie[AMPS_IE_END] = end;
frame.ie[AMPS_IE_OHD] = 0;
- return amps_encode_word(&frame, &registration_id, -1);
+ return amps_encode_word(&frame, &registration_id, debug);
}
-uint64_t amps_encode_registration_increment(uint8_t dcc, uint16_t regincr, uint8_t end)
+uint64_t amps_encode_registration_increment(uint8_t dcc, uint16_t regincr, uint8_t end, int debug)
{
frame_t frame;
@@ -2847,10 +2849,10 @@ uint64_t amps_encode_registration_increment(uint8_t dcc, uint16_t regincr, uint8
frame.ie[AMPS_IE_REGINCR] = regincr;
frame.ie[AMPS_IE_END] = end;
frame.ie[AMPS_IE_OHD] = 4;
- return amps_encode_word(&frame, &registration_increment_global_action, -1);
+ return amps_encode_word(&frame, &registration_increment_global_action, debug);
}
-uint64_t amps_encode_location_area(uint8_t dcc, uint8_t pureg, uint8_t pdreg, uint8_t lreg, uint16_t locaid, uint8_t end)
+uint64_t amps_encode_location_area(uint8_t dcc, uint8_t pureg, uint8_t pdreg, uint8_t lreg, uint16_t locaid, uint8_t end, int debug)
{
frame_t frame;
@@ -2864,10 +2866,10 @@ uint64_t amps_encode_location_area(uint8_t dcc, uint8_t pureg, uint8_t pdreg, ui
frame.ie[AMPS_IE_LOCAID] = locaid;
frame.ie[AMPS_IE_END] = end;
frame.ie[AMPS_IE_OHD] = 4;
- return amps_encode_word(&frame, &location_area_global_action, -1);
+ return amps_encode_word(&frame, &location_area_global_action, debug);
}
-uint64_t amps_encode_new_access_channel_set(uint8_t dcc, uint16_t newacc, uint8_t end)
+uint64_t amps_encode_new_access_channel_set(uint8_t dcc, uint16_t newacc, uint8_t end, int debug)
{
frame_t frame;
@@ -2878,10 +2880,10 @@ uint64_t amps_encode_new_access_channel_set(uint8_t dcc, uint16_t newacc, uint8_
frame.ie[AMPS_IE_NEWACC] = newacc;
frame.ie[AMPS_IE_END] = end;
frame.ie[AMPS_IE_OHD] = 4;
- return amps_encode_word(&frame, &new_access_channel_set_global_action, -1);
+ return amps_encode_word(&frame, &new_access_channel_set_global_action, debug);
}
-uint64_t amps_encode_overload_control(uint8_t dcc, uint8_t *olc, uint8_t end)
+uint64_t amps_encode_overload_control(uint8_t dcc, uint8_t *olc, uint8_t end, int debug)
{
frame_t frame;
@@ -2907,10 +2909,10 @@ uint64_t amps_encode_overload_control(uint8_t dcc, uint8_t *olc, uint8_t end)
frame.ie[AMPS_IE_OLC_15] = olc[15];
frame.ie[AMPS_IE_END] = end;
frame.ie[AMPS_IE_OHD] = 4;
- return amps_encode_word(&frame, &overload_control_global_action, -1);
+ return amps_encode_word(&frame, &overload_control_global_action, debug);
}
-uint64_t amps_encode_access_type(uint8_t dcc, uint8_t bis, uint8_t pci_home, uint8_t pci_roam, uint8_t bspc, uint8_t bscap, uint8_t end)
+uint64_t amps_encode_access_type(uint8_t dcc, uint8_t bis, uint8_t pci_home, uint8_t pci_roam, uint8_t bspc, uint8_t bscap, uint8_t end, int debug)
{
frame_t frame;
@@ -2925,10 +2927,10 @@ uint64_t amps_encode_access_type(uint8_t dcc, uint8_t bis, uint8_t pci_home, uin
frame.ie[AMPS_IE_BSCAP] = bscap;
frame.ie[AMPS_IE_END] = end;
frame.ie[AMPS_IE_OHD] = 4;
- return amps_encode_word(&frame, &access_type_parameters_global_action, -1);
+ return amps_encode_word(&frame, &access_type_parameters_global_action, debug);
}
-uint64_t amps_encode_access_attempt(uint8_t dcc, uint8_t maxbusy_pgr, uint8_t maxsztr_pgr, uint8_t maxbusy_other, uint8_t maxsztr_other, uint8_t end)
+uint64_t amps_encode_access_attempt(uint8_t dcc, uint8_t maxbusy_pgr, uint8_t maxsztr_pgr, uint8_t maxbusy_other, uint8_t maxsztr_other, uint8_t end, int debug)
{
frame_t frame;
@@ -2942,7 +2944,7 @@ uint64_t amps_encode_access_attempt(uint8_t dcc, uint8_t maxbusy_pgr, uint8_t ma
frame.ie[AMPS_IE_MAXSZTR_OTHER] = maxsztr_other;
frame.ie[AMPS_IE_END] = end;
frame.ie[AMPS_IE_OHD] = 4;
- return amps_encode_word(&frame, &access_attempt_parameters_global_action, -1);
+ return amps_encode_word(&frame, &access_attempt_parameters_global_action, debug);
}
static uint64_t amps_encode_word1_abbreviated_address_word(uint8_t dcc, uint32_t min1, int multiple)
@@ -2956,7 +2958,7 @@ static uint64_t amps_encode_word1_abbreviated_address_word(uint8_t dcc, uint32_t
frame.ie[AMPS_IE_T1T2] = 0;
frame.ie[AMPS_IE_DCC] = dcc;
frame.ie[AMPS_IE_MIN1] = min1;
- return amps_encode_word(&frame, &word1_abbreviated_address_word, DEBUG_INFO);
+ return amps_encode_word(&frame, &word1_abbreviated_address_word, 1);
}
static uint64_t amps_encode_word2_extended_address_word_a(uint16_t min2, uint8_t msg_type, uint8_t ordq, uint8_t order)
@@ -2971,7 +2973,7 @@ static uint64_t amps_encode_word2_extended_address_word_a(uint16_t min2, uint8_t
frame.ie[AMPS_IE_LOCAL_MSG_TYPE] = msg_type;
frame.ie[AMPS_IE_ORDQ] = ordq;
frame.ie[AMPS_IE_ORDER] = order;
- return amps_encode_word(&frame, &word2_extended_address_word_a, DEBUG_INFO);
+ return amps_encode_word(&frame, &word2_extended_address_word_a, 1);
}
static uint64_t amps_encode_word2_extended_address_word_b(uint8_t scc, uint16_t min2, uint8_t vmac, uint16_t chan)
@@ -2984,7 +2986,7 @@ static uint64_t amps_encode_word2_extended_address_word_b(uint8_t scc, uint16_t
frame.ie[AMPS_IE_MIN2] = min2;
frame.ie[AMPS_IE_VMAC] = vmac;
frame.ie[AMPS_IE_CHAN] = chan;
- return amps_encode_word(&frame, &word2_extended_address_word_b, DEBUG_INFO);
+ return amps_encode_word(&frame, &word2_extended_address_word_b, 1);
}
static uint64_t amps_encode_mobile_station_control_message_word1_a(uint8_t pscc, uint8_t msg_type, uint8_t ordq, uint8_t order)
@@ -2999,7 +3001,7 @@ static uint64_t amps_encode_mobile_station_control_message_word1_a(uint8_t pscc,
frame.ie[AMPS_IE_LOCAL_MSG_TYPE] = msg_type;
frame.ie[AMPS_IE_ORDQ] = ordq;
frame.ie[AMPS_IE_ORDER] = order;
- return amps_encode_word(&frame, &mobile_station_control_message_word1_a, DEBUG_INFO);
+ return amps_encode_word(&frame, &mobile_station_control_message_word1_a, 1);
}
static uint64_t amps_encode_mobile_station_control_message_word1_b(uint8_t scc, uint8_t pscc, uint8_t dtx, uint8_t pvi, uint8_t mem, uint8_t vmac, uint16_t chan)
@@ -3016,7 +3018,38 @@ static uint64_t amps_encode_mobile_station_control_message_word1_b(uint8_t scc,
frame.ie[AMPS_IE_MEM] = mem;
frame.ie[AMPS_IE_VMAC] = vmac;
frame.ie[AMPS_IE_CHAN] = chan;
- return amps_encode_word(&frame, &mobile_station_control_message_word1_b, DEBUG_INFO);
+ return amps_encode_word(&frame, &mobile_station_control_message_word1_b, 1);
+}
+
+static uint64_t amps_encode_word2_first_alert_with_info_word(uint8_t rl_w, uint8_t signal, uint8_t cpn_rl, uint8_t pi, uint8_t si)
+{
+ frame_t frame;
+
+ memset(&frame, 0, sizeof(frame));
+ frame.ie[AMPS_IE_T1T2] = 1;
+ frame.ie[AMPS_IE_RL_W] = rl_w;
+ frame.ie[AMPS_IE_SIGNAL] = signal;
+ frame.ie[AMPS_IE_CPN_RL] = cpn_rl;
+ frame.ie[AMPS_IE_PI] = pi;
+ frame.ie[AMPS_IE_SI] = si;
+ return amps_encode_word(&frame, &word2_first_alert_with_info_word, 1);
+}
+
+static uint64_t amps_encode_wordn_n_minus_1th_alert_with_info_word(const char *character)
+{
+ frame_t frame;
+
+ memset(&frame, 0, sizeof(frame));
+ frame.ie[AMPS_IE_T1T2] = 1;
+ if (character[0]) {
+ frame.ie[AMPS_IE_CHARACTER_1] = character[0];
+ if (character[1]) {
+ frame.ie[AMPS_IE_CHARACTER_2] = character[1];
+ if (character[2])
+ frame.ie[AMPS_IE_CHARACTER_3] = character[2];
+ }
+ }
+ return amps_encode_word(&frame, &wordn_n_minus_1th_alert_with_info_word, 1);
}
/* decoder function of a word */
@@ -3038,22 +3071,22 @@ static frame_t *amps_decode_word(uint64_t word, struct def_word *w)
for (i = 0; w->ie[i].name; i++)
bits_left += w->ie[i].bits;
- PDEBUG(DFRAME, DEBUG_INFO, "Received: %s\n", w->name);
+ LOGP(DFRAME, LOGL_INFO, "Received: %s\n", w->name);
for (i = 0; w->ie[i].name; i++) {
bits = w->ie[i].bits;
bits_left -= bits;
value = (word >> bits_left) & cut_bits[bits];
frame.ie[w->ie[i].ie] = value;
if (amps_ie_desc[w->ie[i].ie].decoder)
- PDEBUG(DFRAME, DEBUG_DEBUG, " %s%s: %" PRIu64 " = %s (%s)\n", spaces + strlen(w->ie[i].name), w->ie[i].name, value, amps_ie_desc[w->ie[i].ie].decoder(value), amps_ie_desc[w->ie[i].ie].desc);
+ LOGP(DFRAME, LOGL_DEBUG, " %s%s: %" PRIu64 " = %s (%s)\n", spaces + strlen(w->ie[i].name), w->ie[i].name, value, amps_ie_desc[w->ie[i].ie].decoder(value), amps_ie_desc[w->ie[i].ie].desc);
else
- PDEBUG(DFRAME, DEBUG_DEBUG, " %s%s: %" PRIu64 " (%s)\n", spaces + strlen(w->ie[i].name), w->ie[i].name, value, amps_ie_desc[w->ie[i].ie].desc);
+ LOGP(DFRAME, LOGL_DEBUG, " %s%s: %" PRIu64 " (%s)\n", spaces + strlen(w->ie[i].name), w->ie[i].name, value, amps_ie_desc[w->ie[i].ie].desc);
/* show result for 3 IEs of table 4 */
if (w->ie[i].ie == AMPS_IE_LOCAL_MSG_TYPE || w->ie[i].ie == AMPS_IE_ORDQ || w->ie[i].ie == AMPS_IE_ORDER)
t4++;
if (t4 == 3) {
t4 = 0;
- PDEBUG(DFRAME, DEBUG_DEBUG, " %s--> %s\n", spaces, amps_table4_name(frame.ie[AMPS_IE_LOCAL_MSG_TYPE], frame.ie[AMPS_IE_ORDQ], frame.ie[AMPS_IE_ORDER]));
+ LOGP(DFRAME, LOGL_DEBUG, " %s--> %s\n", spaces, amps_table4_name(frame.ie[AMPS_IE_LOCAL_MSG_TYPE], frame.ie[AMPS_IE_ORDQ], frame.ie[AMPS_IE_ORDER]));
}
}
@@ -3071,7 +3104,7 @@ static void amps_decode_word_focc(amps_t *amps, uint64_t word)
/* control message */
if (t1t2 != 3) {
- PDEBUG_CHAN(DFRAME, DEBUG_INFO, "Received Mobile Station Control Message (T1T2 = %d)\n", t1t2);
+ LOGP_CHAN(DFRAME, LOGL_INFO, "Received Mobile Station Control Message (T1T2 = %d)\n", t1t2);
if (t1t2 == 1)
amps->rx_focc_word_count = 1;
if (t1t2 == 0 || t1t2 == 1) {
@@ -3088,7 +3121,7 @@ static void amps_decode_word_focc(amps_t *amps, uint64_t word)
w = &word2_extended_address_word_b;
goto decode;
}
- PDEBUG_CHAN(DFRAME, DEBUG_INFO, "Decoding of more than 2 Control messages not supported\n");
+ LOGP_CHAN(DFRAME, LOGL_INFO, "Decoding of more than 2 Control messages not supported\n");
}
return;
}
@@ -3156,14 +3189,14 @@ static void amps_decode_word_focc(amps_t *amps, uint64_t word)
decode:
if (!w) {
- PDEBUG_CHAN(DFRAME, DEBUG_INFO, "Received Illegal Overhead Message\n");
+ LOGP_CHAN(DFRAME, LOGL_INFO, "Received Illegal Overhead Message\n");
return;
}
frame = amps_decode_word(word, w);
/* show control filler delay */
if (amps->sender.loopback && ohd == 1)
- PDEBUG_CHAN(DDSP, DEBUG_NOTICE, "Round trip delay is %.3f seconds\n", amps->when_received - amps->when_transmitted[frame->ie[AMPS_IE_1111]]);
+ LOGP_CHAN(DDSP, LOGL_NOTICE, "Round trip delay is %.3f seconds\n", amps->when_received - amps->when_transmitted[frame->ie[AMPS_IE_1111]]);
}
/* get word from data bits and call decoder function
@@ -3182,24 +3215,24 @@ static int amps_decode_word_recc(amps_t *amps, uint64_t word, int first)
amps->rx_recc_word_count = 0;
amps->rx_recc_nawc = nawc;
if (f == 0) {
- PDEBUG_CHAN(DFRAME, DEBUG_NOTICE, "Received first word, but F bit is not set.\n");
+ LOGP_CHAN(DFRAME, LOGL_NOTICE, "Received first word, but F bit is not set.\n");
return 0;
}
} else {
if (f == 1) {
- PDEBUG_CHAN(DFRAME, DEBUG_NOTICE, "Received additional word, but F bit is set.\n");
+ LOGP_CHAN(DFRAME, LOGL_NOTICE, "Received additional word, but F bit is set.\n");
return 0;
}
amps->rx_recc_nawc--;
if (amps->rx_recc_nawc != nawc) {
- PDEBUG_CHAN(DFRAME, DEBUG_NOTICE, "Received additional word with NAWC mismatch!\n");
+ LOGP_CHAN(DFRAME, LOGL_NOTICE, "Received additional word with NAWC mismatch!\n");
}
}
msg_count = amps->rx_recc_word_count;
if (msg_count == 8) {
- PDEBUG_CHAN(DFRAME, DEBUG_NOTICE, "Received too many words.\n");
+ LOGP_CHAN(DFRAME, LOGL_NOTICE, "Received too many words.\n");
return 0;
}
@@ -3236,7 +3269,7 @@ static int amps_decode_word_recc(amps_t *amps, uint64_t word, int first)
if (!w) {
- PDEBUG_CHAN(DFRAME, DEBUG_INFO, "Received Illegal RECC Message\n");
+ LOGP_CHAN(DFRAME, LOGL_INFO, "Received Illegal RECC Message\n");
goto done;
}
@@ -3301,7 +3334,7 @@ static int amps_decode_word_recc(amps_t *amps, uint64_t word, int first)
amps->rx_recc_dialing[31] = digit2number[frame->ie[AMPS_IE_DIGIT_32]];
}
- PDEBUG_CHAN(DFRAME, DEBUG_INFO, "expecting %d more word(s) to come\n", amps->rx_recc_nawc);
+ LOGP_CHAN(DFRAME, LOGL_INFO, "expecting %d more word(s) to come\n", amps->rx_recc_nawc);
if (msg_count >= 3 && amps->rx_recc_nawc == 0) {
/* if no digit messages are present, send NULL as dial string (paging reply) */
@@ -3345,7 +3378,7 @@ static void amps_encode_focc_bits(uint64_t word_a, uint64_t word_b, char *bits)
memcpy(bits + 0, dotting, 10);
bits[10] = 'i';
- strcpy(bits + 11, sync_word);
+ memcpy(bits + 11, sync_word, 11);
bits[22] = 'i';
k = 23;
for (i = 0; i < 5; i++) {
@@ -3365,22 +3398,22 @@ static void amps_encode_focc_bits(uint64_t word_a, uint64_t word_b, char *bits)
if (k != 463)
abort();
- bits[463] = '\0';
+ bits[k] = '\0';
- if (debuglevel == DEBUG_DEBUG) {
+#ifdef BIT_DEBUGGING
+ if (loglevel == LOGL_DEBUG) {
char text[64];
strncpy(text, bits, 23);
text[23] = '\0';
-#ifdef BIT_DEBUGGING
- PDEBUG(DFRAME, DEBUG_INFO, "TX FOCC: %s\n", text);
+ LOGP(DFRAME, LOGL_INFO, "TX FOCC: %s\n", text);
for (i = 0; i < 10; i++) {
strncpy(text, bits + 23 + i * 44, 44);
text[44] = '\0';
- PDEBUG(DFRAME, DEBUG_DEBUG, " word %c - %s\n", (i & 1) ? 'b' : 'a', text);
+ LOGP(DFRAME, LOGL_DEBUG, " word %c - %s\n", (i & 1) ? 'b' : 'a', text);
}
-#endif
}
+#endif
}
static void amps_encode_fvc_bits(uint64_t word_a, char *bits)
@@ -3397,19 +3430,19 @@ static void amps_encode_fvc_bits(uint64_t word_a, char *bits)
memcpy(bits + k, dotting, 37);
k += 37;
}
- strcpy(bits + k, sync_word);
+ memcpy(bits + k, sync_word, 11);
k += 11;
for (j = 39; j >= 0; j--)
bits[k++] = ((word_a >> j) & 1) + '0';
}
+
if (k != 1032)
abort();
-
- bits[1032] = '\0';
+ bits[k] = '\0';
#ifdef BIT_DEBUGGING
- if (debuglevel == DEBUG_DEBUG) {
- PDEBUG(DFRAME, DEBUG_INFO, "TX FVC: %s\n", bits);
+ if (loglevel == LOGL_DEBUG) {
+ LOGP(DFRAME, LOGL_INFO, "TX FVC: %s\n", bits);
}
#endif
}
@@ -3417,13 +3450,14 @@ static void amps_encode_fvc_bits(uint64_t word_a, char *bits)
int amps_encode_frame_focc(amps_t *amps, char *bits)
{
uint64_t word;
+ int debug = !amps->tx_focc_debugged;
/* init overhead train */
if (amps->tx_focc_frame_count == 0)
prepare_sysinfo(&amps->si);
/* send overhead train */
if (amps->si.num) {
- word = get_sysinfo(&amps->si);
+ word = get_sysinfo(&amps->si, debug);
if (++amps->tx_focc_frame_count >= amps->si.overhead_repeat)
amps->tx_focc_frame_count = 0;
goto send;
@@ -3474,9 +3508,12 @@ 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);
+ 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, debug);
if (++amps->tx_focc_frame_count >= amps->si.overhead_repeat)
amps->tx_focc_frame_count = 0;
+ if (debug)
+ LOGP_CHAN(DFRAME, LOGL_INFO, "Subsequent system/filler frames are not show, to prevent flooding the output.\n");
+ amps->tx_focc_debugged = 1;
send:
amps_encode_focc_bits(word, word, bits);
@@ -3497,7 +3534,16 @@ int amps_encode_frame_fvc(amps_t *amps, char *bits)
amps->tx_fvc_ordq = trans->ordq;
amps->tx_fvc_order = trans->order;
amps->tx_fvc_chan = trans->chan;
+ strncpy(amps->tx_fvc_callerid, trans->caller_id, sizeof(amps->tx_fvc_callerid) - 1);
+ amps->tx_fvc_callerid_signal = 1;
+ amps->tx_fvc_callerid_screen = 3;
+ if (trans->caller_id[0])
+ amps->tx_fvc_callerid_present = 0;
+ else
+ amps->tx_fvc_callerid_signal = 1;
amps->tx_fvc_send = 1;
+ amps->tx_fvc_word_count = 0;
+ amps->tx_fvc_word_repeat = 0;
}
/* on change of dsp mode */
if (amps->dsp_mode != DSP_MODE_AUDIO_RX_FRAME_TX)
@@ -3506,11 +3552,32 @@ int amps_encode_frame_fvc(amps_t *amps, char *bits)
/* send scheduled mobile control message */
if (amps->tx_fvc_send) {
- amps->tx_fvc_send = 0;
- if (amps->tx_fvc_chan)
- word = amps_encode_mobile_station_control_message_word1_b(amps->sat, amps->sat, (amps->si.word2.dtx) ? 1 : 0, 0, 0, amps->si.vmac, amps->tx_fvc_chan);
- else
- word = amps_encode_mobile_station_control_message_word1_a(amps->sat, amps->tx_fvc_msg_type, amps->tx_fvc_ordq, amps->tx_fvc_order);
+ if (amps->tx_fvc_word_count == 0) {
+ if (amps->tx_fvc_chan)
+ word = amps_encode_mobile_station_control_message_word1_b(amps->sat, amps->sat, (amps->si.word2.dtx) ? 1 : 0, 0, 0, amps->si.vmac, amps->tx_fvc_chan);
+ else
+ word = amps_encode_mobile_station_control_message_word1_a(amps->sat, amps->tx_fvc_msg_type, amps->tx_fvc_ordq, amps->tx_fvc_order);
+ /* done, if we don't have ALERTING with info */
+ if (amps->tx_fvc_order != 17)
+ amps->tx_fvc_send = 0;
+ } else if (amps->tx_fvc_word_count == 1) {
+ int cpn_rl, rl_w;
+ /* number of characters */
+ cpn_rl = strlen(amps->tx_fvc_callerid);
+ /* number of frames that are required to hold number of characters */
+ rl_w = (cpn_rl + 2) / 3;
+ word = amps_encode_word2_first_alert_with_info_word(rl_w, amps->tx_fvc_callerid_signal, cpn_rl, amps->tx_fvc_callerid_present, amps->tx_fvc_callerid_screen);
+ if (cpn_rl == 0)
+ amps->tx_fvc_send = 0;
+ } else {
+ const char *callerid;
+ /* chunk of caller ID */
+ callerid = amps->tx_fvc_callerid + (amps->tx_fvc_word_count - 2) * 3;
+ word = amps_encode_wordn_n_minus_1th_alert_with_info_word(callerid);
+ if (strlen(callerid) <= 3)
+ amps->tx_fvc_send = 0;
+ }
+ amps->tx_fvc_word_count++;
} else
return 1;
@@ -3560,17 +3627,17 @@ static void amps_decode_bits_focc(amps_t *amps, const char *bits)
else
idle = 0;
- PDEBUG_CHAN(DFRAME, DEBUG_INFO, "RX FOCC: B/I = %s\n", (idle) ? "idle" : "busy");
- if (debuglevel == DEBUG_DEBUG) {
+ LOGP_CHAN(DFRAME, LOGL_INFO, "RX FOCC: B/I = %s\n", (idle) ? "idle" : "busy");
+ if (loglevel == LOGL_DEBUG) {
char text[64];
for (i = 0; i < 10; i++) {
strncpy(text, bits + i * 44, 44);
text[44] = '\0';
if ((i & 1) == 0)
- PDEBUG_CHAN(DFRAME, DEBUG_DEBUG, " word a - %s%s\n", text, (crc_a_ok[i >> 1]) ? " ok" : " BAD CRC!");
+ LOGP_CHAN(DFRAME, LOGL_DEBUG, " word a - %s%s\n", text, (crc_a_ok[i >> 1]) ? " ok" : " BAD CRC!");
else
- PDEBUG_CHAN(DFRAME, DEBUG_DEBUG, " word b - %s%s\n", text, (crc_b_ok[i >> 1]) ? " ok" : " BAD CRC!");
+ LOGP_CHAN(DFRAME, LOGL_DEBUG, " word b - %s%s\n", text, (crc_b_ok[i >> 1]) ? " ok" : " BAD CRC!");
}
}
@@ -3646,7 +3713,7 @@ static int amps_decode_bits_recc(amps_t *amps, const char *bits, int first)
crc_ok++;
}
if (crc_ok) {
- PDEBUG_CHAN(DFRAME, DEBUG_NOTICE, "Seems we RX FOCC frame due to loopback, ignoring!\n");
+ LOGP_CHAN(DFRAME, LOGL_NOTICE, "Seems we RX FOCC frame due to loopback, ignoring!\n");
return 0;
}
bits_ -= 221;
@@ -3658,24 +3725,24 @@ static int amps_decode_bits_recc(amps_t *amps, const char *bits, int first)
}
if (first) {
- if (debuglevel == DEBUG_DEBUG || crc_ok_count > 0) {
- PDEBUG_CHAN(DFRAME, DEBUG_INFO, "RX RECC: DCC=%d (%d of 5 CRCs are ok)\n", dcc, crc_ok_count);
+ if (loglevel == LOGL_DEBUG || crc_ok_count > 0) {
+ LOGP_CHAN(DFRAME, LOGL_INFO, "RX RECC: DCC=%d (%d of 5 CRCs are ok)\n", dcc, crc_ok_count);
if (dcc != amps->si.dcc) {
- PDEBUG(DFRAME, DEBUG_INFO, "received DCC=%d mismatches the base station's DCC=%d\n", dcc, amps->si.dcc);
+ LOGP(DFRAME, LOGL_INFO, "received DCC=%d mismatches the base station's DCC=%d\n", dcc, amps->si.dcc);
return 0;
}
}
} else {
- if (debuglevel == DEBUG_DEBUG || crc_ok_count > 0)
- PDEBUG_CHAN(DFRAME, DEBUG_INFO, "RX RECC: (%d of 5 CRCs are ok)\n", crc_ok_count);
+ if (loglevel == LOGL_DEBUG || crc_ok_count > 0)
+ LOGP_CHAN(DFRAME, LOGL_INFO, "RX RECC: (%d of 5 CRCs are ok)\n", crc_ok_count);
}
- if (debuglevel == DEBUG_DEBUG) {
+ if (loglevel == LOGL_DEBUG) {
char text[64];
for (i = 0; i < 5; i++) {
strncpy(text, bits + i * 48, 48);
text[48] = '\0';
- PDEBUG_CHAN(DFRAME, DEBUG_DEBUG, " word - %s%s\n", text, (crc_a_ok[i]) ? " ok" : " BAD CRC!");
+ LOGP_CHAN(DFRAME, LOGL_DEBUG, " word - %s%s\n", text, (crc_a_ok[i]) ? " ok" : " BAD CRC!");
}
}
@@ -3690,7 +3757,7 @@ int amps_decode_frame(amps_t *amps, const char *bits, int count, double level, d
/* not if additional words are received without sync */
if (count != 240) {
- PDEBUG_CHAN(DDSP, DEBUG_INFO, "RX Level: %.0f%% Quality: %.0f%% Polarity: %s\n", level * 100.0, quality * 100.0, (negative) ? "NEGATIVE" : "POSITIVE");
+ LOGP_CHAN(DDSP, LOGL_INFO, "RX Level: %.0f%% Quality: %.0f%% Polarity: %s\n", level * 100.0, quality * 100.0, (negative) ? "NEGATIVE" : "POSITIVE");
}
if (count == 441) {
amps_decode_bits_focc(amps, bits);
@@ -3699,7 +3766,7 @@ int amps_decode_frame(amps_t *amps, const char *bits, int count, double level, d
} else if (count == 240) {
more = amps_decode_bits_recc(amps, bits, 0);
} else {
- PDEBUG_CHAN(DFRAME, DEBUG_ERROR, "Frame with unknown length = %d, please fix!\n", count);
+ LOGP_CHAN(DFRAME, LOGL_ERROR, "Frame with unknown length = %d, please fix!\n", count);
}
return more;