Project

General

Profile

Bug #10454 » retevis_h777s_full_band.py

Jim Unroe, 06/21/2023 06:44 PM

 
1
# Copyright August 2018 Klaus Ruebsam <dg5eau@ruebsam.eu>
2
#
3
# This program is free software: you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation, either version 2 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
15

    
16
import time
17
import struct
18
import logging
19

    
20
from chirp import chirp_common, directory, memmap
21
from chirp import bitwise, errors, util
22
from chirp.settings import RadioSetting, RadioSettingGroup, \
23
    RadioSettingValueInteger, RadioSettingValueList, \
24
    RadioSettingValueBoolean, RadioSettings, \
25
    RadioSettingValueString
26

    
27
LOG = logging.getLogger(__name__)
28

    
29
# memory map
30
# 0000 copy of channel 16: 0100 - 010F
31
# 0010 Channel 1
32
# 0020 Channel 2
33
# 0030 Channel 3
34
# 0040 Channel 4
35
# 0050 Channel 5
36
# 0060 Channel 6
37
# 0070 Channel 7
38
# 0080 Channel 8
39
# 0090 Channel 9
40
# 00A0 Channel 10
41
# 00B0 Channel 11
42
# 00C0 Channel 12
43
# 00D0 Channel 13
44
# 00E0 Channel 14
45
# 00F0 Channel 15
46
# 0100 Channel 16
47
# 03C0 various settings
48

    
49
# the last three bytes of every channel are identical
50
# to the first three bytes of the next channel in row.
51
# However it will automatically be filled by the radio itself
52

    
53
MEM_FORMAT = """
54
#seekto 0x0010;
55
struct {
56
  lbcd rx_freq[4];
57
  lbcd tx_freq[4];
58
  lbcd rx_tone[2];
59
  lbcd tx_tone[2];
60
  u8 unknown1:1,
61
    compand:1,
62
    scramb:1,
63
    scanadd:1,
64
    power:1,
65
    mode:1,
66
    unknown2:1,
67
    bclo:1;
68
  u8 reserved[3];
69
} memory[16];
70

    
71
#seekto 0x03C0;
72
struct {
73
  u8 unknown3c08:1,
74
      scanmode:1,
75
      unknown3c06:1,
76
      unknown3c05:1,
77
      voice:2,
78
      save:1,
79
      beep:1;
80
  u8 squelch;
81
  u8 unknown3c2;
82
  u8 timeout;
83
  u8 voxgain;
84
  u8 specialcode;
85
  u8 unknown3c6;
86
  u8 voxdelay;
87
} settings;
88

    
89
"""
90

    
91
CMD_ACK = b"\x06"
92
CMD_ALT_ACK = b"\x53"
93
CMD_STX = b"\x02"
94
CMD_ENQ = b"\x05"
95

    
96
POWER_LEVELS = [chirp_common.PowerLevel("Low",  watts=0.50),
97
                chirp_common.PowerLevel("High", watts=3.00)]
98
TIMEOUT_LIST = ["Off"] + ["%s seconds" % x for x in range(30, 330, 30)]
99
SCANMODE_LIST = ["Carrier", "Timer"]
100
VOICE_LIST = ["Off", "Chinese", "English"]
101
VOX_LIST = ["Off"] + ["%s" % x for x in range(1, 9)]
102
VOXDELAY_LIST = ["0.5", "1.0", "1.5", "2.0", "2.5", "3.0"]
103
MODE_LIST = ["FM", "NFM"]
104

    
105
TONES = chirp_common.TONES
106
DTCS_CODES = chirp_common.DTCS_CODES
107

    
108
SETTING_LISTS = {
109
    "tot": TIMEOUT_LIST,
110
    "scanmode": SCANMODE_LIST,
111
    "voice": VOICE_LIST,
112
    "vox": VOX_LIST,
113
    "voxdelay": VOXDELAY_LIST,
114
    "mode": MODE_LIST,
115
    }
116

    
117
FRS16_FREQS = [462562500, 462587500, 462612500, 462637500,
118
               462662500, 462625000, 462725000, 462687500,
119
               462712500, 462550000, 462575000, 462600000,
120
               462650000, 462675000, 462700000, 462725000]
121

    
122
PMR_FREQS1 = [446006250, 446018750, 446031250, 446043750, 446056250,
123
              446068750, 446081250, 446093750]
