Эта кодовая ситуация заключается в том, что когда мы вводим номер телефона, мы получаем токены, но когда я вставляю номер телефона в HC05, он показывает неверный номер.Вы можете мне помочь

#define SEGMENTCONFIG 0                                            
#define MAX_Q 10 
                                               
#define DEBUG 1                                                 
#define DATASIZE 32                                         
#define USER_CALL_BUTTON 8                     

char p1[DATASIZE];                                                
char p2[DATASIZE];                                                
char p3[DATASIZE];                                                
char p4[DATASIZE];                                               
char p5[DATASIZE];                                               
char p6[DATASIZE];                                                
char p7[DATASIZE];                                              
char p8[DATASIZE];                                              
char p9[DATASIZE];                                                
char p10[DATASIZE];                                               

char *phoneNumbers[MAX_Q] = {p1,p2,p3,p4,p5,p6,p7,p8,p9,p10};    
byte  queueCounter = 0;                                          
byte  assignedNumber = 0;                                         
byte  calledNumber = 0;                                          

char inData[DATASIZE];                                          
byte dataIndex = 0;                                              
char gsmBuff[DATASIZE];                                        
bool drive7segment;                                              
bool prevButtonState;                                            


/**************************************************************************/
/*                      S E T U P   F U N C T I O N                       */
/**************************************************************************/
void setup() {

  Serial.begin(9600);
  delay(100);    
  Serial2.begin(9600);                                             
  unsigned int brates[7] = {1200,2400,4800,9600,19200,38400,57600}; 
  for(byte x=0; x<7; x++){                                          
    Serial3.begin(brates[x]);
    Serial3.print("AT+IPR=9600\r\n");
    delay(100);
    Serial3.end();     
  }
  Serial3.begin(9600); 
  Serial3.print("AT+CMGF=1\r\n");                                   
  delay(1000);                                                     
  Serial3.print("AT+CMGDA=\"DEL ALL\"\r\n");                      
  delay(1000);                                                    
  Serial3.print("AT+CNMI=2,2,0,0\r\n");                            
  delay(1000);
       
  pinMode(USER_CALL_BUTTON,INPUT);
  digitalWrite(USER_CALL_BUTTON,LOW);

  //initialize the 7 segments
  if(SEGMENTCONFIG){       
    drive7segment = LOW;                     
  }else{
    drive7segment = HIGH;                   
  }
  initSevenSegment(1);                     
  initSevenSegment(2);                    
}

/**************************************************************************/
/*                       M A I N   F U N C T I O N                        */
/**************************************************************************/ 
void loop() {
  checkHC05();
  checkUserButton();
}

/**************************************************************************/
/*                           SUPPORT FUNCTIONS                            */
/**************************************************************************/ 
void initSevenSegment(byte placeValue){

  int offset = 0;
  switch(placeValue){
    case 1:                                     
      offset = 0;                                
      if(DEBUG){
        Serial.println(F("7 SEGMENT ONES"));
      }
      break;
    case 2:
      offset = 14;                                /
      if(DEBUG){
        Serial.println(F("7 SEGMENT TENS"));
      }
      break;
  }

  for (int x=23; x<=35; (x+=2)){
    pinMode((x+offset),OUTPUT);                   
    digitalWrite((x+offset),!drive7segment);       
    if(DEBUG){
      Serial.print(F("configuring digital pin "));
      Serial.println(x+offset);
    }   
  }   
}

