Add tlmConfirm to tlm_dl ota packet-structure (#2991)
[ExpressLRS.git] / src / python / firmware.py
blob4aad42f7fd58bc0faabeeeea5123ffc05660c4ee
1 #!/usr/bin/python
3 from enum import Enum
4 from typing import NamedTuple
6 class MCUType(Enum):
7 ESP32 = 0
8 ESP8266 = 1
10 class DeviceType(Enum):
11 TX = 0
12 RX = 1
13 TX_Backpack = 2
14 VRx_Backpack = 3
16 class RadioType(Enum):
17 SX127X = 0
18 SX1280 = 1
19 LR1121 = 2
21 class FirmwareOptions(NamedTuple):
22 mcuType: MCUType
23 deviceType: DeviceType
24 radioChip: RadioType
25 luaName: str
26 bootloader: str
27 offset: int
28 firmware: str
31 class TXType(Enum):
32 internal = 'internal'
33 external = 'external'
35 def __str__(self):
36 return self.value
39 def find_patch_location(mm):
40 return mm.find(b'\xBE\xEF\xBA\xBE\xCA\xFE\xF0\x0D')
42 def get_hardware(mm):
43 pos = mm.find(b'\xBE\xEF\xBA\xBE\xCA\xFE\xF0\x0D')
44 if pos != -1:
45 pos += 8 + 2 # Skip magic & version
47 return pos