Updated interface bytes and fixed invalid config not being rejected

This commit is contained in:
jacob.eva 2024-06-10 11:53:55 +01:00
parent ef9f87b559
commit d535d4a320
No known key found for this signature in database
GPG Key ID: 0B92E083BBCCAA1E

View File

@ -107,10 +107,13 @@ class KISS():
PLATFORM_AVR = 0x90 PLATFORM_AVR = 0x90
PLATFORM_ESP32 = 0x80 PLATFORM_ESP32 = 0x80
SX127X = 0x00
SX1276 = 0x01 SX1276 = 0x01
SX1278 = 0x02 SX1278 = 0x02
SX1262 = 0x03 SX126X = 0x10
SX1280 = 0x04 SX1262 = 0x11
SX128X = 0x20
SX1280 = 0x21
def int_data_cmd_to_index(int_data_cmd): def int_data_cmd_to_index(int_data_cmd):
match int_data_cmd: match int_data_cmd:
@ -141,14 +144,12 @@ class KISS():
def interface_type_to_str(interface_type): def interface_type_to_str(interface_type):
match interface_type: match interface_type:
case KISS.SX1262: case KISS.SX126X | KISS.SX1262:
return "SX1262" return "SX126X"
case KISS.SX1276: case KISS.SX127X | KISS.SX1276 | KISS.SX1278:
return "SX1276" return "SX127X"
case KISS.SX1278: case KISS.SX128X | KISS.SX1280:
return "SX1278" return "SX128X"
case KISS.SX1280:
return "SX1280"
@staticmethod @staticmethod
def escape(data): def escape(data):
@ -1011,16 +1012,17 @@ class RNodeSubInterface(Interface):
self.parent_interface.subinterfaces[index] = self self.parent_interface.subinterfaces[index] = self
self.validcfg = True self.validcfg = True
if (self.interface_type == "SX1262" or self.interface_type == "SX1276" or self.interface_type == "SX1278"): if (self.interface_type == "SX126X" or self.interface_type == "SX127X"):
if (self.frequency < RNodeSubInterface.LOW_FREQ_MIN or self.frequency > RNodeSubInterface.LOW_FREQ_MAX): if (self.frequency < RNodeSubInterface.LOW_FREQ_MIN or self.frequency > RNodeSubInterface.LOW_FREQ_MAX):
RNS.log("Invalid frequency configured for "+str(self), RNS.LOG_ERROR) RNS.log("Invalid frequency configured for "+str(self), RNS.LOG_ERROR)
self.validcfg = False self.validcfg = False
elif (self.interface_type == "SX1280"): elif (self.interface_type == "SX128X"):
if (self.frequency < RNodeSubInterface.HIGH_FREQ_MIN or self.frequency > RNodeSubInterface.HIGH_FREQ_MAX): if (self.frequency < RNodeSubInterface.HIGH_FREQ_MIN or self.frequency > RNodeSubInterface.HIGH_FREQ_MAX):
RNS.log("Invalid frequency configured for "+str(self), RNS.LOG_ERROR) RNS.log("Invalid frequency configured for "+str(self), RNS.LOG_ERROR)
self.validcfg = False self.validcfg = False
else: else:
RNS.log("Invalid interface type configured for "+str(self), RNS.LOG_ERROR) RNS.log("Invalid interface type configured for "+str(self), RNS.LOG_ERROR)
self.validcfg = False
if (self.txpower < 0 or self.txpower > 22): if (self.txpower < 0 or self.txpower > 22):
RNS.log("Invalid TX power configured for "+str(self), RNS.LOG_ERROR) RNS.log("Invalid TX power configured for "+str(self), RNS.LOG_ERROR)