124
PMR_FREQS2 = [446106250, 446118750, 446131250, 446143750, 446156250,
125
              446168750, 446181250, 446193750]
126

    
127
PMR_FREQS = PMR_FREQS1 + PMR_FREQS2
128

    
129
VALID_CHARS = chirp_common.CHARSET_ALPHANUMERIC + \
130
    "`{|}!\"#$%&'()*+,-./:;<=>?@[]^_"
131

    
132

    
133
def _r2_enter_programming_mode(radio):
134
    serial = radio.pipe
135

    
136
    magic = b"TYOGRAM"
137
    exito = False
138
    serial.write(CMD_STX)
139
    for i in range(0, 5):
140
        for j in range(0, len(magic)):
141
            serial.write(magic[j:j + 1])
142
        ack = serial.read(1)
143
        if ack == CMD_ACK:
144
            exito = True
145
            break
146

    
147
    # check if we had EXITO
148
    if exito is False:
149
        msg = "The radio did not accept program mode after five tries.\n"
150
        msg += "Check your interface cable and power cycle your radio."
151
        raise errors.RadioError(msg)
152

    
153
    try:
154
        serial.write(CMD_STX)
155
        ident = serial.read(8)
156
    except:
157
        _r2_exit_programming_mode(radio)
158
        raise errors.RadioError("Error communicating with radio")
159

    
160
    # No idea yet what the next 7 bytes stand for
161
    # as long as they start with ACK (or ALT_ACK on some devices) we are fine
162
    if not ident.startswith(CMD_ACK) and not ident.startswith(CMD_ALT_ACK):
163
        _r2_exit_programming_mode(radio)
164
        LOG.debug(util.hexprint(ident))
165
        raise errors.RadioError("Radio returned unknown identification string")
166

    
167
    try:
168
        serial.write(CMD_ACK)
169
        ack = serial.read(1)
170
    except:
171
        _r2_exit_programming_mode(radio)
172
        raise errors.RadioError("Error communicating with radio")
173

    
174
    if ack != CMD_ACK:
175
        _r2_exit_programming_mode(radio)
176
        raise errors.RadioError("Radio refused to enter programming mode")
177

    
178
    # the next 6 bytes represent the 6 digit password
179
    # they are somehow coded where '1' becomes x01 and 'a' becomes x25
180
    try:
181
        serial.write(CMD_ENQ)
182
        ack = serial.read(6)
183
    except:
184
        _r2_exit_programming_mode(radio)
185
        raise errors.RadioError("Error communicating with radio")
186

    
187
    # we will only read if no password is set
188
    if ack != b"\xFF\xFF\xFF\xFF\xFF\xFF":
189
        _r2_exit_programming_mode(radio)
190
        raise errors.RadioError("Radio is password protected")
191
    try:
192
        serial.write(CMD_ACK)
193
        ack = serial.read(6)
194

    
195
    except:
196
        _r2_exit_programming_mode(radio)
197
        raise errors.RadioError("Error communicating with radio 2")
198

    
199
    if ack != CMD_ACK:
200
        _r2_exit_programming_mode(radio)
201
        raise errors.RadioError("Radio refused to enter programming mode 2")
202

    
203

    
204
def _r2_exit_programming_mode(radio):
205
    serial = radio.pipe
206
    try:
207
        serial.write(CMD_ACK)
208
    except:
209
        raise errors.RadioError("Radio refused to exit programming mode")
210

    
211

    
212
def _r2_read_block(radio, block_addr, block_size):
213
    serial = radio.pipe
214

    
215
    cmd = struct.pack(">cHb", b'R', block_addr, block_size)
216
    expectedresponse = b"W" + cmd[1:]
217
    LOG.debug("Reading block %04x..." % (block_addr))
218

    
219
    try:
220
        for j in range(0, len(cmd)):
221
            time.sleep(0.005)
222
            serial.write(cmd[j:j + 1])
223

    
224
        response = serial.read(4 + block_size)
225
        if response[:4] != expectedresponse:
226
            _r2_exit_programming_mode(radio)
227
            raise Exception("Error reading block %04x." % (block_addr))
228

    
229
        block_data = response[4:]
230

    
231
        time.sleep(0.005)
232
        serial.write(CMD_ACK)
233
        ack = serial.read(1)
234
    except:
