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

BluetoothGATTGetCharacteristics

関数
指定GATTサービスのキャラクタリスティック一覧を取得する。
DLLBluetoothApis.dll呼出規約winapi対応OSwindows8.0

シグネチャ

// BluetoothApis.dll
#include <windows.h>

HRESULT BluetoothGATTGetCharacteristics(
    HANDLE hDevice,
    BTH_LE_GATT_SERVICE* Service,   // optional
    WORD CharacteristicsBufferCount,
    BTH_LE_GATT_CHARACTERISTIC* CharacteristicsBuffer,   // optional
    WORD* CharacteristicsBufferActual,
    DWORD Flags
);

パラメーター

名前方向
hDeviceHANDLEin
ServiceBTH_LE_GATT_SERVICE*inoptional
CharacteristicsBufferCountWORDin
CharacteristicsBufferBTH_LE_GATT_CHARACTERISTIC*outoptional
CharacteristicsBufferActualWORD*out
FlagsDWORDin

戻り値の型: HRESULT

各言語での呼び出し定義

// BluetoothApis.dll
#include <windows.h>

HRESULT BluetoothGATTGetCharacteristics(
    HANDLE hDevice,
    BTH_LE_GATT_SERVICE* Service,   // optional
    WORD CharacteristicsBufferCount,
    BTH_LE_GATT_CHARACTERISTIC* CharacteristicsBuffer,   // optional
    WORD* CharacteristicsBufferActual,
    DWORD Flags
);
[DllImport("BluetoothApis.dll", ExactSpelling = true)]
static extern int BluetoothGATTGetCharacteristics(
    IntPtr hDevice,   // HANDLE
    IntPtr Service,   // BTH_LE_GATT_SERVICE* optional
    ushort CharacteristicsBufferCount,   // WORD
    IntPtr CharacteristicsBuffer,   // BTH_LE_GATT_CHARACTERISTIC* optional, out
    out ushort CharacteristicsBufferActual,   // WORD* out
    uint Flags   // DWORD
);
<DllImport("BluetoothApis.dll", ExactSpelling:=True)>
Public Shared Function BluetoothGATTGetCharacteristics(
    hDevice As IntPtr,   ' HANDLE
    Service As IntPtr,   ' BTH_LE_GATT_SERVICE* optional
    CharacteristicsBufferCount As UShort,   ' WORD
    CharacteristicsBuffer As IntPtr,   ' BTH_LE_GATT_CHARACTERISTIC* optional, out
    <Out> ByRef CharacteristicsBufferActual As UShort,   ' WORD* out
    Flags As UInteger   ' DWORD
) As Integer
End Function
' hDevice : HANDLE
' Service : BTH_LE_GATT_SERVICE* optional
' CharacteristicsBufferCount : WORD
' CharacteristicsBuffer : BTH_LE_GATT_CHARACTERISTIC* optional, out
' CharacteristicsBufferActual : WORD* out
' Flags : DWORD
Declare PtrSafe Function BluetoothGATTGetCharacteristics Lib "bluetoothapis" ( _
    ByVal hDevice As LongPtr, _
    ByVal Service As LongPtr, _
    ByVal CharacteristicsBufferCount As Integer, _
    ByVal CharacteristicsBuffer As LongPtr, _
    ByRef CharacteristicsBufferActual As Integer, _
    ByVal Flags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

BluetoothGATTGetCharacteristics = ctypes.windll.bluetoothapis.BluetoothGATTGetCharacteristics
BluetoothGATTGetCharacteristics.restype = ctypes.c_int
BluetoothGATTGetCharacteristics.argtypes = [
    wintypes.HANDLE,  # hDevice : HANDLE
    ctypes.c_void_p,  # Service : BTH_LE_GATT_SERVICE* optional
    ctypes.c_ushort,  # CharacteristicsBufferCount : WORD
    ctypes.c_void_p,  # CharacteristicsBuffer : BTH_LE_GATT_CHARACTERISTIC* optional, out
    ctypes.POINTER(ctypes.c_ushort),  # CharacteristicsBufferActual : WORD* out
    wintypes.DWORD,  # Flags : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('BluetoothApis.dll')
BluetoothGATTGetCharacteristics = Fiddle::Function.new(
  lib['BluetoothGATTGetCharacteristics'],
  [
    Fiddle::TYPE_VOIDP,  # hDevice : HANDLE
    Fiddle::TYPE_VOIDP,  # Service : BTH_LE_GATT_SERVICE* optional
    -Fiddle::TYPE_SHORT,  # CharacteristicsBufferCount : WORD
    Fiddle::TYPE_VOIDP,  # CharacteristicsBuffer : BTH_LE_GATT_CHARACTERISTIC* optional, out
    Fiddle::TYPE_VOIDP,  # CharacteristicsBufferActual : WORD* out
    -Fiddle::TYPE_INT,  # Flags : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "bluetoothapis")]
extern "system" {
    fn BluetoothGATTGetCharacteristics(
        hDevice: *mut core::ffi::c_void,  // HANDLE
        Service: *mut BTH_LE_GATT_SERVICE,  // BTH_LE_GATT_SERVICE* optional
        CharacteristicsBufferCount: u16,  // WORD
        CharacteristicsBuffer: *mut BTH_LE_GATT_CHARACTERISTIC,  // BTH_LE_GATT_CHARACTERISTIC* optional, out
        CharacteristicsBufferActual: *mut u16,  // WORD* out
        Flags: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("BluetoothApis.dll")]
public static extern int BluetoothGATTGetCharacteristics(IntPtr hDevice, IntPtr Service, ushort CharacteristicsBufferCount, IntPtr CharacteristicsBuffer, out ushort CharacteristicsBufferActual, uint Flags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'BluetoothApis_BluetoothGATTGetCharacteristics' -Namespace Win32 -PassThru
# $api::BluetoothGATTGetCharacteristics(hDevice, Service, CharacteristicsBufferCount, CharacteristicsBuffer, CharacteristicsBufferActual, Flags)
#uselib "BluetoothApis.dll"
#func global BluetoothGATTGetCharacteristics "BluetoothGATTGetCharacteristics" sptr, sptr, sptr, sptr, sptr, sptr
; BluetoothGATTGetCharacteristics hDevice, varptr(Service), CharacteristicsBufferCount, varptr(CharacteristicsBuffer), varptr(CharacteristicsBufferActual), Flags   ; 戻り値は stat
; hDevice : HANDLE -> "sptr"
; Service : BTH_LE_GATT_SERVICE* optional -> "sptr"
; CharacteristicsBufferCount : WORD -> "sptr"
; CharacteristicsBuffer : BTH_LE_GATT_CHARACTERISTIC* optional, out -> "sptr"
; CharacteristicsBufferActual : WORD* out -> "sptr"
; Flags : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "BluetoothApis.dll"
#cfunc global BluetoothGATTGetCharacteristics "BluetoothGATTGetCharacteristics" sptr, var, int, var, var, int
; res = BluetoothGATTGetCharacteristics(hDevice, Service, CharacteristicsBufferCount, CharacteristicsBuffer, CharacteristicsBufferActual, Flags)
; hDevice : HANDLE -> "sptr"
; Service : BTH_LE_GATT_SERVICE* optional -> "var"
; CharacteristicsBufferCount : WORD -> "int"
; CharacteristicsBuffer : BTH_LE_GATT_CHARACTERISTIC* optional, out -> "var"
; CharacteristicsBufferActual : WORD* out -> "var"
; Flags : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT BluetoothGATTGetCharacteristics(HANDLE hDevice, BTH_LE_GATT_SERVICE* Service, WORD CharacteristicsBufferCount, BTH_LE_GATT_CHARACTERISTIC* CharacteristicsBuffer, WORD* CharacteristicsBufferActual, DWORD Flags)
#uselib "BluetoothApis.dll"
#cfunc global BluetoothGATTGetCharacteristics "BluetoothGATTGetCharacteristics" intptr, var, int, var, var, int
; res = BluetoothGATTGetCharacteristics(hDevice, Service, CharacteristicsBufferCount, CharacteristicsBuffer, CharacteristicsBufferActual, Flags)
; hDevice : HANDLE -> "intptr"
; Service : BTH_LE_GATT_SERVICE* optional -> "var"
; CharacteristicsBufferCount : WORD -> "int"
; CharacteristicsBuffer : BTH_LE_GATT_CHARACTERISTIC* optional, out -> "var"
; CharacteristicsBufferActual : WORD* out -> "var"
; Flags : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	bluetoothapis = windows.NewLazySystemDLL("BluetoothApis.dll")
	procBluetoothGATTGetCharacteristics = bluetoothapis.NewProc("BluetoothGATTGetCharacteristics")
)

// hDevice (HANDLE), Service (BTH_LE_GATT_SERVICE* optional), CharacteristicsBufferCount (WORD), CharacteristicsBuffer (BTH_LE_GATT_CHARACTERISTIC* optional, out), CharacteristicsBufferActual (WORD* out), Flags (DWORD)
r1, _, err := procBluetoothGATTGetCharacteristics.Call(
	uintptr(hDevice),
	uintptr(Service),
	uintptr(CharacteristicsBufferCount),
	uintptr(CharacteristicsBuffer),
	uintptr(CharacteristicsBufferActual),
	uintptr(Flags),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function BluetoothGATTGetCharacteristics(
  hDevice: THandle;   // HANDLE
  Service: Pointer;   // BTH_LE_GATT_SERVICE* optional
  CharacteristicsBufferCount: Word;   // WORD
  CharacteristicsBuffer: Pointer;   // BTH_LE_GATT_CHARACTERISTIC* optional, out
  CharacteristicsBufferActual: Pointer;   // WORD* out
  Flags: DWORD   // DWORD
): Integer; stdcall;
  external 'BluetoothApis.dll' name 'BluetoothGATTGetCharacteristics';
result := DllCall("BluetoothApis\BluetoothGATTGetCharacteristics"
    , "Ptr", hDevice   ; HANDLE
    , "Ptr", Service   ; BTH_LE_GATT_SERVICE* optional
    , "UShort", CharacteristicsBufferCount   ; WORD
    , "Ptr", CharacteristicsBuffer   ; BTH_LE_GATT_CHARACTERISTIC* optional, out
    , "Ptr", CharacteristicsBufferActual   ; WORD* out
    , "UInt", Flags   ; DWORD
    , "Int")   ; return: HRESULT
●BluetoothGATTGetCharacteristics(hDevice, Service, CharacteristicsBufferCount, CharacteristicsBuffer, CharacteristicsBufferActual, Flags) = DLL("BluetoothApis.dll", "int BluetoothGATTGetCharacteristics(void*, void*, int, void*, void*, dword)")
# 呼び出し: BluetoothGATTGetCharacteristics(hDevice, Service, CharacteristicsBufferCount, CharacteristicsBuffer, CharacteristicsBufferActual, Flags)
# hDevice : HANDLE -> "void*"
# Service : BTH_LE_GATT_SERVICE* optional -> "void*"
# CharacteristicsBufferCount : WORD -> "int"
# CharacteristicsBuffer : BTH_LE_GATT_CHARACTERISTIC* optional, out -> "void*"
# CharacteristicsBufferActual : WORD* out -> "void*"
# Flags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。