- 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.
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
};