Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Proposal] New Packet ABC #430

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

[Proposal] New Packet ABC #430

wants to merge 1 commit into from

Conversation

zxzxwu
Copy link
Collaborator

@zxzxwu zxzxwu commented Feb 22, 2024

typing.Annotated(introduced in 3.9, but backward compatible by using typing_extensions) allows providing metadata to field annotations, so we could build packets with this feature.

Example:

@dataclass
class HCI_LE_Set_CIG_Parameters_Command(HCI_Command, DataUnit):
    '''
    See Bluetooth spec @ 7.8.97 LE Set CIG Parameters Command
    '''

    cig_id: Annotated[int, FieldSpec(1)]
    sdu_interval_c_to_p: Annotated[int, FieldSpec(3)]
    sdu_interval_p_to_c: Annotated[int, FieldSpec(3)]
    worst_case_sca: Annotated[int, FieldSpec(1)]
    packing: Annotated[int, FieldSpec(1)]
    framing: Annotated[int, FieldSpec(1)]
    max_transport_latency_c_to_p: Annotated[int, FieldSpec(2)]
    max_transport_latency_p_to_c: Annotated[int, FieldSpec(2)]

    class CisInfo(DataUnit):
        cis_id: Annotated[int, FieldSpec(1)]
        max_sdu_c_to_p: Annotated[int, FieldSpec(2)]
        max_sdu_p_to_c: Annotated[int, FieldSpec(2)]
        phy_c_to_p: Annotated[int, FieldSpec(1)]
        phy_p_to_c: Annotated[int, FieldSpec(1)]
        rtn_c_to_p: Annotated[int, FieldSpec(1)]
        rtn_p_to_c: Annotated[int, FieldSpec(1)]
    
    cis_info: list[CisInfo]

    class Returned(DataUnit):
        status: Annotated[int, STATUS_SPEC]
        cig_id: Annotated[int, FieldSpec(1)]
        connection_handles: Annotated[list[int], FieldSpec(2)]

@zxzxwu zxzxwu marked this pull request as draft February 22, 2024 07:10
@zxzxwu zxzxwu closed this Feb 27, 2024
@zxzxwu zxzxwu reopened this Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant