ホーム › Devices.Bluetooth › BluetoothGATTSetCharacteristicValue
BluetoothGATTSetCharacteristicValue
関数GATTキャラクタリスティックに値を書き込む。
シグネチャ
// BluetoothApis.dll
#include <windows.h>
HRESULT BluetoothGATTSetCharacteristicValue(
HANDLE hDevice,
BTH_LE_GATT_CHARACTERISTIC* Characteristic,
BTH_LE_GATT_CHARACTERISTIC_VALUE* CharacteristicValue,
ULONGLONG ReliableWriteContext, // optional
DWORD Flags
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hDevice | HANDLE | in | キャラクタリスティック値を書き込む対象BLEデバイスのハンドル。 |
| Characteristic | BTH_LE_GATT_CHARACTERISTIC* | in | 値を書き込む対象キャラクタリスティックの構造体ポインタ。 |
| CharacteristicValue | BTH_LE_GATT_CHARACTERISTIC_VALUE* | in | 書き込む値を保持する構造体ポインタ。 |
| ReliableWriteContext | ULONGLONG | inoptional | 信頼性書き込み時のトランザクションコンテキスト。単発書き込み時は0。 |
| Flags | DWORD | in | 書き込み動作を制御するフラグ。応答要求/応答不要等。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// BluetoothApis.dll
#include <windows.h>
HRESULT BluetoothGATTSetCharacteristicValue(
HANDLE hDevice,
BTH_LE_GATT_CHARACTERISTIC* Characteristic,
BTH_LE_GATT_CHARACTERISTIC_VALUE* CharacteristicValue,
ULONGLONG ReliableWriteContext, // optional
DWORD Flags
);[DllImport("BluetoothApis.dll", ExactSpelling = true)]
static extern int BluetoothGATTSetCharacteristicValue(
IntPtr hDevice, // HANDLE
IntPtr Characteristic, // BTH_LE_GATT_CHARACTERISTIC*
IntPtr CharacteristicValue, // BTH_LE_GATT_CHARACTERISTIC_VALUE*
ulong ReliableWriteContext, // ULONGLONG optional
uint Flags // DWORD
);<DllImport("BluetoothApis.dll", ExactSpelling:=True)>
Public Shared Function BluetoothGATTSetCharacteristicValue(
hDevice As IntPtr, ' HANDLE
Characteristic As IntPtr, ' BTH_LE_GATT_CHARACTERISTIC*
CharacteristicValue As IntPtr, ' BTH_LE_GATT_CHARACTERISTIC_VALUE*
ReliableWriteContext As ULong, ' ULONGLONG optional
Flags As UInteger ' DWORD
) As Integer
End Function' hDevice : HANDLE
' Characteristic : BTH_LE_GATT_CHARACTERISTIC*
' CharacteristicValue : BTH_LE_GATT_CHARACTERISTIC_VALUE*
' ReliableWriteContext : ULONGLONG optional
' Flags : DWORD
Declare PtrSafe Function BluetoothGATTSetCharacteristicValue Lib "bluetoothapis" ( _
ByVal hDevice As LongPtr, _
ByVal Characteristic As LongPtr, _
ByVal CharacteristicValue As LongPtr, _
ByVal ReliableWriteContext As LongLong, _
ByVal Flags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
BluetoothGATTSetCharacteristicValue = ctypes.windll.bluetoothapis.BluetoothGATTSetCharacteristicValue
BluetoothGATTSetCharacteristicValue.restype = ctypes.c_int
BluetoothGATTSetCharacteristicValue.argtypes = [
wintypes.HANDLE, # hDevice : HANDLE
ctypes.c_void_p, # Characteristic : BTH_LE_GATT_CHARACTERISTIC*
ctypes.c_void_p, # CharacteristicValue : BTH_LE_GATT_CHARACTERISTIC_VALUE*
ctypes.c_ulonglong, # ReliableWriteContext : ULONGLONG optional
wintypes.DWORD, # Flags : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('BluetoothApis.dll')
BluetoothGATTSetCharacteristicValue = Fiddle::Function.new(
lib['BluetoothGATTSetCharacteristicValue'],
[
Fiddle::TYPE_VOIDP, # hDevice : HANDLE
Fiddle::TYPE_VOIDP, # Characteristic : BTH_LE_GATT_CHARACTERISTIC*
Fiddle::TYPE_VOIDP, # CharacteristicValue : BTH_LE_GATT_CHARACTERISTIC_VALUE*
-Fiddle::TYPE_LONG_LONG, # ReliableWriteContext : ULONGLONG optional
-Fiddle::TYPE_INT, # Flags : DWORD
],
Fiddle::TYPE_INT)#[link(name = "bluetoothapis")]
extern "system" {
fn BluetoothGATTSetCharacteristicValue(
hDevice: *mut core::ffi::c_void, // HANDLE
Characteristic: *mut BTH_LE_GATT_CHARACTERISTIC, // BTH_LE_GATT_CHARACTERISTIC*
CharacteristicValue: *mut BTH_LE_GATT_CHARACTERISTIC_VALUE, // BTH_LE_GATT_CHARACTERISTIC_VALUE*
ReliableWriteContext: u64, // ULONGLONG optional
Flags: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("BluetoothApis.dll")]
public static extern int BluetoothGATTSetCharacteristicValue(IntPtr hDevice, IntPtr Characteristic, IntPtr CharacteristicValue, ulong ReliableWriteContext, uint Flags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'BluetoothApis_BluetoothGATTSetCharacteristicValue' -Namespace Win32 -PassThru
# $api::BluetoothGATTSetCharacteristicValue(hDevice, Characteristic, CharacteristicValue, ReliableWriteContext, Flags)#uselib "BluetoothApis.dll"
#func global BluetoothGATTSetCharacteristicValue "BluetoothGATTSetCharacteristicValue" sptr, sptr, sptr, sptr, sptr
; BluetoothGATTSetCharacteristicValue hDevice, varptr(Characteristic), varptr(CharacteristicValue), ReliableWriteContext, Flags ; 戻り値は stat
; hDevice : HANDLE -> "sptr"
; Characteristic : BTH_LE_GATT_CHARACTERISTIC* -> "sptr"
; CharacteristicValue : BTH_LE_GATT_CHARACTERISTIC_VALUE* -> "sptr"
; ReliableWriteContext : ULONGLONG optional -> "sptr"
; Flags : DWORD -> "sptr"
; ※HSP3.7は int64 引数(64bit値渡し)に非対応です。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "BluetoothApis.dll" #cfunc global BluetoothGATTSetCharacteristicValue "BluetoothGATTSetCharacteristicValue" sptr, var, var, int64, int ; res = BluetoothGATTSetCharacteristicValue(hDevice, Characteristic, CharacteristicValue, ReliableWriteContext, Flags) ; hDevice : HANDLE -> "sptr" ; Characteristic : BTH_LE_GATT_CHARACTERISTIC* -> "var" ; CharacteristicValue : BTH_LE_GATT_CHARACTERISTIC_VALUE* -> "var" ; ReliableWriteContext : ULONGLONG optional -> "int64" ; Flags : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。 ; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。#uselib "BluetoothApis.dll" #cfunc global BluetoothGATTSetCharacteristicValue "BluetoothGATTSetCharacteristicValue" sptr, sptr, sptr, int64, int ; res = BluetoothGATTSetCharacteristicValue(hDevice, varptr(Characteristic), varptr(CharacteristicValue), ReliableWriteContext, Flags) ; hDevice : HANDLE -> "sptr" ; Characteristic : BTH_LE_GATT_CHARACTERISTIC* -> "sptr" ; CharacteristicValue : BTH_LE_GATT_CHARACTERISTIC_VALUE* -> "sptr" ; ReliableWriteContext : ULONGLONG optional -> "int64" ; Flags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。 ; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。
出力引数:
; HRESULT BluetoothGATTSetCharacteristicValue(HANDLE hDevice, BTH_LE_GATT_CHARACTERISTIC* Characteristic, BTH_LE_GATT_CHARACTERISTIC_VALUE* CharacteristicValue, ULONGLONG ReliableWriteContext, DWORD Flags) #uselib "BluetoothApis.dll" #cfunc global BluetoothGATTSetCharacteristicValue "BluetoothGATTSetCharacteristicValue" intptr, var, var, int64, int ; res = BluetoothGATTSetCharacteristicValue(hDevice, Characteristic, CharacteristicValue, ReliableWriteContext, Flags) ; hDevice : HANDLE -> "intptr" ; Characteristic : BTH_LE_GATT_CHARACTERISTIC* -> "var" ; CharacteristicValue : BTH_LE_GATT_CHARACTERISTIC_VALUE* -> "var" ; ReliableWriteContext : ULONGLONG optional -> "int64" ; Flags : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT BluetoothGATTSetCharacteristicValue(HANDLE hDevice, BTH_LE_GATT_CHARACTERISTIC* Characteristic, BTH_LE_GATT_CHARACTERISTIC_VALUE* CharacteristicValue, ULONGLONG ReliableWriteContext, DWORD Flags) #uselib "BluetoothApis.dll" #cfunc global BluetoothGATTSetCharacteristicValue "BluetoothGATTSetCharacteristicValue" intptr, intptr, intptr, int64, int ; res = BluetoothGATTSetCharacteristicValue(hDevice, varptr(Characteristic), varptr(CharacteristicValue), ReliableWriteContext, Flags) ; hDevice : HANDLE -> "intptr" ; Characteristic : BTH_LE_GATT_CHARACTERISTIC* -> "intptr" ; CharacteristicValue : BTH_LE_GATT_CHARACTERISTIC_VALUE* -> "intptr" ; ReliableWriteContext : ULONGLONG optional -> "int64" ; Flags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
bluetoothapis = windows.NewLazySystemDLL("BluetoothApis.dll")
procBluetoothGATTSetCharacteristicValue = bluetoothapis.NewProc("BluetoothGATTSetCharacteristicValue")
)
// hDevice (HANDLE), Characteristic (BTH_LE_GATT_CHARACTERISTIC*), CharacteristicValue (BTH_LE_GATT_CHARACTERISTIC_VALUE*), ReliableWriteContext (ULONGLONG optional), Flags (DWORD)
r1, _, err := procBluetoothGATTSetCharacteristicValue.Call(
uintptr(hDevice),
uintptr(Characteristic),
uintptr(CharacteristicValue),
uintptr(ReliableWriteContext),
uintptr(Flags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction BluetoothGATTSetCharacteristicValue(
hDevice: THandle; // HANDLE
Characteristic: Pointer; // BTH_LE_GATT_CHARACTERISTIC*
CharacteristicValue: Pointer; // BTH_LE_GATT_CHARACTERISTIC_VALUE*
ReliableWriteContext: UInt64; // ULONGLONG optional
Flags: DWORD // DWORD
): Integer; stdcall;
external 'BluetoothApis.dll' name 'BluetoothGATTSetCharacteristicValue';result := DllCall("BluetoothApis\BluetoothGATTSetCharacteristicValue"
, "Ptr", hDevice ; HANDLE
, "Ptr", Characteristic ; BTH_LE_GATT_CHARACTERISTIC*
, "Ptr", CharacteristicValue ; BTH_LE_GATT_CHARACTERISTIC_VALUE*
, "Int64", ReliableWriteContext ; ULONGLONG optional
, "UInt", Flags ; DWORD
, "Int") ; return: HRESULT●BluetoothGATTSetCharacteristicValue(hDevice, Characteristic, CharacteristicValue, ReliableWriteContext, Flags) = DLL("BluetoothApis.dll", "int BluetoothGATTSetCharacteristicValue(void*, void*, void*, qword, dword)")
# 呼び出し: BluetoothGATTSetCharacteristicValue(hDevice, Characteristic, CharacteristicValue, ReliableWriteContext, Flags)
# hDevice : HANDLE -> "void*"
# Characteristic : BTH_LE_GATT_CHARACTERISTIC* -> "void*"
# CharacteristicValue : BTH_LE_GATT_CHARACTERISTIC_VALUE* -> "void*"
# ReliableWriteContext : ULONGLONG optional -> "qword"
# Flags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "bluetoothapis" fn BluetoothGATTSetCharacteristicValue(
hDevice: ?*anyopaque, // HANDLE
Characteristic: [*c]BTH_LE_GATT_CHARACTERISTIC, // BTH_LE_GATT_CHARACTERISTIC*
CharacteristicValue: [*c]BTH_LE_GATT_CHARACTERISTIC_VALUE, // BTH_LE_GATT_CHARACTERISTIC_VALUE*
ReliableWriteContext: u64, // ULONGLONG optional
Flags: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;proc BluetoothGATTSetCharacteristicValue(
hDevice: pointer, # HANDLE
Characteristic: ptr BTH_LE_GATT_CHARACTERISTIC, # BTH_LE_GATT_CHARACTERISTIC*
CharacteristicValue: ptr BTH_LE_GATT_CHARACTERISTIC_VALUE, # BTH_LE_GATT_CHARACTERISTIC_VALUE*
ReliableWriteContext: uint64, # ULONGLONG optional
Flags: uint32 # DWORD
): int32 {.importc: "BluetoothGATTSetCharacteristicValue", stdcall, dynlib: "BluetoothApis.dll".}pragma(lib, "bluetoothapis");
extern(Windows)
int BluetoothGATTSetCharacteristicValue(
void* hDevice, // HANDLE
BTH_LE_GATT_CHARACTERISTIC* Characteristic, // BTH_LE_GATT_CHARACTERISTIC*
BTH_LE_GATT_CHARACTERISTIC_VALUE* CharacteristicValue, // BTH_LE_GATT_CHARACTERISTIC_VALUE*
ulong ReliableWriteContext, // ULONGLONG optional
uint Flags // DWORD
);ccall((:BluetoothGATTSetCharacteristicValue, "BluetoothApis.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{BTH_LE_GATT_CHARACTERISTIC}, Ptr{BTH_LE_GATT_CHARACTERISTIC_VALUE}, UInt64, UInt32),
hDevice, Characteristic, CharacteristicValue, ReliableWriteContext, Flags)
# hDevice : HANDLE -> Ptr{Cvoid}
# Characteristic : BTH_LE_GATT_CHARACTERISTIC* -> Ptr{BTH_LE_GATT_CHARACTERISTIC}
# CharacteristicValue : BTH_LE_GATT_CHARACTERISTIC_VALUE* -> Ptr{BTH_LE_GATT_CHARACTERISTIC_VALUE}
# ReliableWriteContext : ULONGLONG optional -> UInt64
# Flags : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t BluetoothGATTSetCharacteristicValue(
void* hDevice,
void* Characteristic,
void* CharacteristicValue,
uint64_t ReliableWriteContext,
uint32_t Flags);
]]
local bluetoothapis = ffi.load("bluetoothapis")
-- bluetoothapis.BluetoothGATTSetCharacteristicValue(hDevice, Characteristic, CharacteristicValue, ReliableWriteContext, Flags)
-- hDevice : HANDLE
-- Characteristic : BTH_LE_GATT_CHARACTERISTIC*
-- CharacteristicValue : BTH_LE_GATT_CHARACTERISTIC_VALUE*
-- ReliableWriteContext : ULONGLONG optional
-- Flags : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('BluetoothApis.dll');
const BluetoothGATTSetCharacteristicValue = lib.func('__stdcall', 'BluetoothGATTSetCharacteristicValue', 'int32_t', ['void *', 'void *', 'void *', 'uint64_t', 'uint32_t']);
// BluetoothGATTSetCharacteristicValue(hDevice, Characteristic, CharacteristicValue, ReliableWriteContext, Flags)
// hDevice : HANDLE -> 'void *'
// Characteristic : BTH_LE_GATT_CHARACTERISTIC* -> 'void *'
// CharacteristicValue : BTH_LE_GATT_CHARACTERISTIC_VALUE* -> 'void *'
// ReliableWriteContext : ULONGLONG optional -> 'uint64_t'
// Flags : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("BluetoothApis.dll", {
BluetoothGATTSetCharacteristicValue: { parameters: ["pointer", "pointer", "pointer", "u64", "u32"], result: "i32" },
});
// lib.symbols.BluetoothGATTSetCharacteristicValue(hDevice, Characteristic, CharacteristicValue, ReliableWriteContext, Flags)
// hDevice : HANDLE -> "pointer"
// Characteristic : BTH_LE_GATT_CHARACTERISTIC* -> "pointer"
// CharacteristicValue : BTH_LE_GATT_CHARACTERISTIC_VALUE* -> "pointer"
// ReliableWriteContext : ULONGLONG optional -> "u64"
// Flags : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t BluetoothGATTSetCharacteristicValue(
void* hDevice,
void* Characteristic,
void* CharacteristicValue,
uint64_t ReliableWriteContext,
uint32_t Flags);
C, "BluetoothApis.dll");
// $ffi->BluetoothGATTSetCharacteristicValue(hDevice, Characteristic, CharacteristicValue, ReliableWriteContext, Flags);
// hDevice : HANDLE
// Characteristic : BTH_LE_GATT_CHARACTERISTIC*
// CharacteristicValue : BTH_LE_GATT_CHARACTERISTIC_VALUE*
// ReliableWriteContext : ULONGLONG optional
// 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 BluetoothGATTSetCharacteristicValue(
Pointer hDevice, // HANDLE
Pointer Characteristic, // BTH_LE_GATT_CHARACTERISTIC*
Pointer CharacteristicValue, // BTH_LE_GATT_CHARACTERISTIC_VALUE*
long ReliableWriteContext, // ULONGLONG optional
int Flags // DWORD
);
}@[Link("bluetoothapis")]
lib LibBluetoothApis
fun BluetoothGATTSetCharacteristicValue = BluetoothGATTSetCharacteristicValue(
hDevice : Void*, # HANDLE
Characteristic : BTH_LE_GATT_CHARACTERISTIC*, # BTH_LE_GATT_CHARACTERISTIC*
CharacteristicValue : BTH_LE_GATT_CHARACTERISTIC_VALUE*, # BTH_LE_GATT_CHARACTERISTIC_VALUE*
ReliableWriteContext : UInt64, # ULONGLONG optional
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 BluetoothGATTSetCharacteristicValueNative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Uint64, Uint32);
typedef BluetoothGATTSetCharacteristicValueDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, int, int);
final BluetoothGATTSetCharacteristicValue = DynamicLibrary.open('BluetoothApis.dll')
.lookupFunction<BluetoothGATTSetCharacteristicValueNative, BluetoothGATTSetCharacteristicValueDart>('BluetoothGATTSetCharacteristicValue');
// hDevice : HANDLE -> Pointer<Void>
// Characteristic : BTH_LE_GATT_CHARACTERISTIC* -> Pointer<Void>
// CharacteristicValue : BTH_LE_GATT_CHARACTERISTIC_VALUE* -> Pointer<Void>
// ReliableWriteContext : ULONGLONG optional -> Uint64
// Flags : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function BluetoothGATTSetCharacteristicValue(
hDevice: THandle; // HANDLE
Characteristic: Pointer; // BTH_LE_GATT_CHARACTERISTIC*
CharacteristicValue: Pointer; // BTH_LE_GATT_CHARACTERISTIC_VALUE*
ReliableWriteContext: UInt64; // ULONGLONG optional
Flags: DWORD // DWORD
): Integer; stdcall;
external 'BluetoothApis.dll' name 'BluetoothGATTSetCharacteristicValue';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "BluetoothGATTSetCharacteristicValue"
c_BluetoothGATTSetCharacteristicValue :: Ptr () -> Ptr () -> Ptr () -> Word64 -> Word32 -> IO Int32
-- hDevice : HANDLE -> Ptr ()
-- Characteristic : BTH_LE_GATT_CHARACTERISTIC* -> Ptr ()
-- CharacteristicValue : BTH_LE_GATT_CHARACTERISTIC_VALUE* -> Ptr ()
-- ReliableWriteContext : ULONGLONG optional -> Word64
-- Flags : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let bluetoothgattsetcharacteristicvalue =
foreign "BluetoothGATTSetCharacteristicValue"
((ptr void) @-> (ptr void) @-> (ptr void) @-> uint64_t @-> uint32_t @-> returning int32_t)
(* hDevice : HANDLE -> (ptr void) *)
(* Characteristic : BTH_LE_GATT_CHARACTERISTIC* -> (ptr void) *)
(* CharacteristicValue : BTH_LE_GATT_CHARACTERISTIC_VALUE* -> (ptr void) *)
(* ReliableWriteContext : ULONGLONG optional -> uint64_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 ("BluetoothGATTSetCharacteristicValue" bluetooth-gattset-characteristic-value :convention :stdcall) :int32
(h-device :pointer) ; HANDLE
(characteristic :pointer) ; BTH_LE_GATT_CHARACTERISTIC*
(characteristic-value :pointer) ; BTH_LE_GATT_CHARACTERISTIC_VALUE*
(reliable-write-context :uint64) ; ULONGLONG optional
(flags :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $BluetoothGATTSetCharacteristicValue = Win32::API::More->new('BluetoothApis',
'int BluetoothGATTSetCharacteristicValue(HANDLE hDevice, LPVOID Characteristic, LPVOID CharacteristicValue, UINT64 ReliableWriteContext, DWORD Flags)');
# my $ret = $BluetoothGATTSetCharacteristicValue->Call($hDevice, $Characteristic, $CharacteristicValue, $ReliableWriteContext, $Flags);
# hDevice : HANDLE -> HANDLE
# Characteristic : BTH_LE_GATT_CHARACTERISTIC* -> LPVOID
# CharacteristicValue : BTH_LE_GATT_CHARACTERISTIC_VALUE* -> LPVOID
# ReliableWriteContext : ULONGLONG optional -> UINT64
# Flags : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。