اطلاعیه

Collapse
No announcement yet.

کد خواندن اس ام اس دریافتی در sim900

Collapse
X
 
  • فیلتر
  • زمان
  • Show
Clear All
new posts

    کد خواندن اس ام اس دریافتی در sim900

    سلام
    من می خوام متن پیام دریافتی توسط ماژول و بخونم .فرمت دریافتی به صورت زیر است ؛
    0D 0Aمتن پیام دریافتی 0D 0A 0D 0Aشماره تماس و تاریخ و زمان و نام 0D 0A

    چه طور باید کد دریافت و بنویسم که کل این رشته دریافت بشه ؟
    IN GOD WE TRUST

    #2
    پاسخ : کد خواندن اس ام اس دریافتی در sim900

    سلام
    از چه برد یا ماژول sim ای استفاده میکنی؟
    الان کدش رو میخوای؟ یا میگی چرا فرمت دیتا این طوری هستش و میخوای فرمت دیتای دریافتی رو درست کنی؟ کدومش؟
    اللَّهُمَّ صَلِّ عَلَى مُحَمَّدٍ وآلِ مُحَمَّدٍ وعَجِّلْ فَرَجَهُمْ

    اگه دوس دارید سریع به جواب برسید :
    1) قبل از پرسیدن سوال، بسرچید.
    2) سوالاتون رو با جزئیات کامل مطرح کنید.

    دیدگاه


      #3
      پاسخ : کد خواندن اس ام اس دریافتی در sim900

      از sim900 استفاده می کنم و پسوندی نداره . مشکلم اینه که وقتی از دستور serial.read() استفاده می کنم و میریزمش توی یک ارایه دیتا درست دریافت نمیشه ، اگه شما از کد دریافت بهینه ای استفاده کردین لطفا برام بفرستید .
      خیلی ممنون می شم
      بازم از جوابتون ممنونم
      IN GOD WE TRUST

      دیدگاه


        #4
        پاسخ : کد خواندن اس ام اس دریافتی در sim900

        این کد رو تو یکی از پروژه های قدیمی پیدا کردم شاید به دردت بخوره.

        کد:
        void Read_sms(void)
        {
            num=0;
            printf("AT+CMGR=%i%c",sms_ss,enter);
            for(count=0;buffer[count-2]!='O';count++) buffer[count]=getchar();
            delay_ms(500);
            for(count=0,count2=0,count_s=0;buffer[count]!='\0';count++)
            {
                if(buffer[count]==34) count_s++;
                if(count_s==3)
                {
                    if(buffer[count]!=34)
                    {
                        get_number[count2]=buffer[count];
                        count2++;
                    }
                }
                if(count_s==4) count2=0;
                if(count_s==8)
                {
                    if(buffer[count]!=34 && buffer[count]!=10 && buffer[count]!=13 && buffer[count]!=75 && buffer[count]!=79)
                    {
                        text_buffer[count2]=buffer[count];
                        count2++;
                    }
                }
            }
            text_analiz();
            if(strcmp(get_number,NUMBER)==0)  num=1;
            if(num==1)
            {
                if(strcmp(text,STAT_OUT)==0) 
                {
                    state_modual();
                }
                //***************************
                else if(strcmp(text,CH1_ON)==0)  
                {
                    OUT1=1;
                }
                else if(strcmp(text,CH1_OFF)==0) 
                {
                    OUT1=0;
                }
                else if(strcmp(text,CH2_ON)==0) 
                {
                    OUT2=1;
                }
                else if(strcmp(text,CH2_OFF)==0)
                {
                    OUT2=0;
                }
                else if(strcmp(text,CH3_ON)==0) 
                {
                    OUT3=1;
                }
                else if(strcmp(text,CH3_OFF)==0)
                {
                    OUT3=0;
                }
                else if(strcmp(text,CH4_ON)==0) 
                {
                    OUT4=1;
                }
                else if(strcmp(text,CH4_OFF)==0) 
                {
                    OUT4=0;
                }
                //************************** 
                else if(strcmp(text,C1_ON)==0) 
                {
                    OUT1=1;
                }
                else if(strcmp(text,C1_OFF)==0) 
                {
                    OUT1=0;
                }
                else if(strcmp(text,C2_ON)==0) 
                {
                    OUT2=1;
                }
                else if(strcmp(text,C2_OFF)==0) 
                {
                    OUT2=0;
                }
                else if(strcmp(text,C3_ON)==0) 
                {
                    OUT3=1;
                }
                else if(strcmp(text,C3_OFF)==0) 
                {
                    OUT3=0;
                }
                else if(strcmp(text,C4_ON)==0) 
                {
                    OUT4=1;
                }
                else if(strcmp(text,C4_OFF)==0) 
                {
                    OUT4=0;
                } 
                //************************** 
                else if(strcmp(text,H1_ON)==0) 
                {
                    OUT1=1;
                }
                else if(strcmp(text,H1_OFF)==0) 
                {
                    OUT1=0;
                }
                else if(strcmp(text,H2_ON)==0) 
                {
                OUT2=1;
                }
                else if(strcmp(text,H2_OFF)==0) 
                {
                    OUT2=0;
                }
                else if(strcmp(text,H3_ON)==0) 
                {
                    OUT3=1;
                }
                else if(strcmp(text,H3_OFF)==0) 
                {
                    OUT3=0;
                }
                else if(strcmp(text,H4_ON)==0) 
                {
                    OUT4=1;
                }
                else if(strcmp(text,H4_OFF)==0) 
                {
                    OUT4=0;
                }
                //***************************
                else if(strcmp(text,ALL_ON)==0) 
                {
                    OUT1=1;
                    OUT2=1;
                    OUT3=1;
                    OUT4=1;
                }
                else if(strcmp(text,ALL_OFF)==0) 
                {
                    OUT1=0;
                    OUT2=0;
                    OUT3=0;
                    OUT4=0;
                }
                //***************************
                else if(strcmp(text,Protect_E)==0) 
                {
                    GICR|=1<<INT2;
                    safe_on();
                }
                else if(strcmp(text,Protect_D)==0) 
                {
                    GICR&=0xDF;
                    safe=0;
                    safe_off();
                }
            }
            text_clear();
        }
        
        void text_analiz(void)
        {
            for(count=0,count2=0;text_buffer[count]!='\0';count++,count2++)
            {
                if(text_buffer[count]>=65 || text_buffer[count]<=65)
                {
                    text[count2]=tolower(text_buffer[count]);
                }
                else  text[count2]=text_buffer[count];
            }
        }
        چرا ناراحتی پاتریک!
        + امروز ی بچه دیدم سرچهارراه گل میفروخت
        - از دیدنش ناراحت شدی؟
        + نه
        پس چی ناراحتت کرده
        + اینکه دیدن اینجور بچه ها انقدر واسم عادی شده که دیگه ناراحتم نمیکنه
        ------------------------------------------------------------------------------------------------------
        تاحالا فکر کردی بیسواد کیه؟- بی سواد یعنی کسی که نمیتونه ذهنیاتش رو عملی کنه!
        ------------------------------------------------------------------------------------------------------
        محصولات

        دیدگاه


          #5
          پاسخ : کد خواندن اس ام اس دریافتی در sim900

          این دو تا تابع رو هم ببین - خودم نوشتن و تستشون هم کردم(از یکی از پروژه هام برداشتم - ولی فک نکنم بدردت بخوره چون از کتابخونه داری استفاده میکنی - ولی شاید هم خورد:devil2
          ارسال

          کد:
          /*  UserNumber = 0:2
            0 ---> Admin
            1 ---> User1
            2 ---> User2
          
          
            InPut_OutPut = 0:1
            0 = InPut
            1 = OutPut
          
          
            Port
            1:10(OutPut)
            1:5(InPut)
          
          
            PortStatus
            0 : on
            1 : off
          */
          void SendMessage(unsigned char UserNumber, bool InPut_OutPut, unsigned char Port, bool PortStatus) {
          
          
            ReadChargeMobile();
          
          
            for (int i = 0; i <= 12; i++) MobileNumberAdminUser[i] = '\0'; // خالی کردن آرایه
            ReadWrite_MobileNumber_EEPROM(1, UserNumber, MobileNumberAdminUser); // خوندن شماره موبایل
          
          
            Serial2.println("AT+CMGF=1"); //Sets the GSM Module in "Text Mode"
            delay(1000);
          
          
            Serial2.print("AT+CMGS=\"");
            for (int i = 0; i <= 12; i++)
              Serial2.write(MobileNumberAdminUser[i]);
            Serial2.println("\"\r");
            delay(1000);
          
          
            // The SMS text you want to send(Example : Output1on Etebar: 27335 Rial)
            Serial2.print(DataSMS[InPut_OutPut]); Serial2.print(Port); Serial2.print(DataSMS[2 + PortStatus]);
            for (int i = 0; Etebar[i] != '\0'; i++)
              Serial2.write( Etebar[i] );
            delay(1000);
          
          
            Serial2.println((char)26); // ASCII code of CTRL+Z
            delay(10000);
          }
          void SendMessage(unsigned char UserNumber, unsigned char *Data) {
          
          
            ReadChargeMobile();
          
          
            for (int i = 0; i <= 12; i++) MobileNumberAdminUser[i] = '\0'; // خالی کردن آرایه
            ReadWrite_MobileNumber_EEPROM(1, UserNumber, MobileNumberAdminUser); // خوندن شماره موبایل
          
          
            Serial2.println("AT+CMGF=1"); //Sets the GSM Module in "Text Mode"
            delay(1000);
          
          
            // SMS MobileNumber
            Serial2.print("AT+CMGS=\"");
            for (int i = 0; i <= 12; i++) Serial2.write(MobileNumberAdminUser[i]);
            Serial2.println("\"\r");
            delay(1000);
          
          
            // SMS text
            for (int i = 0; Data[i] != '\0'; i++) Serial2.write(Data[i]);
            for (int i = 0; Etebar[i] != '\0'; i++) Serial2.write( Etebar[i] );
          
          
            delay(1000);
          
          
            Serial2.println((char)26); // ASCII code of CTRL+Z
            delay(10000);
          }

          دریافت

          کد:
          int8_t RecieveMessage() {
          
            char DSR[200]; // DataSmsRecieve = DSR
          
          
          
          
            // خالی کردن آرایه
            for (int j = 0; j < 200; j++)  DSR[j] = '\0';
            for (int j = 0; j < 14;  j++)  NewMobileNumber[j] = '\0';
            for (int j = 0; j < 14;  j++)  MobileNumberSender[j] = '\0';
          
          
          
          
            // متصل کردن شماره خانه ای از حافظه که دیتا داخلش قرار داره به کامند دریافت دیتا
            /*  char CommandReadSMS[11] = "AT+CMGR=";
              if ( NML < 10 ) {
                CommandReadSMS[8] = GetChar(NML);
              }
              else if ( NML < 100 ) {
                CommandReadSMS[9] = GetChar( NML % 10 );
                CommandReadSMS[8] = GetChar( NML / 10 );
              }
            */
          
          
          
          
            if ( sendATcommand("AT+CMGF=1", "OK", 300, NULL, 100)       ) {
          #if Debug_Project == 1
              Serial.print("1");
          #endif
            }
            if ( sendATcommand("AT+CSCS=\"GSM\"", "OK", 300, NULL, 100) ) {
          #if Debug_Project == 1
              Serial.print("2");
          #endif
            }
            if ( sendATcommand("AT+CNMI=2,1,0,0", "OK", 300, NULL, 100) ) {
          #if Debug_Project == 1
              Serial.print("3");
          #endif
            }
            if ( sendATcommand("AT+CMGR=1", "*", 1000, DSR, 100)         ) {
          
          
          #if Debug_Project == 1
              Serial.println("4");
              // نمایش دیتا
              for (int w = 0; DSR[w] != '\0'; w++) Serial.write(DSR[w]);  Serial.println();
          #endif
          
          
          
          
              // سیر کردن در آرایه برای پیدا کردن شماره موبایل ارسال کننده و متن پیامک
              for (int j = 0; j < 200; j++)
              {
                // پیدا کردن شماره موبایل ارسال کننده پیامک
                // +CMGL: 1,"REC UNREAD","+989372431686"
                if (DSR[j] == '+' && DSR[j + 1] == '9' && DSR[j + 2] == '8')
                {
                  // ذخیره کردن شماره موبایل ارسال کننده پیامک در آرایه مربوطه
                  for (int f = 0; f < 13; f++) MobileNumberSender[f] = DSR[j + f];
          
          
                  // بررسی شماره موبایل ارسال کننده با 3 شماره موجود - اگه شماره ارسال کننده موجود نبود در ایپرام از تابع خارج میشیم
                  for (int k = 0; k <= 2; k++) {
                    for (int i = 0; i <= 12; i++) MobileNumberAdminUser[i] = '\0'; // خالی کردن آرایه
                    ReadWrite_MobileNumber_EEPROM(1, k, MobileNumberAdminUser); // خوندن شماره موبایل
          
          
                    if (
                      MobileNumberAdminUser[0]  == MobileNumberSender[0]  &&
                      MobileNumberAdminUser[1]  == MobileNumberSender[1]  &&
                      MobileNumberAdminUser[2]  == MobileNumberSender[2]  &&
                      MobileNumberAdminUser[3]  == MobileNumberSender[3]  &&
                      MobileNumberAdminUser[4]  == MobileNumberSender[4]  &&
                      MobileNumberAdminUser[5]  == MobileNumberSender[5]  &&
                      MobileNumberAdminUser[6]  == MobileNumberSender[6]  &&
                      MobileNumberAdminUser[7]  == MobileNumberSender[7]  &&
                      MobileNumberAdminUser[8]  == MobileNumberSender[8]  &&
                      MobileNumberAdminUser[9]  == MobileNumberSender[9]  &&
                      MobileNumberAdminUser[10] == MobileNumberSender[10] &&
                      MobileNumberAdminUser[11] == MobileNumberSender[11] &&
                      MobileNumberAdminUser[12] == MobileNumberSender[12]
                    )
                    {
                      User_Number_Sender_SMS = k; // این کار رو میکنم تا ببینم که کدوم کاربر پیام رو ارسال کرده
                      goto DownFindSender;
                    }
                  }
          
          
          #if Debug_Project == 1
                  Serial.print("Mobile Number Sender is = ");
                  for (int a = 0; a < 13; a++) Serial.write(MobileNumberSender[a]);   Serial.println();
                  Serial.println("This Mobile Number is not Save in EEPROM");
          #endif
                  return 2; // شماره موبایل رو پیدا کردیم اما در حافظه ذخیره نشده بود
          
          
          DownFindSender:
          
          
          
          
                  // بررسی این که پیغام های مد نظر ما ارسال شده یا نه
                  for (int d = 0; d < 200; d++)
                  {
                    if ( // Time?* ---> 4 ----> خوندن زمان
                      ( DSR[d + 0] == 'T' || DSR[d + 0] == 't' ) &&
                      ( DSR[d + 1] == 'I' || DSR[d + 1] == 'i' ) &&
                      ( DSR[d + 2] == 'M' || DSR[d + 2] == 'm' ) &&
                      ( DSR[d + 3] == 'E' || DSR[d + 3] == 'e' ) &&
                      ( DSR[d + 4] == '?' || DSR[d + 4] == '؟' )
                    ) {
          #if Debug_Project == 1
                      Serial.println("What is now Time.");
          #endif
          
          
          
          
                      now     = rtc.now();
                      hour    = now.hour();
                      minute  = now.minute();
                      TimeData[0]  = 'T';
                      TimeData[1]  = 'i';
                      TimeData[2]  = 'm';
                      TimeData[3]  = 'e';
                      TimeData[4]  = '=';
                      TimeData[5]  = (hour / 10) + 48;
                      TimeData[6]  = (hour % 10) + 48;
                      TimeData[7]  = ':';
                      TimeData[8]  = (minute / 10) + 48;
                      TimeData[9]  = (minute % 10) + 48;
                      TimeData[10] = '\n';
                      TimeData[11] = '\0';
          
          
                      SendMessage(User_Number_Sender_SMS, TimeData);
                      return 4;
                    }
                    else if ( //Time=11:12* ---> 5 ---> تنظیم زمان
                      ( DSR[d + 0] == 'T' || DSR[d + 0] == 't' ) &&
                      ( DSR[d + 1] == 'I' || DSR[d + 1] == 'i' ) &&
                      ( DSR[d + 2] == 'M' || DSR[d + 2] == 'm' ) &&
                      ( DSR[d + 3] == 'E' || DSR[d + 3] == 'e' ) &&
                      ( DSR[d + 4] == '='                      ) &&
                      ( isDigit( DSR[d + 5] )                  ) &&
                      ( isDigit( DSR[d + 6] )                  ) &&
                      ( DSR[d + 7] == ':'                      ) &&
                      ( isDigit( DSR[d + 8] )                  ) &&
                      ( isDigit( DSR[d + 9] )                  ) &&
                      ( User_Number_Sender_SMS == 0              ) // فقط ادمین میتونه این کار رو انجام بده
                    ) {
          #if Debug_Project == 1
                      Serial.println("Set now Time.");
          #endif
          
          
          
          
          
          
                      hour    =   GetNumber( DSR[d + 5] ) * 10 + GetNumber( DSR[d + 6] );
                      minute  =   GetNumber( DSR[d + 8] ) * 10 + GetNumber( DSR[d + 9] );
                      now = rtc.now();
                      DateTime dt(now.year(), now.month(), now.date(), hour, minute, now.second(), now.dayOfWeek());
                      rtc.setDateTime(dt);
          
          
          
          
                      now     = rtc.now();
                      hour    = now.hour();
                      minute  = now.minute();
                      TimeData[0]  = 'T';
                      TimeData[1]  = 'i';
                      TimeData[2]  = 'm';
                      TimeData[3]  = 'e';
                      TimeData[4]  = '=';
                      TimeData[5]  = (hour / 10) + 48;
                      TimeData[6]  = (hour % 10) + 48;
                      TimeData[7]  = ':';
                      TimeData[8]  = (minute / 10) + 48;
                      TimeData[9]  = (minute % 10) + 48;
                      TimeData[10] = '\n';
                      TimeData[11] = '\0';
          
          
          
          
                      SendMessage(User_Number_Sender_SMS, TimeData);
          
          
          
          
                      return 5;
                    }
                    else if ( // Day?* ---> 6 ---> خوندن روز ----> Monday
                      ( DSR[d + 0] == 'D' || DSR[d + 0] == 'd' ) &&
                      ( DSR[d + 1] == 'A' || DSR[d + 1] == 'a' ) &&
                      ( DSR[d + 2] == 'Y' || DSR[d + 2] == 'y' ) &&
                      ( DSR[d + 3] == '?' || DSR[d + 3] == '؟' )
                    ) {
          #if Debug_Project == 1
                      Serial.println("What is now Day.");
          #endif
          
          
          
          
                      now = rtc.now(); // بروز کردن زمان
                      SendMessage( User_Number_Sender_SMS, Show_dayOfWeek[now.dayOfWeek()] );
          
          
          
          
                      return 6;
                    }
                    else if ( // day=4* ---> 7 ---> نوشتن روز
                      ( DSR[d + 0] == 'D' || DSR[d + 0] == 'd' ) &&
                      ( DSR[d + 1] == 'A' || DSR[d + 1] == 'a' ) &&
                      ( DSR[d + 2] == 'Y' || DSR[d + 2] == 'y' ) &&
                      ( DSR[d + 3] == '='                      ) &&
                      ( isDigit( DSR[d + 4] )                  ) &&
                      ( User_Number_Sender_SMS == 0              ) // فقط ادمین میتونه این کار رو انجام بده
                    ) {
          #if Debug_Project == 1
                      Serial.println("Set now Day.");
          #endif
          
          
          
          
                      // تنظیم زمان ماژول
                      now = rtc.now(); // بروز کردن زمان
                      DateTime dt( now.year(), now.month(), now.date(), now.hour(), now.minute(), now.second(), GetNumber(DSR[d + 4]) );
                      rtc.setDateTime(dt);
          
          
          
          
                      // ارسال زمان برای کاربر
                      now = rtc.now(); // بروز کردن زمان
                      SendMessage( User_Number_Sender_SMS, Show_dayOfWeek[now.dayOfWeek()] );
          
          
          
          
                      return 7;
                    }
                    else if ( // Admin=+989372431686*** ---> 8 ---> تغییر شماره ادمین
                      ( DSR[d + 0] == 'A' || DSR[d + 0] == 'a'                                 ) &&
                      ( DSR[d + 1] == 'D' || DSR[d + 1] == 'd'                                 ) &&
                      ( DSR[d + 2] == 'M' || DSR[d + 2] == 'm'                                 ) &&
                      ( DSR[d + 3] == 'I' || DSR[d + 3] == 'i'                                 ) &&
                      ( DSR[d + 4] == 'N' || DSR[d + 4] == 'n'                                 ) &&
                      ( DSR[d + 5] == '=' && DSR[d + 6] == '+'                                 ) &&
                      isDigit( DSR[d + 7]  ) && isDigit( DSR[d + 8]  ) && isDigit( DSR[d + 9]  ) &&
                      isDigit( DSR[d + 10] ) && isDigit( DSR[d + 11] ) && isDigit( DSR[d + 12] ) &&
                      isDigit( DSR[d + 13] ) && isDigit( DSR[d + 14] ) && isDigit( DSR[d + 15] ) &&
                      isDigit( DSR[d + 16] ) && isDigit( DSR[d + 17] ) && isDigit( DSR[d + 18] ) &&
                      ( User_Number_Sender_SMS == 0                                              ) // فقط ادمین میتونه این کار رو انجام بده
                    ) {
                      // ذخیره کردن شماره موبایل جدید در آرایه مربوطه
                      for (int f = 0; f < 13; f++) NewMobileNumber[f] = DSR[d + 6 + f];
          
          
                      // ذخیره شماره موبایل در ایپرام
                      ReadWrite_MobileNumber_EEPROM(0, 0, NewMobileNumber);
          
          
          #if Debug_Project == 1
                      Serial.println("Admin=09...***");
          #endif
          
          
          
          
                      // تعریف آرایه و ریختن دیتا داخلش
                      unsigned char ChangeAdmin[30] = { 'A', 'd', 'm', 'i', 'n', '\n', '(',
                                                        NewMobileNumber[0],
                                                        NewMobileNumber[1],
                                                        NewMobileNumber[2],
                                                        NewMobileNumber[3],
                                                        NewMobileNumber[4],
                                                        NewMobileNumber[5],
                                                        NewMobileNumber[6],
                                                        NewMobileNumber[7],
                                                        NewMobileNumber[8],
                                                        NewMobileNumber[9],
                                                        NewMobileNumber[10],
                                                        NewMobileNumber[11],
                                                        NewMobileNumber[12],
                                                        ')', '\n', 'A', 'd', 'd', 'e', 'd', '.', '\n',
                                                        '\0'
                                                      };
          
          
          
          
                      // ارسال پیام به ادمین که عملیات با موفقیت انجام شد
                      SendMessage(0, ChangeAdmin);
          
          
          
          
                      return 8;
                    }
                    else if ( // user1=+989372431686*** ---> 9 ---> تغییر کاربر 1
                      ( DSR[d + 0] == 'U' || DSR[d + 0] == 'u'                                 ) &&
                      ( DSR[d + 1] == 'S' || DSR[d + 1] == 's'                                 ) &&
                      ( DSR[d + 2] == 'E' || DSR[d + 2] == 'e'                                 ) &&
                      ( DSR[d + 3] == 'R' || DSR[d + 3] == 'r'                                 ) &&
                      ( DSR[d + 4] == '1' && DSR[d + 5] == '=' && DSR[d + 6] == '+'            ) &&
                      isDigit( DSR[d + 7]  ) && isDigit( DSR[d + 8]  ) && isDigit( DSR[d + 9]  ) &&
                      isDigit( DSR[d + 10] ) && isDigit( DSR[d + 11] ) && isDigit( DSR[d + 12] ) &&
                      isDigit( DSR[d + 13] ) && isDigit( DSR[d + 14] ) && isDigit( DSR[d + 15] ) &&
                      isDigit( DSR[d + 16] ) && isDigit( DSR[d + 17] ) && isDigit( DSR[d + 18] ) &&
                      ( User_Number_Sender_SMS == 0                                              ) // فقط ادمین میتونه این کار رو انجام بده
                    ) {
                      // ذخیره کردن شماره موبایل جدید در آرایه مربوطه
                      for (int f = 0; f < 13; f++) NewMobileNumber[f] = DSR[d + 6 + f];
          
          
                      // ذخیره شماره موبایل در ایپرام
                      ReadWrite_MobileNumber_EEPROM(0, 1, NewMobileNumber);
          
          
          #if Debug_Project == 1
                      Serial.println("user1=09...***");
          #endif
          
          
          
          
                      // تعریف آرایه و ریختن دیتا داخلش
                      unsigned char ChangeUser1[30] = { 'U', 's', 'e', 'r', '1', '\n', '(',
                                                        NewMobileNumber[0],
                                                        NewMobileNumber[1],
                                                        NewMobileNumber[2],
                                                        NewMobileNumber[3],
                                                        NewMobileNumber[4],
                                                        NewMobileNumber[5],
                                                        NewMobileNumber[6],
                                                        NewMobileNumber[7],
                                                        NewMobileNumber[8],
                                                        NewMobileNumber[9],
                                                        NewMobileNumber[10],
                                                        NewMobileNumber[11],
                                                        NewMobileNumber[12],
                                                        ')', '\n', 'A', 'd', 'd', 'e', 'd', '.', '\n',
                                                        '\0'
                                                      };
          
          
          
          
                      // ارسال پیام به ادمین که عملیات با موفقیت انجام شد
                      SendMessage(0, ChangeUser1);
          
          
          
          
                      return 9;
                    }
                    else if ( // user2=+989372431686*** ---> 10 ---> تغییر کاربر 2
                      ( DSR[d + 0] == 'U' || DSR[d + 0] == 'u'                                 ) &&
                      ( DSR[d + 1] == 'S' || DSR[d + 1] == 's'                                 ) &&
                      ( DSR[d + 2] == 'E' || DSR[d + 2] == 'e'                                 ) &&
                      ( DSR[d + 3] == 'R' || DSR[d + 3] == 'r'                                 ) &&
                      ( DSR[d + 4] == '2' && DSR[d + 5] == '=' && DSR[d + 6] == '+'            ) &&
                      isDigit( DSR[d + 7]  ) && isDigit( DSR[d + 8]  ) && isDigit( DSR[d + 9]  ) &&
                      isDigit( DSR[d + 10] ) && isDigit( DSR[d + 11] ) && isDigit( DSR[d + 12] ) &&
                      isDigit( DSR[d + 13] ) && isDigit( DSR[d + 14] ) && isDigit( DSR[d + 15] ) &&
                      isDigit( DSR[d + 16] ) && isDigit( DSR[d + 17] ) && isDigit( DSR[d + 18] ) &&
                      ( User_Number_Sender_SMS == 0                                              ) // فقط ادمین میتونه این کار رو انجام بده
                    ) {
                      // ذخیره کردن شماره موبایل جدید در آرایه مربوطه
                      for (int f = 0; f < 13; f++) NewMobileNumber[f] = DSR[d + 6 + f];
          
          
                      // ذخیره شماره موبایل در ایپرام
                      ReadWrite_MobileNumber_EEPROM(0, 2, NewMobileNumber);
          
          
          #if Debug_Project == 1
                      Serial.println("user2=09...***");
          #endif
          
          
                      // تعریف آرایه و ریختن دیتا داخلش
                      unsigned char ChangeUser2[30] = { 'U', 's', 'e', 'r', '2', '\n', '(',
                                                        NewMobileNumber[0],
                                                        NewMobileNumber[1],
                                                        NewMobileNumber[2],
                                                        NewMobileNumber[3],
                                                        NewMobileNumber[4],
                                                        NewMobileNumber[5],
                                                        NewMobileNumber[6],
                                                        NewMobileNumber[7],
                                                        NewMobileNumber[8],
                                                        NewMobileNumber[9],
                                                        NewMobileNumber[10],
                                                        NewMobileNumber[11],
                                                        NewMobileNumber[12],
                                                        ')', '\n', 'A', 'd', 'd', 'e', 'd', '.', '\n',
                                                        '\0'
                                                      };
          
          
          
          
                      // ارسال پیام به ادمین که عملیات با موفقیت انجام شد
                      SendMessage(0, ChangeUser2);
          
          
                      return 10;
                    }
                    else if ( // Delete user1 ---> 11 ---> حذف کاربر1
                      ( DSR[d + 0]  == 'D' || DSR[d + 0]  == 'd' ) &&
                      ( DSR[d + 1]  == 'E' || DSR[d + 1]  == 'e' ) &&
                      ( DSR[d + 2]  == 'L' || DSR[d + 2]  == 'l' ) &&
                      ( DSR[d + 3]  == 'E' || DSR[d + 3]  == 'e' ) &&
                      ( DSR[d + 4]  == 'T' || DSR[d + 4]  == 't' ) &&
                      ( DSR[d + 5]  == 'E' || DSR[d + 5]  == 'e' ) &&
                      ( DSR[d + 6]  == ' '                       ) &&
                      ( DSR[d + 7]  == 'U' || DSR[d + 7]  == 'u' ) &&
                      ( DSR[d + 8]  == 'S' || DSR[d + 8]  == 's' ) &&
                      ( DSR[d + 9]  == 'E' || DSR[d + 9]  == 'e' ) &&
                      ( DSR[d + 10] == 'R' || DSR[d + 10] == 'r' ) &&
                      ( DSR[d + 11] == '1'                       ) &&
                      ( User_Number_Sender_SMS == 0                ) // فقط ادمین میتونه این کار رو انجام بده
                    ) {
                      // حذف شماره از ایپرام
                      for (int i = 0; i <= 12; i++) MobileNumberAdminUser[i] == '\0';
                      ReadWrite_MobileNumber_EEPROM(0, 1, MobileNumberAdminUser);
          
          
          #if Debug_Project == 1
                      Serial.println("Delete user1");
          #endif
          
          
                      // ارسال پیام به ادمین که عملیات با موفقیت انجام شد
                      SendMessage(0, (unsigned char *)"User1 Deleted\n");
          
          
                      return 11;
                    }
                    else if ( // Delete user2 ---> 12 ---> حذف کاربر2
                      ( DSR[d + 0]  == 'D' || DSR[d + 0]  == 'd' ) &&
                      ( DSR[d + 1]  == 'E' || DSR[d + 1]  == 'e' ) &&
                      ( DSR[d + 2]  == 'L' || DSR[d + 2]  == 'l' ) &&
                      ( DSR[d + 3]  == 'E' || DSR[d + 3]  == 'e' ) &&
                      ( DSR[d + 4]  == 'T' || DSR[d + 4]  == 't' ) &&
                      ( DSR[d + 5]  == 'E' || DSR[d + 5]  == 'e' ) &&
                      ( DSR[d + 6]  == ' '                     ) &&
                      ( DSR[d + 7]  == 'U' || DSR[d + 7]  == 'u' ) &&
                      ( DSR[d + 8]  == 'S' || DSR[d + 8]  == 's' ) &&
                      ( DSR[d + 9]  == 'E' || DSR[d + 9]  == 'e' ) &&
                      ( DSR[d + 10] == 'R' || DSR[d + 10] == 'r' ) &&
                      ( DSR[d + 11] == '2'                       ) &&
                      ( User_Number_Sender_SMS == 0                ) // فقط ادمین میتونه این کار رو انجام بده
                    ) {
                      // حذف شماره از ایپرام
                      for (int i = 0; i <= 12; i++) MobileNumberAdminUser[i] == '\0';
                      ReadWrite_MobileNumber_EEPROM(0, 2, MobileNumberAdminUser);
          
          
          #if Debug_Project == 1
                      Serial.println("Delete user2\n");
          #endif
          
          
                      // ارسال پیام به ادمین که عملیات با موفقیت انجام شد
                      SendMessage(0, (unsigned char *)"User2 Deleted");
          
          
                      return 12;
                    }
                  }
          
          
          
          
                  SendMessage(User_Number_Sender_SMS, (unsigned char *)"Bad command\n");
          #if Debug_Project == 1
                  Serial.print("Mobile Number Sender is = ");
                  for (int a = 0; a < 13; a++) Serial.write(MobileNumberSender[a]);   Serial.println();
                  Serial.println("This Mobile Number is SaveD in EEPROM, But There are no my Data.");
          #endif
                  return 3; // شماره موبایل رو پیدا کردیم اما دیتای مد نظرمون در محتوای پیام وجود نداشت
                }
              }
          
          
          
          
          #if Debug_Project == 1
              Serial.println("Mobile Number Sender ?????");
          #endif
              return 1; // نتونستیم شماره موبایل ارسال کننده رو بفهمیم - شاید شماره موبایل نبوده و شماره تبلیغاتی بوده است
            }
            else {
          #if Debug_Project == 1
              Serial.println("Data Not Found");
          #endif
              return 0; // دیتای مد نظر رو پیدا نکردیم
            } 
          }
          جدیدترین ویرایش توسط md3848; ۱۳:۰۲ ۱۳۹۵/۰۵/۲۴.
          اللَّهُمَّ صَلِّ عَلَى مُحَمَّدٍ وآلِ مُحَمَّدٍ وعَجِّلْ فَرَجَهُمْ

          اگه دوس دارید سریع به جواب برسید :
          1) قبل از پرسیدن سوال، بسرچید.
          2) سوالاتون رو با جزئیات کامل مطرح کنید.

          دیدگاه


            #6
            دوستان خیلی از جواباتون ممنونم
            کدهارو امتحان می کنم جواب داد حتما نتیجه رو اعلام می کنم
            ممنونم از جوابهاتون

            ممنونم md3848
            ولی اگه امکان داره این تابع رو بذارید :
            sendATcommand("AT+CMGR=1", "*", 1000, DSR, 100)

            مثل اینکه این تابع اس ام اس خانه یکم و می خونه و در ارایه DSR ذخیره می کنه

            کسی نیست کمک کنه
            جدیدترین ویرایش توسط اشکان غفارزاده; ۲۲:۰۵ ۱۳۹۵/۰۵/۲۵.
            IN GOD WE TRUST

            دیدگاه

            لطفا صبر کنید...
            X