void displayOnSegment(byte value, byte segmentNumber){
  int offset = 0;
  switch(segmentNumber){
    case 1:
      offset = 0;
      break;
    case 2:
      offset = 14;
      break;
  }
  
  switch (value){
    case 0:                                         //display 0
      digitalWrite(23+offset, drive7segment);
      digitalWrite(25+offset, drive7segment);
      digitalWrite(27+offset, drive7segment);
      digitalWrite(29+offset, drive7segment);
      digitalWrite(31+offset, drive7segment);
      digitalWrite(33+offset, drive7segment);
      digitalWrite(35+offset, !drive7segment);
      break;
    case 1:                                         //display 1            
      digitalWrite(23+offset, !drive7segment);
      digitalWrite(25+offset, drive7segment);
      digitalWrite(27+offset, drive7segment);
      digitalWrite(29+offset, !drive7segment);
      digitalWrite(31+offset, !drive7segment);
      digitalWrite(33+offset, !drive7segment);
      digitalWrite(35+offset, !drive7segment);
      break;
    case 2:                                         //display 2
      digitalWrite(23+offset, drive7segment);
      digitalWrite(25+offset, drive7segment);
      digitalWrite(27+offset, !drive7segment);
      digitalWrite(29+offset, drive7segment);
      digitalWrite(31+offset, drive7segment);
      digitalWrite(33+offset, !drive7segment);
      digitalWrite(35+offset, drive7segment);   
      break;
    case 3:                                         //display 3
      digitalWrite(23+offset, drive7segment);
      digitalWrite(25+offset, drive7segment);
      digitalWrite(27+offset, drive7segment);
      digitalWrite(29+offset, drive7segment);
      digitalWrite(31+offset, !drive7segment);
      digitalWrite(35+offset, drive7segment);
      digitalWrite(33+offset, !drive7segment);
      break;
    case 4:                                         //display 4
      digitalWrite(23+offset, !drive7segment);
      digitalWrite(25+offset, drive7segment);
      digitalWrite(27+offset, drive7segment);
      digitalWrite(29+offset, !drive7segment);
      digitalWrite(31+offset, !drive7segment);
      digitalWrite(33+offset, drive7segment);
      digitalWrite(35+offset, drive7segment);
      break;
    case 5:                                         //display 5
      digitalWrite(23+offset, drive7segment);
      digitalWrite(25+offset, !drive7segment);
      digitalWrite(27+offset, drive7segment);
      digitalWrite(29+offset, drive7segment);
      digitalWrite(31+offset, !drive7segment);
      digitalWrite(33+offset, drive7segment);
      digitalWrite(35+offset, drive7segment);
      break;
    case 6:                                         //display 6
      digitalWrite(23+offset, drive7segment);
      digitalWrite(25+offset, !drive7segment);
      digitalWrite(33+offset, drive7segment);
      digitalWrite(35+offset, drive7segment);
      digitalWrite(27+offset, drive7segment);
      digitalWrite(29+offset, drive7segment);
      digitalWrite(31+offset, drive7segment);
      break;    
    case 7:                                         //display 7
      digitalWrite(23+offset, drive7segment);
      digitalWrite(25+offset, drive7segment);
      digitalWrite(27+offset, drive7segment);
      digitalWrite(29+offset, !drive7segment);
      digitalWrite(31+offset, !drive7segment);
      digitalWrite(33+offset, !drive7segment);
      digitalWrite(35+offset, !drive7segment);      
      break;  
    case 8:                                         //display 8
      digitalWrite(23+offset, drive7segment);
      digitalWrite(25+offset, drive7segment);
      digitalWrite(27+offset, drive7segment);
      digitalWrite(29+offset, drive7segment);
      digitalWrite(31+offset, drive7segment);
      digitalWrite(33+offset, drive7segment);
      digitalWrite(35+offset, drive7segment);
      break;  
    case 9:                                         //display 9
      digitalWrite(23+offset, drive7segment);
      digitalWrite(25+offset, drive7segment);
      digitalWrite(27+offset, drive7segment);
      digitalWrite(29+offset, drive7segment);
      digitalWrite(31+offset, !drive7segment);
      digitalWrite(33+offset, drive7segment);
      digitalWrite(35+offset, drive7segment);
      break;                     
  } 
}

void anounceNumber(byte num){
  /*this calls an assigned number, and initiates display on 7-segment*/
  /*num = number to call                                             */
  byte ones = num%10;
  byte tens = num/10;
  displayOnSegment(tens,2);
  displayOnSegment(ones,1);
  if(DEBUG){
    Serial.print(F("\nnow serving #: "));
    Serial.println(num);
    Serial.print(F(" ones digit: "));
    Serial.println(ones);
    delay(50);
    Serial.print(F(" tens digit: "));
    Serial.println(tens);
    delay(50);
  }
}

