PORTEMUPortParams.cs :  » Business-Application » 32feet.NET » InTheHand » Net » Ports » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Business Application » 32feet.NET 
32feet.NET » InTheHand » Net » Ports » PORTEMUPortParams.cs
// 32feet.NET - Personal Area Networking for .NET
//
// InTheHand.Net.Ports.PORTEMUPortParams
// 
// Copyright (c) 2003-2008 In The Hand Ltd, All rights reserved.
// This source code is licensed under the In The Hand Community License - see License.txt

using System;
using InTheHand.Net;
using System.Runtime.InteropServices;

#if NETCF

namespace InTheHand.Net.Ports{
#if V2
    [StructLayout(LayoutKind.Sequential)]
    internal struct PORTEMUPortParams
    {
        internal int channel;
        [MarshalAs(UnmanagedType.Bool)]
        internal bool flocal;
        internal long device;//10
        internal int imtu;
        internal int iminmtu;
        internal int imaxmtu;
        internal int isendquota;
        internal int irecvquota;
        internal Guid uuidService;//16
        internal RFCOMM_PORT_FLAGS uiportflags;
    }
#else

  // <summary>
  // Used when creating a virtual serial port.
  // </summary>
  internal sealed class PORTEMUPortParams
  {
    /*int channel;
    int flocal;
    BD_ADDR device;10
    int imtu;
    int iminmtu;
    int imaxmtu;
    int isendquota;
    int irecvquota;
    GUID uuidService;16
    unsigned int uiportflags;*/

    private byte[] m_data;
    
    // <summary>
    // 
    // </summary>
        internal PORTEMUPortParams()
    {
      m_data = new byte[56];
    }

    internal byte[] ToByteArray()
    {
      return m_data;
    }

    // <summary>
    // Set to either an explicit server channel, or, for a server application that wants the server channel to be autobound, to RFCOMM_CHANNEL_MULTIPLE.
    // </summary>
        internal int channel
    {
      get
      {
        return BitConverter.ToInt32(m_data, 0);
      }
      set
      {
        BitConverter.GetBytes(value).CopyTo(m_data, 0);
      }
    }
    // <summary>
    // Set to TRUE for a server port that accepts connections, or to FALSE for a client port that is used to creating outgoing connections.
    // </summary>
        internal bool flocal
    {
      get
      {
        return Convert.ToBoolean(BitConverter.ToInt32(m_data, 4));
      }
      set
      {
        BitConverter.GetBytes((int)(value ? 1 : 0)).CopyTo(m_data, 4);
      }
    }

    // <summary>
    // The address of a target device on a client port.
    // </summary>
        internal long device
    {
      get
      {
                return BitConverter.ToInt64(m_data, 8);
        /*BluetoothAddress ba = new BluetoothAddress();
        Buffer.BlockCopy(m_data, 8, ba.ToByteArray(), 0, 6);
        return ba;*/
      }
      set
      {
                BitConverter.GetBytes(value).CopyTo(m_data, 8);
        //Buffer.BlockCopy(value.ToByteArray(), 0, m_data, 8, 6);
      }
    }

        internal int imtu
    {
      get
      {
        return BitConverter.ToInt32(m_data, 16);
      }
      set
      {
        BitConverter.GetBytes(value).CopyTo(m_data, 16);
      }
    }

        internal int iminmtu
    {
      get
      {
        return BitConverter.ToInt32(m_data, 20);
      }
      set
      {
        BitConverter.GetBytes(value).CopyTo(m_data, 20);
      }
    }

        internal int imaxmtu
    {
      get
      {
        return BitConverter.ToInt32(m_data, 24);
      }
      set
      {
        BitConverter.GetBytes(value).CopyTo(m_data, 24);
      }
    }

        internal int isendquota
    {
      get
      {
        return BitConverter.ToInt32(m_data, 28);
      }
      set
      {
        BitConverter.GetBytes(value).CopyTo(m_data, 28);
      }
    }

        internal int irecvquota
    {
      get
      {
        return BitConverter.ToInt32(m_data, 32);
      }
      set
      {
        BitConverter.GetBytes(value).CopyTo(m_data, 32);
      }
    }
    //etc


    // <summary>
    // Specifies the UUID for the target RFCOMM service.
    // If channel == 0 for the client port, an SDP query is performed to determine the target channel id before the connection is made.
    // </summary>
        internal Guid uuidService
    {
      get
      {
        byte[] guidbytes = new byte[16];
        Buffer.BlockCopy(m_data, 36, guidbytes, 0, 16);
        return new Guid(guidbytes);
      }
      set
      {
        Buffer.BlockCopy(value.ToByteArray(), 0, m_data, 36, 16);
      }
    }

    // <summary>
    // Port Flags.
    // </summary>
        internal RFCOMM_PORT_FLAGS uiportflags
    {
      get
      {
                return (RFCOMM_PORT_FLAGS)BitConverter.ToInt32(m_data, 52);
      }
      set
      {
        BitConverter.GetBytes((int)value).CopyTo(m_data, 52);
      }
    }
  }
#endif

  [Flags()]
    internal enum RFCOMM_PORT_FLAGS : int
  {
        REMOTE_DCB = 0x00000001,
        KEEP_DCD = 0x00000002,
        AUTHENTICATE = 0x00000004,
        ENCRYPT = 0x00000008, 
  }
}

#endif
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.