1
votes

I do need a virtual serial port since a program#1 has to set up a bluetooth connection for a second program (program#2) that uses System.IO.Ports.SerialPort, don't I? It isn't a requirement providing that program#1 and #2 run concurrently using the same serial port.

  • 32Feet.NET: Ok. But I get "No ports available" if I start the SuD 7 times (one after another). COM9 -> COM7 -> COM5 -> COM4 -> COM2 -> COM0 -> "No ports available".

    1. program#1 invokes

      bdi.SetServiceState(BluetoothService.SerialPort, true)

    2. 32feet.Net creates Key in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Bluetooth\Serial\Ports

    3. 32feet.Net calls

      RegisterDevice(portPrefix, portIndex, "btd.dll", ref pep);

    4. program#2: this.comX.Open(); ... this.comX.Close();

  • EMDK: An IndexOutOfRangeException is thrown if I start the SuD 7 times (one after another). COM2 -> COM4 -> COM5 -> COM6 -> COM7 -> COM9 -> IndexOutOfRangeException.

    program#1: I'm using LocalComPort and HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Bluetooth\Serial\Ports isn't updated.

    program#2: this.comX.Open(); ... this.comX.Close();

What is the reason? There's no process#1 and process#2 left.

2

2 Answers

0
votes

Once you've set the port up one time why do you ever have to do it again? With SetServiceState the configuration is set in the Registry for ever and thus will be there for ever, e.g. after a reboot... Presumably the same is true for the method you are using in EMDK. I don't recognise that name (maybe it is Motorola only) but on my M3 Sky I have used the BTExplorerApi and it has a for-ever and a not-for-ever flag in the port-set-up function.

On 32feet.NET with the MSFT stack. (Note: Peter was the expert in this not me). :-,( As I understand it if you use class BluetoothSerialPort, that will create a port that's configured temporary (not over reboot etc). Maybe that's what you want?

0
votes

Once you've set the port up one time why do you ever have to do it again?

Use case scenario: Mr. X uses one mobile device and one serial RS232 Bluetooth adapter to communicate with several units. But for the seventh there won't be any virtual serial port left.

I was using 32feet.Net for ES400 trouble-free. For MC55, MC35 the phenomena under discussion appears. And that was the reason why I created this question.

I don't know what's going on under the hood yet. But as far as EMDK concerned: if the connection isn't needed any longer, you have to unpair the device.

I'm using EMDK for Motorola ES400 and MC55:

/// <summary>
/// Removes the pairing, turns Bluetooth off and disables the bluetooth object.
/// </summary>
public void ReleaseLink(){
    try{
        this.remoteDevice.UnPair();
        this.bluetooth.Dispose();

I'm using 32feet.NET for Motorola MC35 (BluetoothSerialPort that invokes RegisterDevice):

if (!bdi.Authenticated)
{
    string pair = rd.Pin;
    paired = BluetoothSecurity.PairRequest(bdi.DeviceAddress, pair);

    if (!paired)
    {
         return;
    }
}

spp = BluetoothSerialPort.CreateClient(new BluetoothEndPoint(remoteAddress,BluetoothService.SerialPort));

public void ReleaseLink()
{
    try
    {
        BluetoothSecurity.RemoveDevice(spp.Address);
        spp.Dispose();