Skip to content

Commit

Permalink
uvk5: Add a restricted version for unsupported firmwares
Browse files Browse the repository at this point in the history
Since this is such a problem (new firmwares popping up everywhere),
add a fallback version-agnostic implementation of the base class
that is fully read-only (and won't upload). This will mean that
anyone with an unsupported firmware will be able to download the image
for inspection and make it easier for us to determine if we should
just whitelist the version.
  • Loading branch information
kk7ds committed Aug 19, 2024
1 parent 7aba83d commit 906e7a1
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion chirp/drivers/uvk5.py
Original file line number Diff line number Diff line change
Expand Up @@ -2075,11 +2075,45 @@ def detect_from_serial(cls, pipe):
for rclass in cls.detected_models():
if rclass.k5_approve_firmware(firmware):
return rclass
raise errors.RadioError('Firmware %r not supported' % firmware)

return UVK5RestrictedRadio


@directory.register
class RA79Radio(UVK5Radio):
"""Retevis RA79"""
VENDOR = "Retevis"
MODEL = "RA79"


@directory.register
@directory.detected_by(UVK5Radio)
class UVK5RestrictedRadio(UVK5RadioBase):
VARIANT = 'unsupported'

@classmethod
def k5_approve_firmware(cls, firmware):
return False

def process_mmap(self):
firmware = self.metadata.get('uvk5_firmware', '<unknown>')
LOG.warning('Firmware %s is not supported by CHIRP. '
'Image data will be read-only.', firmware)
self._memobj = bitwise.parse(MEM_FORMAT, self._mmap)

def sync_out(self):
raise errors.RadioError(
_('Upload is disabled due to unsupported firmware version'))

def get_memory(self, n):
mem = super().get_memory(n)
mem.immutable = dir(mem)
return mem

def set_memory(self, m):
raise errors.InvalidValueError(
_('Memories are read-only due to unsupported firmware version'))

def set_settings(self, settings):
raise errors.InvalidValueError(
_('Settings are read-only due to unsupported firmware version'))

0 comments on commit 906e7a1

Please sign in to comment.