Jump to content

How send SMS Farsi (Arabic) with a GSM modem

- - - - -

  • Please log in to reply
1 reply to this topic

#1
afshin160

afshin160

    Newbie

  • Members
  • Pip
  • 1 posts
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.



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 #

#2
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,720 posts
  • Programming Language:C, Java, C++, PHP, Python, Perl, Assembly, Bash, Others
  • Learning:JavaScript
I take it that this is the line where your problem is?

myport.WriteLine("AT+CMGS=\""+txtTel.Text.Trim()+"\"\r");


I did a quick look around the Internet and found that you need to use Unicode to send your text message. There's an example of Unicode conversion in C# here.
sudo rm -rf /




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users