S
SpreadTooThin
I have a C routine that wants to call a method of its user.
In this case the method is a method inside a class.
The C routine is passed a void * which can be used by the user any way
they like.
I use that parameter and pass the actual instance of the C++ class
that performed the call.
The C callback handler then uses the instance of the class and calls
the appropriate method.
Here is the code but it doesn't work. What am I doing wrong?
In this case the method is a method inside a class.
The C routine is passed a void * which can be used by the user any way
they like.
I use that parameter and pass the actual instance of the C++ class
that performed the call.
The C callback handler then uses the instance of the class and calls
the appropriate method.
Here is the code but it doesn't work. What am I doing wrong?
Code:
void DeviceFoundCallBack(void * userRefCon,
IOBluetoothDeviceInquiryRef inquiryRef, IOBluetoothDeviceRef
deviceRef)
{
userRefCon->DeviceFoundCallBack(inquiryRef, deviceRef);
}
void CompleteCallback(void * userRefCon, IOBluetoothDeviceInquiryRef
inquiryRef, IOBluetoothDeviceRef deviceRef)
{
userRefCon->CompleteCallBack(inquiryRef, deviceRef);
}
void BlueTooth::startSearch(void)
{
_inquiry =
IOBluetoothDeviceInquiryCreateWithCallbackRefCon(this); // This will
be passed back to us to let us know the instance.
IOBluetoothDeviceInquirySetDeviceFoundCallback(_inquiry,
&DeviceFoundCallBack);
}