Provide IntFlag.name property fallback

This commit is contained in:
Josh Wu
2023-11-26 19:26:42 +08:00
parent a9628f73e3
commit a65a215fd7

View File

@@ -3829,9 +3829,11 @@ class HCI_LE_Set_Advertising_Set_Random_Address_Command(HCI_Command):
'advertising_event_properties', 'advertising_event_properties',
{ {
'size': 2, 'size': 2,
'mapper': lambda x: HCI_LE_Set_Extended_Advertising_Parameters_Command.AdvertisingProperties( 'mapper': lambda x: str(
x HCI_LE_Set_Extended_Advertising_Parameters_Command.AdvertisingProperties(
).name, x
)
),
}, },
), ),
('primary_advertising_interval_min', 3), ('primary_advertising_interval_min', 3),
@@ -3840,9 +3842,9 @@ class HCI_LE_Set_Advertising_Set_Random_Address_Command(HCI_Command):
'primary_advertising_channel_map', 'primary_advertising_channel_map',
{ {
'size': 1, 'size': 1,
'mapper': lambda x: HCI_LE_Set_Extended_Advertising_Parameters_Command.ChannelMap( 'mapper': lambda x: str(
x HCI_LE_Set_Extended_Advertising_Parameters_Command.ChannelMap(x)
).name, ),
}, },
), ),
('own_address_type', OwnAddressType.TYPE_SPEC), ('own_address_type', OwnAddressType.TYPE_SPEC),
@@ -3872,11 +3874,25 @@ class HCI_LE_Set_Extended_Advertising_Parameters_Command(HCI_Command):
ANONYMOUS_ADVERTISING = 1 << 5 ANONYMOUS_ADVERTISING = 1 << 5
INCLUDE_TX_POWER = 1 << 6 INCLUDE_TX_POWER = 1 << 6
def __str__(self) -> str:
return '|'.join(
flag.name
for flag in HCI_LE_Set_Extended_Advertising_Parameters_Command.AdvertisingProperties
if self.value & flag.value and flag.name is not None
)
class ChannelMap(enum.IntFlag): class ChannelMap(enum.IntFlag):
CHANNEL_37 = 1 << 0 CHANNEL_37 = 1 << 0
CHANNEL_38 = 1 << 1 CHANNEL_38 = 1 << 1
CHANNEL_39 = 1 << 2 CHANNEL_39 = 1 << 2
def __str__(self) -> str:
return '|'.join(
flag.name
for flag in HCI_LE_Set_Extended_Advertising_Parameters_Command.ChannelMap
if self.value & flag.value and flag.name is not None
)
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
@HCI_Command.command( @HCI_Command.command(