void sendMessage(byte param1, byte param2=0, char param3[DATASIZE] = ""){
  switch (param1){
    case 0:                                                                 
      Serial2.println(F("MEMORY FULL"));
      if(DEBUG){
        Serial.println(F("MEMORY FULL via bluetooth"));
        delay(50);
      }
      break;
    case 1:                                                                
      sprintf(gsmBuff,"AT+CMGS=\"%s\"\r\n",param3);
      Serial3.print(gsmBuff);
      memset(gsmBuff,0,DATASIZE);
      delay(1000);
      sprintf(gsmBuff,"You are no: %d",param2);
      Serial3.print(gsmBuff);
      Serial3.write(0x1A);
      Serial3.flush();
      memset(gsmBuff,0,DATASIZE);
      if(DEBUG){
        Serial.print(F("You are no: "));
        Serial.print(param2);
        Serial.print(F(" send to: "));
        Serial.println(param3);
        delay(50);
      }
      break;  
    case 2:                                                                 
      Serial2.println(F("INVALID NUMBER"));     
      if(DEBUG){
        Serial.println(F("INVALID NUMBER via bluetooth"));
        delay(50);
      }
      break;
    case 3:                                                                 
      sprintf(gsmBuff,"AT+CMGS=\"%s\"\r\n",param3);
      Serial3.print(gsmBuff);
      memset(gsmBuff,0,DATASIZE);
      delay(1000);
      sprintf(gsmBuff,"Get ready no: %d",param2);
      Serial3.print(gsmBuff);
      Serial3.write(0x1A);
      Serial3.flush();
      memset(gsmBuff,0,DATASIZE);
      if(DEBUG){
        Serial.print(F("Get ready no: "));
        Serial.print(param2);
        Serial.print(F(" send to: "));
        Serial.println(param3);
      }
      break;
  }
}

void checkHC05(){
  
    if(Serial2.available()){
      delay(100);
      while(Serial2.available()){
        inData[dataIndex] = Serial2.read();
        dataIndex++;
        if(dataIndex > (DATASIZE-1)){                      
          while(Serial2.available()){                      
            Serial2.read();                            
          }
          break;
        }
      }

      if(DEBUG){
        Serial.print(F("\nreceived: "));
        Serial.println(inData);
        delay(50);
      }
      
      if(!checkNumber(inData,dataIndex)){                   
        sendMessage(2);
      }else{                                                  
        if(queueCounter < MAX_Q){                           
          queueCounter++;                                    
          assignedNumber++;                                  
          if(assignedNumber > MAX_Q){
            assignedNumber = 1;
          }
          strcpy(phoneNumbers[assignedNumber-1],inData);     
          sendMessage(1,assignedNumber,inData);
          
        }else{
          sendMessage(0);                                    
        }         
      }
      dataIndex=0;
      memset(inData,0,DATASIZE);
      displayData();    
    }
}

void displayData(){
  if(DEBUG){
    Serial.println(F("----summary----"));
    delay(50);
    for(byte x=0; x < MAX_Q; x++){
      Serial.print(x+1);
      Serial.print(F(" : "));
      Serial.println(phoneNumbers[x]);
      delay(50);
    }
    Serial.print(F("total # in queue: "));
    Serial.println(queueCounter);
    delay(50);
    Serial.print(F("latest assigned no: "));
    Serial.println(assignedNumber);
    delay(50);
    Serial.print(F("last called no: "));
    Serial.println(calledNumber);
  }
}

bool checkNumber(char inArray[DATASIZE], int inSize){
  int falseCounter = 0;
  for(byte x=0; x<(inSize); x++){
    if((47<inArray[x])&&(inArray[x]<58)){                      
      
    }else if(inArray[x] == 43){                                 
    }else{
      falseCounter++;
    }
  }
 if(falseCounter > 0){
  return false;
 }else{
  return true;
 }
}

void clearPhoneNumber(byte location){
  /*this clears the stored phone number               */
  /*location = index of the phone number to be cleared*/
  memset(phoneNumbers[location],0,DATASIZE);
}

void checkUserButton(){
  /*this checs if the user has pressed the USER_CALL_BUTTON and responds accordingly*/
  bool nowButtonState = digitalRead(USER_CALL_BUTTON);
  if(nowButtonState == HIGH){                                      
    if(prevButtonState){                                         
      if(queueCounter > 0){                                       
        calledNumber++;                                           
        if(calledNumber > MAX_Q){
          calledNumber = 1;
        }
        anounceNumber(calledNumber);                             
        queueCounter--;                                           
        if(queueCounter < 0){
          queueCounter = 0;
        }
        clearPhoneNumber(calledNumber-1);                       
        if(queueCounter > 5){                                    
          byte prepNumber = calledNumber+5;
          if(prepNumber > MAX_Q){
            prepNumber = prepNumber%MAX_Q;
          }
          sendMessage(3,prepNumber,phoneNumbers[prepNumber-1]);           
        }
      }else{
        if(DEBUG){
          Serial.println(F("\nNO MORE PEOPLE IN QUEUE"));
        }
      }
      displayData();     
    }      
  }
  prevButtonState = nowButtonState;
}

, 👍0