реализация команды получения от dbus свойств "WFDIEs - ay - (read)" для пути типа fi.w1.wpa_supplicant1

This commit is contained in:
Ilgiz Kamelyev 2026-04-26 10:11:31 +05:00
parent 1fbcf4d222
commit e04fdfca56
15 changed files with 311 additions and 18 deletions

View File

@ -58,4 +58,6 @@ python -m app.cli --config-file /etc/wf-agent/app.yaml get_wpa_interface_network
python -m app.cli --config-file /etc/wf-agent/app.yaml get_wpa_interface_blobs \
--object-path /fi/w1/wpa_supplicant1/Interfaces/0
python -m app.cli --config-file /etc/wf-agent/app.yaml get_wpa_supplicant_wfdies
```

View File

@ -26,7 +26,7 @@ import common_pb2 as common__pb2
import commands_pb2 as commands__pb2
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x10northbound.proto\x12\x15wfagent.northbound.v1\x1a\x0c\x63ommon.proto\x1a\x0e\x63ommands.proto\"\x9a\x04\n\x0e\x43lientEnvelope\x12\x18\n\x10protocol_version\x18\x01 \x01(\t\x12\x14\n\x0cmessage_kind\x18\x02 \x01(\t\x12\x12\n\nsession_id\x18\x03 \x01(\t\x12\x12\n\nrequest_id\x18\x04 \x01(\t\x12\x16\n\x0e\x63orrelation_id\x18\x05 \x01(\t\x12\x17\n\x0fsent_at_unix_ms\x18\x06 \x01(\x03\x12:\n\x0c\x63lient_hello\x18\n \x01(\x0b\x32\".wfagent.northbound.v1.ClientHelloH\x00\x12G\n\x0f\x63ommand_request\x18\x0b \x01(\x0b\x32,.wfagent.northbound.v1.CommandRequestMessageH\x00\x12\x45\n\x0e\x63ommand_cancel\x18\x0c \x01(\x0b\x32+.wfagent.northbound.v1.CommandCancelMessageH\x00\x12<\n\tsubscribe\x18\r \x01(\x0b\x32\'.wfagent.northbound.v1.SubscribeRequestH\x00\x12@\n\x0bunsubscribe\x18\x0e \x01(\x0b\x32).wfagent.northbound.v1.UnsubscribeRequestH\x00\x12+\n\x04ping\x18\x0f \x01(\x0b\x32\x1b.wfagent.northbound.v1.PingH\x00\x42\x06\n\x04\x62ody\"\x86\x04\n\x0eServerEnvelope\x12\x18\n\x10protocol_version\x18\x01 \x01(\t\x12\x14\n\x0cmessage_kind\x18\x02 \x01(\t\x12\x12\n\nsession_id\x18\x03 \x01(\t\x12\x12\n\nrequest_id\x18\x04 \x01(\t\x12\x16\n\x0e\x63orrelation_id\x18\x05 \x01(\t\x12\x17\n\x0fsent_at_unix_ms\x18\x06 \x01(\x03\x12:\n\x0cserver_hello\x18\n \x01(\x0b\x32\".wfagent.northbound.v1.ServerHelloH\x00\x12I\n\x10\x63ommand_response\x18\x0b \x01(\x0b\x32-.wfagent.northbound.v1.CommandResponseMessageH\x00\x12\x34\n\x05\x65vent\x18\x0c \x01(\x0b\x32#.wfagent.northbound.v1.EventMessageH\x00\x12\x35\n\x05\x65rror\x18\r \x01(\x0b\x32$.wfagent.northbound.v1.ErrorResponseH\x00\x12+\n\x04pong\x18\x0e \x01(\x0b\x32\x1b.wfagent.northbound.v1.PongH\x00\x12\x42\n\rsession_state\x18\x0f \x01(\x0b\x32).wfagent.northbound.v1.SessionStateUpdateH\x00\x42\x06\n\x04\x62ody\":\n\x0b\x43lientHello\x12\x13\n\x0b\x63lient_type\x18\x01 \x01(\t\x12\x16\n\x0e\x63lient_version\x18\x02 \x01(\t\"T\n\x0bServerHello\x12\x13\n\x0bserver_name\x18\x01 \x01(\t\x12\x18\n\x10protocol_version\x18\x02 \x01(\t\x12\x16\n\x0eserver_version\x18\x03 \x01(\t\"\xfc\x01\n\x15\x43ommandRequestMessage\x12\x34\n\x06target\x18\x01 \x01(\x0b\x32$.wfagent.northbound.v1.CommandTarget\x12\x39\n\x07\x63ommand\x18\x02 \x01(\x0b\x32(.wfagent.northbound.v1.CommandDescriptor\x12\x34\n\targuments\x18\x03 \x03(\x0b\x32!.wfagent.proto.v1.CommandArgument\x12<\n\x07options\x18\x04 \x01(\x0b\x32+.wfagent.northbound.v1.CommandClientOptions\"M\n\rCommandTarget\x12\x13\n\x0btarget_type\x18\x01 \x01(\t\x12\x11\n\ttarget_id\x18\x02 \x01(\t\x12\x14\n\x0ctarget_scope\x18\x03 \x01(\t\"?\n\x11\x43ommandDescriptor\x12\x14\n\x0c\x63ommand_kind\x18\x01 \x01(\t\x12\x14\n\x0c\x63ommand_name\x18\x02 \x01(\t\"\x88\x01\n\x14\x43ommandClientOptions\x12\x18\n\x10\x65xpects_response\x18\x01 \x01(\x08\x12\x12\n\ntimeout_ms\x18\x02 \x01(\x03\x12\x15\n\rpriority_hint\x18\x03 \x01(\x05\x12\x16\n\x0e\x61llow_queueing\x18\x04 \x01(\x08\x12\x13\n\x0b\x61llow_retry\x18\x05 \x01(\x08\"A\n\x14\x43ommandCancelMessage\x12\x19\n\x11target_request_id\x18\x01 \x01(\t\x12\x0e\n\x06reason\x18\x02 \x01(\t\"\x8e\x03\n\x16\x43ommandResponseMessage\x12\x0e\n\x06status\x18\x01 \x01(\t\x12\x14\n\x0c\x63ommand_kind\x18\x02 \x01(\t\x12\x13\n\x0btarget_type\x18\x03 \x01(\t\x12\x11\n\ttarget_id\x18\x04 \x01(\t\x12\x1a\n\x12started_at_unix_ms\x18\x05 \x01(\x03\x12\x1b\n\x13\x66inished_at_unix_ms\x18\x06 \x01(\x03\x12\x0e\n\x04text\x18\n \x01(\tH\x00\x12,\n\x02kv\x18\x0b \x01(\x0b\x32\x1e.wfagent.proto.v1.KeyValueListH\x00\x12\x38\n\nstructured\x18\x0c \x01(\x0b\x32\".wfagent.proto.v1.StructuredFieldsH\x00\x12,\n\x05\x65rror\x18\r \x01(\x0b\x32\x1b.wfagent.proto.v1.ErrorInfoH\x00\x12=\n\x10runtime_snapshot\x18\x0e \x01(\x0b\x32!.wfagent.proto.v1.RuntimeSnapshotH\x00\x42\x08\n\x06result\"\xfc\x01\n\x0c\x45ventMessage\x12\x12\n\nevent_type\x18\x01 \x01(\t\x12\x13\n\x0bsource_type\x18\x02 \x01(\t\x12\x11\n\tsource_id\x18\x03 \x01(\t\x12\x10\n\x08severity\x18\x04 \x01(\t\x12\x1b\n\x13observed_at_unix_ms\x18\x05 \x01(\x03\x12\x0e\n\x04text\x18\n \x01(\tH\x00\x12,\n\x02kv\x18\x0b \x01(\x0b\x32\x1e.wfagent.proto.v1.KeyValueListH\x00\x12\x38\n\nstructured\x18\x0c \x01(\x0b\x32\".wfagent.proto.v1.StructuredFieldsH\x00\x42\t\n\x07payload\"\x88\x01\n\x10SubscribeRequest\x12\x17\n\x0fsubscription_id\x18\x01 \x01(\t\x12\x12\n\nevent_type\x18\x02 \x01(\t\x12\x13\n\x0bsource_type\x18\x03 \x01(\t\x12\x11\n\tsource_id\x18\x04 \x01(\t\x12\r\n\x05topic\x18\x05 \x01(\t\x12\x10\n\x08severity\x18\x06 \x01(\t\"-\n\x12UnsubscribeRequest\x12\x17\n\x0fsubscription_id\x18\x01 \x01(\t\"K\n\rErrorResponse\x12\x12\n\nerror_code\x18\x01 \x01(\t\x12\x15\n\rerror_message\x18\x02 \x01(\t\x12\x0f\n\x07\x64\x65tails\x18\x03 \x01(\t\";\n\x12SessionStateUpdate\x12\x15\n\rsession_state\x18\x01 \x01(\t\x12\x0e\n\x06reason\x18\x02 \x01(\t\"\x06\n\x04Ping\"\x06\n\x04Pongb\x06proto3')
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x10northbound.proto\x12\x15wfagent.northbound.v1\x1a\x0c\x63ommon.proto\x1a\x0e\x63ommands.proto\"\x9a\x04\n\x0e\x43lientEnvelope\x12\x18\n\x10protocol_version\x18\x01 \x01(\t\x12\x14\n\x0cmessage_kind\x18\x02 \x01(\t\x12\x12\n\nsession_id\x18\x03 \x01(\t\x12\x12\n\nrequest_id\x18\x04 \x01(\t\x12\x16\n\x0e\x63orrelation_id\x18\x05 \x01(\t\x12\x17\n\x0fsent_at_unix_ms\x18\x06 \x01(\x03\x12:\n\x0c\x63lient_hello\x18\n \x01(\x0b\x32\".wfagent.northbound.v1.ClientHelloH\x00\x12G\n\x0f\x63ommand_request\x18\x0b \x01(\x0b\x32,.wfagent.northbound.v1.CommandRequestMessageH\x00\x12\x45\n\x0e\x63ommand_cancel\x18\x0c \x01(\x0b\x32+.wfagent.northbound.v1.CommandCancelMessageH\x00\x12<\n\tsubscribe\x18\r \x01(\x0b\x32\'.wfagent.northbound.v1.SubscribeRequestH\x00\x12@\n\x0bunsubscribe\x18\x0e \x01(\x0b\x32).wfagent.northbound.v1.UnsubscribeRequestH\x00\x12+\n\x04ping\x18\x0f \x01(\x0b\x32\x1b.wfagent.northbound.v1.PingH\x00\x42\x06\n\x04\x62ody\"\x86\x04\n\x0eServerEnvelope\x12\x18\n\x10protocol_version\x18\x01 \x01(\t\x12\x14\n\x0cmessage_kind\x18\x02 \x01(\t\x12\x12\n\nsession_id\x18\x03 \x01(\t\x12\x12\n\nrequest_id\x18\x04 \x01(\t\x12\x16\n\x0e\x63orrelation_id\x18\x05 \x01(\t\x12\x17\n\x0fsent_at_unix_ms\x18\x06 \x01(\x03\x12:\n\x0cserver_hello\x18\n \x01(\x0b\x32\".wfagent.northbound.v1.ServerHelloH\x00\x12I\n\x10\x63ommand_response\x18\x0b \x01(\x0b\x32-.wfagent.northbound.v1.CommandResponseMessageH\x00\x12\x34\n\x05\x65vent\x18\x0c \x01(\x0b\x32#.wfagent.northbound.v1.EventMessageH\x00\x12\x35\n\x05\x65rror\x18\r \x01(\x0b\x32$.wfagent.northbound.v1.ErrorResponseH\x00\x12+\n\x04pong\x18\x0e \x01(\x0b\x32\x1b.wfagent.northbound.v1.PongH\x00\x12\x42\n\rsession_state\x18\x0f \x01(\x0b\x32).wfagent.northbound.v1.SessionStateUpdateH\x00\x42\x06\n\x04\x62ody\":\n\x0b\x43lientHello\x12\x13\n\x0b\x63lient_type\x18\x01 \x01(\t\x12\x16\n\x0e\x63lient_version\x18\x02 \x01(\t\"T\n\x0bServerHello\x12\x13\n\x0bserver_name\x18\x01 \x01(\t\x12\x18\n\x10protocol_version\x18\x02 \x01(\t\x12\x16\n\x0eserver_version\x18\x03 \x01(\t\"\xfc\x01\n\x15\x43ommandRequestMessage\x12\x34\n\x06target\x18\x01 \x01(\x0b\x32$.wfagent.northbound.v1.CommandTarget\x12\x39\n\x07\x63ommand\x18\x02 \x01(\x0b\x32(.wfagent.northbound.v1.CommandDescriptor\x12\x34\n\targuments\x18\x03 \x03(\x0b\x32!.wfagent.proto.v1.CommandArgument\x12<\n\x07options\x18\x04 \x01(\x0b\x32+.wfagent.northbound.v1.CommandClientOptions\"M\n\rCommandTarget\x12\x13\n\x0btarget_type\x18\x01 \x01(\t\x12\x11\n\ttarget_id\x18\x02 \x01(\t\x12\x14\n\x0ctarget_scope\x18\x03 \x01(\t\"?\n\x11\x43ommandDescriptor\x12\x14\n\x0c\x63ommand_kind\x18\x01 \x01(\t\x12\x14\n\x0c\x63ommand_name\x18\x02 \x01(\t\"\x88\x01\n\x14\x43ommandClientOptions\x12\x18\n\x10\x65xpects_response\x18\x01 \x01(\x08\x12\x12\n\ntimeout_ms\x18\x02 \x01(\x03\x12\x15\n\rpriority_hint\x18\x03 \x01(\x05\x12\x16\n\x0e\x61llow_queueing\x18\x04 \x01(\x08\x12\x13\n\x0b\x61llow_retry\x18\x05 \x01(\x08\"A\n\x14\x43ommandCancelMessage\x12\x19\n\x11target_request_id\x18\x01 \x01(\t\x12\x0e\n\x06reason\x18\x02 \x01(\t\"\xa3\x03\n\x16\x43ommandResponseMessage\x12\x0e\n\x06status\x18\x01 \x01(\t\x12\x14\n\x0c\x63ommand_kind\x18\x02 \x01(\t\x12\x13\n\x0btarget_type\x18\x03 \x01(\t\x12\x11\n\ttarget_id\x18\x04 \x01(\t\x12\x1a\n\x12started_at_unix_ms\x18\x05 \x01(\x03\x12\x1b\n\x13\x66inished_at_unix_ms\x18\x06 \x01(\x03\x12\x13\n\traw_bytes\x18\t \x01(\x0cH\x00\x12\x0e\n\x04text\x18\n \x01(\tH\x00\x12,\n\x02kv\x18\x0b \x01(\x0b\x32\x1e.wfagent.proto.v1.KeyValueListH\x00\x12\x38\n\nstructured\x18\x0c \x01(\x0b\x32\".wfagent.proto.v1.StructuredFieldsH\x00\x12,\n\x05\x65rror\x18\r \x01(\x0b\x32\x1b.wfagent.proto.v1.ErrorInfoH\x00\x12=\n\x10runtime_snapshot\x18\x0e \x01(\x0b\x32!.wfagent.proto.v1.RuntimeSnapshotH\x00\x42\x08\n\x06result\"\xfc\x01\n\x0c\x45ventMessage\x12\x12\n\nevent_type\x18\x01 \x01(\t\x12\x13\n\x0bsource_type\x18\x02 \x01(\t\x12\x11\n\tsource_id\x18\x03 \x01(\t\x12\x10\n\x08severity\x18\x04 \x01(\t\x12\x1b\n\x13observed_at_unix_ms\x18\x05 \x01(\x03\x12\x0e\n\x04text\x18\n \x01(\tH\x00\x12,\n\x02kv\x18\x0b \x01(\x0b\x32\x1e.wfagent.proto.v1.KeyValueListH\x00\x12\x38\n\nstructured\x18\x0c \x01(\x0b\x32\".wfagent.proto.v1.StructuredFieldsH\x00\x42\t\n\x07payload\"\x88\x01\n\x10SubscribeRequest\x12\x17\n\x0fsubscription_id\x18\x01 \x01(\t\x12\x12\n\nevent_type\x18\x02 \x01(\t\x12\x13\n\x0bsource_type\x18\x03 \x01(\t\x12\x11\n\tsource_id\x18\x04 \x01(\t\x12\r\n\x05topic\x18\x05 \x01(\t\x12\x10\n\x08severity\x18\x06 \x01(\t\"-\n\x12UnsubscribeRequest\x12\x17\n\x0fsubscription_id\x18\x01 \x01(\t\"K\n\rErrorResponse\x12\x12\n\nerror_code\x18\x01 \x01(\t\x12\x15\n\rerror_message\x18\x02 \x01(\t\x12\x0f\n\x07\x64\x65tails\x18\x03 \x01(\t\";\n\x12SessionStateUpdate\x12\x15\n\rsession_state\x18\x01 \x01(\t\x12\x0e\n\x06reason\x18\x02 \x01(\t\"\x06\n\x04Ping\"\x06\n\x04Pongb\x06proto3')
_globals = globals()
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
@ -52,19 +52,19 @@ if not _descriptor._USE_C_DESCRIPTORS:
_globals['_COMMANDCANCELMESSAGE']._serialized_start=1819
_globals['_COMMANDCANCELMESSAGE']._serialized_end=1884
_globals['_COMMANDRESPONSEMESSAGE']._serialized_start=1887
_globals['_COMMANDRESPONSEMESSAGE']._serialized_end=2285
_globals['_EVENTMESSAGE']._serialized_start=2288
_globals['_EVENTMESSAGE']._serialized_end=2540
_globals['_SUBSCRIBEREQUEST']._serialized_start=2543
_globals['_SUBSCRIBEREQUEST']._serialized_end=2679
_globals['_UNSUBSCRIBEREQUEST']._serialized_start=2681
_globals['_UNSUBSCRIBEREQUEST']._serialized_end=2726
_globals['_ERRORRESPONSE']._serialized_start=2728
_globals['_ERRORRESPONSE']._serialized_end=2803
_globals['_SESSIONSTATEUPDATE']._serialized_start=2805
_globals['_SESSIONSTATEUPDATE']._serialized_end=2864
_globals['_PING']._serialized_start=2866
_globals['_PING']._serialized_end=2872
_globals['_PONG']._serialized_start=2874
_globals['_PONG']._serialized_end=2880
_globals['_COMMANDRESPONSEMESSAGE']._serialized_end=2306
_globals['_EVENTMESSAGE']._serialized_start=2309
_globals['_EVENTMESSAGE']._serialized_end=2561
_globals['_SUBSCRIBEREQUEST']._serialized_start=2564
_globals['_SUBSCRIBEREQUEST']._serialized_end=2700
_globals['_UNSUBSCRIBEREQUEST']._serialized_start=2702
_globals['_UNSUBSCRIBEREQUEST']._serialized_end=2747
_globals['_ERRORRESPONSE']._serialized_start=2749
_globals['_ERRORRESPONSE']._serialized_end=2824
_globals['_SESSIONSTATEUPDATE']._serialized_start=2826
_globals['_SESSIONSTATEUPDATE']._serialized_end=2885
_globals['_PING']._serialized_start=2887
_globals['_PING']._serialized_end=2893
_globals['_PONG']._serialized_start=2895
_globals['_PONG']._serialized_end=2901
# @@protoc_insertion_point(module_scope)

View File

@ -17,6 +17,7 @@ from app.cli.commands import (
build_wpa_interface_bss_paths_command,
build_wpa_interface_network_paths_command,
build_wpa_interface_blobs_command,
build_wpa_supplicant_wfdies_command,
build_wpa_interface_ifname_command,
build_wpa_interface_capabilities_command,
build_wpa_interface_state_command,
@ -66,6 +67,7 @@ __all__ = [
"build_wpa_interface_bss_paths_command",
"build_wpa_interface_network_paths_command",
"build_wpa_interface_blobs_command",
"build_wpa_supplicant_wfdies_command",
"build_wpa_interface_ifname_command",
"build_wpa_interface_capabilities_command",
"build_wpa_interface_state_command",

View File

@ -18,6 +18,7 @@ from app.cli.commands import (
build_wpa_interface_bss_paths_command,
build_wpa_interface_network_paths_command,
build_wpa_interface_blobs_command,
build_wpa_supplicant_wfdies_command,
build_wpa_interface_ifname_command,
build_wpa_interface_capabilities_command,
build_wpa_interface_state_command,
@ -145,6 +146,9 @@ def run_cli_with_args(config_source: Path, args: argparse.Namespace) -> int:
if getattr(args, "command", None) == "get_wpa_interface_blobs":
command = build_wpa_interface_blobs_command(args)
return run_command_submission_command(config, command)
if getattr(args, "command", None) == "get_wpa_supplicant_wfdies":
command = build_wpa_supplicant_wfdies_command(args)
return run_command_submission_command(config, command)
LOG.info("cli skeleton ready")
return 0

View File

@ -416,6 +416,22 @@ def add_command_submission_command_parsers(
)
_add_transport_arguments(blobs_parser)
wfdies_parser = subparsers.add_parser(
"get_wpa_supplicant_wfdies",
help="Read WFDIEs from the main wpa_supplicant object",
)
wfdies_parser.add_argument(
"--request-id",
default="",
help="Override request identifier",
)
wfdies_parser.add_argument(
"--correlation-id",
default="",
help="Override correlation identifier",
)
_add_transport_arguments(wfdies_parser)
def _add_transport_arguments(parser: argparse.ArgumentParser) -> None:
parser.add_argument(
@ -691,6 +707,50 @@ def _build_wpa_interface_property_command(
)
def _build_wpa_supplicant_property_command(
*,
action: str,
property_name: str,
args: argparse.Namespace,
) -> CliCommandSubmissionCommand:
request_id = str(getattr(args, "request_id", "") or "")
if not request_id:
request_id = f"dbus.get_property:dbus:fi.w1.wpa_supplicant1:{uuid4().hex[:8]}"
correlation_id = str(getattr(args, "correlation_id", "") or "")
if not correlation_id:
correlation_id = request_id
return CliCommandSubmissionCommand(
action=action,
command_kind="dbus.get_property",
target_type="dbus",
target_id="fi.w1.wpa_supplicant1",
command_name=action,
request_id=request_id,
correlation_id=correlation_id,
bridge_uri=str(getattr(args, "bridge_uri", "")),
timeout_sec=float(getattr(args, "timeout_sec", 5.0)),
arguments=(
command_bindings.CommandArgument(
name="service_name",
string_value="fi.w1.wpa_supplicant1",
),
command_bindings.CommandArgument(
name="object_path",
string_value="/fi/w1/wpa_supplicant1",
),
command_bindings.CommandArgument(
name="interface_name",
string_value="fi.w1.wpa_supplicant1",
),
command_bindings.CommandArgument(
name="property_name",
string_value=property_name,
),
),
)
def build_wpa_interface_state_command(
args: argparse.Namespace,
) -> CliCommandSubmissionCommand:
@ -811,6 +871,16 @@ def build_wpa_interface_blobs_command(
)
def build_wpa_supplicant_wfdies_command(
args: argparse.Namespace,
) -> CliCommandSubmissionCommand:
return _build_wpa_supplicant_property_command(
action="get_wpa_supplicant_wfdies",
property_name="WFDIEs",
args=args,
)
async def _run_command_response_loop(
client: CliCommandTransportClient,
*,

View File

@ -243,6 +243,7 @@ class CliNorthboundProtocol:
correlation_id: str = "",
started_at_unix_ms: int = 0,
finished_at_unix_ms: int = 0,
raw_bytes: bytes | None = None,
text: str | None = None,
kv: Any | None = None,
structured: Any | None = None,
@ -258,6 +259,8 @@ class CliNorthboundProtocol:
"started_at_unix_ms": started_at_unix_ms,
"finished_at_unix_ms": finished_at_unix_ms,
}
if raw_bytes is not None:
response_kwargs["raw_bytes"] = raw_bytes
if text is not None:
response_kwargs["text"] = text
if kv is not None:

View File

@ -179,6 +179,9 @@ def _format_command_response(envelope: Any) -> str:
if result_kind == "text":
text = str(getattr(command_response, "text", "") or "")
parts.append(f"text={text}")
elif result_kind == "raw_bytes":
raw_bytes = bytes(getattr(command_response, "raw_bytes", b"") or b"")
parts.append(f"raw_bytes={raw_bytes.hex()}")
elif result_kind == "kv":
kv = getattr(command_response, "kv", None)
if kv is not None:

View File

@ -321,6 +321,7 @@ class CommandBridgeNorthboundCodec:
correlation_id: str = "",
started_at_unix_ms: int = 0,
finished_at_unix_ms: int = 0,
raw_bytes: bytes | None = None,
text: str | None = None,
kv: Any | None = None,
structured: Any | None = None,
@ -336,6 +337,8 @@ class CommandBridgeNorthboundCodec:
"started_at_unix_ms": started_at_unix_ms,
"finished_at_unix_ms": finished_at_unix_ms,
}
if raw_bytes is not None:
response_kwargs["raw_bytes"] = raw_bytes
if text is not None:
response_kwargs["text"] = text
if kv is not None:

View File

@ -92,6 +92,7 @@ message CommandResponseMessage {
int64 finished_at_unix_ms = 6;
oneof result {
bytes raw_bytes = 9;
string text = 10;
wfagent.proto.v1.KeyValueList kv = 11;
wfagent.proto.v1.StructuredFields structured = 12;

View File

@ -1008,6 +1008,115 @@ def test_cli_command_flow_integration_wpa_interface_disconnect_reason(
assert "text=17" in captured.out
def test_cli_command_flow_integration_wpa_supplicant_wfdies(
tmp_path: Path, capsys
) -> None:
root = tmp_path / "app.toml"
_make_root_config(root, bridge_port=18114)
async def handler(websocket: Any) -> None:
hello = _parse_client_envelope(await websocket.recv())
assert hello.message_kind == "CLIENT_HELLO"
await websocket.send(
command_northbound_bindings.ServerEnvelope(
protocol_version="1.0",
message_kind="SERVER_HELLO",
session_id="session-1",
sent_at_unix_ms=1,
server_hello=command_northbound_bindings.ServerHello(
server_name="wf-agent",
protocol_version="1.0",
server_version="0.1.0",
),
).SerializeToString()
)
request = _parse_client_envelope(await websocket.recv())
assert request.message_kind == "COMMAND_REQUEST"
assert request.command_request.command.command_kind == "dbus.get_property"
assert request.command_request.command.command_name == "get_wpa_supplicant_wfdies"
assert request.command_request.target.target_type == "dbus"
assert request.command_request.target.target_id == "fi.w1.wpa_supplicant1"
arguments = request.command_request.arguments
assert [argument.name for argument in arguments] == [
"service_name",
"object_path",
"interface_name",
"property_name",
]
assert arguments[0].string_value == "fi.w1.wpa_supplicant1"
assert arguments[1].string_value == "/fi/w1/wpa_supplicant1"
assert arguments[2].string_value == "fi.w1.wpa_supplicant1"
assert arguments[3].string_value == "WFDIEs"
await websocket.send(
command_northbound_bindings.ServerEnvelope(
protocol_version="1.0",
message_kind="COMMAND_RESPONSE",
session_id="session-1",
request_id=request.request_id,
correlation_id=request.correlation_id,
sent_at_unix_ms=2,
command_response=command_northbound_bindings.CommandResponseMessage(
status="QUEUED",
command_kind="dbus.get_property",
target_type="dbus",
target_id="fi.w1.wpa_supplicant1",
),
).SerializeToString()
)
await websocket.send(
command_northbound_bindings.ServerEnvelope(
protocol_version="1.0",
message_kind="COMMAND_RESPONSE",
session_id="session-1",
request_id=request.request_id,
correlation_id=request.correlation_id,
sent_at_unix_ms=3,
command_response=command_northbound_bindings.CommandResponseMessage(
status="SUCCEEDED",
command_kind="dbus.get_property",
target_type="dbus",
target_id="fi.w1.wpa_supplicant1",
started_at_unix_ms=4,
finished_at_unix_ms=5,
raw_bytes=bytes.fromhex("010203"),
),
).SerializeToString()
)
async def scenario() -> None:
server, port = await _run_server(handler)
try:
root.write_text(
root.read_text(encoding="utf-8").replace(
"bind_port = 18114", f"bind_port = {port}"
),
encoding="utf-8",
)
exit_code = await asyncio.to_thread(
main,
[
"--config-file",
str(root),
"get_wpa_supplicant_wfdies",
"--timeout-sec",
"0.2",
],
)
assert exit_code == 0
finally:
server.close()
await server.wait_closed()
asyncio.run(scenario())
captured = capsys.readouterr()
rendered = captured.out + captured.err
assert "command dbus.get_property" in rendered
assert "state=QUEUED" in rendered
assert "state=SUCCEEDED" in rendered
assert "raw_bytes=010203" in rendered
@pytest.mark.parametrize(
(
"command_name",

View File

@ -19,6 +19,7 @@ from app.cli.commands import (
build_wpa_interface_bss_paths_command,
build_wpa_interface_network_paths_command,
build_wpa_interface_blobs_command,
build_wpa_supplicant_wfdies_command,
build_wpa_interface_ifname_command,
build_wpa_interface_capabilities_command,
build_wpa_interface_state_command,
@ -414,6 +415,31 @@ def test_cli_command_submission_parses_wpa_interface_country_preset() -> None:
assert command.arguments[3].string_value == "Country"
def test_cli_command_submission_parses_wpa_supplicant_wfdies_preset() -> None:
parser = build_parser()
args = parser.parse_args(["get_wpa_supplicant_wfdies"])
command = build_wpa_supplicant_wfdies_command(args)
assert command.action == "get_wpa_supplicant_wfdies"
assert command.command_kind == "dbus.get_property"
assert command.command_name == "get_wpa_supplicant_wfdies"
assert command.target_type == "dbus"
assert command.target_id == "fi.w1.wpa_supplicant1"
assert command.request_id
assert command.correlation_id == command.request_id
assert [argument.name for argument in command.arguments] == [
"service_name",
"object_path",
"interface_name",
"property_name",
]
assert command.arguments[0].string_value == "fi.w1.wpa_supplicant1"
assert command.arguments[1].string_value == "/fi/w1/wpa_supplicant1"
assert command.arguments[2].string_value == "fi.w1.wpa_supplicant1"
assert command.arguments[3].string_value == "WFDIEs"
@pytest.mark.parametrize(
("command_name", "builder", "property_name"),
[

View File

@ -240,6 +240,30 @@ def test_render_server_envelope_command_response_empty_text_is_visible():
assert "text=" in rendered
def test_render_server_envelope_command_response_raw_bytes_is_visible():
envelope = northbound_bindings.ServerEnvelope(
protocol_version="1.0",
message_kind="COMMAND_RESPONSE",
session_id="session-1",
request_id="request-1",
correlation_id="corr-1",
sent_at_unix_ms=125,
command_response=northbound_bindings.CommandResponseMessage(
status="SUCCEEDED",
command_kind="dbus.get_property",
target_type="dbus",
target_id="fi.w1.wpa_supplicant1",
raw_bytes=bytes.fromhex("010203"),
),
)
rendered = render_server_envelope(envelope, output_mode="human")
assert "command dbus.get_property" in rendered
assert "state=SUCCEEDED" in rendered
assert "raw_bytes=010203" in rendered
def test_cli_subscription_command_renders_human_output(tmp_path: Path, capsys) -> None:
root = tmp_path / "app.toml"
_make_root_config(root, bridge_port=18100)

View File

@ -120,7 +120,7 @@ def test_cli_northbound_protocol_builds_command_frames() -> None:
correlation_id="corr-5",
started_at_unix_ms=129,
finished_at_unix_ms=130,
text="done",
raw_bytes=b"\x01\x02\x03",
sent_at_unix_ms=131,
)
error = protocol.build_error_response(
@ -155,7 +155,8 @@ def test_cli_northbound_protocol_builds_command_frames() -> None:
assert parsed_cancel.command_cancel.target_request_id == "request-5"
assert parsed_response.message_kind == "COMMAND_RESPONSE"
assert parsed_response.command_response.status == "SUCCEEDED"
assert parsed_response.command_response.text == "done"
assert parsed_response.command_response.WhichOneof("result") == "raw_bytes"
assert parsed_response.command_response.raw_bytes == b"\x01\x02\x03"
assert parsed_error.message_kind == "ERROR"
assert parsed_error.error.error_code == "VALIDATION_FAILED"
assert parsed_error.error.details == "missing target"

View File

@ -210,6 +210,7 @@ class _FakeInterface:
self.current_auth_mode = "WPA2-PSK"
self.country = "US"
self.DisconnectReason = 17
self.WFDIEs = bytes.fromhex("010203")
self.BSSs = [
"/fi/w1/wpa_supplicant1/BSS/1",
"/fi/w1/wpa_supplicant1/BSS/2",
@ -605,6 +606,22 @@ def test_dbus_command_executor_reads_wpa_interface_country_property_as_empty_tex
assert result.payload.text == ""
def test_dbus_command_executor_reads_wpa_supplicant_wfdies_property() -> None:
executor = DbusCommandExecutor(connection=_FakeConnection())
request = _make_request(
"dbus.get_property",
service_name="fi.w1.wpa_supplicant1",
object_path="/fi/w1/wpa_supplicant1",
interface_name="fi.w1.wpa_supplicant1",
property_name="WFDIEs",
)
result = executor.execute(request, CommandExecutionContext(request=request))
assert result.header.status == "SUCCEEDED"
assert result.payload.raw_bytes == bytes.fromhex("010203")
def test_dbus_command_executor_connects_lazy_connection_before_execute() -> None:
connection = _LazyConnection()
executor = DbusCommandExecutor(connection=connection)

View File

@ -128,3 +128,31 @@ def test_northbound_runtime_snapshot_bindings_round_trip() -> None:
assert parsed.message_kind == "COMMAND_RESPONSE"
assert parsed.command_response.WhichOneof("result") == "runtime_snapshot"
assert parsed.command_response.runtime_snapshot.listeners[0].name == "file-events"
def test_northbound_command_response_raw_bytes_round_trip() -> None:
envelope = northbound_bindings.ServerEnvelope(
protocol_version="1.0",
message_kind="COMMAND_RESPONSE",
session_id="session-1",
request_id="request-1",
correlation_id="corr-1",
sent_at_unix_ms=123,
command_response=northbound_bindings.CommandResponseMessage(
status="SUCCEEDED",
command_kind="dbus.get_property",
target_type="dbus",
target_id="fi.w1.wpa_supplicant1",
started_at_unix_ms=456,
finished_at_unix_ms=789,
raw_bytes=bytes.fromhex("010203"),
),
)
parsed = northbound_bindings.ServerEnvelope.FromString(
envelope.SerializeToString()
)
assert parsed.message_kind == "COMMAND_RESPONSE"
assert parsed.command_response.WhichOneof("result") == "raw_bytes"
assert parsed.command_response.raw_bytes == bytes.fromhex("010203")