235
        _r2_exit_programming_mode(radio)
236
        raise errors.RadioError("Failed to read block at %04x" % block_addr)
237

    
238
    if ack != CMD_ACK:
239
        _r2_exit_programming_mode(radio)
240
        raise Exception("No ACK reading block %04x." % (block_addr))
241

    
242
    return block_data
243

    
244

    
245
def _r2_write_block(radio, block_addr, block_size):
246
    serial = radio.pipe
247

    
248
    cmd = struct.pack(">cHb", b'W', block_addr, block_size)
249
    data = radio.get_mmap()[block_addr:block_addr + block_size]
250

    
251
    LOG.debug("Writing block %04x..." % (block_addr))
252
    LOG.debug(util.hexprint(cmd + data))
253

    
254
    try:
255
        for j in range(0, len(cmd)):
256
            serial.write(cmd[j:j + 1])
257
        for j in range(0, len(data)):
258
            serial.write(data[j:j + 1])
259
        if serial.read(1) != CMD_ACK:
260
            raise Exception("No ACK")
261
    except:
262
        _r2_exit_programming_mode(radio)
263
        raise errors.RadioError("Failed to send block "
264
                                "%04x to radio" % block_addr)
265

    
266

    
267
def do_download(radio):
268
    LOG.debug("download")
269
    _r2_enter_programming_mode(radio)
270

    
271
    data = b""
272

    
273
    status = chirp_common.Status()
274
    status.msg = "Cloning from radio"
275

    
276
    status.cur = 0
277
    status.max = radio._memsize
278

    
279
    for addr in range(0, radio._memsize, radio._block_size):
280
        status.cur = addr + radio._block_size
281
        radio.status_fn(status)
282

    
283
        block = _r2_read_block(radio, addr, radio._block_size)
284
        data += block
285

    
286
        LOG.debug("Address: %04x" % addr)
287
        LOG.debug(util.hexprint(block))
288

    
289
    _r2_exit_programming_mode(radio)
290

    
291
    return memmap.MemoryMapBytes(data)
292

    
293

    
294
def do_upload(radio):
295
    status = chirp_common.Status()
296
    status.msg = "Uploading to radio"
297

    
298
    _r2_enter_programming_mode(radio)
299

    
300
    status.cur = 0
301
    status.max = radio._memsize
302

    
303
    for start_addr, end_addr, block_size in radio._ranges:
304
        for addr in range(start_addr, end_addr, block_size):
305
            status.cur = addr + block_size
306
            radio.status_fn(status)
307
            _r2_write_block(radio, addr, block_size)
308

    
309
    _r2_exit_programming_mode(radio)
310

    
311

    
312
@directory.register
313
class RadioddityR2(chirp_common.CloneModeRadio):
314
    """Radioddity R2"""
315
    VENDOR = "Radioddity"
316
    MODEL = "R2"
317
    BAUD_RATE = 9600
318
    NEEDS_COMPAT_SERIAL = False
319

    
320
    # definitions on how to read StartAddr EndAddr BlockZize
321
    _ranges = [
322
               (0x0000, 0x01F8, 0x08),
323
               (0x01F8, 0x03F0, 0x08)
324
              ]
325
    _memsize = 0x03F0
326
    # never read more than 8 bytes at once
327
    _block_size = 0x08
328
    # frequency range is 400-470MHz
329
    _range = [400000000, 470000000]
330
    # maximum 16 channels
331
    _upper = 16
332

    
333
    _frs16 = _pmr = False
334

    
335
    def get_features(self):
336
        rf = chirp_common.RadioFeatures()
337
        rf.has_settings = True
338
        rf.has_bank = False
339
        rf.has_tuning_step = False
340
        rf.has_name = False
341
        rf.has_offset = True
342
        rf.has_mode = True
343
        rf.has_dtcs = True
344
        rf.has_rx_dtcs = True
345
        rf.has_dtcs_polarity = True
346
        rf.has_ctone = True
347
        rf.has_cross = True
348
        rf.can_odd_split = False
349
        # FIXME: Is this right? The get_memory() has no checking for
350
        # deleted memories, but set_memory() used to reference a missing
351
        # variable likely copied from another driver
352
        rf.can_delete = False
353
        rf.valid_modes = MODE_LIST
354
        rf.valid_duplexes = ["", "-", "+", "off"]
355
        rf.valid_tmodes = ["", "Tone", "TSQL", "DTCS", "Cross"]
356
        rf.valid_cross_modes = [
357
            "Tone->DTCS",
358
            "DTCS->Tone",
359
            "->Tone",
360
            "Tone->Tone",
361
            "->DTCS",
362
            "DTCS->",
363
            "DTCS->DTCS"]
364
        rf.valid_power_levels = POWER_LEVELS
365
        rf.valid_skips = ["", "S"]
366
        rf.valid_bands = [self._range]
367
        rf.memory_bounds = (1, self._upper)
368
        rf.valid_tuning_steps = [2.5, 5.0, 6.25, 10.0, 12.5, 25.0]
369
        return rf
370

    
371
    def process_mmap(self):
372
        """Process the mem map into the mem object"""
373
        self._memobj = bitwise.parse(MEM_FORMAT, self._mmap)
374
        # to set the vars on the class to the correct ones
375

    
376
    def sync_in(self):
377
        """Download from radio"""
378
        try:
379
            data = do_download(self)
380
        except errors.RadioError:
381
            # Pass through any real errors we raise
382
            raise
383
        except:
384
            # If anything unexpected happens, make sure we raise
385
            # a RadioError and log the problem
386
            LOG.exception('Unexpected error during download')
387
            raise errors.RadioError('Unexpected error communicating '
388
                                    'with the radio')
389
        self._mmap = data
390
        self.process_mmap()
391

    
392
    def sync_out(self):
393
        """Upload to radio"""
394
        try:
395
            do_upload(self)
396
        except:
397
            # If anything unexpected happens, make sure we raise
398
            # a RadioError and log the problem
399
            LOG.exception('Unexpected error during upload')
400
            raise errors.RadioError('Unexpected error communicating '
401
                                    'with the radio')
402

    
403
    def get_raw_memory(self, number):
404
        return repr(self._memobj.memory[number - 1])
405

    
406
    def decode_tone(self, val):
407
        """Parse the tone data to decode from mem, it returns:
408
        Mode (''|DTCS|Tone), Value (None|###), Polarity (None,N,R)"""
409
        if val.get_raw() == "\xFF\xFF":
410
            return '', None, None
411

    
412
        val = int(val)
413

    
414
        if val >= 12000:
415
            a = val - 12000
416
            return 'DTCS', a, 'R'
417

    
418
        elif val >= 8000:
419
            a = val - 8000
420
            return 'DTCS', a, 'N'
421

    
422
        else:
423
            a = val / 10.0
424
            return 'Tone', a, None
425

    
426
    def encode_tone(self, memval, mode, value, pol):
427
        """Parse the tone data to encode from UI to mem"""
428
        if mode == '':
429
            memval[0].set_raw(0xFF)
430
            memval[1].set_raw(0xFF)
431
        elif mode == 'Tone':
432
            memval.set_value(int(value * 10))
433
        elif mode == 'DTCS':
434
            flag = 0x80 if pol == 'N' else 0xC0
435
            memval.set_value(value)
436
            memval[1].set_bits(flag)
437
        else:
438
            raise Exception("Internal error: invalid mode `%s'" % mode)
439

    
440
    def get_memory(self, number):
441
        bitpos = (1 << ((number - 1) % 8))
442
        bytepos = ((number - 1) / 8)
443
        LOG.debug("bitpos %s" % bitpos)
444
        LOG.debug("bytepos %s" % bytepos)
445

    
446
        _mem = self._memobj.memory[number - 1]
447

    
448
        mem = chirp_common.Memory()
449

    
450
        mem.number = number
451

    
452
        mem.freq = int(_mem.rx_freq) * 10
453

    
454
        # We'll consider any blank (i.e. 0MHz frequency) to be empty
455
        if mem.freq == 0:
456
            mem.empty = True
457
            return mem
458

    
459
        if _mem.rx_freq.get_raw() == "\xFF\xFF\xFF\xFF":
460
            mem.freq = 0
461
            mem.empty = True
462
            return mem
463

    
464
        txfreq = int(_mem.tx_freq) * 10
465
        if txfreq == mem.freq:
466
            mem.duplex = ""
467
        elif txfreq == 0:
468
            mem.duplex = "off"
469
            mem.offset = 0
470
        # 166666665*10 is the equivalent for FF FF FF FF
