QBluetoothServiceInfo Class

QBluetoothServiceInfo クラスは、Bluetooth サービスの属性へのアクセスを可能にします。詳細...

Header: #include <QBluetoothServiceInfo>
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 は、Bluetooth デバイスが提供するサービスに関する情報を提供します。また、ローカルデバイスに新しいサービスを登録するために使用することもできます。このような登録は Bluetooth SDP エントリにのみ影響することに注意してください。着信接続をリッスンしているサーバー(RFCOMMサーバーなど)は、registerService() が呼び出される前に起動しておく必要がある。登録解除は逆の順序で行う必要があります。

QBluetoothServiceInfo は、従来の意味での値型ではありません。同じサービス情報オブジェクトのすべてのコピーは、変更時に切り離されないため、同じデータを共有します。これにより、2つのコピーで同じBluetoothサービスを登録(解除)することができます。

iOSでは、プラットフォームがQBluetoothServiceInfo関連機能へのアクセスを許可するAPIを公開していないため、このクラスは使用できません。

メンバ型ドキュメント

enum QBluetoothServiceInfo::AttributeId

Bluetoothサービス属性。これらの属性の詳細については、Bluetooth Core Specificationを参照してください。

定数説明
QBluetoothServiceInfo::ServiceRecordHandle0x0000属性を取得できるサービスレコードを指定します。
QBluetoothServiceInfo::ServiceClassIds0x0001サービスが準拠するサービスクラスのUUID。最も一般的なサービスクラスは(QBluetoothUuid::ServiceClassUuid)で定義されています。
QBluetoothServiceInfo::ServiceRecordState0x0002属性は、他のサービス属性が追加、削除、または変更されたときに変更されます。
QBluetoothServiceInfo::ServiceId0x0003サービスを一意に識別するUUID。
QBluetoothServiceInfo::ProtocolDescriptorList0x0004サービスが使用するプロトコルのリスト。最も一般的なプロトコルのUUIDは以下で定義されています。QBluetoothUuid::ProtocolUuid
QBluetoothServiceInfo::BrowseGroupList0x0005サービスが属するブラウズグループのリスト.
QBluetoothServiceInfo::LanguageBaseAttributeIdList0x0006人間が読める属性をサポートするための言語ベース属性IDのリスト.
QBluetoothServiceInfo::ServiceInfoTimeToLive0x0007サービスレコードが有効で変更されないと予想される秒数.
QBluetoothServiceInfo::ServiceAvailability0x0008サービスの可用性を示す値.
QBluetoothServiceInfo::BluetoothProfileDescriptorList0x0009サービスが準拠するプロファイルのリスト.
QBluetoothServiceInfo::DocumentationUrl0x000Aサービスのドキュメントを指すURL。
QBluetoothServiceInfo::ClientExecutableUrl0x000Bサービスを利用するために使用できるアプリケーションの場所を指すURL。
QBluetoothServiceInfo::IconUrl0x000Cサービスを表すアイコンの場所を指すURL。
QBluetoothServiceInfo::AdditionalProtocolDescriptorList0x000Dサービスが使用する追加プロトコル。この属性は、ProtocolDescriptorList を拡張します。
QBluetoothServiceInfo::PrimaryLanguageBase0x0100主言語テキスト記述子の基本インデックス。
QBluetoothServiceInfo::ServiceNamePrimaryLanguageBase + 0x0000主要言語におけるBluetoothサービスの名前。
QBluetoothServiceInfo::ServiceDescriptionPrimaryLanguageBase + 0x0001主要言語でのBluetoothサービスの説明。
QBluetoothServiceInfo::ServiceProviderPrimaryLanguageBase + 0x0002主要言語でのBluetoothサービスの説明。

注: Windowsでは、ServiceClassIdsとProtocolDescriptorListは、サービス作成時に自動的にデフォルト値に設定されます。これらの属性の値を手動で設定しても動作せず、このプラットフォームでは予期しない結果になることがあります。

enum QBluetoothServiceInfo::Protocol

この列挙型はサービスが使用するソケットプロトコルを記述する。

