forked from auto-pts/auto-pts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Service ID `BTP_SERVICE_ID_SDP = 30` for SDP. Add SDP command `SDP_SEARCH_REQ`, `SDP_ATTR_REQ`, and `SDP_SEARCH_ATTR_REQ`. Add SDP event `SDP_EV_SERVICE_RECORD_HANDLE`. Handle BTP SDP command `SDP_SEARCH_REQ` to start service search transaction. Handle the event `SDP_EV_SERVICE_RECORD_HANDLE` to get service record handle. Handle BTP SDP command `SDP_ATTR_REQ` to start service attribution transaction. Handle BTP SDP command `SDP_SEARCH_ATTR_REQ` to start service search transaction. Signed-off-by: Lyle Zhu <[email protected]>
- Loading branch information
1 parent
94f15c0
commit 6c0c09e
Showing
10 changed files
with
775 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,4 +41,5 @@ | |
from .tmap import * | ||
from .ots import * | ||
from .pbp import * | ||
from .sdp import * | ||
# GENERATOR append 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# | ||
# auto-pts - The Bluetooth PTS Automation Framework | ||
# | ||
# Copyright (c) 2017, Intel Corporation. | ||
# Copyright (c) 2024, Codecoup. | ||
# | ||
# This program is free software; you can redistribute it and/or modify it | ||
# under the terms and conditions of the GNU General Public License, | ||
# version 2, as published by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
# more details. | ||
# | ||
import logging | ||
|
||
from autopts.ptsprojects.stack.common import Property, wait_for_event | ||
from autopts.pybtp.types import AdType, IOCap, Addr | ||
|
||
|
||
class SDP: | ||
def __init__(self): | ||
|
||
self.service_record_handles = {} | ||
|
||
def add_service_record_handles(self, addr, handle): | ||
handles = [] | ||
if addr in self.service_record_handles.keys(): | ||
handles.append(self.service_record_handles[addr]) | ||
handles.append(handle) | ||
self.service_record_handles[addr] = handles | ||
|
||
def has_service_record_handle(self, addr=None): | ||
if addr and addr in self.service_record_handles.keys(): | ||
if len(self.service_record_handles[addr]) > 0: | ||
handle = self.service_record_handles[addr][0] | ||
return handle | ||
else: | ||
if len(self.service_record_handles) > 0: | ||
addr = list(self.service_record_handles.keys())[0] | ||
if len(self.service_record_handles[addr]) > 0: | ||
handle = self.service_record_handles[addr][0] | ||
return handle | ||
return 0 | ||
|
||
def get_service_record_handle(self, addr=None): | ||
if addr and addr in self.service_record_handles.keys(): | ||
if len(self.service_record_handles[addr]) > 0: | ||
handle = self.service_record_handles[addr][0] | ||
del self.service_record_handles[addr][0] | ||
return handle | ||
else: | ||
if len(self.service_record_handles) > 0: | ||
addr = list(self.service_record_handles.keys())[0] | ||
if len(self.service_record_handles[addr]) > 0: | ||
handle = self.service_record_handles[addr][0] | ||
del self.service_record_handles[addr][0] | ||
return handle | ||
return 0 | ||
|
||
def sdp_wait_for_service_record_handle(self, timeout=5, addr=None): | ||
handle = self.get_service_record_handle(addr) | ||
if handle != 0: | ||
return handle | ||
|
||
wait_for_event(timeout, lambda: self.has_service_record_handle(addr) > 0) | ||
|
||
return self.get_service_record_handle(addr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.