GSM Communication on EBox4300--(3)

GSM Communication on EBox4300--(3)

GSM Communication on EBox4300--(1) is mainly about the framework of implementing GSM communication on EBox4300 ; GSM Communication on EBox4300--(2) states the production of hardware; this time, let’s talk about the communication between EBox4300 and TC35i.

   According to the "TC35i_ATC_V01.03" document of TC35i, we can use AT commands to control its behavior. Since earphones and microphones were not added in the previous hardware design, voice tests such as phone calls cannot be carried out here. Texting is the simplest and most direct test. The AT commands related to SMS are as follows:

    AT+CMGC: send a short message

    AT+CMGD: Delete the short message in the SIM card memory

    AT+CMGF: select short message information format: 0-PDU; 1-text

    AT+CMGL: List the short message PDU/text in the SIM card: 0/"REC UNREAD" -unread , 1/"REC READ"-read, 2/"STO UNSENT" -to be sent , 3/"STO SENT"-sent,


    AT+CMGR: read short message

    AT+CMGS: send short message

    AT+CMGW: Write the short message to be sent to the SIM memory

    AT+CMSS: send short message from SIM card memory

    AT+CNMI: display the newly received short message

    AT+CPMS: select short message memory

    AT+CSCA: Short message center address

    AT+CSCB: select cellular broadcast message

    AT+CSMP: Set the parameters of short message text mode

    AT+CSMS: select short message service

   The above AT commands are interacted through the serial port. According to the article Serial Port Debug on EBox4300 I wrote before , the EBox4300 can communicate with the TC35i through the serial port.

   The operation of the serial port can be realized by managed code, that is, the SerialPort in System.IO.Ports is used, which mainly includes Open, Close, Read and Write functions. Design a simple interface to display the ongoing serial port operation, as shown in Figure 1 below:

Figure 1: A simple UI debugging interface

   In the above figure, 1 and 2 are display windows for ZigBee (serial port 1 of EBox4300) signal transmission and reception; 3 and 4 are display windows for GSM short message transmission and reception; 5 is the target user's mobile phone number input box; 6 is for progress Simple operation buttons, including serial port opening and closing, TC35i module initialization, sending and receiving display area clearing and so on.

    EBox4300 sends commands to TC35i, which is actually to write characters to serial port 2. The output of serial port 2 can be used: m_serialPort2.Write();

   For example, when initializing the SMS mode settings, you can use:

//set AT+CMGF=1+carriage return and line feed

m_serialPort2.Write(new char[] {'A','T','+','C','M','G','F','=', '1' }, 0, 9) ;

m_serialPort2.Write(new byte[] {0x0D }, 0, 1);

m_serialPort2.Write(new byte[] {0x0A }, 0, 1);

   Special attention should be paid to: the content of the short message must end with hexadecimal number 0x1A. For example, when sending a short message, first send the other party's number, and then send the data:

//Send the phone number of the other party entered in the text

stATCommand = "AT+CMGS=+86" + textBoxPhoneNumber.Text;

btATCommand = stATCommand.ToCharArray();

m_serialPort2.Write(btATCommand, 0, 22);

m_serialPort2.Write(new byte[] {0x0D }, 0, 1);

m_serialPort2.Write(new byte[] {0x0A }, 0, 1);


m_serialPort2.Write(new char[] {'H','e','l','l','o'}, 0, 5);

//set SMS end symbol

m_serialPort2.Write(new byte[] {0x1A }, 0, 1);

   At this point, GSM network networking has been realized on EBox4300, and the part of sending SMS has been completed. I hope it will be useful to everyone. Thank you for your attention!

   For the demonstration of the project, you can watch the video on Youtube, the link address is: .


Reference: GSM Communication on EBox4300--(3)-Cloud + Community-Tencent Cloud