ホーム › Devices.Bluetooth › BluetoothGATTGetIncludedServices
BluetoothGATTGetIncludedServices
関数指定サービスに含まれるGATTインクルードサービスを取得する。
シグネチャ
// BluetoothApis.dll
#include <windows.h>
HRESULT BluetoothGATTGetIncludedServices(
HANDLE hDevice,
BTH_LE_GATT_SERVICE* ParentService, // optional
WORD IncludedServicesBufferCount,
BTH_LE_GATT_SERVICE* IncludedServicesBuffer, // optional
WORD* IncludedServicesBufferActual,
DWORD Flags
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hDevice | HANDLE | in | インクルードサービスを取得する対象BLEデバイスのハンドル。 |
| ParentService | BTH_LE_GATT_SERVICE* | inoptional | インクルード元となる親サービスの構造体ポインタ。 |
| IncludedServicesBufferCount | WORD | in | バッファが格納できる要素数。サイズ照会時は0。 |
| IncludedServicesBuffer | BTH_LE_GATT_SERVICE* | outoptional | 取得したインクルードサービス情報を受け取る配列ポインタ。サイズ照会時はNULL。 |
| IncludedServicesBufferActual | WORD* | out | 実際のインクルードサービス数を受け取る出力ポインタ。 |
| Flags | DWORD | in | 取得動作を制御するフラグ。BLUETOOTH_GATT_FLAG_NONE等。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// BluetoothApis.dll
#include <windows.h>
HRESULT BluetoothGATTGetIncludedServices(
HANDLE hDevice,
BTH_LE_GATT_SERVICE* ParentService, // optional
WORD IncludedServicesBufferCount,
BTH_LE_GATT_SERVICE* IncludedServicesBuffer, // optional
WORD* IncludedServicesBufferActual,
DWORD Flags
);[DllImport("BluetoothApis.dll", ExactSpelling = true)]
static extern int BluetoothGATTGetIncludedServices(
IntPtr hDevice, // HANDLE
IntPtr ParentService, // BTH_LE_GATT_SERVICE* optional
ushort IncludedServicesBufferCount, // WORD
IntPtr IncludedServicesBuffer, // BTH_LE_GATT_SERVICE* optional, out
out ushort IncludedServicesBufferActual, // WORD* out
uint Flags // DWORD
);<DllImport("BluetoothApis.dll", ExactSpelling:=True)>
Public Shared Function BluetoothGATTGetIncludedServices(
hDevice As IntPtr, ' HANDLE
ParentService As IntPtr, ' BTH_LE_GATT_SERVICE* optional
IncludedServicesBufferCount As UShort, ' WORD
IncludedServicesBuffer As IntPtr, ' BTH_LE_GATT_SERVICE* optional, out
<Out> ByRef IncludedServicesBufferActual As UShort, ' WORD* out
Flags As UInteger ' DWORD
) As Integer
End Function' hDevice : HANDLE
' ParentService : BTH_LE_GATT_SERVICE* optional
' IncludedServicesBufferCount : WORD
' IncludedServicesBuffer : BTH_LE_GATT_SERVICE* optional, out
' IncludedServicesBufferActual : WORD* out
' Flags : DWORD
Declare PtrSafe Function BluetoothGATTGetIncludedServices Lib "bluetoothapis" ( _
ByVal hDevice As LongPtr, _
ByVal ParentService As LongPtr, _
ByVal IncludedServicesBufferCount As Integer, _
ByVal IncludedServicesBuffer As LongPtr, _
ByRef IncludedServicesBufferActual 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
BluetoothGATTGetIncludedServices = ctypes.windll.bluetoothapis.BluetoothGATTGetIncludedServices
BluetoothGATTGetIncludedServices.restype = ctypes.c_int
BluetoothGATTGetIncludedServices.argtypes = [
wintypes.HANDLE, # hDevice : HANDLE
ctypes.c_void_p, # ParentService : BTH_LE_GATT_SERVICE* optional
ctypes.c_ushort, # IncludedServicesBufferCount : WORD
ctypes.c_void_p, # IncludedServicesBuffer : BTH_LE_GATT_SERVICE* optional, out
ctypes.POINTER(ctypes.c_ushort), # IncludedServicesBufferActual : WORD* out
wintypes.DWORD, # Flags : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('BluetoothApis.dll')
BluetoothGATTGetIncludedServices = Fiddle::Function.new(
lib['BluetoothGATTGetIncludedServices'],
[
Fiddle::TYPE_VOIDP, # hDevice : HANDLE
Fiddle::TYPE_VOIDP, # ParentService : BTH_LE_GATT_SERVICE* optional
-Fiddle::TYPE_SHORT, # IncludedServicesBufferCount : WORD
Fiddle::TYPE_VOIDP, # IncludedServicesBuffer : BTH_LE_GATT_SERVICE* optional, out
Fiddle::TYPE_VOIDP, # IncludedServicesBufferActual : WORD* out
-Fiddle::TYPE_INT, # Flags : DWORD
],
Fiddle::TYPE_INT)#[link(name = "bluetoothapis")]
extern "system" {
fn BluetoothGATTGetIncludedServices(
hDevice: *mut core::ffi::c_void, // HANDLE
ParentService: *mut BTH_LE_GATT_SERVICE, // BTH_LE_GATT_SERVICE* optional
IncludedServicesBufferCount: u16, // WORD
IncludedServicesBuffer: *mut BTH_LE_GATT_SERVICE, // BTH_LE_GATT_SERVICE* optional, out
IncludedServicesBufferActual: *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 BluetoothGATTGetIncludedServices(IntPtr hDevice, IntPtr ParentService, ushort IncludedServicesBufferCount, IntPtr IncludedServicesBuffer, out ushort IncludedServicesBufferActual, uint Flags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'BluetoothApis_BluetoothGATTGetIncludedServices' -Namespace Win32 -PassThru
# $api::BluetoothGATTGetIncludedServices(hDevice, ParentService, IncludedServicesBufferCount, IncludedServicesBuffer, IncludedServicesBufferActual, Flags)#uselib "BluetoothApis.dll"
#func global BluetoothGATTGetIncludedServices "BluetoothGATTGetIncludedServices" sptr, sptr, sptr, sptr, sptr, sptr
; BluetoothGATTGetIncludedServices hDevice, varptr(ParentService), IncludedServicesBufferCount, varptr(IncludedServicesBuffer), varptr(IncludedServicesBufferActual), Flags ; 戻り値は stat
; hDevice : HANDLE -> "sptr"
; ParentService : BTH_LE_GATT_SERVICE* optional -> "sptr"
; IncludedServicesBufferCount : WORD -> "sptr"
; IncludedServicesBuffer : BTH_LE_GATT_SERVICE* optional, out -> "sptr"
; IncludedServicesBufferActual : WORD* out -> "sptr"
; Flags : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "BluetoothApis.dll" #cfunc global BluetoothGATTGetIncludedServices "BluetoothGATTGetIncludedServices" sptr, var, int, var, var, int ; res = BluetoothGATTGetIncludedServices(hDevice, ParentService, IncludedServicesBufferCount, IncludedServicesBuffer, IncludedServicesBufferActual, Flags) ; hDevice : HANDLE -> "sptr" ; ParentService : BTH_LE_GATT_SERVICE* optional -> "var" ; IncludedServicesBufferCount : WORD -> "int" ; IncludedServicesBuffer : BTH_LE_GATT_SERVICE* optional, out -> "var" ; IncludedServicesBufferActual : WORD* out -> "var" ; Flags : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "BluetoothApis.dll" #cfunc global BluetoothGATTGetIncludedServices "BluetoothGATTGetIncludedServices" sptr, sptr, int, sptr, sptr, int ; res = BluetoothGATTGetIncludedServices(hDevice, varptr(ParentService), IncludedServicesBufferCount, varptr(IncludedServicesBuffer), varptr(IncludedServicesBufferActual), Flags) ; hDevice : HANDLE -> "sptr" ; ParentService : BTH_LE_GATT_SERVICE* optional -> "sptr" ; IncludedServicesBufferCount : WORD -> "int" ; IncludedServicesBuffer : BTH_LE_GATT_SERVICE* optional, out -> "sptr" ; IncludedServicesBufferActual : WORD* out -> "sptr" ; Flags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT BluetoothGATTGetIncludedServices(HANDLE hDevice, BTH_LE_GATT_SERVICE* ParentService, WORD IncludedServicesBufferCount, BTH_LE_GATT_SERVICE* IncludedServicesBuffer, WORD* IncludedServicesBufferActual, DWORD Flags) #uselib "BluetoothApis.dll" #cfunc global BluetoothGATTGetIncludedServices "BluetoothGATTGetIncludedServices" intptr, var, int, var, var, int ; res = BluetoothGATTGetIncludedServices(hDevice, ParentService, IncludedServicesBufferCount, IncludedServicesBuffer, IncludedServicesBufferActual, Flags) ; hDevice : HANDLE -> "intptr" ; ParentService : BTH_LE_GATT_SERVICE* optional -> "var" ; IncludedServicesBufferCount : WORD -> "int" ; IncludedServicesBuffer : BTH_LE_GATT_SERVICE* optional, out -> "var" ; IncludedServicesBufferActual : WORD* out -> "var" ; Flags : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT BluetoothGATTGetIncludedServices(HANDLE hDevice, BTH_LE_GATT_SERVICE* ParentService, WORD IncludedServicesBufferCount, BTH_LE_GATT_SERVICE* IncludedServicesBuffer, WORD* IncludedServicesBufferActual, DWORD Flags) #uselib "BluetoothApis.dll" #cfunc global BluetoothGATTGetIncludedServices "BluetoothGATTGetIncludedServices" intptr, intptr, int, intptr, intptr, int ; res = BluetoothGATTGetIncludedServices(hDevice, varptr(ParentService), IncludedServicesBufferCount, varptr(IncludedServicesBuffer), varptr(IncludedServicesBufferActual), Flags) ; hDevice : HANDLE -> "intptr" ; ParentService : BTH_LE_GATT_SERVICE* optional -> "intptr" ; IncludedServicesBufferCount : WORD -> "int" ; IncludedServicesBuffer : BTH_LE_GATT_SERVICE* optional, out -> "intptr" ; IncludedServicesBufferActual : WORD* out -> "intptr" ; Flags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
bluetoothapis = windows.NewLazySystemDLL("BluetoothApis.dll")
procBluetoothGATTGetIncludedServices = bluetoothapis.NewProc("BluetoothGATTGetIncludedServices")
)
// hDevice (HANDLE), ParentService (BTH_LE_GATT_SERVICE* optional), IncludedServicesBufferCount (WORD), IncludedServicesBuffer (BTH_LE_GATT_SERVICE* optional, out), IncludedServicesBufferActual (WORD* out), Flags (DWORD)
r1, _, err := procBluetoothGATTGetIncludedServices.Call(
uintptr(hDevice),
uintptr(ParentService),
uintptr(IncludedServicesBufferCount),
uintptr(IncludedServicesBuffer),
uintptr(IncludedServicesBufferActual),
uintptr(Flags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction BluetoothGATTGetIncludedServices(
hDevice: THandle; // HANDLE
ParentService: Pointer; // BTH_LE_GATT_SERVICE* optional
IncludedServicesBufferCount: Word; // WORD
IncludedServicesBuffer: Pointer; // BTH_LE_GATT_SERVICE* optional, out
IncludedServicesBufferActual: Pointer; // WORD* out
Flags: DWORD // DWORD
): Integer; stdcall;
external 'BluetoothApis.dll' name 'BluetoothGATTGetIncludedServices';result := DllCall("BluetoothApis\BluetoothGATTGetIncludedServices"
, "Ptr", hDevice ; HANDLE
, "Ptr", ParentService ; BTH_LE_GATT_SERVICE* optional
, "UShort", IncludedServicesBufferCount ; WORD
, "Ptr", IncludedServicesBuffer ; BTH_LE_GATT_SERVICE* optional, out
, "Ptr", IncludedServicesBufferActual ; WORD* out
, "UInt", Flags ; DWORD
, "Int") ; return: HRESULT●BluetoothGATTGetIncludedServices(hDevice, ParentService, IncludedServicesBufferCount, IncludedServicesBuffer, IncludedServicesBufferActual, Flags) = DLL("BluetoothApis.dll", "int BluetoothGATTGetIncludedServices(void*, void*, int, void*, void*, dword)")
# 呼び出し: BluetoothGATTGetIncludedServices(hDevice, ParentService, IncludedServicesBufferCount, IncludedServicesBuffer, IncludedServicesBufferActual, Flags)
# hDevice : HANDLE -> "void*"
# ParentService : BTH_LE_GATT_SERVICE* optional -> "void*"
# IncludedServicesBufferCount : WORD -> "int"
# IncludedServicesBuffer : BTH_LE_GATT_SERVICE* optional, out -> "void*"
# IncludedServicesBufferActual : WORD* out -> "void*"
# Flags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "bluetoothapis" fn BluetoothGATTGetIncludedServices(
hDevice: ?*anyopaque, // HANDLE
ParentService: [*c]BTH_LE_GATT_SERVICE, // BTH_LE_GATT_SERVICE* optional
IncludedServicesBufferCount: u16, // WORD
IncludedServicesBuffer: [*c]BTH_LE_GATT_SERVICE, // BTH_LE_GATT_SERVICE* optional, out
IncludedServicesBufferActual: [*c]u16, // WORD* out
Flags: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;proc BluetoothGATTGetIncludedServices(
hDevice: pointer, # HANDLE
ParentService: ptr BTH_LE_GATT_SERVICE, # BTH_LE_GATT_SERVICE* optional
IncludedServicesBufferCount: uint16, # WORD
IncludedServicesBuffer: ptr BTH_LE_GATT_SERVICE, # BTH_LE_GATT_SERVICE* optional, out
IncludedServicesBufferActual: ptr uint16, # WORD* out
Flags: uint32 # DWORD
): int32 {.importc: "BluetoothGATTGetIncludedServices", stdcall, dynlib: "BluetoothApis.dll".}pragma(lib, "bluetoothapis");
extern(Windows)
int BluetoothGATTGetIncludedServices(
void* hDevice, // HANDLE
BTH_LE_GATT_SERVICE* ParentService, // BTH_LE_GATT_SERVICE* optional
ushort IncludedServicesBufferCount, // WORD
BTH_LE_GATT_SERVICE* IncludedServicesBuffer, // BTH_LE_GATT_SERVICE* optional, out
ushort* IncludedServicesBufferActual, // WORD* out
uint Flags // DWORD
);ccall((:BluetoothGATTGetIncludedServices, "BluetoothApis.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{BTH_LE_GATT_SERVICE}, UInt16, Ptr{BTH_LE_GATT_SERVICE}, Ptr{UInt16}, UInt32),
hDevice, ParentService, IncludedServicesBufferCount, IncludedServicesBuffer, IncludedServicesBufferActual, Flags)
# hDevice : HANDLE -> Ptr{Cvoid}
# ParentService : BTH_LE_GATT_SERVICE* optional -> Ptr{BTH_LE_GATT_SERVICE}
# IncludedServicesBufferCount : WORD -> UInt16
# IncludedServicesBuffer : BTH_LE_GATT_SERVICE* optional, out -> Ptr{BTH_LE_GATT_SERVICE}
# IncludedServicesBufferActual : WORD* out -> Ptr{UInt16}
# Flags : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t BluetoothGATTGetIncludedServices(
void* hDevice,
void* ParentService,
uint16_t IncludedServicesBufferCount,
void* IncludedServicesBuffer,
uint16_t* IncludedServicesBufferActual,
uint32_t Flags);
]]
local bluetoothapis = ffi.load("bluetoothapis")
-- bluetoothapis.BluetoothGATTGetIncludedServices(hDevice, ParentService, IncludedServicesBufferCount, IncludedServicesBuffer, IncludedServicesBufferActual, Flags)
-- hDevice : HANDLE
-- ParentService : BTH_LE_GATT_SERVICE* optional
-- IncludedServicesBufferCount : WORD
-- IncludedServicesBuffer : BTH_LE_GATT_SERVICE* optional, out
-- IncludedServicesBufferActual : WORD* out
-- Flags : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('BluetoothApis.dll');
const BluetoothGATTGetIncludedServices = lib.func('__stdcall', 'BluetoothGATTGetIncludedServices', 'int32_t', ['void *', 'void *', 'uint16_t', 'void *', 'uint16_t *', 'uint32_t']);
// BluetoothGATTGetIncludedServices(hDevice, ParentService, IncludedServicesBufferCount, IncludedServicesBuffer, IncludedServicesBufferActual, Flags)
// hDevice : HANDLE -> 'void *'
// ParentService : BTH_LE_GATT_SERVICE* optional -> 'void *'
// IncludedServicesBufferCount : WORD -> 'uint16_t'
// IncludedServicesBuffer : BTH_LE_GATT_SERVICE* optional, out -> 'void *'
// IncludedServicesBufferActual : WORD* out -> 'uint16_t *'
// Flags : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("BluetoothApis.dll", {
BluetoothGATTGetIncludedServices: { parameters: ["pointer", "pointer", "u16", "pointer", "pointer", "u32"], result: "i32" },
});
// lib.symbols.BluetoothGATTGetIncludedServices(hDevice, ParentService, IncludedServicesBufferCount, IncludedServicesBuffer, IncludedServicesBufferActual, Flags)
// hDevice : HANDLE -> "pointer"
// ParentService : BTH_LE_GATT_SERVICE* optional -> "pointer"
// IncludedServicesBufferCount : WORD -> "u16"
// IncludedServicesBuffer : BTH_LE_GATT_SERVICE* optional, out -> "pointer"
// IncludedServicesBufferActual : WORD* out -> "pointer"
// Flags : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t BluetoothGATTGetIncludedServices(
void* hDevice,
void* ParentService,
uint16_t IncludedServicesBufferCount,
void* IncludedServicesBuffer,
uint16_t* IncludedServicesBufferActual,
uint32_t Flags);
C, "BluetoothApis.dll");
// $ffi->BluetoothGATTGetIncludedServices(hDevice, ParentService, IncludedServicesBufferCount, IncludedServicesBuffer, IncludedServicesBufferActual, Flags);
// hDevice : HANDLE
// ParentService : BTH_LE_GATT_SERVICE* optional
// IncludedServicesBufferCount : WORD
// IncludedServicesBuffer : BTH_LE_GATT_SERVICE* optional, out
// IncludedServicesBufferActual : 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 BluetoothGATTGetIncludedServices(
Pointer hDevice, // HANDLE
Pointer ParentService, // BTH_LE_GATT_SERVICE* optional
short IncludedServicesBufferCount, // WORD
Pointer IncludedServicesBuffer, // BTH_LE_GATT_SERVICE* optional, out
ShortByReference IncludedServicesBufferActual, // WORD* out
int Flags // DWORD
);
}@[Link("bluetoothapis")]
lib LibBluetoothApis
fun BluetoothGATTGetIncludedServices = BluetoothGATTGetIncludedServices(
hDevice : Void*, # HANDLE
ParentService : BTH_LE_GATT_SERVICE*, # BTH_LE_GATT_SERVICE* optional
IncludedServicesBufferCount : UInt16, # WORD
IncludedServicesBuffer : BTH_LE_GATT_SERVICE*, # BTH_LE_GATT_SERVICE* optional, out
IncludedServicesBufferActual : 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 BluetoothGATTGetIncludedServicesNative = Int32 Function(Pointer<Void>, Pointer<Void>, Uint16, Pointer<Void>, Pointer<Uint16>, Uint32);
typedef BluetoothGATTGetIncludedServicesDart = int Function(Pointer<Void>, Pointer<Void>, int, Pointer<Void>, Pointer<Uint16>, int);
final BluetoothGATTGetIncludedServices = DynamicLibrary.open('BluetoothApis.dll')
.lookupFunction<BluetoothGATTGetIncludedServicesNative, BluetoothGATTGetIncludedServicesDart>('BluetoothGATTGetIncludedServices');
// hDevice : HANDLE -> Pointer<Void>
// ParentService : BTH_LE_GATT_SERVICE* optional -> Pointer<Void>
// IncludedServicesBufferCount : WORD -> Uint16
// IncludedServicesBuffer : BTH_LE_GATT_SERVICE* optional, out -> Pointer<Void>
// IncludedServicesBufferActual : WORD* out -> Pointer<Uint16>
// Flags : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function BluetoothGATTGetIncludedServices(
hDevice: THandle; // HANDLE
ParentService: Pointer; // BTH_LE_GATT_SERVICE* optional
IncludedServicesBufferCount: Word; // WORD
IncludedServicesBuffer: Pointer; // BTH_LE_GATT_SERVICE* optional, out
IncludedServicesBufferActual: Pointer; // WORD* out
Flags: DWORD // DWORD
): Integer; stdcall;
external 'BluetoothApis.dll' name 'BluetoothGATTGetIncludedServices';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "BluetoothGATTGetIncludedServices"
c_BluetoothGATTGetIncludedServices :: Ptr () -> Ptr () -> Word16 -> Ptr () -> Ptr Word16 -> Word32 -> IO Int32
-- hDevice : HANDLE -> Ptr ()
-- ParentService : BTH_LE_GATT_SERVICE* optional -> Ptr ()
-- IncludedServicesBufferCount : WORD -> Word16
-- IncludedServicesBuffer : BTH_LE_GATT_SERVICE* optional, out -> Ptr ()
-- IncludedServicesBufferActual : WORD* out -> Ptr Word16
-- Flags : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let bluetoothgattgetincludedservices =
foreign "BluetoothGATTGetIncludedServices"
((ptr void) @-> (ptr void) @-> uint16_t @-> (ptr void) @-> (ptr uint16_t) @-> uint32_t @-> returning int32_t)
(* hDevice : HANDLE -> (ptr void) *)
(* ParentService : BTH_LE_GATT_SERVICE* optional -> (ptr void) *)
(* IncludedServicesBufferCount : WORD -> uint16_t *)
(* IncludedServicesBuffer : BTH_LE_GATT_SERVICE* optional, out -> (ptr void) *)
(* IncludedServicesBufferActual : 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 ("BluetoothGATTGetIncludedServices" bluetooth-gattget-included-services :convention :stdcall) :int32
(h-device :pointer) ; HANDLE
(parent-service :pointer) ; BTH_LE_GATT_SERVICE* optional
(included-services-buffer-count :uint16) ; WORD
(included-services-buffer :pointer) ; BTH_LE_GATT_SERVICE* optional, out
(included-services-buffer-actual :pointer) ; WORD* out
(flags :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $BluetoothGATTGetIncludedServices = Win32::API::More->new('BluetoothApis',
'int BluetoothGATTGetIncludedServices(HANDLE hDevice, LPVOID ParentService, WORD IncludedServicesBufferCount, LPVOID IncludedServicesBuffer, LPVOID IncludedServicesBufferActual, DWORD Flags)');
# my $ret = $BluetoothGATTGetIncludedServices->Call($hDevice, $ParentService, $IncludedServicesBufferCount, $IncludedServicesBuffer, $IncludedServicesBufferActual, $Flags);
# hDevice : HANDLE -> HANDLE
# ParentService : BTH_LE_GATT_SERVICE* optional -> LPVOID
# IncludedServicesBufferCount : WORD -> WORD
# IncludedServicesBuffer : BTH_LE_GATT_SERVICE* optional, out -> LPVOID
# IncludedServicesBufferActual : WORD* out -> LPVOID
# Flags : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。