NMT-900: Handle channels >= 1025 correctly
This commit is contained in:
@@ -47,8 +47,8 @@ uint64_t nmt_encode_channel(int nmt_system, int channel, int power)
|
|||||||
value |= power << 9;
|
value |= power << 9;
|
||||||
} else {
|
} else {
|
||||||
/* interleaved channels are indicated in traffic area */
|
/* interleaved channels are indicated in traffic area */
|
||||||
if (value > 1000)
|
if (value >= 1024)
|
||||||
value -= 1000;
|
value -= 1024;
|
||||||
value |= channel;
|
value |= channel;
|
||||||
/* if channel >= 512, set upper bit */
|
/* if channel >= 512, set upper bit */
|
||||||
if (value & 0x200)
|
if (value & 0x200)
|
||||||
@@ -132,7 +132,7 @@ uint64_t nmt_encode_traffic_area(int nmt_system, int channel, uint8_t traffic_ar
|
|||||||
} else {
|
} else {
|
||||||
/* upper bit is used for indication of interleaved channel */
|
/* upper bit is used for indication of interleaved channel */
|
||||||
value = traffic_area & 0x7f;
|
value = traffic_area & 0x7f;
|
||||||
if (channel > 1000)
|
if (channel >= 1024)
|
||||||
value |= 0x80;
|
value |= 0x80;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -487,7 +487,7 @@ static const char *param_ta_900(uint64_t value, int __attribute__((unused)) ndig
|
|||||||
static char result[32];
|
static char result[32];
|
||||||
|
|
||||||
if ((value & 0x80))
|
if ((value & 0x80))
|
||||||
sprintf(result, "%" PRIu64 " (Channel No. + 1000)", value & 0x7f);
|
sprintf(result, "%" PRIu64 " (Channel No. + 1024)", value & 0x7f);
|
||||||
else
|
else
|
||||||
sprintf(result, "%" PRIu64, value);
|
sprintf(result, "%" PRIu64, value);
|
||||||
|
|
||||||
|
@@ -490,10 +490,16 @@ static void nmt_page(transaction_t *trans, int try)
|
|||||||
static int match_channel(nmt_t *nmt, frame_t *frame)
|
static int match_channel(nmt_t *nmt, frame_t *frame)
|
||||||
{
|
{
|
||||||
int channel, power;
|
int channel, power;
|
||||||
|
int rc;
|
||||||
|
|
||||||
/* check channel match */
|
/* check channel match */
|
||||||
nmt_decode_channel(nmt->sysinfo.system, frame->channel_no, &channel, &power);
|
rc = nmt_decode_channel(nmt->sysinfo.system, frame->channel_no, &channel, &power);
|
||||||
if ((channel & 0x3ff) != (nmt->sender.kanal & 0x3ff)) {
|
if (rc < 0) {
|
||||||
|
PDEBUG_CHAN(DNMT, DEBUG_NOTICE, "Frame with illegal encoded channel received, ignoring.\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* in case of interleaved channel, ignore the missing upper bit */
|
||||||
|
if ((channel % 1024) != (nmt->sender.kanal % 1024)) {
|
||||||
PDEBUG_CHAN(DNMT, DEBUG_NOTICE, "Frame for different channel %d received, ignoring.\n", channel);
|
PDEBUG_CHAN(DNMT, DEBUG_NOTICE, "Frame for different channel %d received, ignoring.\n", channel);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user