Coverage for tests/tests_rf/virtual_rf/const.py: 0%

1#!/usr/bin/env python3

2"""A virtual RF network useful for testing."""

3

4 from enum import StrEnum

5 from typing import TypedDict

6

7

8 class _ComPortsT(TypedDict):

9 manufacturer: str

10 product: str

11 vid: int

12 pid: int

13

14 description: str

15 serial_number: str | None

16 interface: str | None

17

18 device: str

19 name: str

20

21

22# NOTE: Below values are from real devices (with some contrived values)

23

24 COMPORTS_ATMEGA32U4: _ComPortsT = { # 8/16 MHz atmega32u4 (HW Uart)

25 "manufacturer": "SparkFun",

26 "product": "evofw3 atmega32u4",

27 "vid": 0x1B4F, # aka SparkFun Electronics

28 "pid": 0x9206,

29 #

30 "description": "evofw3 atmega32u4",

31 "serial_number": None,

32 "interface": None,

33 #

34 "device": "/dev/ttyACM0", # is not a fixed value

35 "name": "ttyACM0", # not fixed

36}

37

38 COMPORTS_ATMEGA328P: _ComPortsT = { # 16MHZ atmega328 (SW Uart)

39 "manufacturer": "FTDI",

40 "product": "FT232R USB UART",

41 "vid": 0x0403, # aka Future Technology Devices International Ltd.

42 "pid": 0x6001,

43 #

44 "description": "FT232R USB UART - FT232R USB UART",

45 "serial_number": "A50285BI",

46 "interface": "FT232R USB UART",

47 #

48 "device": "/dev/ttyUSB0", # is not a fixed value

49 "name": "ttyUSB0", # not fixed

50}

51

52 COMPORTS_TI4310: _ComPortsT = { # Honeywell HGI80 (partially contrived)

53 "manufacturer": "Texas Instruments",

54 "product": "TUSB3410 Boot Device",

55 "vid": 0x10AC, # aka Honeywell, Inc.

56 "pid": 0x0102,

57 #

58 "description": "TUSB3410 Boot Device", # contrived

59 "serial_number": "TUSB3410",

60 "interface": None, # assumed

61 #

62 "device": "/dev/ttyUSB0", # is not a fixed value

63 "name": "ttyUSB0", # not fixed

64}

65

66

67 class HgiFwTypes(StrEnum):

68 EVOFW3 = " ".join(COMPORTS_ATMEGA32U4[k] for k in ("manufacturer", "product")) # type: ignore[literal-required]

69 HGI_80 = " ".join(COMPORTS_TI4310[k] for k in ("manufacturer", "product")) # type: ignore[literal-required]

70

71

72 SCHEMA_1 = {

73 "orphans_hvac": ["41:111111"],

74 "known_list": {

75 "18:111111": {"class": "HGI", "fw_version": "EVOFW3"},

76 "41:111111": {"class": "REM"},

77 },

78}

79

80 SCHEMA_2 = {

81 "orphans_hvac": ["42:222222"],

82 "known_list": {

83 "18:222222": {"class": "HGI", "fw_version": "HGI_80"},

84 "42:222222": {"class": "FAN"},

85 },

86}

87

88 SCHEMA_3 = {

89 "orphans_hvac": ["42:333333"],

90 "known_list": {"18:333333": {"class": "HGI"}, "42:333333": {"class": "FAN"}},

91}