السلام عليكم
اخي الامر AT+CMGL="ALL" هو لقرائة جميع الرسائل الموجودة في الهاتف و الكارت
الامر ATE0 كما اخبرتك هو تقريبا نفسه AT فقط عندما
نرسل AT يرد علينا OK
اما ATE0 فهو لتعطيل ECHO و بالتالي الهاتف لا يرد يستقبل فقط
اخي جرب الامر
كود:
AT+CMGL="ALL" ,hyperterminal في
|
سلام عليكم
اخي كريم انظر الى هذا تسلسل في الارسال الاكواد وكل الامر ينتظر كلمة ok
كود:
while(1) {
GM862_Send(atc0); // Send "AT" string until GSM862 sets up its baud rade
Delay_ms(100); // and gets it correctly
if (Get_response() == GSM_OK) // If GSM862 says "OK" on our baud rate we program can continue
break;
}
GM862_Send(atc1); // Disable command echo
Wait_response(GSM_OK);
GM862_Send(atc2); // Set message type as TXT
Wait_response(GSM_OK);
while(1){
GM862_Send(atc5); // Delete all messages (if any)
if (get_response() == GSM_OK) // If messages are deleted
break; // break from while
Delay_ms(500);
}
// blink as a sign that initialization is successfully completed
Digital_OUTPUT = 0xFF;
Delay_ms(500);
Digital_OUTPUT = 0;
// infinite loop
while(1)
{
GM862_Send(atc6); // Read status of the messages and read message it self "AT+CMGL=\"ALL\"";
Delay_ms(100); // Wait until the message is read
while(1)
{
GM862_Send(atc0); // Wait until the module is ready "AT";
Delay_ms(50);
if (Get_response() == GSM_OK)
break;
}
if (Unread_flag)
{
if (PORT_flag)
{ // Turn ON/OFF port D LEDs if there were new commands
PORT_flag = 0;
Digital_Output = Digital_O;
}
while(1)
{
GM862_Send(atc0); // Wait until the module is ready
Delay_ms(50);
if (Get_response() == GSM_OK)
break;
}
if (status_req)
{ // Send status SMS if it's been requested
status_req = 0;
Send_Status();
}
Unread_flag = 0;
}
while(1)
{
GM862_Send(atc5); // Delete all messages (if any)
Delay_ms(50);
if (get_response() == GSM_OK) // If messages are deleted
break; // break from while
Delay_ms(50);
if (Unread_flag)
{ // if we have received message in mean time
Unread_flag = 0;
break; // break from while
}
}
Wait();
}
}
اخي كريم هذه الرسائل المخزنة
كود:
// Set of basic AT commands
const char atc0[] = "AT"; // Every AT command starts with "AT"
const char atc1[] = "ATE0"; // Disable command echo
const char atc2[] = "AT+CMGF=1"; // TXT messages
char atc3[] = "AT+CMGS=\""; // sends SMS to desired number
const char atc4[] = "AT+CMGR=1"; // Command for reading message from location 1 from inbox
const char atc5[] = "AT+CMGD=1,4"; // Erasing all messages from inbox
const char atc6[] = "AT+CMGL=\"ALL\""; // Check status of received SMS
//
ما تلاحظة بالكود اذا ارسل AT ينتظر كلمة ok
بعدها أجدة يرسل ATE0 ايضا ينتظر كلمة ok
سؤالي هنا لماذا ينتظر كلمة ok اذا لم يكن يرسل اي شيء
وايضا لما اجربة على hyperterminal يتوقف تماما عن كتابة اي انك لاتستطيع ان تكتب حرف واحدا هل يمكن تفسير ذلك
وماذا يحدث ان لم أكتبة في كود
=============================================
وهذا كود أخر لموديل أخر من GSM
كود:
// Negotiate baud rate
while(1) {
GM862_Send(atc0); // Send "AT" string until GSM862 sets up its baud rade
Delay_ms(100); // and gets it correctly
if (Get_response() == GSM_OK) // If GSM862 says "OK" on our baud rate we program can continue
break;
}
//
GM862_Send(atc1); // Disable command echo
Wait_response(GSM_OK);
GM862_Send(atc2); // Set message type as TXT
Wait_response(GSM_OK);
GM862_Send(atc5); // Delete all messages (if any)
Wait_response(GSM_OK);
Send_Status(); // Send Status after power-up
Wait();
while(1) {
GM862_Send(atc4); // Read SMS message on location 1
while (1){
rsp = Get_response();
if (rsp == GSM_OK || rsp == GSM_ERROR) break;
}
if (status_req){ // Send status SMS if it's been requested
status_req = 0;
Send_Status();
}
if (rsp == GSM_OK){
Wait();
GM862_Send(atc5); // Delete all messages (if any)
while (1){
rsp = Get_response();
if (rsp == GSM_OK) break;
}
}
Wait();
}
}
اجده في كلا كودين يوجد هناك تسلسل في الاوامر وهي
كود:
// Negotiate baud rate
while(1) {
GM862_Send(atc0); // Send "AT" string until GSM862 sets up its baud rade
Delay_ms(100); // and gets it correctly
if (Get_response() == GSM_OK) // If GSM862 says "OK" on our baud rate we program can continue
break;
}
//
GM862_Send(atc1); // Disable command echo
Wait_response(GSM_OK);
GM862_Send(atc2); // Set message type as TXT
Wait_response(GSM_OK);
GM862_Send(atc5); // Delete all messages (if any)
Wait_response(GSM_OK);
على فكرة وضعت جزء من كود وليس كود كامل وأنما كان قصدي من ذلك معرفة تسلسل الاوامر البرمجية مفروض كتابتها لغرض استلام الرسالة او ارسال معلومات