Win32 API 日本語リファレンス
ホームDevices.Bluetooth › BTH_LE_GATT_DESCRIPTOR_VALUE

BTH_LE_GATT_DESCRIPTOR_VALUE

構造体
サイズx64: 40 バイト / x86: 36 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
DescriptorTypeBTH_LE_GATT_DESCRIPTOR_TYPE4+0+0記述子の種類を示す列挙値。値の解釈に用いる。
DescriptorUuidBTH_LE_UUID20+4+4記述子を識別するUUIDを保持するBTH_LE_UUID。
Anonymous_Anonymous_e__Union8/4+24+24記述子種別ごとの構造化された値を格納する無名共用体。
DataSizeDWORD4+32+28Data配列に含まれる生データのバイト数を示す。
DataBYTE1+36+32記述子の生データを保持する可変長バイト配列の先頭。

共用体: _Anonymous_e__Union x64 8B / x86 4B

フィールドサイズx64x86
CharacteristicExtendedProperties_CharacteristicExtendedProperties_e__Struct8/4+0+0
ClientCharacteristicConfiguration_ClientCharacteristicConfiguration_e__Struct8/4+0+0
ServerCharacteristicConfiguration_ServerCharacteristicConfiguration_e__Struct8/4+0+0
CharacteristicFormat_CharacteristicFormat_e__Struct8/4+0+0

各言語での定義

#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_VALUE  (x64 40 / x86 36 バイト)
typedef struct BTH_LE_GATT_DESCRIPTOR_VALUE {
    BTH_LE_GATT_DESCRIPTOR_TYPE DescriptorType;
    BTH_LE_UUID DescriptorUuid;
    _Anonymous_e__Union Anonymous;
    DWORD DataSize;
    BYTE Data[1];
} BTH_LE_GATT_DESCRIPTOR_VALUE;
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_VALUE
{
    public int DescriptorType;
    public BTH_LE_UUID DescriptorUuid;
    public _Anonymous_e__Union Anonymous;
    public uint DataSize;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public byte[] Data;
}
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_VALUE
    Public DescriptorType As Integer
    Public DescriptorUuid As BTH_LE_UUID
    Public Anonymous As _Anonymous_e__Union
    Public DataSize As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public Data() As Byte
End Structure
import 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_VALUE(ctypes.Structure):
    _fields_ = [
        ("DescriptorType", ctypes.c_int),
        ("DescriptorUuid", BTH_LE_UUID),
        ("Anonymous", _Anonymous_e__Union),
        ("DataSize", wintypes.DWORD),
        ("Data", ctypes.c_ubyte * 1),
    ]
#[repr(C)]
pub struct BTH_LE_UUID {
    pub IsShortUuid: u8,
    pub Value: _Value_e__Union,
}

#[repr(C)]
pub struct BTH_LE_GATT_DESCRIPTOR_VALUE {
    pub DescriptorType: i32,
    pub DescriptorUuid: BTH_LE_UUID,
    pub Anonymous: _Anonymous_e__Union,
    pub DataSize: u32,
    pub Data: [u8; 1],
}
import "golang.org/x/sys/windows"

type BTH_LE_UUID struct {
	IsShortUuid byte
	Value _Value_e__Union
}

type BTH_LE_GATT_DESCRIPTOR_VALUE struct {
	DescriptorType int32
	DescriptorUuid BTH_LE_UUID
	Anonymous _Anonymous_e__Union
	DataSize uint32
	Data [1]byte
}
type
  BTH_LE_UUID = record
    IsShortUuid: ByteBool;
    Value: _Value_e__Union;
  end;

  BTH_LE_GATT_DESCRIPTOR_VALUE = record
    DescriptorType: Integer;
    DescriptorUuid: BTH_LE_UUID;
    Anonymous: _Anonymous_e__Union;
    DataSize: DWORD;
    Data: array[0..0] of Byte;
  end;
const BTH_LE_UUID = extern struct {
    IsShortUuid: u8,
    Value: _Value_e__Union,
};

const BTH_LE_GATT_DESCRIPTOR_VALUE = extern struct {
    DescriptorType: i32,
    DescriptorUuid: BTH_LE_UUID,
    Anonymous: _Anonymous_e__Union,
    DataSize: u32,
    Data: [1]u8,
};
type
  BTH_LE_UUID {.bycopy.} = object
    IsShortUuid: uint8
    Value: _Value_e__Union

  BTH_LE_GATT_DESCRIPTOR_VALUE {.bycopy.} = object
    DescriptorType: int32
    DescriptorUuid: BTH_LE_UUID
    Anonymous: _Anonymous_e__Union
    DataSize: uint32
    Data: array[1, uint8]
struct BTH_LE_UUID
{
    ubyte IsShortUuid;
    _Value_e__Union Value;
}

struct BTH_LE_GATT_DESCRIPTOR_VALUE
{
    int DescriptorType;
    BTH_LE_UUID DescriptorUuid;
    _Anonymous_e__Union Anonymous;
    uint DataSize;
    ubyte[1] Data;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; BTH_LE_GATT_DESCRIPTOR_VALUE サイズ: 36 バイト(x86)
dim st, 9    ; 4byte整数×9(構造体サイズ 36 / 4 切り上げ)
; DescriptorType : BTH_LE_GATT_DESCRIPTOR_TYPE (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; DescriptorUuid : BTH_LE_UUID (+4, 20byte)  varptr(st)+4 を基点に操作(20byte:入れ子/配列)
; Anonymous : _Anonymous_e__Union (+24, 4byte)  varptr(st)+24 を基点に操作(4byte:入れ子/配列)
; DataSize : DWORD (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; Data : BYTE (+32, 1byte)  varptr(st)+32 を基点に操作(1byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; BTH_LE_GATT_DESCRIPTOR_VALUE サイズ: 40 バイト(x64)
dim st, 10    ; 4byte整数×10(構造体サイズ 40 / 4 切り上げ)
; DescriptorType : BTH_LE_GATT_DESCRIPTOR_TYPE (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; DescriptorUuid : BTH_LE_UUID (+4, 20byte)  varptr(st)+4 を基点に操作(20byte:入れ子/配列)
; Anonymous : _Anonymous_e__Union (+24, 8byte)  varptr(st)+24 を基点に操作(8byte:入れ子/配列)
; DataSize : DWORD (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; Data : BYTE (+36, 1byte)  varptr(st)+36 を基点に操作(1byte:入れ子/配列)
; ※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_VALUE
    #field int DescriptorType
    #field BTH_LE_UUID DescriptorUuid
    #field byte Anonymous 8
    #field int DataSize
    #field byte Data 1
#endstruct

stdim st, BTH_LE_GATT_DESCRIPTOR_VALUE        ; NSTRUCT 変数を確保
st->DescriptorType = 100
mes "DescriptorType=" + st->DescriptorType
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。