Пример #1
0
        public SubmitMessage(GsmDataCoding coding)
        {
            _Coding = coding;
            if (coding == GsmDataCoding.Ascii)
            {
                _DataHeader = new DataHeader();
                {
                    InfoElement.PortAddress elem = new InfoElement.PortAddress(InfoElement.AddressingScheme.TwoOctet)
                    {
                        SourcePort = 16001,
                        TargetPort = 16001
                    };
                    _DataHeader.Add(elem);
                }
                _DataHeaderIndication = DataHeaderIndication.Yes;
            }
            else
            {
                _DataHeaderIndication = DataHeaderIndication.No;
            }

            _ProtocolIdentifier = new ProtocolIdentifier();
            _DataCodingScheme   = new DataCodingScheme(coding);
            _ValidityPeriod     = new ValidityPeriod(ValidityPeriodDuration.OneDay);
        }
        public DeliverMessage(string pdu)
        {
            _CenterAddress = new Address(DataRepresentation.Octet, pdu);
            pdu            = pdu.Substring(2 * (_CenterAddress.Length + 1));

            byte h = byte.Parse(pdu.Substring(0, 2), System.Globalization.NumberStyles.HexNumber);

            {
                _MessageTypeIndication  = (MessageTypeIndication)((0x03) & h);
                _MoreMessagesToSend     = (MoreMessagesToSend)((0x04) & h);
                _ReplyPath              = (ReplyPath)((0x80) & h);
                _DataHeaderIndication   = (DataHeaderIndication)((0x40) & h);
                _StatusReportIndication = (StatusReportIndication)((0x20) & h);
            }

            if (_MessageTypeIndication != MessageTypeIndication.Deliver)
            {
                throw new ArgumentException();
            }

            pdu = pdu.Substring(2);
            _OriginatingAddress = new Address(DataRepresentation.SemiOctet, pdu);
            pdu = pdu.Substring(_OriginatingAddress.Length + 4);

            _ProtocolIdentifier = new ProtocolIdentifier(pdu.Substring(0, 2));
            pdu = pdu.Substring(2);

            _DataCodingScheme = new DataCodingScheme(pdu.Substring(0, 2));
            pdu = pdu.Substring(2);

            _TimeStamp = new ServiceCentreTimeStamp(pdu.Substring(0, 14));
            pdu        = pdu.Substring(14);

            //
            // udl (User Data Length) = (Data Length + User Data Header Length + 1)
            byte udl = byte.Parse(pdu.Substring(0, 2), System.Globalization.NumberStyles.HexNumber);

            pdu = pdu.Substring(2);

            switch (_DataCodingScheme.MessageCoding)
            {
            case GsmDataCoding.Ascii:
            {
                Process(pdu);
                break;
            }

            case GsmDataCoding.GsmDefault:
            {
                Process(pdu);
                break;
            }

            default:
            {
                throw new NotImplementedException();
            }
            }
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        public SubmitMessage(GsmDataCoding coding, int port)
        {
            _Coding = coding;
            _DataHeaderIndication = DataHeaderIndication.Yes;
            _DataHeader           = new DataHeader();
            {
                InfoElement.PortAddress elem = new InfoElement.PortAddress(InfoElement.AddressingScheme.TwoOctet)
                {
                    SourcePort = (ushort)port,
                    TargetPort = (ushort)port
                };
                _DataHeader.Add(elem);
            }

            _ProtocolIdentifier = new ProtocolIdentifier();
            _DataCodingScheme   = new DataCodingScheme(coding);
            _ValidityPeriod     = new ValidityPeriod(ValidityPeriodDuration.OneDay);
        }