Groups > Palm OS > Bluetooth Forum > Hardcoding a device's address




Hardcoding a device's address

Hardcoding a device's address
Sat, 24 Jun 2006 14:05:34 -040
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.

This program works fine (hope the formatting is okay):

static BtLibDeviceAddressType gBdAddr;	// BSSa: device address

err = PrvBtOpenLibAndRegisterCallback();
    if(err)
        return;
	/*-------------------------------------------------------*/
	/* Discover the Bluetooth remote device                  */
	/*-------------------------------------------------------*/
	err = BtLibDiscoverSingleDevice(
		gBtLibRefNum,			// Reference number for Bluetooth library
		NULL,					// NULL => default text is "Select a device:"
		NULL,					// No filter
		0,						// 0 filters
	 	&gBdAddr,				// Address of the selected device
	 	true,					// Display name, not address
	 	false);					// don't ignore the parameters

PrvBtUnregisterCallbackAndCloseLib();

	config.function = 0;							// Must be zero
	config.drvrDataP = (MemPtr)&btParams;
	config.drvrDataSize = sizeof(BtVdOpenParams);
	btParams.role = btVdClient;						// We are the client side
	btParams.u.client.method = btVdUseUuidList;		// Use SDP

	// Set up the remote address (can be null if not initialized)
	btParams.u.client.remoteDevAddr.address[0] = gBdAddr.address[0];
	btParams.u.client.remoteDevAddr.address[1] = gBdAddr.address[1];
	btParams.u.client.remoteDevAddr.address[2] = gBdAddr.address[2];
	btParams.u.client.remoteDevAddr.address[3] = gBdAddr.address[3];
	btParams.u.client.remoteDevAddr.address[4] = gBdAddr.address[4];
	btParams.u.client.remoteDevAddr.address[5] = gBdAddr.address[5];

		sppUuid.size = btLibUuidSize16;
		sppUuid.UUID[0] = 0x11;
		sppUuid.UUID[1] = 0x01;
		btParams.u.client.u.uuidList.tab = &sppUuid;  // the list of service
uuids
		btParams.u.client.u.uuidList.len = 1;         // the number of uuids
in the list

	err = SrmExtOpen(
		sysFileCVirtRfComm,
		&config,	
		sizeof(config),
		&gBtPortId
	);

but if I try to change it to:
btParams.u.client.remoteDevAddr.address[0] = 0x00;
btParams.u.client.remoteDevAddr.address[1] = 0xA0;
...

I get the error: serErrConfigurationFailed - The port needs time to
configure, and the configuration has failed.  I'll take any hints I
can get.

-- 
Jevin Maltais [jevin@techie.com]
http://jevy.org
Post Reply
about | contact