PORTEMUPortParams.cs :  » Business-Application » 32feet.NET » InTheHand » Net » 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 » PORTEMUPortParams.cs
// 32feet.NET - Personal Area Networking for .NET
//
// InTheHand.Net.Ports.PORTEMUPortParams
// 
// Copyright (c) 2003-2006 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;

namespace InTheHand.Net.Ports{
  // <summary>
  // Used when creating a virtual serial port.
  // </summary>
  internal 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>
    public PORTEMUPortParams()
    {
      m_data = new byte[56];

      Flags = RFCommPortFlags.RemoteDCB;
    }

    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>
    public 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>
    public bool Local
    {
      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>
    public BluetoothAddress Address
    {
      get
      {
        BluetoothAddress ba = new BluetoothAddress();
        Buffer.BlockCopy(m_data, 8, ba.ToByteArray(), 0, 6);
        return ba;
      }
      set
      {
        Buffer.BlockCopy(value.ToByteArray(), 0, m_data, 8, 6);
      }
    }

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

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

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

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

    public int ReceiveQuota
    {
      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>
    public Guid Service
    {
      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>
    public RFCommPortFlags Flags
    {
      get
      {
        return (RFCommPortFlags)BitConverter.ToInt32(m_data, 52);
      }
      set
      {
        BitConverter.GetBytes((int)value).CopyTo(m_data, 52);
      }
    }
  }

  [Flags()]
  internal enum RFCommPortFlags : int
  {
    RemoteDCB = 0x00000001,
    KeepDCD = 0x00000002, 
    Authenticate = 0x00000004, 
    Encrypt = 0x00000008, 
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.