T
Tiger Developer
Hi guys,
I'm stucked with a bluetooth application.
Shortly , my visual c++ 2003 bluetooth code is intended to query for devices
nearby (example : my cellphone with bluetooh)
I'm using the below code; (my code compiles fine, but when I hit the line,
BtHandle = BluetoothFindFirstDevice(&search_param, &btDevInfo);
I debug and assume that it will wait for querying devices nearby but it
immediately switches to dissambler code;
I then toogle another breakpoint to another line below this line and resume
from debug , it comes to this line and
i see that "BtHandle" returns "unknown value" , as if it doesnot query any
devices, something wrong occurs here as much as i understand here.
Where am i doing wrong here ?
Someone please shed a light upon me due i'm stucked at this point.
I'm using built-in Widcomm stack in my Win2003 server. Does it matter for
this code to work on different stacks? (Microsoft,Widcomm,Toshiba,etc..)
Actually, the application i'm working on is intended to work on any machine
with bluetooth whatever bluetooth stack it has ?
Where do i have to start from ?
This is an urgent call, please some experienced guy, direct me in the right
order.
Thanks much and Regards
Tiger Developer
HBLUETOOTH_DEVICE_FIND BtHandle;
BLUETOOTH_DEVICE_INFO btDevInfo;
BLUETOOTH_DEVICE_SEARCH_PARAMS search_param;
memset(&search_param, 0, sizeof(search_param));
search_param.dwSize = sizeof(search_param);
search_param.fReturnAuthenticated = FALSE;
search_param.fReturnRemembered = FALSE;
search_param.fReturnUnknown = TRUE;
search_param.fReturnConnected = FALSE;
search_param.fIssueInquiry = TRUE;
search_param.cTimeoutMultiplier = 20;
search_param.hRadio = NULL;
memset(&btDevInfo, 0, sizeof(btDevInfo));
btDevInfo.dwSize = sizeof(btDevInfo);
device_count = 0;
BtHandle = BluetoothFindFirstDevice(&search_param, &btDevInfo);
if (BtHandle == 0)
{
last_error = GetLastError();
printf("\nNo devices found: %d", last_error);
BluetoothFindDeviceClose(BtHandle);
exit (0);
}
else
{
szAccept = 'y';
bContinue = TRUE;
while (bContinue)
{
device_count++;
wcstombs(szDeviceName, btDevInfo.szName, sizeof(szDeviceName));
printf("\nFound Device %d : %s", device_count, szDeviceName);
printf("\nDevice address %x", btDevInfo.Address.ullLong);
if (btDevInfo.fConnected)
printf("\n It is connected");
else
printf("\n Device is not connected");
if (btDevInfo.fRemembered)
printf("\n It is remembered");
else
printf("\n Device is not remembered");
printf("\nPress 'y' to accept or 'n' to not accept this device ");
szAccept = _getch();
if (szAccept == 'n')
{
memset(&btDevInfo, 0, sizeof(btDevInfo));
btDevInfo.dwSize = sizeof(btDevInfo);
bResult = BluetoothFindNextDevice(BtHandle, &btDevInfo);
if (bResult == FALSE)
{
last_error = GetLastError();
printf("\nBluetoothFindNextDevice returned error: %d", last_error);
BluetoothFindDeviceClose(BtHandle);
exit (0);
}
}
else
bContinue = FALSE;
}
}
I'm stucked with a bluetooth application.
Shortly , my visual c++ 2003 bluetooth code is intended to query for devices
nearby (example : my cellphone with bluetooh)
I'm using the below code; (my code compiles fine, but when I hit the line,
BtHandle = BluetoothFindFirstDevice(&search_param, &btDevInfo);
I debug and assume that it will wait for querying devices nearby but it
immediately switches to dissambler code;
I then toogle another breakpoint to another line below this line and resume
from debug , it comes to this line and
i see that "BtHandle" returns "unknown value" , as if it doesnot query any
devices, something wrong occurs here as much as i understand here.
Where am i doing wrong here ?
Someone please shed a light upon me due i'm stucked at this point.
I'm using built-in Widcomm stack in my Win2003 server. Does it matter for
this code to work on different stacks? (Microsoft,Widcomm,Toshiba,etc..)
Actually, the application i'm working on is intended to work on any machine
with bluetooth whatever bluetooth stack it has ?
Where do i have to start from ?
This is an urgent call, please some experienced guy, direct me in the right
order.
Thanks much and Regards
Tiger Developer
HBLUETOOTH_DEVICE_FIND BtHandle;
BLUETOOTH_DEVICE_INFO btDevInfo;
BLUETOOTH_DEVICE_SEARCH_PARAMS search_param;
memset(&search_param, 0, sizeof(search_param));
search_param.dwSize = sizeof(search_param);
search_param.fReturnAuthenticated = FALSE;
search_param.fReturnRemembered = FALSE;
search_param.fReturnUnknown = TRUE;
search_param.fReturnConnected = FALSE;
search_param.fIssueInquiry = TRUE;
search_param.cTimeoutMultiplier = 20;
search_param.hRadio = NULL;
memset(&btDevInfo, 0, sizeof(btDevInfo));
btDevInfo.dwSize = sizeof(btDevInfo);
device_count = 0;
BtHandle = BluetoothFindFirstDevice(&search_param, &btDevInfo);
if (BtHandle == 0)
{
last_error = GetLastError();
printf("\nNo devices found: %d", last_error);
BluetoothFindDeviceClose(BtHandle);
exit (0);
}
else
{
szAccept = 'y';
bContinue = TRUE;
while (bContinue)
{
device_count++;
wcstombs(szDeviceName, btDevInfo.szName, sizeof(szDeviceName));
printf("\nFound Device %d : %s", device_count, szDeviceName);
printf("\nDevice address %x", btDevInfo.Address.ullLong);
if (btDevInfo.fConnected)
printf("\n It is connected");
else
printf("\n Device is not connected");
if (btDevInfo.fRemembered)
printf("\n It is remembered");
else
printf("\n Device is not remembered");
printf("\nPress 'y' to accept or 'n' to not accept this device ");
szAccept = _getch();
if (szAccept == 'n')
{
memset(&btDevInfo, 0, sizeof(btDevInfo));
btDevInfo.dwSize = sizeof(btDevInfo);
bResult = BluetoothFindNextDevice(BtHandle, &btDevInfo);
if (bResult == FALSE)
{
last_error = GetLastError();
printf("\nBluetoothFindNextDevice returned error: %d", last_error);
BluetoothFindDeviceClose(BtHandle);
exit (0);
}
}
else
bContinue = FALSE;
}
}