Hi all,
Currently I'm working on
Blusoleil SDK[
^]. I have to create a wrapper for their library.
I have a problem on registering the callback function. The definition is something like this:
C++
--------
Prototype Function:
BTINT32 Btsdk_RegisterGetStatusInfoCB4ThirdParty(
Func_ReceiveBluetoothStatusInfo* statusCBK);
typedef void Func_ReceiveBluetoothStatusInfo(
ULONG usMsgType, ULONG pulData, ULONG param, BTUINT8 *arg);
C#
------
[DllImport("BsSdk.dll")]
[return: MarshalAs(UnmanagedType.U4)]
public static extern Int32 Btsdk_RegisterGetStatusInfoCB4ThirdParty(ref Func_ReceiveBluetoothStatusInfo statusCBK);
public delegate void Func_ReceiveBluetoothStatusInfo (UInt32 usMsgType,UInt32 pulData,UInt32 param, ref Byte arg);
Function to test the call back :
public static void Test_RegisterGetStatusCBK()
{
Func_ReceiveBluetoothStatusInfo Bd = BsStatusCBKFuc;
Btsdk_RegisterGetStatusInfoCB4ThirdParty(ref Bd);
}
public static void BsStatusCBKFuc(UInt32 usMsgType, UInt32 pucData, UInt32 param, ref Byte arg)
{
switch (usMsgType)
{
case Hndle.BTSDK_BLUETOOTH_STATUS_FLAG:
{
switch (pucData)
{
case (uint)BluetoothState.BTSDK_BTSTATUS_TURNON:
{
MessageBox.Show(@"Bluetooth is turned on");
break;
}
}
}
}
The problem is, that the callback function doesn't hit anymore. It seem the
Btsdk_RegisterGetStatusInfoCB4ThirdParty
is not succesfull. Can anyone give me an idea? Was my method wrong?