471
        # stored in the TX field
472
        elif txfreq == 1666666650:
473
            mem.duplex = "off"
474
            mem.offset = 0
475
        elif txfreq < mem.freq:
476
            mem.duplex = "-"
477
            mem.offset = mem.freq - txfreq
478
        elif txfreq > mem.freq:
479
            mem.duplex = "+"
480
            mem.offset = txfreq - mem.freq
481

    
482
        # get bandwidth FM or NFM
483
        mem.mode = MODE_LIST[_mem.mode]
484

    
485
        # tone data
486
        txtone = self.decode_tone(_mem.tx_tone)
487
        rxtone = self.decode_tone(_mem.rx_tone)
488
        chirp_common.split_tone_decode(mem, txtone, rxtone)
489

    
490
        if not _mem.scanadd:
491
            mem.skip = "S"
492

    
493
        mem.power = POWER_LEVELS[_mem.power]
494

    
495
        # add extra channel settings to the OTHER tab of the properties
496
        # extra settings are unfortunately inverted
497
        mem.extra = RadioSettingGroup("extra", "Extra")
498

    
499
        bclo = RadioSetting("bclo", "Busy Lockout",
500
                            RadioSettingValueBoolean(not bool(_mem.bclo)))
501
        bclo.set_doc("Busy Lockout")
502
        mem.extra.append(bclo)
503

    
504
        scramb = RadioSetting("scramb", "Scramble",
505
                              RadioSettingValueBoolean(not bool(_mem.scramb)))
506
        scramb.set_doc("Scramble Audio Signal")
507
        mem.extra.append(scramb)
508

    
509
        compand = RadioSetting("compand", "Compander",
510
                               RadioSettingValueBoolean(
511
                                   not bool(_mem.compand)))
512
        compand.set_doc("Compress Audio for TX")
513
        mem.extra.append(compand)
514

    
515
        immutable = []
516

    
517
        if self._frs16:
518
            if mem.freq in FRS16_FREQS:
519
                if mem.number >= 1 and mem.number <= 16:
520
                    FRS_FREQ = FRS16_FREQS[mem.number - 1]
521
                    mem.freq = FRS_FREQ
522
                mem.duplex == ''
523
                mem.offset = 0
524
                mem.mode = "NFM"
525
                immutable = ["empty", "freq", "duplex", "offset", "mode"]
526
        elif self._pmr:
527
            if mem.freq in PMR_FREQS:
528
                if mem.number >= 1 and mem.number <= 16:
529
                    PMR_FREQ = PMR_FREQS[mem.number - 1]
530
                    mem.freq = PMR_FREQ
531
                mem.duplex = ''
532
                mem.offset = 0
533
                mem.mode = "NFM"
534
                mem.power = POWER_LEVELS[0]
535
                immutable = ["empty", "freq", "duplex", "offset", "mode",
536
                             "power"]
537

    
538
        mem.immutable = immutable
539

    
540
        return mem
541

    
542
    def set_memory(self, mem):
543
        bitpos = (1 << ((mem.number - 1) % 8))
544
        bytepos = ((mem.number - 1) / 8)
545
        LOG.debug("bitpos %s" % bitpos)
546
        LOG.debug("bytepos %s" % bytepos)
547

    
548
        # Get a low-level memory object mapped to the image
549
        _mem = self._memobj.memory[mem.number - 1]
550

    
551
        _rsvd = _mem.reserved.get_raw()
552

    
553
        if mem.empty:
554
            _mem.set_raw("\xFF" * 13 + _rsvd)
555
            return
556

    
557
        _mem.rx_freq = mem.freq / 10
558

    
559
        if mem.duplex == "off":
560
            for i in range(0, 4):
561
                _mem.tx_freq[i].set_raw("\xFF")
562
        elif mem.duplex == "+":
563
            _mem.tx_freq = (mem.freq + mem.offset) / 10
564
        elif mem.duplex == "-":
565
            _mem.tx_freq = (mem.freq - mem.offset) / 10
566
        else:
567
            _mem.tx_freq = mem.freq / 10
568

    
569
        # power, default power is low
570
        if mem.power:
571
            _mem.power = POWER_LEVELS.index(mem.power)
572
        else:
573
            _mem.power = 0     # low
574

    
575
        # tone data
576
        ((txmode, txtone, txpol), (rxmode, rxtone, rxpol)) = \
