In The Hand
BluetoothListener Constructor (service, sdpRecord, channelOffset)
NamespacesInTheHand.Net.SocketsBluetoothListenerBluetoothListener(Guid, array<Byte>[]()[], Int32)
.NET Components for Mobility
Initializes a new instance of the BluetoothListener class to listen on the specified service identifier, publishing the specified SDP record.
Declaration Syntax
C#Visual Basic
public BluetoothListener(
	Guid service,
	byte[] sdpRecord,
	int channelOffset
)
Public Sub New ( _
	service As Guid, _
	sdpRecord As Byte(), _
	channelOffset As Integer _
)
Parameters
service (Guid)
The Bluetooth service to listen for.
sdpRecord (array< Byte >[]()[])
Prepared SDP Record to publish.
channelOffset (Int32)
The index in the sdpRecord byte array where the RFCOMM Channel Number that the server is listening on is to be placed. However the supplied record is now parsed into an ServiceRecord instance, and the channel offset is not used.
Remarks
Note: The constructors taking the SDP record explicitly (as a byte array) should only be used if a specialized SDP record is required. For instance when using one of the standard profiles. Otherwise use one of the other constructors e.g. BluetoothListener(Guid) which create a generic SDP Record from the specified service identifier.

Instead of passing a byte array containing a hand-built record, the record can also be built using the ServiceRecord and ServiceElement classes, and passed to the respective constuctor, e.g. BluetoothListener(Guid, ServiceRecord)

Any useful SDP record will include a ProtocolDescriptor element containing the RFCOMM Channel number that the server is listening on, and a ServiceClassId element containing the service UUIDs. The record supplied in the sdpRecord parameter should contain those elements. On successful Start()()(), the RFCOMM Channel number that the protocol stack has assigned to the server is retrieved, and copied into the service record before it is published. The channelOffset indicates the location of the respective byte in the sdpRecord byte array.

An example SDP record is as follows. This is actually the format of the generic record used in the other constructors. For another example see the code in the ObexListener class.

CopyC#
// The asterisks note where the Service UUID and the Channel number are
// to be filled in.
byte[] record = new byte[] {
  //Element Sequence:
  0x35,0x27,
    //UInt16: 0x0001  -- ServiceClassIdList
    0x09,0x00,0x01,
    //Element Sequence:
    0x35,0x11,
    //  UUID128: 00000000-0000-0000-0000-000000000000 -- * Service UUID
        0x1c,
          0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
          0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
    // 
    //UInt16: 0x0004  -- ProtocolDescriptorList
    0x09,0x00,0x04,
    //Element Sequence:
    0x35,0x0c,
    //  Element Sequence:
        0x35,0x03,
    //      UUID16: 0x0100  -- L2CAP
            0x19,0x01,0x00,
    //  Element Sequence:
        0x35,0x05,
    //      UUID16: 0x0003  -- RFCOMM
            0x19,0x00,0x03,
    //      UInt8: 0x00     -- * Channel Number
            0x08,0x00
};
For that record the channelOffset is 40.

Assembly: InTheHand.Net.Personal (Module: InTheHand.Net.Personal) Version: 3.0.0.0