定数説明
QBluetoothServiceInfo::UnknownProtocol0サービスは未知のソケットプロトコルを使用する。
QBluetoothServiceInfo::L2capProtocol1L2CAPソケットプロトコルを使用しています。このプロトコルはAndroidの直接ソケット接続ではサポートされていません。
QBluetoothServiceInfo::RfcommProtocol2RFCOMMソケットプロトコルを使用しています。

メンバー関数説明

QBluetoothServiceInfo::QBluetoothServiceInfo()

新しい無効な QBluetoothServiceInfo を構築します;

QBluetoothServiceInfo::QBluetoothServiceInfo(const QBluetoothServiceInfo &other)

other のコピーである新しい QBluetoothServiceInfo を構築する。

2つのコピーは、書き込み時に切り離されない同じ基礎データを共有し続ける。

[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 が含まれていれば真を返し、そうでなければ偽を返す。

QBluetoothDeviceInfo QBluetoothServiceInfo::device() const

このサービスを提供する Bluetooth デバイスのアドレスを返します。

setDevice()も参照してください

bool QBluetoothServiceInfo::isComplete() const

QBluetoothServiceInfo オブジェクトが完全であるとみなされた場合はtrueを返し、そうでない場合はfalseを返す。

完全なQBluetoothServiceInfo オブジェクトにはProtocolDescriptorList 属性が含まれます。

bool QBluetoothServiceInfo::isRegistered() const

サービス情報がプラットフォームのサービス発見プロトコル(SDP)実装に登録されている場合はtrueを返し、そうでない場合はfalseを返す。

bool QBluetoothServiceInfo::isValid() const

QBluetoothServiceInfo オブジェクトが有効であれば真を、そうでなければ偽を返します。

無効なQBluetoothServiceInfo オブジェクトは属性を持ちません。

QBluetoothServiceInfo::Sequence QBluetoothServiceInfo::protocolDescriptor(QBluetoothUuid::ProtocolUuid protocol) const

プロトコルのパラメータを、プロトコルprotocolQBluetoothServiceInfo::Sequence として返す。

protocol がサポートされていない場合は、空のQBluetoothServiceInfo::Sequence が返される。

int QBluetoothServiceInfo::protocolServiceMultiplexer() const

これは便利な関数である。L2CAP プロトコルをサポートするサービスのプロトコル/サービスマルチプレクサを返す。

この関数は、QBluetoothServiceInfo::attribute(QBluetoothServiceInfo::ProtocolDescriptorList) が返すQBluetoothServiceInfo::Sequence から情報を抽出するのと同じである。

bool QBluetoothServiceInfo::registerService(const QBluetoothAddress &localAdapter = QBluetoothAddress())

このサービスをプラットフォームのサービス検出プロトコル (SDP) 実装に登録し、他のデバイスがサービス検出を実行したときに検出できるようにする。サービスが正常に登録された場合はtrueを返し、そうでない場合はfalseを返す。そうでなければfalseを返す。いったん登録されると、レコードの変更はできない。サービスの登録を解除し、変更を加えて再度登録する必要がある。

localAdapter パラメータは、サービスを登録するローカルのBluetoothアダプタを決定する。localAdapternull の場合、デフォルトのBluetoothアダプタが使用されます。このサービス情報オブジェクトがすでにローカルアダプタ経由で登録されており、この関数が別のローカルアダプタを使用して呼び出された場合、以前の登録は削除され、新しいアダプタを使用してサービスが再登録されます。

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)

このサービスを提供するBluetoothデバイスを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(Service Discovery Protocol)実装で、このサービスの登録を解除する。この後、サービスはサービス検出によって他のデバイスから検出できなくなります。

サービスの登録解除に成功した場合は true を返し、失敗した場合は false を返します。

QBluetoothServiceInfo &QBluetoothServiceInfo::operator=(const QBluetoothServiceInfo &other)

other のコピーを作成し、このQBluetoothServiceInfo オブジェクトに割り当てる。2つのコピーは、同じサービスと登録の詳細を共有し続ける。

© 2025 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.