577
            chirp_common.split_tone_encode(mem)
578
        self.encode_tone(_mem.tx_tone, txmode, txtone, txpol)
579
        self.encode_tone(_mem.rx_tone, rxmode, rxtone, rxpol)
580

    
581
        _mem.scanadd = mem.skip != "S"
582
        _mem.mode = MODE_LIST.index(mem.mode)
583

    
584
        # extra settings are unfortunately inverted
585
        for setting in mem.extra:
586
            LOG.debug("@set_mem:", setting.get_name(), setting.value)
587
            setattr(_mem, setting.get_name(), not setting.value)
588

    
589
    def get_settings(self):
590
        _settings = self._memobj.settings
591
        basic = RadioSettingGroup("basic", "Basic Settings")
592
        top = RadioSettings(basic)
593

    
594
        rs = RadioSetting("settings.squelch", "Squelch Level",
595
                          RadioSettingValueInteger(0, 9, _settings.squelch))
596
        basic.append(rs)
597

    
598
        rs = RadioSetting("settings.timeout", "Timeout Timer",
599
                          RadioSettingValueList(
600
                              TIMEOUT_LIST, TIMEOUT_LIST[_settings.timeout]))
601

    
602
        basic.append(rs)
603

    
604
        rs = RadioSetting("settings.scanmode", "Scan Mode",
605
                          RadioSettingValueList(
606
                              SCANMODE_LIST,
607
                              SCANMODE_LIST[_settings.scanmode]))
608
        basic.append(rs)
609

    
610
        rs = RadioSetting("settings.voice", "Voice Prompts",
611
                          RadioSettingValueList(
612
                              VOICE_LIST, VOICE_LIST[_settings.voice]))
613
        basic.append(rs)
614

    
615
        rs = RadioSetting("settings.voxgain", "VOX Level",
616
                          RadioSettingValueList(
617
                              VOX_LIST, VOX_LIST[_settings.voxgain]))
618
        basic.append(rs)
619

    
620
        rs = RadioSetting("settings.voxdelay", "VOX Delay Time",
621
                          RadioSettingValueList(
622
                              VOXDELAY_LIST,
623
                              VOXDELAY_LIST[_settings.voxdelay]))
624
        basic.append(rs)
625

    
626
        rs = RadioSetting("settings.save", "Battery Save",
627
                          RadioSettingValueBoolean(_settings.save))
628
        basic.append(rs)
629

    
630
        rs = RadioSetting("settings.beep", "Beep Tone",
631
                          RadioSettingValueBoolean(_settings.beep))
632
        basic.append(rs)
633

    
634
        def _filter(name):
635
            filtered = ""
636
            for char in str(name):
637
                if char in VALID_CHARS:
638
                    filtered += char
639
                else:
640
                    filtered += " "
641
            return filtered
642

    
643
        return top
644

    
645
    def set_settings(self, settings):
646
        for element in settings:
647
            if not isinstance(element, RadioSetting):
648
                self.set_settings(element)
649
                continue
650
            else:
651
                try:
652
                    if "." in element.get_name():
653
                        bits = element.get_name().split(".")
654
                        obj = self._memobj
655
                        for bit in bits[:-1]:
656
                            obj = getattr(obj, bit)
657
                        setting = bits[-1]
658
                    else:
659
                        obj = self._memobj.settings
660
                        setting = element.get_name()
661

    
662
                    LOG.debug("Setting %s = %s" % (setting, element.value))
663
                    setattr(obj, setting, element.value)
664
                except Exception as e:
665
                    LOG.debug(element.get_name())
666
                    raise
667

    
668
    @classmethod
669
    def match_model(cls, filedata, filename):
670
        # This radio has always been post-metadata, so never do
671
        # old-school detection
672
        return False
673

    
674

    
675
@directory.register
676
class RetevisRT24(RadioddityR2):
677
    """Retevis RT24"""
678
    VENDOR = "Retevis"
679
    MODEL = "RT24"
680

    
681
    _pmr = True
682

    
683

    
684
@directory.register
685
class RetevisH777S(RadioddityR2):
686
    """Retevis H777S"""
687
    VENDOR = "Retevis"
688
    MODEL = "H777S"
689

    
690
    _frs16 = False  # sold as FRS radio but supports full band TX/RX
(5-5/5)