ホーム › Devices.Bluetooth › BTH_LE_GATT_DESCRIPTOR
BTH_LE_GATT_DESCRIPTOR
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| ServiceHandle | WORD | 2 | +0 | +0 | この記述子が属するサービスの属性ハンドル。 |
| CharacteristicHandle | WORD | 2 | +2 | +2 | この記述子が属する特性の属性ハンドル。 |
| DescriptorType | BTH_LE_GATT_DESCRIPTOR_TYPE | 4 | +4 | +4 | 記述子の種類を示す列挙値。CCCDや拡張プロパティ等を表す。 |
| DescriptorUuid | BTH_LE_UUID | 20 | +8 | +8 | 記述子を識別するUUIDを保持するBTH_LE_UUID。 |
| AttributeHandle | WORD | 2 | +28 | +28 | 記述子の属性ハンドルを示す16ビット値。 |
各言語での定義
#include <windows.h>
// BTH_LE_UUID (x64 20 / x86 20 バイト)
typedef struct BTH_LE_UUID {
BOOLEAN IsShortUuid;
_Value_e__Union Value;
} BTH_LE_UUID;
// BTH_LE_GATT_DESCRIPTOR (x64 32 / x86 32 バイト)
typedef struct BTH_LE_GATT_DESCRIPTOR {
WORD ServiceHandle;
WORD CharacteristicHandle;
BTH_LE_GATT_DESCRIPTOR_TYPE DescriptorType;
BTH_LE_UUID DescriptorUuid;
WORD AttributeHandle;
} BTH_LE_GATT_DESCRIPTOR;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct BTH_LE_UUID
{
[MarshalAs(UnmanagedType.U1)] public bool IsShortUuid;
public _Value_e__Union Value;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct BTH_LE_GATT_DESCRIPTOR
{
public ushort ServiceHandle;
public ushort CharacteristicHandle;
public int DescriptorType;
public BTH_LE_UUID DescriptorUuid;
public ushort AttributeHandle;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure BTH_LE_UUID
<MarshalAs(UnmanagedType.U1)> Public IsShortUuid As Boolean
Public Value As _Value_e__Union
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure BTH_LE_GATT_DESCRIPTOR
Public ServiceHandle As UShort
Public CharacteristicHandle As UShort
Public DescriptorType As Integer
Public DescriptorUuid As BTH_LE_UUID
Public AttributeHandle As UShort
End Structureimport ctypes
from ctypes import wintypes
class BTH_LE_UUID(ctypes.Structure):
_fields_ = [
("IsShortUuid", ctypes.c_byte),
("Value", _Value_e__Union),
]
class BTH_LE_GATT_DESCRIPTOR(ctypes.Structure):
_fields_ = [
("ServiceHandle", ctypes.c_ushort),
("CharacteristicHandle", ctypes.c_ushort),
("DescriptorType", ctypes.c_int),
("DescriptorUuid", BTH_LE_UUID),
("AttributeHandle", ctypes.c_ushort),
]#[repr(C)]
pub struct BTH_LE_UUID {
pub IsShortUuid: u8,
pub Value: _Value_e__Union,
}
#[repr(C)]
pub struct BTH_LE_GATT_DESCRIPTOR {
pub ServiceHandle: u16,
pub CharacteristicHandle: u16,
pub DescriptorType: i32,
pub DescriptorUuid: BTH_LE_UUID,
pub AttributeHandle: u16,
}import "golang.org/x/sys/windows"
type BTH_LE_UUID struct {
IsShortUuid byte
Value _Value_e__Union
}
type BTH_LE_GATT_DESCRIPTOR struct {
ServiceHandle uint16
CharacteristicHandle uint16
DescriptorType int32
DescriptorUuid BTH_LE_UUID
AttributeHandle uint16
}type
BTH_LE_UUID = record
IsShortUuid: ByteBool;
Value: _Value_e__Union;
end;
BTH_LE_GATT_DESCRIPTOR = record
ServiceHandle: Word;
CharacteristicHandle: Word;
DescriptorType: Integer;
DescriptorUuid: BTH_LE_UUID;
AttributeHandle: Word;
end;const BTH_LE_UUID = extern struct {
IsShortUuid: u8,
Value: _Value_e__Union,
};
const BTH_LE_GATT_DESCRIPTOR = extern struct {
ServiceHandle: u16,
CharacteristicHandle: u16,
DescriptorType: i32,
DescriptorUuid: BTH_LE_UUID,
AttributeHandle: u16,
};type
BTH_LE_UUID {.bycopy.} = object
IsShortUuid: uint8
Value: _Value_e__Union
BTH_LE_GATT_DESCRIPTOR {.bycopy.} = object
ServiceHandle: uint16
CharacteristicHandle: uint16
DescriptorType: int32
DescriptorUuid: BTH_LE_UUID
AttributeHandle: uint16struct BTH_LE_UUID
{
ubyte IsShortUuid;
_Value_e__Union Value;
}
struct BTH_LE_GATT_DESCRIPTOR
{
ushort ServiceHandle;
ushort CharacteristicHandle;
int DescriptorType;
BTH_LE_UUID DescriptorUuid;
ushort AttributeHandle;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; BTH_LE_GATT_DESCRIPTOR サイズ: 32 バイト(x64)
dim st, 8 ; 4byte整数×8(構造体サイズ 32 / 4 切り上げ)
; ServiceHandle : WORD (+0, 2byte) wpoke st,0,値 / 値 = wpeek(st,0)
; CharacteristicHandle : WORD (+2, 2byte) wpoke st,2,値 / 値 = wpeek(st,2)
; DescriptorType : BTH_LE_GATT_DESCRIPTOR_TYPE (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; DescriptorUuid : BTH_LE_UUID (+8, 20byte) varptr(st)+8 を基点に操作(20byte:入れ子/配列)
; AttributeHandle : WORD (+28, 2byte) wpoke st,28,値 / 値 = wpeek(st,28)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global BTH_LE_UUID
#field bool1 IsShortUuid
#field byte Value 16
#endstruct
#defstruct global BTH_LE_GATT_DESCRIPTOR
#field short ServiceHandle
#field short CharacteristicHandle
#field int DescriptorType
#field BTH_LE_UUID DescriptorUuid
#field short AttributeHandle
#endstruct
stdim st, BTH_LE_GATT_DESCRIPTOR ; NSTRUCT 変数を確保
st->ServiceHandle = 100
mes "ServiceHandle=" + st->ServiceHandle