ホーム › Devices.Bluetooth › BluetoothGATTGetCharacteristics
BluetoothGATTGetCharacteristics
関数指定GATTサービスのキャラクタリスティック一覧を取得する。
シグネチャ
// 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
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hDevice | HANDLE | in | キャラクタリスティックを取得する対象BLEデバイスのハンドル。 |
| Service | BTH_LE_GATT_SERVICE* | inoptional | 取得対象とするGATTサービスの構造体ポインタ。NULLで全サービス対象。 |
| CharacteristicsBufferCount | WORD | in | バッファが格納できる要素数。サイズ照会時は0。 |
| CharacteristicsBuffer | BTH_LE_GATT_CHARACTERISTIC* | outoptional | 取得したキャラクタリスティック情報を受け取る配列ポインタ。サイズ照会時はNULL。 |
| CharacteristicsBufferActual | WORD* | out | 実際のキャラクタリスティック数を受け取る出力ポインタ。 |
| Flags | DWORD | in | 取得動作を制御するフラグ。BLUETOOTH_GATT_FLAG_NONE等。 |
戻り値の型: 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 方式にも切替可。#uselib "BluetoothApis.dll" #cfunc global BluetoothGATTGetCharacteristics "BluetoothGATTGetCharacteristics" sptr, sptr, int, sptr, sptr, int ; res = BluetoothGATTGetCharacteristics(hDevice, varptr(Service), CharacteristicsBufferCount, varptr(CharacteristicsBuffer), varptr(CharacteristicsBufferActual), Flags) ; hDevice : HANDLE -> "sptr" ; Service : BTH_LE_GATT_SERVICE* optional -> "sptr" ; CharacteristicsBufferCount : WORD -> "int" ; CharacteristicsBuffer : BTH_LE_GATT_CHARACTERISTIC* optional, out -> "sptr" ; CharacteristicsBufferActual : WORD* out -> "sptr" ; Flags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; 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, intptr, int, intptr, intptr, int ; res = BluetoothGATTGetCharacteristics(hDevice, varptr(Service), CharacteristicsBufferCount, varptr(CharacteristicsBuffer), varptr(CharacteristicsBufferActual), Flags) ; hDevice : HANDLE -> "intptr" ; Service : BTH_LE_GATT_SERVICE* optional -> "intptr" ; CharacteristicsBufferCount : WORD -> "int" ; CharacteristicsBuffer : BTH_LE_GATT_CHARACTERISTIC* optional, out -> "intptr" ; CharacteristicsBufferActual : WORD* out -> "intptr" ; Flags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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 // HRESULTfunction 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)。const std = @import("std");
extern "bluetoothapis" fn BluetoothGATTGetCharacteristics(
hDevice: ?*anyopaque, // HANDLE
Service: [*c]BTH_LE_GATT_SERVICE, // BTH_LE_GATT_SERVICE* optional
CharacteristicsBufferCount: u16, // WORD
CharacteristicsBuffer: [*c]BTH_LE_GATT_CHARACTERISTIC, // BTH_LE_GATT_CHARACTERISTIC* optional, out
CharacteristicsBufferActual: [*c]u16, // WORD* out
Flags: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;proc BluetoothGATTGetCharacteristics(
hDevice: pointer, # HANDLE
Service: ptr BTH_LE_GATT_SERVICE, # BTH_LE_GATT_SERVICE* optional
CharacteristicsBufferCount: uint16, # WORD
CharacteristicsBuffer: ptr BTH_LE_GATT_CHARACTERISTIC, # BTH_LE_GATT_CHARACTERISTIC* optional, out
CharacteristicsBufferActual: ptr uint16, # WORD* out
Flags: uint32 # DWORD
): int32 {.importc: "BluetoothGATTGetCharacteristics", stdcall, dynlib: "BluetoothApis.dll".}pragma(lib, "bluetoothapis");
extern(Windows)
int BluetoothGATTGetCharacteristics(
void* hDevice, // HANDLE
BTH_LE_GATT_SERVICE* Service, // BTH_LE_GATT_SERVICE* optional
ushort CharacteristicsBufferCount, // WORD
BTH_LE_GATT_CHARACTERISTIC* CharacteristicsBuffer, // BTH_LE_GATT_CHARACTERISTIC* optional, out
ushort* CharacteristicsBufferActual, // WORD* out
uint Flags // DWORD
);ccall((:BluetoothGATTGetCharacteristics, "BluetoothApis.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{BTH_LE_GATT_SERVICE}, UInt16, Ptr{BTH_LE_GATT_CHARACTERISTIC}, Ptr{UInt16}, UInt32),
hDevice, Service, CharacteristicsBufferCount, CharacteristicsBuffer, CharacteristicsBufferActual, Flags)
# hDevice : HANDLE -> Ptr{Cvoid}
# Service : BTH_LE_GATT_SERVICE* optional -> Ptr{BTH_LE_GATT_SERVICE}
# CharacteristicsBufferCount : WORD -> UInt16
# CharacteristicsBuffer : BTH_LE_GATT_CHARACTERISTIC* optional, out -> Ptr{BTH_LE_GATT_CHARACTERISTIC}
# CharacteristicsBufferActual : WORD* out -> Ptr{UInt16}
# Flags : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t BluetoothGATTGetCharacteristics(
void* hDevice,
void* Service,
uint16_t CharacteristicsBufferCount,
void* CharacteristicsBuffer,
uint16_t* CharacteristicsBufferActual,
uint32_t Flags);
]]
local bluetoothapis = ffi.load("bluetoothapis")
-- bluetoothapis.BluetoothGATTGetCharacteristics(hDevice, Service, CharacteristicsBufferCount, CharacteristicsBuffer, CharacteristicsBufferActual, Flags)
-- hDevice : HANDLE
-- Service : BTH_LE_GATT_SERVICE* optional
-- CharacteristicsBufferCount : WORD
-- CharacteristicsBuffer : BTH_LE_GATT_CHARACTERISTIC* optional, out
-- CharacteristicsBufferActual : WORD* out
-- Flags : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('BluetoothApis.dll');
const BluetoothGATTGetCharacteristics = lib.func('__stdcall', 'BluetoothGATTGetCharacteristics', 'int32_t', ['void *', 'void *', 'uint16_t', 'void *', 'uint16_t *', 'uint32_t']);
// BluetoothGATTGetCharacteristics(hDevice, Service, CharacteristicsBufferCount, CharacteristicsBuffer, CharacteristicsBufferActual, Flags)
// hDevice : HANDLE -> 'void *'
// Service : BTH_LE_GATT_SERVICE* optional -> 'void *'
// CharacteristicsBufferCount : WORD -> 'uint16_t'
// CharacteristicsBuffer : BTH_LE_GATT_CHARACTERISTIC* optional, out -> 'void *'
// CharacteristicsBufferActual : WORD* out -> 'uint16_t *'
// Flags : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("BluetoothApis.dll", {
BluetoothGATTGetCharacteristics: { parameters: ["pointer", "pointer", "u16", "pointer", "pointer", "u32"], result: "i32" },
});
// lib.symbols.BluetoothGATTGetCharacteristics(hDevice, Service, CharacteristicsBufferCount, CharacteristicsBuffer, CharacteristicsBufferActual, Flags)
// hDevice : HANDLE -> "pointer"
// Service : BTH_LE_GATT_SERVICE* optional -> "pointer"
// CharacteristicsBufferCount : WORD -> "u16"
// CharacteristicsBuffer : BTH_LE_GATT_CHARACTERISTIC* optional, out -> "pointer"
// CharacteristicsBufferActual : WORD* out -> "pointer"
// Flags : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t BluetoothGATTGetCharacteristics(
void* hDevice,
void* Service,
uint16_t CharacteristicsBufferCount,
void* CharacteristicsBuffer,
uint16_t* CharacteristicsBufferActual,
uint32_t Flags);
C, "BluetoothApis.dll");
// $ffi->BluetoothGATTGetCharacteristics(hDevice, Service, CharacteristicsBufferCount, CharacteristicsBuffer, CharacteristicsBufferActual, Flags);
// hDevice : HANDLE
// Service : BTH_LE_GATT_SERVICE* optional
// CharacteristicsBufferCount : WORD
// CharacteristicsBuffer : BTH_LE_GATT_CHARACTERISTIC* optional, out
// CharacteristicsBufferActual : WORD* out
// Flags : DWORD
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Bluetoothapis extends StdCallLibrary {
Bluetoothapis INSTANCE = Native.load("bluetoothapis", Bluetoothapis.class);
int BluetoothGATTGetCharacteristics(
Pointer hDevice, // HANDLE
Pointer Service, // BTH_LE_GATT_SERVICE* optional
short CharacteristicsBufferCount, // WORD
Pointer CharacteristicsBuffer, // BTH_LE_GATT_CHARACTERISTIC* optional, out
ShortByReference CharacteristicsBufferActual, // WORD* out
int Flags // DWORD
);
}@[Link("bluetoothapis")]
lib LibBluetoothApis
fun BluetoothGATTGetCharacteristics = BluetoothGATTGetCharacteristics(
hDevice : Void*, # HANDLE
Service : BTH_LE_GATT_SERVICE*, # BTH_LE_GATT_SERVICE* optional
CharacteristicsBufferCount : UInt16, # WORD
CharacteristicsBuffer : BTH_LE_GATT_CHARACTERISTIC*, # BTH_LE_GATT_CHARACTERISTIC* optional, out
CharacteristicsBufferActual : UInt16*, # WORD* out
Flags : UInt32 # DWORD
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef BluetoothGATTGetCharacteristicsNative = Int32 Function(Pointer<Void>, Pointer<Void>, Uint16, Pointer<Void>, Pointer<Uint16>, Uint32);
typedef BluetoothGATTGetCharacteristicsDart = int Function(Pointer<Void>, Pointer<Void>, int, Pointer<Void>, Pointer<Uint16>, int);
final BluetoothGATTGetCharacteristics = DynamicLibrary.open('BluetoothApis.dll')
.lookupFunction<BluetoothGATTGetCharacteristicsNative, BluetoothGATTGetCharacteristicsDart>('BluetoothGATTGetCharacteristics');
// hDevice : HANDLE -> Pointer<Void>
// Service : BTH_LE_GATT_SERVICE* optional -> Pointer<Void>
// CharacteristicsBufferCount : WORD -> Uint16
// CharacteristicsBuffer : BTH_LE_GATT_CHARACTERISTIC* optional, out -> Pointer<Void>
// CharacteristicsBufferActual : WORD* out -> Pointer<Uint16>
// Flags : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
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';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "BluetoothGATTGetCharacteristics"
c_BluetoothGATTGetCharacteristics :: Ptr () -> Ptr () -> Word16 -> Ptr () -> Ptr Word16 -> Word32 -> IO Int32
-- hDevice : HANDLE -> Ptr ()
-- Service : BTH_LE_GATT_SERVICE* optional -> Ptr ()
-- CharacteristicsBufferCount : WORD -> Word16
-- CharacteristicsBuffer : BTH_LE_GATT_CHARACTERISTIC* optional, out -> Ptr ()
-- CharacteristicsBufferActual : WORD* out -> Ptr Word16
-- Flags : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let bluetoothgattgetcharacteristics =
foreign "BluetoothGATTGetCharacteristics"
((ptr void) @-> (ptr void) @-> uint16_t @-> (ptr void) @-> (ptr uint16_t) @-> uint32_t @-> returning int32_t)
(* hDevice : HANDLE -> (ptr void) *)
(* Service : BTH_LE_GATT_SERVICE* optional -> (ptr void) *)
(* CharacteristicsBufferCount : WORD -> uint16_t *)
(* CharacteristicsBuffer : BTH_LE_GATT_CHARACTERISTIC* optional, out -> (ptr void) *)
(* CharacteristicsBufferActual : WORD* out -> (ptr uint16_t) *)
(* Flags : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library bluetoothapis (t "BluetoothApis.dll"))
(cffi:use-foreign-library bluetoothapis)
(cffi:defcfun ("BluetoothGATTGetCharacteristics" bluetooth-gattget-characteristics :convention :stdcall) :int32
(h-device :pointer) ; HANDLE
(service :pointer) ; BTH_LE_GATT_SERVICE* optional
(characteristics-buffer-count :uint16) ; WORD
(characteristics-buffer :pointer) ; BTH_LE_GATT_CHARACTERISTIC* optional, out
(characteristics-buffer-actual :pointer) ; WORD* out
(flags :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $BluetoothGATTGetCharacteristics = Win32::API::More->new('BluetoothApis',
'int BluetoothGATTGetCharacteristics(HANDLE hDevice, LPVOID Service, WORD CharacteristicsBufferCount, LPVOID CharacteristicsBuffer, LPVOID CharacteristicsBufferActual, DWORD Flags)');
# my $ret = $BluetoothGATTGetCharacteristics->Call($hDevice, $Service, $CharacteristicsBufferCount, $CharacteristicsBuffer, $CharacteristicsBufferActual, $Flags);
# hDevice : HANDLE -> HANDLE
# Service : BTH_LE_GATT_SERVICE* optional -> LPVOID
# CharacteristicsBufferCount : WORD -> WORD
# CharacteristicsBuffer : BTH_LE_GATT_CHARACTERISTIC* optional, out -> LPVOID
# CharacteristicsBufferActual : WORD* out -> LPVOID
# Flags : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。