Click here to Skip to main content
15,890,982 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi .. I have a question with the following code to easily send SMS but can not do other languages ​​do send word. (eg "in Arabic). I read somewhere that I must first code word after I submitted.

The following code I'm easy to send messages.

<pre lang="cs">using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO.Ports;
using System.Threading;
namespace sms_at_command
{
    public partial class Form1 : Form
    {
        SerialPort myport = new SerialPort();
        string DeviceName = "";
        public Form1()
        {
            InitializeComponent();
            //تنظیمات پورت
            myport.BaudRate = 9600;
            myport.Parity = Parity.None;
            myport.StopBits = StopBits.One;
            myport.DataBits = 8;
            myport.ReadBufferSize = 10000;
            myport.ReadTimeout = 1000;
            myport.WriteBufferSize = 10000;
            myport.WriteTimeout = 10000;
            myport.RtsEnable = true;
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            cmbPortName.SelectedIndex = 0;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (cmbPortName.Text.Trim() != "")
            {
                try
                {
                    lblDeviceName.Text = "";
                    myport.PortName = cmbPortName.Text.Trim();
                    if (!myport.IsOpen)
                        myport.Open();
                    myport.DiscardOutBuffer();//خالی کردن بافر
                    myport.WriteLine("AT+cgmm\r");//دستور شناخت مدل دستگاه
                    Thread.Sleep(500);
                    DeviceName = myport.ReadExisting();
                    if (DeviceName.Contains("ERROR"))
                        MessageBox.Show("Device does not support this command or any other problem...");
                    else
                    {
                        //دستورات زیر برای بیرون کشیدن نام دستگاه از رشته خوانده شده از پورت هست
                        //(char)13   کاراکتر اینتر!
                        DeviceName = DeviceName.Remove(0, DeviceName.IndexOf((char)13)).Trim();
                        DeviceName = DeviceName.Substring(0, DeviceName.IndexOf((char)13));
                        MessageBox.Show("detected successfully" + Environment.NewLine + "Device Name:" + Environment.NewLine + DeviceName, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        lblDeviceName.Text ="Device Name: "+ DeviceName;
                        btnSend.Enabled = true;
                    }
                    myport.DiscardOutBuffer();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    myport.Close();
                }
            }
        }
        private void cmbPortName_SelectedIndexChanged(object sender, EventArgs e)
        {
            btnSend.Enabled = false;
        }
        private void btnSend_Click(object sender, EventArgs e)
        {
            if (txtTel.Text.Trim() != "")
            {
                try
                {
                    if (!myport.IsOpen)
                        myport.Open();
                    //خالی کردن بافر
                    myport.DiscardOutBuffer();
                    myport.DiscardInBuffer();
                    //قراردادن دستگاه در حالت متنی
                    myport.WriteLine("AT+CMGF=1\r");
                    //دستور ارسال اس ام اس
                    myport.WriteLine("AT+CMGS=\""+txtTel.Text.Trim()+"\"\r");
                    myport.WriteLine(txtMessage.Text.Trim() + '\x001a');// \x001a  (برای انتهای پیام ctrl+z معادل)
                    Thread.Sleep(500);
                    if (myport.ReadExisting().Contains("ERROR"))
                        MessageBox.Show("Device does not support this command or any other problem...");
                    else
                    {
                        MessageBox.Show("Sent successfully", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    myport.DiscardOutBuffer();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    myport.Close();
                }
            }
            else
            {
                MessageBox.Show("Enter Tel");
                txtTel.Focus();
            }
        }
        private void button1_Click_1(object sender, EventArgs e)
        {
            help f = new help();
            f.ShowDialog();
            f.Dispose();
        }
    }
}






Please "Help Me Please

How SMS Farsi (Arabic) with a GSM modem, I upload C #
Posted
Updated 1-May-11 2:30am
v2

1 solution

Hi afshin

You have to chose the correct encoding format. The default encoding schema use for SMS is "GSM default alphabet (GSM 03.38)[^]" or this link http://www.developershome.com/sms/gsmAlphabet.asp[^]

This does not define Arabic character set.

Use AT+CSCS to set TE character set to support the correct encoding.
AT+CSCS=? to list all supported encodings. But please note, that not all GSM units/modem support all types of encoding.

To really make it the correct way. You have to switch SMS message format to PDU encoding via AT+CMGF command.
Via PDU format, you can select the correct encoding, make long SMS ( over 160 char ), sending pictures, ring tone etc...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900