HandlerHTTP.cpp
uint8_t HandlerHTTP::sendDataToServer(int themperature, uint8_t motionCounter, uint8_t isHaveVoltage){
 // Serial.println(F("Start send data to Server"));
  if(modem->openConnect()== false)return RETURN_ERROR;
 // Serial.println(F("Open connect"));
  modem->sendCommand(F("AT+HTTPPARA=\"CID\",1 "));
  if(!modem->checkOnOK(0))return NO_SEND;
  //char *command = "AT+HTTPPARA=\"URL\",\"";
  String head = "&field";
    // -------------------------------------------------------------------------------
    // on change methods(add fields) strings bottm must be remaked
    // ------------------------------------------------------------------------------
  String tail = "";
  tail += head + "1=" + String(themperature);
  tail += head + "2=" + String(motionCounter);
  tail += head + "3=" + isHaveVoltage + "\" ";
  String res = String(F("AT+HTTPPARA=\"URL\",\"")) + String(requestHeader) + String(tail);
  Serial.println(res);
  modem->sendCommand(res);
  if(!modem->checkOnOK(0)) {
  //  Serial.println(F("Error on set URL params"));
    return WRONG_DATA;
  }
  modem->sendCommand(F("AT+HTTPACTION=0"));
  uint8_t isSuccess = checkIsSuccess();
  modem->closeConnect();
  if(isSuccess != 0){
    modem->sendCommand(F("AT+SAPBR=0,1"));
    delay(200);
    modem->dropGSM();
    Serial.println(F("Drop Connect with ERROR\n"));
  }
  return isSuccess;
}
/*
* Build modem commands for send data to server
* return codes may be [ SUCCESS 0, NO_SEND 1, WRONG_DATA 3 ]
* param:
*     themperature - themperature DS18B20
*     motionCounter - if last  DROP_MOTION_TIME(see in Constants) sensor occured motion - send number > 0
*     isHaveVoltage - 1 if outer voltage it is, 0 if battery power
*/
Build modem commands for send data to server
return codes may be [ SUCCESS 0, NO_SEND 1, WRONG_DATA 3 ]
param:
themperature - themperature DS18B20
motionCounter - if last  DROP_MOTION_TIME sensor occured motion - send number > 0
isHaveVoltage - 1 if outer voltage it is, 0 if battery power
Build modem commands for send data to server return codes may be [ SUCCESS 0 NO_SEND 1 WRONG_DATA 3 ] param : themperature - themperature DS18B20 motionCounter - if last DROP_MOTION_TIME sensor occured motion - send number > 0 isHaveVoltage - 1 if outer voltage it is 0 if battery power
uint8_t HandlerHTTP::sendDataToServer(int themperature, uint8_t motionCounter, uint8_t isHaveVoltage){
  if(modem->openConnect()== false)return RETURN_ERROR;
  modem->sendCommand(F("AT+HTTPPARA=\"CID\",1 "));
  if(!modem->checkOnOK(0))return NO_SEND;
  String head = "&field";
  String tail = "";
  tail += head + "1=" + String(themperature);
  tail += head + "2=" + String(motionCounter);
  tail += head + "3=" + isHaveVoltage + "\" ";
  String res = String(F("AT+HTTPPARA=\"URL\",\"")) + String(requestHeader) + String(tail);
  Serial.println(res);
  modem->sendCommand(res);
  if(!modem->checkOnOK(0)) {
    return WRONG_DATA;
  }
  modem->sendCommand(F("AT+HTTPACTION=0"));
  uint8_t isSuccess = checkIsSuccess();
  modem->closeConnect();
  if(isSuccess != 0){
    modem->sendCommand(F("AT+SAPBR=0,1"));
    delay(200);
    modem->dropGSM();
    Serial.println(F("Drop Connect with ERROR\n"));
  }
  return isSuccess;
}
uint8_t HandlerHTTP :: sendDataToServer ( int themperature , uint8_t motionCounter , uint8_t isHaveVoltage ) { if ( modem -> openConnect ( ) == false ) return RETURN_ERROR ; modem -> sendCommand ( F ( " \" \" " ) ) ; if ( ! modem -> checkOnOK ( 0 ) ) return NO_SEND ; String head = " " ; String tail = " " ; tail += head + " " + String ( themperature ) ; tail += head + " " + String ( motionCounter ) ; tail += head + " " + isHaveVoltage + " \" " ; String res = String ( F ( " \" \" \" " ) ) + String ( requestHeader ) + String ( tail ) ; Serial . println ( res ) ; modem -> sendCommand ( res ) ; if ( ! modem -> checkOnOK ( 0 ) ) { return WRONG_DATA ; } modem -> sendCommand ( F ( " " ) ) ; uint8_t isSuccess = checkIsSuccess ( ) ; modem -> closeConnect ( ) ; if ( isSuccess != 0 ) { modem -> sendCommand ( F ( " " ) ) ; delay ( 200 ) ; modem -> dropGSM ( ) ; Serial . println ( F ( " \n " ) ) ; } return isSuccess ; }
Build modem commands for send data to server
return codes may be [ SUCCESS 0, NO_SEND 1, WRONG_DATA 3 ]
param:
themperature - themperature DS18B20
motionCounter - if last  DROP_MOTION_TIME(see in Constants) sensor occured motion - send number > 0
isHaveVoltage - 1 if outer voltage it is, 0 if battery power
Build modem commands for send data to server return codes may be [ SUCCESS 0 NO_SEND 1 WRONG_DATA 3 ] param : themperature - themperature DS18B20 motionCounter - if last DROP_MOTION_TIME ( see in Constants ) sensor occured motion - send number > 0 isHaveVoltage - 1 if outer voltage it is 0 if battery power
// Serial.println(F("Start send data to Server")); // Serial.println(F("Open connect")); //char *command = "AT+HTTPPARA=\"URL\",\""; // ------------------------------------------------------------------------------- // on change methods(add fields) strings bottm must be remaked // ------------------------------------------------------------------------------ //  Serial.println(F("Error on set URL params"));