boolean SIMCOM900::call(char* number, unsigned int milliseconds) { if (getStatus()==IDLE) return false; //_tf.setTimeout(_GSM_DATA_TOUT_); SimpleWrite("ATD"); SimpleWrite(number); SimpleWriteln(";"); delay(milliseconds); SimpleWriteln("ATH"); return true; }
int SIMCOM900::changeNSIPmode(char mode) { //_tf.setTimeout(_TCP_CONNECTION_TOUT_); //if (getStatus()!=ATTACHED) // return 0; //_cell.flush(); SimpleWrite(F("AT+QIDNSIP=")); SimpleWriteln(mode); if(gsm.WaitResp(5000, 50, "OK")!=RX_FINISHED_STR_NOT_RECV) return 0; //if(!_tf.find("OK")) return 0; return 1; }
int SIMCOM900::setPIN(char *pin) { //Status = READY or ATTACHED. if((getStatus() != IDLE)) return 2; //_tf.setTimeout(_GSM_DATA_TOUT_); //Timeout for expecting modem responses. //_cell.flush(); //AT command to set PIN. SimpleWrite(F("AT+CPIN=")); SimpleWriteln(pin); //Expect "OK". if(gsm.WaitResp(5000, 50, "OK")!=RX_FINISHED_STR_NOT_RECV) return 0; else return 1; }
boolean SIMCOM900::readSMS(char* msg, int msglength, char* number, int nlength) { long index; char *p_char; char *p_char1; /* if (getStatus()==IDLE) return false; */ #ifdef UNO _tf.setTimeout(_GSM_DATA_TOUT_); #endif //_cell.flush(); SimpleWriteln(F("AT+CMGL=\"REC UNREAD\",1")); if(gsm.WaitResp(5000, 50, "+CMGL")!=RX_FINISHED_STR_RECV) //if(_tf.find("+CMGL: ")) { /* //index p_char = strchr((char *)(gsm.comm_buf),':'); p_char1 = p_char+2; //we are on the first char of string p_char = strchr((char *)(p_char1), ','); if (p_char != NULL) { *p_char = 0; } //strcpy(msg, (char *)(p_char1)); // rec unread p_char++; p_char1 = strchr((char *)(p_char), ','); if (p_char1 != NULL) { *p_char1 = 0; } // number p_char1++; p_char1++; p_char = strchr((char *)(p_char1), '\"'); if (p_char != NULL) { *p_char = 0; } strcpy(number, (char *)(p_char1)); // UTC time p_char = strchr((char *)(p_char), '\n'); p_char1 = strchr((char *)(p_char), '\n'); if (p_char1 != NULL) { *p_char1 = 0; } strcpy(msg, (char *)(p_char)); */ #ifdef UNO index=_tf.getValue(); #endif #ifdef MEGA //index=_cell.read(); #endif #ifdef UNO _tf.getString("\",\"", "\"", number, nlength); #endif #ifdef MEGA _cell.getString("\",\"", "\"", number, nlength); #endif #ifdef UNO _tf.getString("\n", "\nOK", msg, msglength); #endif #ifdef MEGA _cell.getString("\n", "\nOK", msg, msglength); #endif SimpleWrite(F("AT+CMGD=")); SimpleWriteln(index); // Serial.print("VAL= "); // Serial.println(index); gsm.WaitResp(5000, 50, "OK"); return true; }; return false; };
boolean SIMCOM900::readSMS(char* msg, int msglength, char* number, int nlength) { Serial.println(F("This method is deprecated! Please use GetSMS in the SMS class.")); long index; char *p_char; char *p_char1; /* if (getStatus()==IDLE) return false; */ #ifdef UNO _tf.setTimeout(_GSM_DATA_TOUT_); #endif //_cell.flush(); WaitResp(500, 500); SimpleWriteln(F("AT+CMGL=\"REC UNREAD\",1")); WaitResp(5000, 500); if(gsm.IsStringReceived("+CMGL")) { //index p_char = strchr((char *)(gsm.comm_buf),'+CMGL'); p_char1 = p_char+3; //we are on the first char of string p_char = p_char1+1; *p_char = 0; index=atoi(p_char1); p_char1 = p_char+1; p_char = strstr((char *)(p_char1), "\",\""); p_char1 = p_char+3; p_char = strstr((char *)(p_char1), "\",\""); if (p_char != NULL) { *p_char = 0; } strcpy(number, (char *)(p_char1)); ////// p_char1 = p_char+3; p_char = strstr((char *)(p_char1), "\",\""); p_char1 = p_char+3; p_char = strstr((char *)(p_char1), "\n"); p_char1 = p_char+1; p_char = strstr((char *)(p_char1), "\n"); if (p_char != NULL) { *p_char = 0; } strcpy(msg, (char *)(p_char1)); // #ifdef UNO // index=_tf.getValue(); // #endif // #ifdef MEGA //index=_cell.read(); // #endif // Serial.println("DEBUG"); // #ifdef UNO // _tf.getString("\",\"", "\"", number, nlength); // #endif // Serial.println("PRIMA"); // #ifdef MEGA // _cell.getString("\",\"", "\"", number, nlength); // #endif // Serial.println("DEBUG"); // #ifdef UNO // _tf.getString("\n", "\nOK", msg, msglength); // #endif // #ifdef MEGA // _cell.getString("\n", "\nOK", msg, msglength); // #endif SimpleWrite(F("AT+CMGD=")); SimpleWriteln(index); // Serial.print("VAL= "); // Serial.println(index); gsm.WaitResp(5000, 50, "OK"); return true; }; return false; };