I have similar problem.
We're developing GPS application (on windows mobile 5/6 platform) for automotive/drivers. ATM we're switching from using GPS Intermediate Driver API (GPSOpenDevice(), GPSGetPosition() etc) to parsing NMEA directly from COM port - no matter if it's virtual COM port from GPS ID, hardware bluetooth port or builtin GPS 'hardware' COM port.
Users of this application have the configuration options, where they choose which GPS receiver they want to use: device builtin, bluetooth GPS, or advanced configuration where they configure all stuff like GPS ID program COM port, hardware COM port, baud rate etc manually.
For bluetooth GPS, we're using 32feet library to show them bluetooth devices already configured/paired on their device, as well as bluetooth devices in range. If user chooses a device which is not paired yet, we're first pairing it using BluetoothSecurity.PairRequest then enabling serial port using SetServiceState. After that GPS Intermediate Driver is configured to use serial port just configured as hardware port and signaled to reload it's configuration. The code looks like this (removed not relevant parts)
BluetoothDeviceInfo[ devices = bc.DiscoverDevices(255, true, true, true);
BluetoothDeviceInfo bdi = ... // user selects one of discovered devices
if (bdi.Authenticated == false)
{
bool ret = BluetoothSecurity.PairRequest(bdi.DeviceAddress, PinValue);
if (ret == false)
// handle error - couldn't connect to selected device
bdi.SetServiceState(BluetoothService.SerialPort, true, true);
// this function reads port name from HKLM\Software\Microsoft\Bluetooth\Serial\Ports\<device address>\Port
SelectedPort = GPSConfig.GetBluetoothPortName(bdi.DeviceAddress);
}
The problem we're having is with PairRequest/SetServiceState. On the first sight it works fine - the configuration is set up in the registry (HKLM\Software\Microsoft\Bluetooth) exactly like bluetooth configurator from windows mobile does it. The only exception is, that it doesn't work until the device is rebooted.
I read the 32feet source code to see how SetServiceState and PairRequest work and it seems that those functions do not notify bluetooth(?) driver that the configuration changed. There must be some way to do this. Devices configured with control panel bluetooth configurator do not require reboot to work.
Is there some way to fix this issue? Maybe setting those devices directly to the registry is not the best idea. Maybe provisioning would work better?
Btw. I know BluetoothClient works nice when communicating to the bluetooth GPS receiver, but I can't use it because the rest of our GPS related code is expecting virtual or hardware COM port from which it can read.
I can provide some more details if needed.
Best regards
Grzegorz Aksamit