Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7625825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:14:34+00:00 2026-05-31T05:14:34+00:00

I’m working on a program in C# that can send a SMS from my

  • 0

I’m working on a program in C# that can send a SMS from my computer using my GSM modem, and I got most of my program to work.

I can send most Hayes AT commands like: “AT” and “AT+CGMI;+CGMM”, which returns the message “OK”, so I know I can communicate with the modem.

However I DO have problems sending a standard 7-bit encoded message from the modem to my cell phone.

With the help of PDUspy I have a somewhat confident that I’m encoding my message right.

However the following code fails miserably:

public string SendEncodedSms(string reciever, string message)
{
  string response = GetResponse("AT+CMGF=0");
  if (isFine(response))
  {
    string encodedBody = "000100" + EncodedReceiver(reciever) + "0000";
    encodedBody += EncodeToSeptet(message);

    int cmgs_header = encodedBody.Length / 2;

    port.WriteLine("AT+CMGS=" + cmgs_header.ToString() + "\r\n");
    port.WriteLine(encodedBody + (char)26);

    return ReadResponse(300);
  }
  else throw new ApplicationException("Cant go into SMS PDU mode");
}

There five function calls inside:

  • GetResponse() is function that works as a wrapper when communicating with the modem – always making sure each command ends with a “\r”, and returns OK or Error depending on the response from the modem.

  • isFine() is a simple function that check whether or not the response from GetResponse() contained a “OK” message.

  • ReadResponse() returns any response from the modem whether that is OK or any error messages and whatever there also might be embedded between the AT command and the status message.

  • EncodeReceiver() encode the receivers phone number in reverse nibble notation. E.g. 12345678 becomes 21436587.

  • EncodeToSeptet() Encodes the message from 8bit notation to 7bit notation.

All functions have been confirmed to work fine using PDU spy and responses sent to debug window.

Calling SendEncodedSms("<my phone number>", "test") returns:

AT+CMGS=17

0001000A91xxxxxxxxxx000004F4F29C0E

+CMS ERROR: 304

I replaced my encoded phone number for privacy issues… 😉

  • Is there anybody who can give me a hint what I am failing at?

UPDATED:

Link hinted I was calculating cmgs_header wrong.

After a bit of cleaning code I got:

public string SendEncodedSms(string receiver, string message)
{
  if(isFine("AT+CMGF=0"))
  {
     string encodedBody = EncodedReceiver(receiver) + "0000";
     encodedBody += EncodeToSeptet(message);

     /* The +2 in calculation is a hack. Its probleby two of the octets 
      * in 000100 that should be a part of length calculation. But need 
      * to verify in against severeal sites.
      */
     int cmgs_header = (encodedBody.Length / 2) + 2;

     encodedBody = "000100" + encodedBody;

     // Rest is as before.

    ...

  }

  else ...
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T05:14:35+00:00Added an answer on May 31, 2026 at 5:14 am

    Maybe this helps you. Why don’t you send the SMS in text mode?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.