Remove match and therefore dependency on Python 3.10

This commit is contained in:
jacob.eva 2024-09-03 22:12:25 +01:00
parent 7f2154110c
commit 063ea2bb7a
No known key found for this signature in database
GPG Key ID: 0B92E083BBCCAA1E

View File

@ -116,40 +116,42 @@ class KISS():
SX1280 = 0x21 SX1280 = 0x21
def int_data_cmd_to_index(int_data_cmd): def int_data_cmd_to_index(int_data_cmd):
match int_data_cmd: if int_data_cmd == KISS.CMD_INT0_DATA:
case KISS.CMD_INT0_DATA: return 0
return 0 elif int_data_cmd == KISS.CMD_INT1_DATA:
case KISS.CMD_INT1_DATA: return 1
return 1 elif int_data_cmd == KISS.CMD_INT2_DATA:
case KISS.CMD_INT2_DATA: return 2
return 2 elif int_data_cmd == KISS.CMD_INT3_DATA:
case KISS.CMD_INT3_DATA: return 3
return 3 elif int_data_cmd == KISS.CMD_INT4_DATA:
case KISS.CMD_INT4_DATA: return 4
return 4 elif int_data_cmd == KISS.CMD_INT5_DATA:
case KISS.CMD_INT5_DATA: return 5
return 5 elif int_data_cmd == KISS.CMD_INT6_DATA:
case KISS.CMD_INT6_DATA: return 6
return 6 elif int_data_cmd == KISS.CMD_INT7_DATA:
case KISS.CMD_INT7_DATA: return 7
return 7 elif int_data_cmd == KISS.CMD_INT8_DATA:
case KISS.CMD_INT8_DATA: return 8
return 8 elif int_data_cmd == KISS.CMD_INT9_DATA:
case KISS.CMD_INT9_DATA: return 9
return 9 elif int_data_cmd == KISS.CMD_INT10_DATA:
case KISS.CMD_INT10_DATA: return 10
return 10 elif int_data_cmd == KISS.CMD_INT11_DATA:
case KISS.CMD_INT11_DATA: return 11
return 11 else:
return 0
def interface_type_to_str(interface_type): def interface_type_to_str(interface_type):
match interface_type: if interface_type == KISS.SX126X or interface_type == KISS.SX1262:
case KISS.SX126X | KISS.SX1262:
return "SX126X" return "SX126X"
case KISS.SX127X | KISS.SX1276 | KISS.SX1278: elif interface_type == KISS.SX127X or interface_type == KISS.SX1276 or interface_type == KISS.SX1278:
return "SX127X" return "SX127X"
case KISS.SX128X | KISS.SX1280: elif interface_type == KISS.SX128X or interface_type == KISS.SX1280:
return "SX128X" return "SX128X"
else:
return "SX127X"
@staticmethod @staticmethod
def escape(data): def escape(data):
@ -915,46 +917,45 @@ class RNodeSubInterface(Interface):
super().__init__() super().__init__()
match index: if index == 0:
case 0: sel_cmd = KISS.CMD_SEL_INT0
sel_cmd = KISS.CMD_SEL_INT0 data_cmd= KISS.CMD_INT0_DATA
data_cmd= KISS.CMD_INT0_DATA elif index == 1:
case 1: sel_cmd = KISS.CMD_SEL_INT1
sel_cmd = KISS.CMD_SEL_INT1 data_cmd= KISS.CMD_INT1_DATA
data_cmd= KISS.CMD_INT1_DATA elif index == 2:
case 2: sel_cmd = KISS.CMD_SEL_INT2
sel_cmd = KISS.CMD_SEL_INT2 data_cmd= KISS.CMD_INT2_DATA
data_cmd= KISS.CMD_INT2_DATA elif index == 3:
case 3: sel_cmd = KISS.CMD_SEL_INT3
sel_cmd = KISS.CMD_SEL_INT3 data_cmd= KISS.CMD_INT3_DATA
data_cmd= KISS.CMD_INT3_DATA elif index == 4:
case 4: sel_cmd = KISS.CMD_SEL_INT4
sel_cmd = KISS.CMD_SEL_INT4 data_cmd= KISS.CMD_INT4_DATA
data_cmd= KISS.CMD_INT4_DATA elif index == 5:
case 5: sel_cmd = KISS.CMD_SEL_INT5
sel_cmd = KISS.CMD_SEL_INT5 data_cmd= KISS.CMD_INT5_DATA
data_cmd= KISS.CMD_INT5_DATA elif index == 6:
case 6: sel_cmd = KISS.CMD_SEL_INT6
sel_cmd = KISS.CMD_SEL_INT6 data_cmd= KISS.CMD_INT6_DATA
data_cmd= KISS.CMD_INT6_DATA elif index == 7:
case 7: sel_cmd = KISS.CMD_SEL_INT7
sel_cmd = KISS.CMD_SEL_INT7 data_cmd= KISS.CMD_INT7_DATA
data_cmd= KISS.CMD_INT7_DATA elif index == 8:
case 8: sel_cmd = KISS.CMD_SEL_INT8
sel_cmd = KISS.CMD_SEL_INT8 data_cmd= KISS.CMD_INT8_DATA
data_cmd= KISS.CMD_INT8_DATA elif index == 9:
case 9: sel_cmd = KISS.CMD_SEL_INT9
sel_cmd = KISS.CMD_SEL_INT9 data_cmd= KISS.CMD_INT9_DATA
data_cmd= KISS.CMD_INT9_DATA elif index == 10:
case 10: sel_cmd = KISS.CMD_SEL_INT10
sel_cmd = KISS.CMD_SEL_INT10 data_cmd= KISS.CMD_INT10_DATA
data_cmd= KISS.CMD_INT10_DATA elif index == 11:
case 11: sel_cmd = KISS.CMD_SEL_INT11
sel_cmd = KISS.CMD_SEL_INT11 data_cmd= KISS.CMD_INT11_DATA
data_cmd= KISS.CMD_INT11_DATA else:
case _: sel_cmd = KISS.CMD_SEL_INT0
sel_cmd = KISS.CMD_SEL_INT0 data_cmd= KISS.CMD_INT0_DATA
data_cmd= KISS.CMD_INT0_DATA
self.owner = owner self.owner = owner
self.name = name self.name = name