def ReadLocalOobDataCompleteCapture():
return Capture(
HciMatchers.CommandComplete(hci_packets.OpCode.READ_LOCAL_OOB_DATA),
- lambda packet: HciMatchers.ExtractMatchingCommandComplete(packet.event, hci_packets.OpCode.READ_LOCAL_OOB_DATA)
+ lambda packet: HciMatchers.ExtractMatchingCommandComplete(packet.payload, hci_packets.OpCode.READ_LOCAL_OOB_DATA)
)
@staticmethod
def ReadLocalOobExtendedDataCompleteCapture():
return Capture(
HciMatchers.CommandComplete(hci_packets.OpCode.READ_LOCAL_OOB_EXTENDED_DATA),
- lambda packet: HciMatchers.ExtractMatchingCommandComplete(packet.event, hci_packets.OpCode.READ_LOCAL_OOB_EXTENDED_DATA)
+ lambda packet: HciMatchers.ExtractMatchingCommandComplete(packet.payload, hci_packets.OpCode.READ_LOCAL_OOB_EXTENDED_DATA)
)
@staticmethod
def ReadBdAddrCompleteCapture():
return Capture(
HciMatchers.CommandComplete(hci_packets.OpCode.READ_BD_ADDR),
- lambda packet: hci_packets.ReadBdAddrCompleteView(HciMatchers.ExtractMatchingCommandComplete(packet.event, hci_packets.OpCode.READ_BD_ADDR)))
+ lambda packet: hci_packets.ReadBdAddrCompleteView(HciMatchers.ExtractMatchingCommandComplete(packet.payload, hci_packets.OpCode.READ_BD_ADDR)))
@staticmethod
def ConnectionRequestCapture():
return Capture(
HciMatchers.EventWithCode(hci_packets.EventCode.CONNECTION_REQUEST),
lambda packet: hci_packets.ConnectionRequestView(
- HciMatchers.ExtractEventWithCode(packet.event, hci_packets.EventCode.CONNECTION_REQUEST)))
+ HciMatchers.ExtractEventWithCode(packet.payload, hci_packets.EventCode.CONNECTION_REQUEST)))
@staticmethod
def ConnectionCompleteCapture():
return Capture(
HciMatchers.EventWithCode(hci_packets.EventCode.CONNECTION_COMPLETE),
lambda packet: hci_packets.ConnectionCompleteView(
- HciMatchers.ExtractEventWithCode(packet.event, hci_packets.EventCode.CONNECTION_COMPLETE)))
+ HciMatchers.ExtractEventWithCode(packet.payload, hci_packets.EventCode.CONNECTION_COMPLETE)))
@staticmethod
def DisconnectionCompleteCapture():
return Capture(
HciMatchers.EventWithCode(hci_packets.EventCode.DISCONNECTION_COMPLETE),
lambda packet: hci_packets.DisconnectionCompleteView(
- HciMatchers.ExtractEventWithCode(packet.event, hci_packets.EventCode.DISCONNECTION_COMPLETE)))
+ HciMatchers.ExtractEventWithCode(packet.payload, hci_packets.EventCode.DISCONNECTION_COMPLETE)))
@staticmethod
def LeConnectionCompleteCapture():
return Capture(HciMatchers.LeConnectionComplete(),
- lambda packet: HciMatchers.ExtractLeConnectionComplete(packet.event))
+ lambda packet: HciMatchers.ExtractLeConnectionComplete(packet.payload))
@staticmethod
def SimplePairingCompleteCapture():
return Capture(HciMatchers.EventWithCode(hci_packets.EventCode.SIMPLE_PAIRING_COMPLETE),
lambda packet: hci_packets.SimplePairingCompleteView(
- HciMatchers.ExtractEventWithCode(packet.event, hci_packets.EventCode.SIMPLE_PAIRING_COMPLETE)))
+ HciMatchers.ExtractEventWithCode(packet.payload, hci_packets.EventCode.SIMPLE_PAIRING_COMPLETE)))
class L2capCaptures(object):
@staticmethod
def CommandComplete(opcode=None):
- return lambda msg: HciMatchers._is_matching_command_complete(msg.event, opcode)
+ return lambda msg: HciMatchers._is_matching_command_complete(msg.payload, opcode)
@staticmethod
def ExtractMatchingCommandComplete(packet_bytes, opcode=None):
@staticmethod
def EventWithCode(event_code):
- return lambda msg: HciMatchers._is_matching_event(msg.event, event_code)
+ return lambda msg: HciMatchers._is_matching_event(msg.payload, event_code)
@staticmethod
def ExtractEventWithCode(packet_bytes, event_code):
@staticmethod
def LeEventWithCode(subevent_code):
- return lambda msg: HciMatchers._extract_matching_le_event(msg.event, subevent_code) is not None
+ return lambda msg: HciMatchers._extract_matching_le_event(msg.payload, subevent_code) is not None
@staticmethod
def ExtractLeEventWithCode(packet_bytes, subevent_code):
@staticmethod
def LeConnectionComplete():
- return lambda msg: HciMatchers._extract_le_connection_complete(msg.event) is not None
+ return lambda msg: HciMatchers._extract_le_connection_complete(msg.payload) is not None
@staticmethod
def ExtractLeConnectionComplete(packet_bytes):
self.our_acl_stream = FilteringEventStream(acl_stream, None)
def send(self, pb_flag, b_flag, data):
- acl_msg = hci_facade.AclMsg(
+ acl_msg = hci_facade.AclPacket(
handle=self.handle, packet_boundary_flag=int(pb_flag), broadcast_flag=int(b_flag), data=data)
- self.device.hci.SendAclData(acl_msg)
+ self.device.hci.SendAcl(acl_msg)
def send_first(self, data):
self.send(hci_packets.PacketBoundaryFlag.FIRST_AUTOMATICALLY_FLUSHABLE,
want this if you are testing HCI itself.
"""
self.device = device
- self._setup_event_stream()
- self._setup_le_event_stream()
+ self.event_stream = EventStream(self.device.hci.StreamEvents(empty_proto.Empty()))
+ self.le_event_stream = EventStream(self.device.hci.StreamLeSubevents(empty_proto.Empty()))
if acl_streaming:
self.register_for_events(hci_packets.EventCode.ROLE_CHANGE, hci_packets.EventCode.CONNECTION_REQUEST,
hci_packets.EventCode.CONNECTION_COMPLETE,
hci_packets.EventCode.CONNECTION_PACKET_TYPE_CHANGED)
- self._setup_acl_stream()
-
- def _setup_event_stream(self):
- self.event_stream = EventStream(self.device.hci.FetchEvents(empty_proto.Empty()))
-
- def _setup_le_event_stream(self):
- self.le_event_stream = EventStream(self.device.hci.FetchLeSubevents(empty_proto.Empty()))
-
- def _setup_acl_stream(self):
- self.acl_stream = EventStream(self.device.hci.FetchAclPackets(empty_proto.Empty()))
+ self.acl_stream = EventStream(self.device.hci.StreamAcl(empty_proto.Empty()))
def close(self):
safeClose(self.event_stream)
def register_for_events(self, *event_codes):
for event_code in event_codes:
- msg = hci_facade.EventCodeMsg(code=int(event_code))
- self.device.hci.RegisterEventHandler(msg)
+ self.device.hci.RequestEvent(hci_facade.EventRequest(code=int(event_code)))
def register_for_le_events(self, *event_codes):
for event_code in event_codes:
- msg = hci_facade.EventCodeMsg(code=int(event_code))
- self.device.hci.RegisterLeEventHandler(msg)
+ self.device.hci.RequestLeSubevent(hci_facade.EventRequest(code=int(event_code)))
def send_command_with_complete(self, command):
- cmd_bytes = bytes(command.Serialize())
- cmd = hci_facade.CommandMsg(command=cmd_bytes)
- self.device.hci.EnqueueCommandWithComplete(cmd)
+ self.device.hci.SendCommandWithComplete(hci_facade.Command(payload=bytes(command.Serialize())))
def send_command_with_status(self, command):
- cmd_bytes = bytes(command.Serialize())
- cmd = hci_facade.CommandMsg(command=cmd_bytes)
- self.device.hci.EnqueueCommandWithStatus(cmd)
+ self.device.hci.SendCommandWithStatus(hci_facade.Command(payload=bytes(command.Serialize())))
def enable_inquiry_and_page_scan(self):
self.send_command_with_complete(
service HciHalFacade {
rpc SendCommand(Command) returns (google.protobuf.Empty) {}
- rpc SendAcl(AclPacket) returns (google.protobuf.Empty) {}
- rpc SendSco(ScoPacket) returns (google.protobuf.Empty) {}
- rpc SendIso(IsoPacket) returns (google.protobuf.Empty) {}
-
rpc StreamEvents(google.protobuf.Empty) returns (stream Event) {}
+
+ rpc SendAcl(AclPacket) returns (google.protobuf.Empty) {}
rpc StreamAcl(google.protobuf.Empty) returns (stream AclPacket) {}
+
+ rpc SendSco(ScoPacket) returns (google.protobuf.Empty) {}
rpc StreamSco(google.protobuf.Empty) returns (stream ScoPacket) {}
+
+ rpc SendIso(IsoPacket) returns (google.protobuf.Empty) {}
rpc StreamIso(google.protobuf.Empty) returns (stream IsoPacket) {}
}
self.cert_hal.send_hci_command(command)
def enqueue_acl_data(self, handle, pb_flag, b_flag, acl):
- acl_msg = hci_facade.AclMsg(
+ acl_msg = hci_facade.AclPacket(
handle=int(handle), packet_boundary_flag=int(pb_flag), broadcast_flag=int(b_flag), data=acl)
- self.dut.hci.SendAclData(acl_msg)
+ self.dut.hci.SendAcl(acl_msg)
def send_hal_acl_data(self, handle, pb_flag, b_flag, acl):
lower = handle & 0xff
self.dut_hci.send_command_with_complete(cmd2loop)
looped_bytes = bytes(cmd2loop.Serialize())
- assertThat(self.dut_hci.get_event_stream()).emits(lambda packet: looped_bytes in packet.event)
+ assertThat(self.dut_hci.get_event_stream()).emits(lambda packet: looped_bytes in packet.payload)
def test_inquiry_from_dut(self):
self.dut_hci.register_for_events(hci_packets.EventCode.INQUIRY_RESULT)
self.send_hal_hci_command(
hci_packets.LeSetExtendedAdvertisingEnableBuilder(hci_packets.Enable.ENABLED, [enabled_set]))
- assertThat(self.dut_hci.get_le_event_stream()).emits(lambda packet: b'Im_A_Cert' in packet.event)
+ assertThat(self.dut_hci.get_le_event_stream()).emits(lambda packet: b'Im_A_Cert' in packet.payload)
self.send_hal_hci_command(
hci_packets.LeSetExtendedAdvertisingEnableBuilder(hci_packets.Enable.DISABLED, [enabled_set]))
def setup_test(self):
super().setup_test()
self.dut_le_acl_manager = PyLeAclManager(self.dut)
- self.cert_hci_le_event_stream = EventStream(self.cert.hci.FetchLeSubevents(empty_proto.Empty()))
- self.cert_acl_data_stream = EventStream(self.cert.hci.FetchAclPackets(empty_proto.Empty()))
+ self.cert_hci_le_event_stream = EventStream(self.cert.hci.StreamLeSubevents(empty_proto.Empty()))
+ self.cert_acl_data_stream = EventStream(self.cert.hci.StreamAcl(empty_proto.Empty()))
def teardown_test(self):
safeClose(self.cert_hci_le_event_stream)
self.dut.hci_le_initiator_address.SetPrivacyPolicyForInitiatorAddress(private_policy)
def register_for_event(self, event_code):
- msg = hci_facade.EventCodeMsg(code=int(event_code))
- self.cert.hci.RegisterEventHandler(msg)
+ msg = hci_facade.EventRequest(code=int(event_code))
+ self.cert.hci.RequestEvent(msg)
def register_for_le_event(self, event_code):
- msg = hci_facade.LeSubeventCodeMsg(code=int(event_code))
- self.cert.hci.RegisterLeEventHandler(msg)
+ msg = hci_facade.EventRequest(code=int(event_code))
+ self.cert.hci.RequestLeSubevent(msg)
def enqueue_hci_command(self, command, expect_complete):
cmd_bytes = bytes(command.Serialize())
- cmd = hci_facade.CommandMsg(command=cmd_bytes)
+ cmd = hci_facade.Command(payload=cmd_bytes)
if (expect_complete):
- self.cert.hci.EnqueueCommandWithComplete(cmd)
+ self.cert.hci.SendCommandWithComplete(cmd)
else:
- self.cert.hci.EnqueueCommandWithStatus(cmd)
+ self.cert.hci.SendCommandWithStatus(cmd)
def enqueue_acl_data(self, handle, pb_flag, b_flag, acl):
- acl_msg = hci_facade.AclMsg(
+ acl_msg = hci_facade.AclPacket(
handle=int(handle), packet_boundary_flag=int(pb_flag), broadcast_flag=int(b_flag), data=acl)
- self.cert.hci.SendAclData(acl_msg)
+ self.cert.hci.SendAcl(acl_msg)
def dut_connects(self, check_address):
self.register_for_le_event(hci_packets.SubeventCode.CONNECTION_COMPLETE)
address = hci_packets.Address()
def get_handle(packet):
- packet_bytes = packet.event
+ packet_bytes = packet.payload
nonlocal handle
nonlocal address
if b'\x3e\x13\x01\x00' in packet_bytes:
handle = 0xfff
def get_handle(packet):
- packet_bytes = packet.event
+ packet_bytes = packet.payload
nonlocal handle
if b'\x3e\x13\x01\x00' in packet_bytes:
cc_view = hci_packets.LeConnectionCompleteView(
super().setup_class(dut_module='HCI_INTERFACES', cert_module='HCI')
def register_for_event(self, event_code):
- msg = hci_facade.EventCodeMsg(code=int(event_code))
- self.cert.hci.RegisterEventHandler(msg)
+ msg = hci_facade.EventRequest(code=int(event_code))
+ self.cert.hci.RequestEvent(msg)
def register_for_le_event(self, event_code):
- msg = hci_facade.LeSubeventCodeMsg(code=int(event_code))
- self.cert.hci.RegisterLeEventHandler(msg)
+ msg = hci_facade.EventRequest(code=int(event_code))
+ self.cert.hci.RequestLeSubevent(msg)
def enqueue_hci_command(self, command, expect_complete):
cmd_bytes = bytes(command.Serialize())
- cmd = hci_facade.CommandMsg(command=cmd_bytes)
+ cmd = hci_facade.Command(payload=cmd_bytes)
if (expect_complete):
- self.cert.hci.EnqueueCommandWithComplete(cmd)
+ self.cert.hci.SendCommandWithComplete(cmd)
else:
- self.cert.hci.EnqueueCommandWithStatus(cmd)
+ self.cert.hci.SendCommandWithStatus(cmd)
def test_le_ad_scan_dut_advertises(self):
self.register_for_le_event(hci_packets.SubeventCode.ADVERTISING_REPORT)
self.register_for_le_event(hci_packets.SubeventCode.EXTENDED_ADVERTISING_REPORT)
- with EventStream(self.cert.hci.FetchLeSubevents(empty_proto.Empty())) as hci_le_event_stream:
+ with EventStream(self.cert.hci.StreamLeSubevents(empty_proto.Empty())) as hci_le_event_stream:
# CERT Scans
self.enqueue_hci_command(hci_packets.LeSetRandomAddressBuilder('0C:05:04:03:02:01'), True)
create_response = self.dut.hci_le_advertising_manager.CreateAdvertiser(request)
- hci_le_event_stream.assert_event_occurs(lambda packet: b'Im_The_DUT' in packet.event)
+ hci_le_event_stream.assert_event_occurs(lambda packet: b'Im_The_DUT' in packet.payload)
remove_request = le_advertising_facade.RemoveAdvertiserRequest(advertiser_id=create_response.advertiser_id)
self.dut.hci_le_advertising_manager.RemoveAdvertiser(remove_request)
std::unique_ptr<BasePacketBuilder> builder =
ConnectionCompleteBuilder::Create(ErrorCode::SUCCESS, handle, addr, LinkType::ACL, Enable::DISABLED);
ConnectionEvent success;
- success.set_event(builder_to_string(std::move(builder)));
+ success.set_payload(builder_to_string(std::move(builder)));
per_connection_events_[current_connection_request_]->OnIncomingEvent(success);
current_connection_request_++;
}
std::unique_ptr<BasePacketBuilder> builder =
ConnectionCompleteBuilder::Create(reason, 0, address, LinkType::ACL, Enable::DISABLED);
ConnectionEvent fail;
- fail.set_event(builder_to_string(std::move(builder)));
+ fail.set_payload(builder_to_string(std::move(builder)));
per_connection_events_[current_connection_request_]->OnIncomingEvent(fail);
current_connection_request_++;
}
std::unique_ptr<BasePacketBuilder> builder =
DisconnectionCompleteBuilder::Create(ErrorCode::SUCCESS, handle_, reason);
ConnectionEvent disconnection;
- disconnection.set_event(builder_to_string(std::move(builder)));
+ disconnection.set_payload(builder_to_string(std::move(builder)));
event_stream_->OnIncomingEvent(disconnection);
}
void OnReadRemoteVersionInformationComplete(
}
message ConnectionEvent {
- bytes event = 1;
+ bytes payload = 1;
}
message AclData {
std::vector<uint8_t> bytes_;
};
- ::grpc::Status EnqueueCommandWithComplete(::grpc::ServerContext* context, const ::bluetooth::hci::CommandMsg* command,
- ::google::protobuf::Empty* response) override {
+ ::grpc::Status SendCommandWithComplete(
+ ::grpc::ServerContext* context,
+ const ::bluetooth::hci::Command* command,
+ ::google::protobuf::Empty* response) override {
auto packet = std::make_unique<TestCommandBuilder>(
- std::vector<uint8_t>(command->command().begin(), command->command().end()));
+ std::vector<uint8_t>(command->payload().begin(), command->payload().end()));
hci_layer_->EnqueueCommand(std::move(packet),
facade_handler_->BindOnceOn(this, &HciLayerFacadeService::on_complete));
return ::grpc::Status::OK;
}
- ::grpc::Status EnqueueCommandWithStatus(::grpc::ServerContext* context, const ::bluetooth::hci::CommandMsg* command,
- ::google::protobuf::Empty* response) override {
+ ::grpc::Status SendCommandWithStatus(
+ ::grpc::ServerContext* context,
+ const ::bluetooth::hci::Command* command,
+ ::google::protobuf::Empty* response) override {
auto packet = std::make_unique<TestCommandBuilder>(
- std::vector<uint8_t>(command->command().begin(), command->command().end()));
+ std::vector<uint8_t>(command->payload().begin(), command->payload().end()));
hci_layer_->EnqueueCommand(std::move(packet), facade_handler_->BindOnceOn(this, &HciLayerFacadeService::on_status));
return ::grpc::Status::OK;
}
- ::grpc::Status RegisterEventHandler(::grpc::ServerContext* context, const ::bluetooth::hci::EventCodeMsg* event,
- ::google::protobuf::Empty* response) override {
+ ::grpc::Status RequestEvent(
+ ::grpc::ServerContext* context,
+ const ::bluetooth::hci::EventRequest* event,
+ ::google::protobuf::Empty* response) override {
hci_layer_->RegisterEventHandler(static_cast<EventCode>(event->code()),
facade_handler_->BindOn(this, &HciLayerFacadeService::on_event));
return ::grpc::Status::OK;
}
- ::grpc::Status RegisterLeEventHandler(::grpc::ServerContext* context,
- const ::bluetooth::hci::LeSubeventCodeMsg* event,
- ::google::protobuf::Empty* response) override {
+ ::grpc::Status RequestLeSubevent(
+ ::grpc::ServerContext* context,
+ const ::bluetooth::hci::EventRequest* event,
+ ::google::protobuf::Empty* response) override {
hci_layer_->RegisterLeEventHandler(static_cast<SubeventCode>(event->code()),
facade_handler_->BindOn(this, &HciLayerFacadeService::on_le_subevent));
return ::grpc::Status::OK;
}
- ::grpc::Status FetchEvents(::grpc::ServerContext* context, const ::google::protobuf::Empty* request,
- ::grpc::ServerWriter<EventMsg>* writer) override {
+ ::grpc::Status StreamEvents(
+ ::grpc::ServerContext* context,
+ const ::google::protobuf::Empty* request,
+ ::grpc::ServerWriter<Event>* writer) override {
return pending_events_.RunLoop(context, writer);
};
- ::grpc::Status FetchLeSubevents(::grpc::ServerContext* context, const ::google::protobuf::Empty* request,
- ::grpc::ServerWriter<LeSubeventMsg>* writer) override {
+ ::grpc::Status StreamLeSubevents(
+ ::grpc::ServerContext* context,
+ const ::google::protobuf::Empty* request,
+ ::grpc::ServerWriter<LeSubevent>* writer) override {
return pending_le_events_.RunLoop(context, writer);
};
std::vector<uint8_t> bytes_;
};
- ::grpc::Status SendAclData(::grpc::ServerContext* context, const ::bluetooth::hci::AclMsg* acl,
- ::google::protobuf::Empty* response) override {
+ ::grpc::Status SendAcl(
+ ::grpc::ServerContext* context,
+ const ::bluetooth::hci::AclPacket* acl,
+ ::google::protobuf::Empty* response) override {
waiting_acl_packet_ =
std::make_unique<TestAclBuilder>(acl->handle(), acl->packet_boundary_flag(), acl->broadcast_flag(),
std::vector<uint8_t>(acl->data().begin(), acl->data().end()));
return ::grpc::Status::OK;
}
- ::grpc::Status FetchAclPackets(::grpc::ServerContext* context, const ::google::protobuf::Empty* request,
- ::grpc::ServerWriter<AclMsg>* writer) override {
+ ::grpc::Status StreamAcl(
+ ::grpc::ServerContext* context,
+ const ::google::protobuf::Empty* request,
+ ::grpc::ServerWriter<AclPacket>* writer) override {
hci_layer_->GetAclQueueEnd()->RegisterDequeue(
facade_handler_, common::Bind(&HciLayerFacadeService::on_acl_ready, common::Unretained(this)));
unregister_acl_dequeue_ = true;
ASSERT(acl_ptr != nullptr);
ASSERT(acl_ptr->IsValid());
LOG_INFO("Got an Acl message for handle 0x%hx", acl_ptr->GetHandle());
- AclMsg incoming;
+ AclPacket incoming;
incoming.set_data(std::string(acl_ptr->begin(), acl_ptr->end()));
pending_acl_events_.OnIncomingEvent(std::move(incoming));
}
void on_event(hci::EventPacketView view) {
ASSERT(view.IsValid());
LOG_INFO("Got an Event %s", EventCodeText(view.GetEventCode()).c_str());
- EventMsg response;
- response.set_event(std::string(view.begin(), view.end()));
+ Event response;
+ response.set_payload(std::string(view.begin(), view.end()));
pending_events_.OnIncomingEvent(std::move(response));
}
void on_le_subevent(hci::LeMetaEventView view) {
ASSERT(view.IsValid());
LOG_INFO("Got an LE Event %s", SubeventCodeText(view.GetSubeventCode()).c_str());
- LeSubeventMsg response;
- response.set_event(std::string(view.begin(), view.end()));
+ LeSubevent response;
+ response.set_payload(std::string(view.begin(), view.end()));
pending_le_events_.OnIncomingEvent(std::move(response));
}
void on_complete(hci::CommandCompleteView view) {
ASSERT(view.IsValid());
LOG_INFO("Got a Command complete %s", OpCodeText(view.GetCommandOpCode()).c_str());
- EventMsg response;
- response.set_event(std::string(view.begin(), view.end()));
+ Event response;
+ response.set_payload(std::string(view.begin(), view.end()));
pending_events_.OnIncomingEvent(std::move(response));
}
void on_status(hci::CommandStatusView view) {
ASSERT(view.IsValid());
LOG_INFO("Got a Command status %s", OpCodeText(view.GetCommandOpCode()).c_str());
- EventMsg response;
- response.set_event(std::string(view.begin(), view.end()));
+ Event response;
+ response.set_payload(std::string(view.begin(), view.end()));
pending_events_.OnIncomingEvent(std::move(response));
}
HciLayer* hci_layer_;
Controller* controller_;
::bluetooth::os::Handler* facade_handler_;
- ::bluetooth::grpc::GrpcEventQueue<EventMsg> pending_events_{"FetchHciEvent"};
- ::bluetooth::grpc::GrpcEventQueue<LeSubeventMsg> pending_le_events_{"FetchLeSubevent"};
- ::bluetooth::grpc::GrpcEventQueue<AclMsg> pending_acl_events_{"FetchAclData"};
+ ::bluetooth::grpc::GrpcEventQueue<Event> pending_events_{"StreamEvents"};
+ ::bluetooth::grpc::GrpcEventQueue<LeSubevent> pending_le_events_{"StreamLeSubevents"};
+ ::bluetooth::grpc::GrpcEventQueue<AclPacket> pending_acl_events_{"StreamAcl"};
bool unregister_acl_dequeue_{false};
std::unique_ptr<TestAclBuilder> waiting_acl_packet_;
bool completed_packets_callback_registered_{false};
import "google/protobuf/empty.proto";
service HciLayerFacade {
- rpc EnqueueCommandWithComplete(CommandMsg) returns (google.protobuf.Empty) {}
- rpc EnqueueCommandWithStatus(CommandMsg) returns (google.protobuf.Empty) {}
- rpc RegisterEventHandler(EventCodeMsg) returns (google.protobuf.Empty) {}
- rpc RegisterLeEventHandler(LeSubeventCodeMsg) returns (google.protobuf.Empty) {}
- rpc SendAclData(AclMsg) returns (google.protobuf.Empty) {}
- rpc FetchEvents(google.protobuf.Empty) returns (stream EventMsg) {}
- rpc FetchLeSubevents(google.protobuf.Empty) returns (stream LeSubeventMsg) {}
- rpc FetchAclPackets(google.protobuf.Empty) returns (stream AclMsg) {}
+ rpc SendCommandWithComplete(Command) returns (google.protobuf.Empty) {}
+ rpc SendCommandWithStatus(Command) returns (google.protobuf.Empty) {}
+
+ rpc RequestEvent(EventRequest) returns (google.protobuf.Empty) {}
+ rpc StreamEvents(google.protobuf.Empty) returns (stream Event) {}
+
+ rpc RequestLeSubevent(EventRequest) returns (google.protobuf.Empty) {}
+ rpc StreamLeSubevents(google.protobuf.Empty) returns (stream LeSubevent) {}
+
+ rpc SendAcl(AclPacket) returns (google.protobuf.Empty) {}
+ rpc StreamAcl(google.protobuf.Empty) returns (stream AclPacket) {}
}
-message CommandMsg {
- bytes command = 1;
+message Command {
+ bytes payload = 1;
}
-message EventMsg {
- bytes event = 1;
+message Event {
+ bytes payload = 1;
}
-message LeSubeventMsg {
- bytes event = 1;
+message LeSubevent {
+ bytes payload = 1;
}
-message AclMsg {
+message AclPacket {
uint32 handle = 1;
uint32 packet_boundary_flag = 2;
uint32 broadcast_flag = 3;
bytes data = 4;
}
-message EventCodeMsg {
- uint32 code = 1;
-}
-
-message LeSubeventCodeMsg {
+message EventRequest {
uint32 code = 1;
}
3,
ClockAccuracy::PPM_20);
LeConnectionEvent success;
- success.set_event(builder_to_string(std::move(builder)));
+ success.set_payload(builder_to_string(std::move(builder)));
per_connection_events_[current_connection_request_]->OnIncomingEvent(success);
}
current_connection_request_++;
std::unique_ptr<BasePacketBuilder> builder = LeConnectionCompleteBuilder::Create(
reason, 0, Role::CENTRAL, address.GetAddressType(), address.GetAddress(), 0, 0, 0, ClockAccuracy::PPM_20);
LeConnectionEvent fail;
- fail.set_event(builder_to_string(std::move(builder)));
+ fail.set_payload(builder_to_string(std::move(builder)));
per_connection_events_[current_connection_request_]->OnIncomingEvent(fail);
current_connection_request_++;
}
std::unique_ptr<BasePacketBuilder> builder =
DisconnectionCompleteBuilder::Create(ErrorCode::SUCCESS, handle_, reason);
LeConnectionEvent disconnection;
- disconnection.set_event(builder_to_string(std::move(builder)));
+ disconnection.set_payload(builder_to_string(std::move(builder)));
event_stream_->OnIncomingEvent(disconnection);
}
}
message LeConnectionEvent {
- bytes event = 1;
+ bytes payload = 1;
}
message LeConnectionCommandMsg {
"""
if self.remote_host_supported_features_notification_registered:
return
- msg = hci_facade.EventCodeMsg(code=int(hci_packets.EventCode.REMOTE_HOST_SUPPORTED_FEATURES_NOTIFICATION))
- self.device.hci.RegisterEventHandler(msg)
+ msg = hci_facade.EventRequest(code=int(hci_packets.EventCode.REMOTE_HOST_SUPPORTED_FEATURES_NOTIFICATION))
+ self.device.hci.RequestEvent(msg)
self.remote_host_supported_features_notification_registered = True
def get_remote_name(self, remote_address):
}
impl HciLayerFacade for HciLayerFacadeService {
- fn enqueue_command_with_complete(
+ fn send_command_with_complete(
&mut self,
ctx: RpcContext<'_>,
- mut cmd: CommandMsg,
+ mut cmd: Command,
sink: UnarySink<Empty>,
) {
self.rt.block_on(
self.hci_exports
- .enqueue_command_with_complete(cmd.take_command().into()),
+ .enqueue_command_with_complete(cmd.take_payload().into()),
);
let f = sink
ctx.spawn(f);
}
- fn enqueue_command_with_status(
+ fn send_command_with_status(
&mut self,
ctx: RpcContext<'_>,
- mut cmd: CommandMsg,
+ mut cmd: Command,
sink: UnarySink<Empty>,
) {
self.rt.block_on(
self.hci_exports
- .enqueue_command_with_complete(cmd.take_command().into()),
+ .enqueue_command_with_complete(cmd.take_payload().into()),
);
let f = sink
ctx.spawn(f);
}
- fn register_event_handler(
+ fn request_event(
&mut self,
ctx: RpcContext<'_>,
- code: EventCodeMsg,
+ code: EventRequest,
sink: UnarySink<Empty>,
) {
self.rt.block_on(
ctx.spawn(f);
}
- fn register_le_event_handler(
+ fn request_le_subevent(
&mut self,
_ctx: RpcContext<'_>,
- _code: LeSubeventCodeMsg,
+ _code: EventRequest,
_sink: UnarySink<Empty>,
) {
unimplemented!()
}
- fn send_acl_data(&mut self, _ctx: RpcContext<'_>, _data: AclMsg, _sink: UnarySink<Empty>) {
+ fn send_acl(&mut self, _ctx: RpcContext<'_>, _data: AclPacket, _sink: UnarySink<Empty>) {
unimplemented!()
}
- fn fetch_events(
+ fn stream_events(
&mut self,
_ctx: RpcContext<'_>,
_req: Empty,
- mut resp: ServerStreamingSink<EventMsg>,
+ mut resp: ServerStreamingSink<Event>,
) {
let evt_rx = self.hci_exports.evt_rx.clone();
self.rt.spawn(async move {
while let Some(event) = evt_rx.lock().await.recv().await {
- let mut evt = EventMsg::default();
- evt.set_event(event.to_vec());
+ let mut evt = Event::default();
+ evt.set_payload(event.to_vec());
resp.send((evt, WriteFlags::default())).await.unwrap();
}
});
}
- fn fetch_le_subevents(
+ fn stream_le_subevents(
&mut self,
_ctx: RpcContext<'_>,
_req: Empty,
- mut _resp: ServerStreamingSink<LeSubeventMsg>,
+ mut _resp: ServerStreamingSink<LeSubevent>,
) {
unimplemented!()
}
- fn fetch_acl_packets(
+ fn stream_acl(
&mut self,
_ctx: RpcContext<'_>,
_req: Empty,
- mut _resp: ServerStreamingSink<AclMsg>,
+ mut _resp: ServerStreamingSink<AclPacket>,
) {
unimplemented!()
}