Example #1
0
        // Public Methods (1) 

        /// <summary>
        /// Reads Service Centre Address from device
        /// </summary>
        public DeviceAddress AddressType_Read()
        {
            try
            {
                string command = ATCommands.AddressType_Read;
                _serialport.DiscardInBuffer();
                _serialport.DiscardOutBuffer();
                receiveNow.Reset();
                _serialport.Write(command);

                string response = ReadResponse(1000);
                if (response.EndsWith(ATFinalResultCode.ERROR) || response.Length == 0)
                {
                    return(null);
                }
                else if (response.EndsWith(ATFinalResultCode.OK))
                {
                    string        result      = ReadResult(response, command, ATFinalResultCode.OK);
                    char[]        delimiter   = { ',' };
                    string[]      finalResult = result.Split(delimiter);
                    SCAddressType _type       = new SCAddressType();
                    if (finalResult[1].Trim() == "145")
                    {
                        _type = SCAddressType.International;
                    }
                    else if (finalResult[1].Trim() == "129")
                    {
                        _type = SCAddressType.Other;
                    }

                    string        returnSubCSCA = "+CSCA: ";
                    string        number1       = finalResult[0].Trim();
                    string        number2       = number1.Remove(0, returnSubCSCA.Length);
                    char[]        triming       = { '"' };
                    string        number3       = number2.Trim(triming);
                    DeviceAddress da            = new DeviceAddress(number3, _type);
                    return(da);
                }
            }
            catch (Exception ex)
            {
                ShowMessageInStatusbarEventArgs ev = new ShowMessageInStatusbarEventArgs(ex.Message, 5 * 1000);
                OnShowMessageInStatusbar(ev);
            }

            return(null);
        }
Example #2
0
        private void ButtonSetServiceCenter_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ServiceCenterAddress address = new ServiceCenterAddress();
                SCAddressType        type    = new SCAddressType();
                if (TextBoxServiceCenter.Text.StartsWith("+"))
                {
                    type = SCAddressType.International;
                }
                else
                {
                    type = SCAddressType.Other;
                }

                DeviceAddress da = new DeviceAddress(TextBoxServiceCenter.Text, type);
                address.AddressAndType = da;
            }
            catch (Exception ex)
            {
            }
        }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the <see
 /// cref="T:LogicLayer.DeviceAddress">DeviceAddress</see> class.
 /// </summary>
 /// <param name="number"></param>
 /// <param name="type"></param>
 public DeviceAddress(string number, SCAddressType type)
 {
     this._scNumber = number;
     this._type     = type;
 }