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
case KISS.CMD_INT1_DATA: elif int_data_cmd == KISS.CMD_INT1_DATA:
return 1 return 1
case KISS.CMD_INT2_DATA: elif int_data_cmd == KISS.CMD_INT2_DATA:
return 2 return 2
case KISS.CMD_INT3_DATA: elif int_data_cmd == KISS.CMD_INT3_DATA:
return 3 return 3
case KISS.CMD_INT4_DATA: elif int_data_cmd == KISS.CMD_INT4_DATA:
return 4 return 4
case KISS.CMD_INT5_DATA: elif int_data_cmd == KISS.CMD_INT5_DATA:
return 5 return 5
case KISS.CMD_INT6_DATA: elif int_data_cmd == KISS.CMD_INT6_DATA:
return 6 return 6
case KISS.CMD_INT7_DATA: elif int_data_cmd == KISS.CMD_INT7_DATA:
return 7 return 7
case KISS.CMD_INT8_DATA: elif int_data_cmd == KISS.CMD_INT8_DATA:
return 8 return 8
case KISS.CMD_INT9_DATA: elif int_data_cmd == KISS.CMD_INT9_DATA:
return 9 return 9
case KISS.CMD_INT10_DATA: elif int_data_cmd == KISS.CMD_INT10_DATA:
return 10 return 10
case KISS.CMD_INT11_DATA: elif int_data_cmd == 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,44 +917,43 @@ 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
case 1: elif index == 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
case 2: elif index == 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
case 3: elif index == 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
case 4: elif index == 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
case 5: elif index == 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
case 6: elif index == 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
case 7: elif index == 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
case 8: elif index == 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
case 9: elif index == 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
case 10: elif index == 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
case 11: elif index == 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
case _: else:
sel_cmd = KISS.CMD_SEL_INT0 sel_cmd = KISS.CMD_SEL_INT0
data_cmd= KISS.CMD_INT0_DATA data_cmd= KISS.CMD_INT0_DATA