//FIXME FIXME FIXME #define AT_MESG_MAX_LENGTH 2048 /* much more than 10 SMSs */
#define AT_MESG_MAX_LENGTH 2048 /* much more than 10 SMSs */
#define AT_BUFSIZ AT_MESG_MAX_LENGTH
//FIXME FIXME FIXME #define AT_MESG_MAX_LINES 256 /* 256 lines, so it can contains the results of AT+CLAC, that gives all the AT commands the phone supports */
#define AT_MESG_MAX_LINES 20 /* 256 lines, so it can contains the results of AT+CLAC, that gives all the AT commands the phone supports */
ERRORA("Too many lines in result (>%d). la_counter=%d. tech_pvt->reading_sms_msg=%d. Stop accumulating lines.\n",GSMOPEN_P_LOG,AT_MESG_MAX_LINES,la_counter,tech_pvt->reading_sms_msg);
WARNINGA("read was %d bytes, tmp_answer3= --|%s|--\n",GSMOPEN_P_LOG,read_count,tmp_answer3);
at_ack=AT_ERROR;
break;
}
}
}else{
last_line_ptr=tmp_answer;
...
...
@@ -666,22 +676,34 @@ int gsmopen_serial_read_AT(private_t *tech_pvt, int look_for_ack, int timeout_us
// match expected string -> accept it withtout CRLF
la_counter++;
if(la_counter==AT_MESG_MAX_LINES){
ERRORA("Too many lines in result (>%d). la_counter=%d. tech_pvt->reading_sms_msg=%d. Stop accumulating lines.\n",GSMOPEN_P_LOG,AT_MESG_MAX_LINES,la_counter,tech_pvt->reading_sms_msg);
WARNINGA("read was %d bytes, tmp_answer3= --|%s|--\n",GSMOPEN_P_LOG,read_count,tmp_answer3);
at_ack=AT_ERROR;
break;
}
}
/* if the last line read was not a complete line, we'll read the rest in the future */
/* let's list the complete lines read so far, without re-listing the lines that has yet been listed */
if(option_debug>1){
for(i=la_read;i<la_counter;i++)
DEBUGA_GSMOPEN("Read line %d: |%s|\n",GSMOPEN_P_LOG,i,tech_pvt->line_array.result[i]);
for(i=la_read;i<la_counter;i++){
DEBUGA_GSMOPEN("Read line %d: |%s| la_counter=%d\n",GSMOPEN_P_LOG,i,tech_pvt->line_array.result[i],la_counter);
}
if(la_counter==AT_MESG_MAX_LINES){
ERRORA("Too many lines in result (>%d). la_counter=%d. tech_pvt->reading_sms_msg=%d. Stop accumulating lines.\n",GSMOPEN_P_LOG,AT_MESG_MAX_LINES,la_counter,tech_pvt->reading_sms_msg);
WARNINGA("read was %d bytes, tmp_answer3= --|%s|--\n",GSMOPEN_P_LOG,read_count,tmp_answer3);
at_ack=AT_ERROR;
break;
}
/* let's interpret the complete lines read so far (WITHOUT looking for OK, ERROR, and EXPECTED_STRING), without re-interpreting the lines that has been yet interpreted, so we're sure we don't miss anything */
for(i=la_read;i<la_counter;i++){
...
...
@@ -1544,6 +1566,7 @@ int gsmopen_serial_read_AT(private_t *tech_pvt, int look_for_ack, int timeout_us
/* if we are reading an sms message from memory, put the line into the sms buffer if the line is not "OK" or "ERROR" */
if(tech_pvt->reading_sms_msg>1&&at_ack==-1){
intc;
...
...
@@ -1706,11 +1729,13 @@ int gsmopen_serial_read_AT(private_t *tech_pvt, int look_for_ack, int timeout_us
if(look_for_ack&&at_ack>-1)
break;
if(la_counter>AT_MESG_MAX_LINES){
ERRORA("Too many lines in result (>%d). Stopping reader.\n",GSMOPEN_P_LOG,AT_MESG_MAX_LINES);
if(la_counter==AT_MESG_MAX_LINES){
ERRORA("Too many lines in result (>%d). la_counter=%d. tech_pvt->reading_sms_msg=%d. Stop accumulating lines.\n",GSMOPEN_P_LOG,AT_MESG_MAX_LINES,la_counter,tech_pvt->reading_sms_msg);
WARNINGA("read was %d bytes, tmp_answer3= --|%s|--\n",GSMOPEN_P_LOG,read_count,tmp_answer3);