NMT-900: Handle channels >= 1025 correctly
This commit is contained in:
parent
3218d1a8e0
commit
f7476bce41
|
@ -47,8 +47,8 @@ uint64_t nmt_encode_channel(int nmt_system, int channel, int power)
|
|||
value |= power << 9;
|
||||
} else {
|
||||
/* interleaved channels are indicated in traffic area */
|
||||
if (value > 1000)
|
||||
value -= 1000;
|
||||
if (value >= 1024)
|
||||
value -= 1024;
|
||||
value |= channel;
|
||||
/* if channel >= 512, set upper bit */
|
||||
if (value & 0x200)
|
||||
|
@ -132,7 +132,7 @@ uint64_t nmt_encode_traffic_area(int nmt_system, int channel, uint8_t traffic_ar
|
|||
} else {
|
||||
/* upper bit is used for indication of interleaved channel */
|
||||
value = traffic_area & 0x7f;
|
||||
if (channel > 1000)
|
||||
if (channel >= 1024)
|
||||
value |= 0x80;
|
||||
}
|
||||
|
||||
|
@ -487,7 +487,7 @@ static const char *param_ta_900(uint64_t value, int __attribute__((unused)) ndig
|
|||
static char result[32];
|
||||
|
||||
if ((value & 0x80))
|
||||
sprintf(result, "%" PRIu64 " (Channel No. + 1000)", value & 0x7f);
|
||||
sprintf(result, "%" PRIu64 " (Channel No. + 1024)", value & 0x7f);
|
||||
else
|
||||
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)
|
||||
{
|
||||
int channel, power;
|
||||
int rc;
|
||||
|
||||
/* check channel match */
|
||||
nmt_decode_channel(nmt->sysinfo.system, frame->channel_no, &channel, &power);
|
||||
if ((channel & 0x3ff) != (nmt->sender.kanal & 0x3ff)) {
|
||||
rc = nmt_decode_channel(nmt->sysinfo.system, frame->channel_no, &channel, &power);
|
||||
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);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue