QBluetoothServiceInfo Class
QBluetoothServiceInfo 클래스를 사용하면 블루투스 서비스의 속성에 접근할 수 있습니다. 더 보기...
| 헤더: | #include <QBluetoothServiceInfo> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Bluetooth) target_link_libraries(mytarget PRIVATE Qt6::Bluetooth) |
| qmake: | QT += bluetooth |
공개 유형
| class | Alternative |
| class | Sequence |
| enum | AttributeId { ServiceRecordHandle, ServiceClassIds, ServiceRecordState, ServiceId, ProtocolDescriptorList, …, ServiceProvider } |
| enum | Protocol { UnknownProtocol, L2capProtocol, RfcommProtocol } |
공개 함수
| QBluetoothServiceInfo() | |
| QBluetoothServiceInfo(const QBluetoothServiceInfo &other) | |
| ~QBluetoothServiceInfo() | |
| QVariant | attribute(quint16 attributeId) const |
| QList<quint16> | attributes() const |
| bool | contains(quint16 attributeId) const |
| QBluetoothDeviceInfo | device() const |
| bool | isComplete() const |
| bool | isRegistered() const |
| bool | isValid() const |
| QBluetoothServiceInfo::Sequence | protocolDescriptor(QBluetoothUuid::ProtocolUuid protocol) const |
| int | protocolServiceMultiplexer() const |
| bool | registerService(const QBluetoothAddress &localAdapter = QBluetoothAddress()) |
| void | removeAttribute(quint16 attributeId) |
| int | serverChannel() const |
| quint8 | serviceAvailability() const |
| QList<QBluetoothUuid> | serviceClassUuids() const |
| QString | serviceDescription() const |
| QString | serviceName() const |
| QString | serviceProvider() const |
| QBluetoothUuid | serviceUuid() const |
| void | setAttribute(quint16 attributeId, const QBluetoothServiceInfo::Alternative &value) |
| void | setAttribute(quint16 attributeId, const QBluetoothServiceInfo::Sequence &value) |
| void | setAttribute(quint16 attributeId, const QBluetoothUuid &value) |
| void | setAttribute(quint16 attributeId, const QVariant &value) |
| void | setDevice(const QBluetoothDeviceInfo &device) |
| void | setServiceAvailability(quint8 availability) |
| void | setServiceDescription(const QString &description) |
| void | setServiceName(const QString &name) |
| void | setServiceProvider(const QString &provider) |
| void | setServiceUuid(const QBluetoothUuid &uuid) |
| QBluetoothServiceInfo::Protocol | socketProtocol() const |
| bool | unregisterService() |
| QBluetoothServiceInfo & | operator=(const QBluetoothServiceInfo &other) |
상세 설명
QBluetoothServiceInfo는 블루투스 장치가 제공하는 서비스에 대한 정보를 제공합니다. 또한 이 클래스를 사용하여 로컬 장치에 새로운 서비스를 등록할 수 있습니다. 이러한 등록은 블루투스 SDP 항목에만 영향을 미친다는 점에 유의하십시오. registerService()를 호출하기 전에, 들어오는 연결을 수신 대기하는 모든 서버(예: RFCOMM 서버)가 먼저 시작되어 있어야 합니다. 등록 해제는 이와 반대 순서로 수행되어야 합니다.
QBluetoothServiceInfo는 전통적인 의미의 값 형이 아닙니다. 동일한 서비스 정보 객체의 모든 복사본은 변경 시 분리되지 않으므로 동일한 데이터를 공유합니다. 이를 통해 두 개의 복사본이 동일한 블루투스 서비스를 (해)등록할 수 있습니다.
iOS에서는 플랫폼이 QBluetoothServiceInfo 관련 기능에 대한 액세스를 허용할 수 있는 API를 노출하지 않기 때문에 이 클래스를 사용할 수 없습니다.
멤버 유형 문서
enum QBluetoothServiceInfo::AttributeId
블루투스 서비스 속성. 이러한 속성에 대한 자세한 설명은 블루투스 핵심 사양(Bluetooth Core Specification)을 참조하십시오.
| 상수 | 값 | 설명 |
|---|---|---|
QBluetoothServiceInfo::ServiceRecordHandle | 0x0000 | 속성을 검색할 수 있는 서비스 레코드를 지정합니다. |
QBluetoothServiceInfo::ServiceClassIds | 0x0001 | 서비스가 준수하는 서비스 클래스의 UUID입니다. 가장 일반적인 서비스 클래스는 (QBluetoothUuid::ServiceClassUuid)에 정의되어 있습니다. |
QBluetoothServiceInfo::ServiceRecordState | 0x0002 | 다른 서비스 속성이 추가, 삭제 또는 수정될 때 변경되는 속성입니다. |
QBluetoothServiceInfo::ServiceId | 0x0003 | 서비스를 고유하게 식별하는 UUID입니다. |
QBluetoothServiceInfo::ProtocolDescriptorList | 0x0004 | 서비스에서 사용하는 프로토콜 목록입니다. 가장 일반적인 프로토콜 UUID는 다음에서 정의되어 있습니다. QBluetoothUuid::ProtocolUuid |
QBluetoothServiceInfo::BrowseGroupList | 0x0005 | 서비스가 속한 탐색 그룹 목록입니다. |
QBluetoothServiceInfo::LanguageBaseAttributeIdList | 0x0006 | 사람이 읽을 수 있는 속성을 지원하기 위한 언어 기반 속성 ID 목록입니다. |
QBluetoothServiceInfo::ServiceInfoTimeToLive | 0x0007 | 서비스 레코드가 유효하고 변경되지 않은 상태로 유지될 것으로 예상되는 시간(초). |
QBluetoothServiceInfo::ServiceAvailability | 0x0008 | 서비스의 가용성을 나타내는 값. |
QBluetoothServiceInfo::BluetoothProfileDescriptorList | 0x0009 | 서비스가 준수하는 프로필 목록. |
QBluetoothServiceInfo::DocumentationUrl | 0x000A | 서비스에 대한 문서를 가리키는 URL. |
QBluetoothServiceInfo::ClientExecutableUrl | 0x000B | 서비스를 이용하는 데 사용할 수 있는 애플리케이션의 위치를 가리키는 URL. |
QBluetoothServiceInfo::IconUrl | 0x000C | 서비스를 나타내는 아이콘의 위치로 연결되는 URL. |
QBluetoothServiceInfo::AdditionalProtocolDescriptorList | 0x000D | 서비스에서 사용하는 추가 프로토콜. 이 속성은 ProtocolDescriptorList 를 확장합니다. |
QBluetoothServiceInfo::PrimaryLanguageBase | 0x0100 | 기본 언어 텍스트 설명자의 기본 인덱스. |
QBluetoothServiceInfo::ServiceName | PrimaryLanguageBase + 0x0000 | 주 언어의 블루투스 서비스 이름. |
QBluetoothServiceInfo::ServiceDescription | PrimaryLanguageBase + 0x0001 | 주 언어의 블루투스 서비스에 대한 설명. |
QBluetoothServiceInfo::ServiceProvider | PrimaryLanguageBase + 0x0002 | 블루투스 서비스의 기본 언어를 제공하는 회사/단체의 이름. 참고: Windows에서는 서비스가 생성될 때 ServiceClassIds 및 ProtocolDescriptorList가 자동으로 기본값으로 설정됩니다. 이 플랫폼에서 이러한 속성의 값을 수동으로 설정하면 작동하지 않을 뿐만 아니라 예상치 못한 결과를 초래할 수 있습니다. |
enum QBluetoothServiceInfo::Protocol
이 열거형은 서비스에서 사용하는 소켓 프로토콜을 나타냅니다.
| 상수 | 값 | 설명 |
|---|---|---|
QBluetoothServiceInfo::UnknownProtocol | 0 | 서비스는 알 수 없는 소켓 프로토콜을 사용합니다. |
QBluetoothServiceInfo::L2capProtocol | 1 | 서비스가 L2CAP 소켓 프로토콜을 사용합니다. 이 프로토콜은 Android에서 직접 소켓 연결에 지원되지 않습니다. |
QBluetoothServiceInfo::RfcommProtocol | 2 | 서비스가 RFCOMM 소켓 프로토콜을 사용합니다. |
멤버 함수 설명서
QBluetoothServiceInfo::QBluetoothServiceInfo()
새로운 유효하지 않은 QBluetoothServiceInfo 객체를 생성합니다.
QBluetoothServiceInfo::QBluetoothServiceInfo(const QBluetoothServiceInfo &other)
other 의 복사본인 새로운 QBluetoothServiceInfo를 생성합니다.
이 두 복사본은 쓰기 작업 시에도 분리되지 않는 동일한 기본 데이터를 계속 공유합니다.
[noexcept] QBluetoothServiceInfo::~QBluetoothServiceInfo()
QBluetoothServiceInfo 객체를 삭제합니다.
QVariant QBluetoothServiceInfo::attribute(quint16 attributeId) const
attributeId 속성의 값을 반환합니다.
setAttribute()도 참조하십시오 .
QList<quint16> QBluetoothServiceInfo::attributes() const
QBluetoothServiceInfo 객체가 가진 모든 속성 ID의 목록을 반환합니다.
bool QBluetoothServiceInfo::contains(quint16 attributeId) const
QBluetoothServiceInfo 객체에 attributeId 속성이 포함되어 있으면 true를 반환하고, 그렇지 않으면 false를 반환합니다.
QBluetoothDeviceInfo QBluetoothServiceInfo::device() const
이 서비스를 제공하는 블루투스 장치의 주소를 반환합니다.
setDevice()도 참조하십시오 .
bool QBluetoothServiceInfo::isComplete() const
QBluetoothServiceInfo 객체가 완전한 것으로 간주되면 true를 반환하고, 그렇지 않으면 false를 반환합니다.
완전한 QBluetoothServiceInfo 객체에는 ProtocolDescriptorList 속성이 포함되어 있습니다.
bool QBluetoothServiceInfo::isRegistered() const
서비스 정보가 플랫폼의 SDP(서비스 검색 프로토콜) 구현에 등록되어 있으면 true를 반환하고, 그렇지 않으면 false를 반환합니다.
bool QBluetoothServiceInfo::isValid() const
QBluetoothServiceInfo 객체가 유효한 경우 true를 반환하고, 그렇지 않으면 false를 반환합니다.
유효하지 않은 ` QBluetoothServiceInfo ` 객체에는 속성이 없습니다.
QBluetoothServiceInfo::Sequence QBluetoothServiceInfo::protocolDescriptor(QBluetoothUuid::ProtocolUuid protocol) const
protocol 프로토콜에 대한 프로토콜 매개변수를 QBluetoothServiceInfo::Sequence 형식으로 반환합니다.
protocol 가 지원되지 않는 경우, 빈 QBluetoothServiceInfo::Sequence 가 반환됩니다.
int QBluetoothServiceInfo::protocolServiceMultiplexer() const
이 함수는 편의 함수입니다. L2CAP 프로토콜을 지원하는 서비스에 대한 프로토콜/서비스 멀티플렉서를 반환하며, 그렇지 않은 경우 -1을 반환합니다.
이 함수는 QBluetoothServiceInfo::attribute(QBluetoothServiceInfo::ProtocolDescriptorList)에서 반환되는 QBluetoothServiceInfo::Sequence 에서 정보를 추출하는 것과 동일합니다.
bool QBluetoothServiceInfo::registerService(const QBluetoothAddress &localAdapter = QBluetoothAddress())
이 서비스를 플랫폼의 서비스 검색 프로토콜(SDP) 구현에 등록하여, 다른 기기가 서비스 검색을 수행할 때 이 서비스를 찾을 수 있도록 합니다. 서비스가 성공적으로 등록되면 true를 반환하고, 그렇지 않으면 false를 반환합니다. 일단 등록된 후에는 레코드를 변경할 수 없습니다. 변경 사항이 적용된 상태로 서비스를 사용하려면 먼저 등록을 해제하고 다시 등록해야 합니다.
localAdapter 매개변수는 서비스를 등록할 로컬 블루투스 어댑터를 지정합니다. localAdapter 가 null 인 경우 기본 블루투스 어댑터가 사용됩니다. 이 서비스 정보 객체가 이미 로컬 어댑터를 통해 등록되어 있는 상태에서 다른 로컬 어댑터를 사용하여 이 함수를 호출하면, 이전 등록이 제거되고 새로운 어댑터를 사용하여 서비스가 재등록됩니다.
void QBluetoothServiceInfo::removeAttribute(quint16 attributeId)
QBluetoothServiceInfo 객체에서 attributeId 속성을 제거합니다.
서비스 정보가 이미 플랫폼의 SDP 데이터베이스에 등록되어 있는 경우, registerService()가 다시 호출될 때까지 데이터베이스 항목은 업데이트되지 않습니다.
int QBluetoothServiceInfo::serverChannel() const
이 함수는 편의 함수입니다. RFCOMM 프로토콜을 지원하는 서비스의 경우 서버 채널을 반환하고, 그렇지 않은 경우 -1을 반환합니다.
이 함수는 QBluetoothServiceInfo::attribute(QBluetootherServiceInfo::ProtocolDescriptorList)에서 반환된 QBluetoothServiceInfo::Sequence 의 정보를 추출하는 것과 동일합니다.
quint8 QBluetoothServiceInfo::serviceAvailability() const
이 함수는 편의 함수입니다. attribute(QBluetoothServiceInfo::ServiceAvailability).toUInt()를 호출하는 것과 동일합니다.
서비스의 가용성을 반환합니다.
setServiceAvailability() 및 attribute()도 참조하십시오 .
QList<QBluetoothUuid> QBluetoothServiceInfo::serviceClassUuids() const
이 서비스가 준수하는 서비스 클래스를 설명하는 UUID 목록을 반환합니다.
이 함수는 편의 함수입니다. 이는 attribute(QBluetoothServiceInfo::ServiceClassIds).value<QBluetoothServiceInfo::Sequence>()를 호출한 후, 그 QBluetoothUuid 항목을 순회하는 것과 동일합니다.
attribute()도 참조하십시오 .
QString QBluetoothServiceInfo::serviceDescription() const
이 함수는 편의 함수입니다. attribute(QBluetoothServiceInfo::ServiceDescription).toString()을 호출하는 것과 동일합니다.
기본 언어로 된 서비스 설명을 반환합니다.
setServiceDescription() 및 attribute()도 참조하십시오 .
QString QBluetoothServiceInfo::serviceName() const
이 함수는 편의 함수입니다. attribute(QBluetoothServiceInfo::ServiceName).toString()을 호출하는 것과 동일합니다.
기본 언어로 된 서비스 이름을 반환합니다.
setServiceName() 및 attribute()도 참조하십시오 .
QString QBluetoothServiceInfo::serviceProvider() const
이 함수는 편의 함수입니다. attribute(QBluetoothServiceInfo::ServiceProvider).toString()을 호출하는 것과 동일합니다.
기본 언어로 된 서비스 제공자를 반환합니다.
setServiceProvider() 및 attribute()도 참조하십시오 .
QBluetoothUuid QBluetoothServiceInfo::serviceUuid() const
이 함수는 편의 함수입니다. attribute(QBluetoothServiceInfo::ServiceId).value<QBluetoothUuid>()를 호출하는 것과 동일합니다.
서비스의 사용자 정의 UUID를 반환합니다. 이 UUID는 null일 수 있습니다. Bluetooth SIG 표준 에 기반한 UUID는 serviceClassUuids()를 통해 가져와야 합니다.
setServiceUuid() 및 attribute()도 참조하십시오 .
void QBluetoothServiceInfo::setAttribute(quint16 attributeId, const QBluetoothServiceInfo::Alternative &value)
이 함수는 편의 함수입니다.
attributeId 로 식별되는 속성을 value 로 설정합니다.
서비스 정보가 이미 플랫폼의 SDP 데이터베이스에 등록되어 있는 경우, registerService()이 다시 호출될 때까지 데이터베이스 항목은 업데이트되지 않습니다.
attribute()도 참조하십시오 .
void QBluetoothServiceInfo::setAttribute(quint16 attributeId, const QBluetoothServiceInfo::Sequence &value)
이 함수는 편의 함수입니다.
attributeId 로 식별되는 속성을 value 로 설정합니다.
서비스 정보가 이미 플랫폼의 SDP 데이터베이스에 등록되어 있는 경우, registerService()가 다시 호출될 때까지 데이터베이스 항목은 업데이트되지 않습니다.
void QBluetoothServiceInfo::setAttribute(quint16 attributeId, const QBluetoothUuid &value)
이것은 편의 함수입니다.
attributeId 로 식별되는 속성을 value 로 설정합니다.
서비스 정보가 이미 플랫폼의 SDP 데이터베이스에 등록되어 있는 경우, registerService()이 다시 호출될 때까지 데이터베이스 항목은 업데이트되지 않습니다.
void QBluetoothServiceInfo::setAttribute(quint16 attributeId, const QVariant &value)
attributeId 로 식별되는 속성을 value 로 설정합니다.
서비스 정보가 플랫폼의 SDP 데이터베이스에 이미 등록되어 있는 경우, registerService()이 다시 호출될 때까지 데이터베이스 항목은 업데이트되지 않습니다.
참고: 속성이 바이트 인코딩된 값을 요구하는경우 (예: Bluetooth HID 서비스), 해당 속성은 QByteArray 로 설정해야 합니다.
isRegistered() 및 registerService()도 참조하십시오 .
void QBluetoothServiceInfo::setDevice(const QBluetoothDeviceInfo &device)
이 서비스를 제공하는 블루투스 장치를 device 로 설정합니다.
device()도 참조하십시오 .
void QBluetoothServiceInfo::setServiceAvailability(quint8 availability)
이 함수는 편의 함수입니다. setAttribute(QBluetoothServiceInfo::ServiceAvailability, availability)를 호출하는 것과 동일합니다.
서비스의 가용성을 availability 로 설정합니다.
serviceAvailability() 및 setAttribute()도 참조하십시오 .
void QBluetoothServiceInfo::setServiceDescription(const QString &description)
이 함수는 편의 함수입니다. setAttribute(QBluetoothServiceInfo::ServiceDescription, description)을 호출하는 것과 동일합니다.
기본 언어로 된 서비스 설명을 description 로 설정합니다.
serviceDescription() 및 setAttribute()도 참조하십시오 .
void QBluetoothServiceInfo::setServiceName(const QString &name)
이 함수는 편의 함수입니다. 이 함수는 setAttribute(QBluetoothServiceInfo::ServiceName, name)을 호출하는 것과 동일합니다.
기본 언어의 서비스 이름을 name 로 설정합니다.
serviceName() 및 setAttribute()도 참조하십시오 .
void QBluetoothServiceInfo::setServiceProvider(const QString &provider)
이 함수는 편의 함수입니다. setAttribute(QBluetoothServiceInfo::ServiceProvider, provider)를 호출하는 것과 동일합니다.
기본 언어의 서비스 제공자를 provider 로 설정합니다.
serviceProvider() 및 setAttribute()도 참조하십시오 .
void QBluetoothServiceInfo::setServiceUuid(const QBluetoothUuid &uuid)
이 함수는 편의 함수입니다. setAttribute(QBluetoothServiceInfo::ServiceId, uuid)를 호출하는 것과 동일합니다.
사용자 정의 서비스 UUID를 uuid 로 설정합니다. 이 함수는 표준화된 서비스 UUID를 설정하는 데 사용해서는 안 됩니다.
serviceUuid() 및 setAttribute()도 참조하십시오 .
QBluetoothServiceInfo::Protocol QBluetoothServiceInfo::socketProtocol() const
QBluetoothServiceInfo 객체가 사용하는 프로토콜을 반환합니다.
bool QBluetoothServiceInfo::unregisterService()
플랫폼의 서비스 검색 프로토콜(SDP) 구현에서 이 서비스의 등록을 해제합니다. 이 작업이 완료되면 다른 기기에서는 더 이상 서비스 검색을 통해 해당 서비스를 찾을 수 없게 됩니다.
서비스 등록 해제가 성공하면 true를 반환하고, 그렇지 않으면 false를 반환합니다.
QBluetoothServiceInfo &QBluetoothServiceInfo::operator=(const QBluetoothServiceInfo &other)
other 의 복사본을 생성하여 이 QBluetoothServiceInfo 객체에 할당합니다. 두 복사본은 계속해서 동일한 서비스 및 등록 정보를 공유합니다.
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.