.NET Components for Mobility

Parking Bluetooth Connections WM

Last post 05-21-2008 6:54 AM by alanjmcf. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 05-19-2008 4:31 AM

    Parking Bluetooth Connections WM

    I'm developing a Bluetooth peer2peer Application on Windows Mobile for my thesis.

    The first attempt was to open/close the connection between the Devices before/after it's usage.

    Because of slow Connect mechanism i've decided to let the connections open. But the max 7 active connections are a problem to do it like that.

    Because the Function to enter the parkmode are not implemented yesterday i've downloaded the source code and added some lines to the SocketOptionHelper and to the BluetoothClient.

    The lines of Code i've added:

    SocketOptionHelper

    private bool parkmode = false;
    
    public bool Parkmode 
    {
         set 
         {
              if(value != parkmode) 
              {
                   parkmode = value;
                   
                   if(parkmode)
                   {
                        //enter parkmode
                        byte[] pmbt = new byte[6];
                        uint beacon_max = 0xffff;
                        uint beacon_min = 0x0001;
                        uint interval = 1200; //0.75s
                        
                        BitConverter.GetBytes(beacon_max).CopyTo(pmbt, 0);
                        BitConverter.GetBytes(beacon_min).CopyTo(pmbt, 2);
                        BitConverter.GetBytes(interval).CopyTo(pmbt, 4);
    
                        m_socket.SetSocketOption(BluetoothSocketOptionLevel.RFComm, 
                           BluetoothSocketOptionName.EnterParkMode, pmbt);
                   } else {
                        //exit parmode
                        m_socket.SetSocketOption(BluetoothSocketOptionLevel.RFComm, 
                           BluetoothSocketOptionName.ExitParkMode , 
                           ((BluetoothEndpoint)m_socket.RemoteEndPoint).Address.ToByteArray());
                   }
              }
         }
         get
         {
              return parkmode;
         }
    }
    
    BluetoothClient
    public bool Parkmode
    {
         set
         {
              m_optionHelper.Parkmode = value;
         }
         get
         {
              return m_optionHelper.Parkmode;
         }
    }
    
    I've tried the Code in Windows Vista (I know its just documented to Work under Windows CE and under WM 5.0) and in Windows Mobile 6.0.

    In both cases I get an InvalidArgumentException.

    Has anyone tried something similar? I'm not seeing any Bugs in the code.
  • 05-21-2008 6:54 AM In reply to

    Re: Parking Bluetooth Connections WM

    Don;t know what should work here, but...

    InvalidArgumentException who huh? :-)   Is that an ArgumentException or an InvalidOperationException perchance.  What throws it?  Show us the stack trace.

    Alan J. McFarlane
    http://www.alanjmcf.me.uk/
    Please follow-up in the newsgroup for the benefit of all.
    Have I helped? Consider visiting my Amazon wishlist, see my homepage.
Page 1 of 1 (2 items)
Copyright © 2001-2008 In The Hand Ltd. All rights reserved. Terms of Use and Privacy Policy.