Sim800l/Sim800l.cpp
bool Sim800l::updateRtc(int utc){
  
  activateBearerProfile();
  _buffer=dateNet();
  deactivateBearerProfile();
  
  _buffer=_buffer.substring(_buffer.indexOf(",")+1,_buffer.length());
  String dt=_buffer.substring(0,_buffer.indexOf(","));
  String tm=_buffer.substring(_buffer.indexOf(",")+1,_buffer.length()) ;

  int hour = tm.substring(0,2).toInt();
  int day = dt.substring(8,10).toInt();

  hour=hour+utc;

  String tmp_hour;
  String tmp_day;
  //TODO : fix if the day is 0, this occur when day is 1 then decrement to 1, 
  //       will need to check the last month what is the last day .  
  if (hour<0){
    hour+=24;
    day-=1;
  }
  if (hour<10){

      tmp_hour="0"+String(hour);
  }else{
    tmp_hour=String(hour);
  }
  if (day<10){
    tmp_day="0"+String(day);    
  }else{
    tmp_day=String(day);
  }
    //for debugging
  //Serial.println("at+cclk=\""+dt.substring(2,4)+"/"+dt.substring(5,7)+"/"+tmp_day+","+tmp_hour+":"+tm.substring(3,5)+":"+tm.substring(6,8)+"-03\"\r\n");
  SIM.print("at+cclk=\""+dt.substring(2,4)+"/"+dt.substring(5,7)+"/"+tmp_day+","+tmp_hour+":"+tm.substring(3,5)+":"+tm.substring(6,8)+"-03\"\r\n");
  if ( (_readSerial().indexOf("ER"))!=-1) {return false;}else return true;

   
  }
// Update the RTC of the module with the date of GSM. 
Update the RTC of the module with the date of GSM.
Update the RTC of the module with the date of GSM .
bool Sim800l::updateRtc(int utc){
  activateBearerProfile();
  _buffer=dateNet();
  deactivateBearerProfile();
  _buffer=_buffer.substring(_buffer.indexOf(",")+1,_buffer.length());
  String dt=_buffer.substring(0,_buffer.indexOf(","));
  String tm=_buffer.substring(_buffer.indexOf(",")+1,_buffer.length()) ;
  int hour = tm.substring(0,2).toInt();
  int day = dt.substring(8,10).toInt();
  hour=hour+utc;
  String tmp_hour;
  String tmp_day;
  if (hour<0){
    hour+=24;
    day-=1;
  }
  if (hour<10){
      tmp_hour="0"+String(hour);
  }else{
    tmp_hour=String(hour);
  }
  if (day<10){
    tmp_day="0"+String(day);    
  }else{
    tmp_day=String(day);
  }
  SIM.print("at+cclk=\""+dt.substring(2,4)+"/"+dt.substring(5,7)+"/"+tmp_day+","+tmp_hour+":"+tm.substring(3,5)+":"+tm.substring(6,8)+"-03\"\r\n");
  if ( (_readSerial().indexOf("ER"))!=-1) {return false;}else return true;
  }
bool Sim800l :: updateRtc ( int utc ) { activateBearerProfile ( ) ; _buffer = dateNet ( ) ; deactivateBearerProfile ( ) ; _buffer = _buffer . substring ( _buffer . indexOf ( " " ) + 1 , _buffer . length ( ) ) ; String dt = _buffer . substring ( 0 , _buffer . indexOf ( " " ) ) ; String tm = _buffer . substring ( _buffer . indexOf ( " " ) + 1 , _buffer . length ( ) ) ; int hour = tm . substring ( 0 , 2 ) . toInt ( ) ; int day = dt . substring ( 8 , 10 ) . toInt ( ) ; hour = hour + utc ; String tmp_hour ; String tmp_day ; if ( hour < 0 ) { hour += 24 ; day -= 1 ; } if ( hour < 10 ) { tmp_hour = " " + String ( hour ) ; } else { tmp_hour = String ( hour ) ; } if ( day < 10 ) { tmp_day = " " + String ( day ) ; } else { tmp_day = String ( day ) ; } SIM . print ( " \" " + dt . substring ( 2 , 4 ) + " " + dt . substring ( 5 , 7 ) + " " + tmp_day + " " + tmp_hour + " " + tm . substring ( 3 , 5 ) + " " + tm . substring ( 6 , 8 ) + " \" \r \n " ) ; if ( ( _readSerial ( ) . indexOf ( " " ) ) != -1 ) { return false ; } else return true ; }
Update the RTC of the module with the date of GSM.
Update the RTC of the module with the date of GSM .
//TODO : fix if the day is 0, this occur when day is 1 then decrement to 1,  //       will need to check the last month what is the last day .   //for debugging //Serial.println("at+cclk=\""+dt.substring(2,4)+"/"+dt.substring(5,7)+"/"+tmp_day+","+tmp_hour+":"+tm.substring(3,5)+":"+tm.substring(6,8)+"-03\"\r\n");