On Sat, Jun 24, 2006 at 02:05:34PM -0400, Jevin Maltais wrote:
> Hey everyone,
>
> I would like to hardcode the address of the device I am connecting to
> as it won't change and so I can skip the discovery stage. I'm using a
> modified version of Peter's BTSerialSample program.
>
try using BtLibAddrAToBtd for a hard coded address.
Stuart
--
Stuart Eichert
Copera, Inc.
sceos@copera.com
|
Using the following globals:
static BtLibDeviceAddressType deviceAddress;
static BtLibFriendlyNameType deviceName;
And my gPreferences variable, which is a record/struct containing:
Boolean bluetoothEnabled;
BtLibDeviceAddressType bluetoothDeviceAddress;
UInt8
bluetoothDeviceName[btLibMaxDeviceNameLength];
Of which a type/class and constant were taken from an BtLibTypes.h
include...
And after opening the appropriate library, establising libRefNum, I can
use the following function to obtain the address of the discovered and
selected device.
This value is stored in gPreferences.bluetoothDeviceAddress, with the
name stored in gPreferences.bluetoothDeviceName.
I have tried using the callback notification, but find that if the
device has been discovered, it should always be cached and available
immediately.
//---- START CODE SNIPPET
static Boolean BluetoothDiscover(void)
{
Err error;
error = BtLibDiscoverSingleDevice( libRefNum,
NULL,
NULL,
0,
&deviceAddress,
false,
true);
switch (error) {
case btLibErrNoError:
// Success.
break;
case btLibErrCanceled:
Log("User canceled the discovery.");
return false;
case btLibErrNotOpen:
Log("The referenced Bluetooth library is not
open.");
return false;
case btLibErrStackNotOpen:
Log("The Bluetooth stack failed to initialize when
the library was opened.");
return false;
default:
Log("BtLibDiscoverSingleDevice() returned
unhandled Error");
return false;
}
MemMove(&gPreferences.bluetoothDeviceAddress,
&deviceAddress,
sizeof(gPreferences.bluetoothDeviceAddress));
deviceName.name = (unsigned char
*)&gPreferences.bluetoothDeviceName[0];
deviceName.nameLength =
sizeof(gPreferences.bluetoothDeviceName);
error = BtLibGetRemoteDeviceName ( libRefNum,
&gPreferences.bluetoothDeviceAddress,
&deviceName,
btLibCachedThenRemote);
switch (error) {
case btLibErrNoError:
// Success.
break;
case btLibErrBusy:
Log("There is already a name request pending.");
return false;
case btLibErrNotOpen:
Log("The referenced Bluetooth library is not
open.");
return false;
case btLibErrPending:
Log("The results will be returned through a
notification.");
return false;
case btLibErrStackNotOpen:
Log("The Bluetooth stack failed to initialize when
the library was opened.");
return false;
default:
Log("BtLibGetRemoteDeviceName() returned
unhandled Error");
return false;
}
return true;
}
//---- END CODE SNIPPET
Regards
Jason
-----Original Message-----
From: bounce-507358-89538@news.palmos.com
[mailto:bounce-507358-89538@news.palmos.com] On Behalf Of Peter Easton
Sent: Monday, 26 June 2006 6:05 p.m.
To: Bluetooth Forum
Subject: Re: Hardcoding a device's address
Hi,
Try doing a discovery of a device with a known BdAddr and dumping out
the octets of the BdAddr. My guess is that the octets are not ordered
in the way you might expect; they might be reversed or byte-swapped. I
think there was a posting to this forum a while back that explained
this.
Regards,
Peter
--
For information on using the PalmSource Developer Forums, or to
unsubscribe, please see http://www.palmos.com/dev/support/forums/
###################################################################
WARNING: This email may contain information which is confidential
and may be privileged. If you are not the intended recipient,
you must not read, use, copy or distribute this email or its
attachments (if any). If you have received this email in error,
please notify us immediately by return email, facsimile or
telephone (you may call us collect) and
delete this email - Thank you
###################################################################
|