Esempio n. 1
0
        private ServiceAttribute BuildAttribute(Structs.SDP_Service_Attribute_Value_Data attrData)
        {
            ushort attrId0   = attrData.Attribute_ID;
            IntPtr pElemData = attrData.pSDP_Data_Element;
            var    elem      = BuildElement(pElemData);

            return(new ServiceAttribute(attrId0, elem));
        }
Esempio n. 2
0
        internal static IntPtr ProtoDListMake(List <IntPtr> listAllocs, byte port)
        {
            IntPtr pCur;
            var    elemDataRfcomm = new Structs.SDP_Data_Element(
                StackConsts.SDP_Data_Element_Type.UUID_16, 2);

            elemDataRfcomm.FakeAtUnionPosition  = 0x00; // TODO Endian???!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            elemDataRfcomm.FakeAtUnionPosition1 = 0x03;
            IntPtr pCurRfcomm = CopyToNative(listAllocs, ref elemDataRfcomm);
            //
            var elemDataScn = new Structs.SDP_Data_Element(
                StackConsts.SDP_Data_Element_Type.UnsignedInteger1Byte, 1);

            elemDataScn.FakeAtUnionPosition = port;
            IntPtr pCurScn = CopyToNative(listAllocs, ref elemDataScn);
            //
            var elemListL1Arr = new[] { elemDataRfcomm, elemDataScn };
            var elemListL1    = new Structs.SDP_Data_Element(
                StackConsts.SDP_Data_Element_Type.Sequence, 2);

            SetPointerToArray(listAllocs, ref elemListL1, elemListL1Arr);
            IntPtr pelemListL1 = CopyToNative(listAllocs, ref elemListL1);
            //
            var elemDataL2Cap = new Structs.SDP_Data_Element(
                StackConsts.SDP_Data_Element_Type.UUID_16, 2);

            elemDataL2Cap.FakeAtUnionPosition  = 0x01;
            elemDataL2Cap.FakeAtUnionPosition1 = 0x00;
            IntPtr pCurL2Cap = CopyToNative(listAllocs, ref elemDataL2Cap);
            //
            var elemListL0Arr = new[] { elemDataL2Cap };
            var elemListL0    = new Structs.SDP_Data_Element(
                StackConsts.SDP_Data_Element_Type.Sequence, 1);

            SetPointerToArray(listAllocs, ref elemListL0, elemListL0Arr);
            IntPtr pelemListL0 = CopyToNative(listAllocs, ref elemListL0);
            //
            var elemListRootArr = new[] { elemListL0, elemListL1 };
            var elemListRoot    = new Structs.SDP_Data_Element(
                StackConsts.SDP_Data_Element_Type.Sequence, 2);

            SetPointerToArray(listAllocs, ref elemListRoot, elemListRootArr);
            IntPtr pelemListRoot = CopyToNative(listAllocs, ref elemListRoot);
            //
            var attrData = new Structs.SDP_Service_Attribute_Value_Data(0x4, pelemListRoot);

            pCur = CopyToNative(listAllocs, ref attrData);
            var attrRsp = new Structs.SDP_Service_Attribute_Response_Data(1, pCur);

            pCur = CopyToNative(listAllocs, ref attrRsp);
            return(pCur);
        }
Esempio n. 3
0
        private static ServiceRecord DoTestParseOneAttribute(List <IntPtr> listAllocs, Structs.SDP_Data_Element elem, ushort attrId)
        {
            IntPtr        pCur;
            ServiceRecord r;
            IntPtr        pElem = CopyToNative(listAllocs, ref elem);
            //
            var attrData = new Structs.SDP_Service_Attribute_Value_Data(
                attrId, pElem);

            pCur = CopyToNative(listAllocs, ref attrData);
            var attrRsp = new Structs.SDP_Service_Attribute_Response_Data(1, pCur);

            pCur = CopyToNative(listAllocs, ref attrRsp);
            //
            var stuff = Create_BluetopiaSdpQuery();

            r = stuff.DutSdpQuery.BuildRecord(pCur);
            return(r);
        }
Esempio n. 4
0
        public void UInt8()
        {
            var    listAllocs = new List <IntPtr>();
            IntPtr pCur;
            //
            var elemData = new Structs.SDP_Data_Element(
                StackConsts.SDP_Data_Element_Type.UnsignedInteger1Byte, 1);

            elemData.FakeAtUnionPosition = 0xF5;
            pCur = CopyToNative(listAllocs, ref elemData);
            //
            var attrData = new Structs.SDP_Service_Attribute_Value_Data(0xF123, pCur);

            pCur = CopyToNative(listAllocs, ref attrData);
            //
            var attrRsp = new Structs.SDP_Service_Attribute_Response_Data(1, pCur);

            pCur = CopyToNative(listAllocs, ref attrRsp);
            //
            var svcSrchAttrRsp = new Structs.SDP_Response_Data__SDP_Service_Search_Attribute_Response_Data(
                StackConsts.SDP_Response_Data_Type.ServiceSearchAttributeResponse,
                1, pCur);

            pCur = CopyToNative(listAllocs, ref svcSrchAttrRsp);
            //
            var stuff = Create_BluetopiaSdpQuery();
            List <ServiceRecord> rList = stuff.DutSdpQuery.BuildRecordList(pCur);

            Assert.AreEqual(1, rList.Count);
            ServiceRecord r = rList[0];
            //
            var attr = r[0];

            Assert.AreEqual(unchecked ((ServiceAttributeId)0xF123), attr.Id, "AttrId");
            //Assert.AreEqual(unchecked((short)0xF123), attr.IdAsOrdinalNumber, "IdAsOrdinalNumber");
            Assert.AreEqual(ElementType.UInt8, attr.Value.ElementType, "ET");
            Assert.AreEqual(ElementTypeDescriptor.UnsignedInteger, attr.Value.ElementTypeDescriptor, "ET");
            Assert.AreEqual(0xF5, attr.Value.Value, "v");
            //
            Free(listAllocs);
        }