boolean Adafruit_FONA::enableGPS(boolean onoff) {
  uint16_t state;

  // first check if its already on or off

  if (_type == FONA808_V2) {
    if (! sendParseReply(F("AT+CGNSPWR?"), F("+CGNSPWR: "), &state) )
      return false;
  } else {
    if (! sendParseReply(F("AT+CGPSPWR?"), F("+CGPSPWR: "), &state))
      return false;
  }

  if (onoff && !state) {
    if (_type == FONA808_V2) {
      if (! sendCheckReply(F("AT+CGNSPWR=1"), F("OK")))  // try GNS command
	return false;
    } else {
      if (! sendCheckReply(F("AT+CGPSPWR=1"), F("OK")))
	return false;
    }
  } else if (!onoff && state) {
    if (_type == FONA808_V2) {
      if (! sendCheckReply(F("AT+CGNSPWR=0"), F("OK"))) // try GNS command
	return false;
    } else {
      if (! sendCheckReply(F("AT+CGPSPWR=0"), F("OK")))
	return false;
    }
  }
  return true;
}
int8_t Adafruit_FONA::getNumSMS(void) {
  uint16_t numsms;

  // get into text mode
  if (! sendCheckReply(F("AT+CMGF=1"), F("OK"))) return -1;

  // ask how many sms are stored
  if ( (_type == FONA3G_A) || (_type == FONA3G_E) ) {
    if (! sendParseReply(F("AT+CPMS?"), F("+CPMS: \"ME\","), &numsms) ) return -1;
  } else {
    if (! sendParseReply(F("AT+CPMS?"), F("+CPMS: \"SM_P\","), &numsms) ) return -1;
  }
  return numsms;
}
Ejemplo n.º 3
0
int8_t Adafruit_FONA::getFMVolume() {
  uint16_t level;

  if (! sendParseReply(F("AT+FMVOLUME?"), F("+FMVOLUME: "), &level) ) return 0;

  return level;
}
Ejemplo n.º 4
0
uint8_t Adafruit_FONA::getVolume(void) {
    uint16_t reply;
    
    if (! sendParseReply(F("AT+CLVL?"), F("+CLVL: "), &reply) ) return 0;
    
    return reply;
}
Ejemplo n.º 5
0
uint8_t Adafruit_FONA::getNetworkStatus(void) {
    uint16_t status;
    
    if (! sendParseReply(F("AT+CREG?"), F("+CREG: "), &status, ',', 1)) return 0;
    
    return status;
}
Ejemplo n.º 6
0
bool Adafruit_FONA::readRTC(uint8_t *year, uint8_t *month, uint8_t *date, uint8_t *hr, uint8_t *min, uint8_t *sec) {
    uint16_t v;
    sendParseReply(F("AT+CCLK?"), F("+CCLK: "), &v, '/', 0);
    *year = v;
    
    Serial.println(*year);
}
Ejemplo n.º 7
0
uint8_t Adafruit_FONA::getSMSInterrupt(void) {
    uint16_t reply;

    if (! sendParseReply(F("AT+CFGRI?"), F("+CFGRI: "), &reply) ) return 0;

    return reply;
}
Ejemplo n.º 8
0
uint8_t Adafruit_FONA::getRSSI(void) {
    uint16_t reply;
    
    if (! sendParseReply(F("AT+CSQ"), F("+CSQ: "), &reply) ) return 0;
    
    return reply;
}
Ejemplo n.º 9
0
uint8_t Adafruit_FONA::GPRSstate(void) {
  uint16_t state;

  if (! sendParseReply(F("AT+CGATT?"), F("+AT+CGATT: "), &state) )
    return -1;

  return state;
}
uint8_t Adafruit_FONA::getCallStatus(void) {
  uint16_t phoneStatus;

  if (! sendParseReply(F("AT+CPAS"), F("+CPAS: "), &phoneStatus)) 
    return FONA_CALL_FAILED; // 1, since 0 is actually a known, good reply

  return phoneStatus;  // 0 ready, 2 unkown, 3 ringing, 4 call in progress
}
Ejemplo n.º 11
0
int8_t Adafruit_FONA::getNumSMS(void) {
    uint16_t numsms;

    if (! sendCheckReply(F("AT+CMGF=1"), F("OK"))) return -1;
    // ask how many sms are stored

    if (! sendParseReply(F("AT+CPMS?"), F("+CPMS: \"SM_P\","), &numsms) ) return -1;

    return numsms;
}
uint16_t Adafruit_FONA::TCPavailable(void) {
  uint16_t avail;

  if (! sendParseReply(F("AT+CIPRXGET=4"), F("+CIPRXGET: 4,"), &avail, ',', 0) ) return false;

#ifdef ADAFRUIT_FONA_DEBUG
  Serial.print (avail); Serial.println(F(" bytes available"));
#endif

  return avail;
}
bool FONA808::enableGPS(bool enable){
  if(m_ppp.isPPPLinkOpen()){
	mSerial.setPppPause(true); 
	wait_ms(1000);
	mSerial.printf("+++");
	wait_ms(1000);
	mSerial.cleanBuffer();
  }

  uint16_t state;
  if (! sendParseReply("AT+CGPSPWR?","+CGPSPWR: ", &state,',',0,500)){
     	if(m_ppp.isPPPLinkOpen()){
		sendCheckReply("ATO","CONNECT",500);
		mSerial.cleanBuffer();
		mSerial.setPppPause(false);
	}
	 return false;
     }
  	DEBUG_PRINT("Stato GPS: %d", state);

  if (enable && !state) {
     if (! sendCheckReply("AT+CGPSPWR=1", "OK",500)){
	if(m_ppp.isPPPLinkOpen()){
		sendCheckReply("ATO","CONNECT",500);
		mSerial.cleanBuffer();
		mSerial.setPppPause(false);	
	}
	return false;
     }
  } else if (!enable && state) {
    if (! sendCheckReply("AT+CGPSPWR=0", "OK",500)){
	if(m_ppp.isPPPLinkOpen()){
		sendCheckReply("ATO","CONNECT",500);
		mSerial.cleanBuffer();
		mSerial.setPppPause(false);
	}
	return false;
     }
  }

  if(m_ppp.isPPPLinkOpen()){
	sendCheckReply("ATO","CONNECT",500);
	mSerial.cleanBuffer();
	mSerial.setPppPause(false);
  }
  return true;
}
Ejemplo n.º 14
0
/* returns the percentage charge of battery as reported by sim800 */
bool Adafruit_FONA::getBattPercent(uint16_t *p) {
    return sendParseReply(F("AT+CBC"), F("+CBC: "), p, ',', 1);
}
Ejemplo n.º 15
0
/* returns value in mV (uint16_t) */
bool Adafruit_FONA::getBattVoltage(uint16_t *v) {
    return sendParseReply(F("AT+CBC"), F("+CBC: "), v, ',', 2);
}
Ejemplo n.º 16
0
bool Adafruit_FONA::getADCVoltage(uint16_t *v) {
    return sendParseReply(F("AT+CADC?"), F("+CADC: 1,"), v);
}
/* returns value in mV (uint16_t) */
boolean Adafruit_FONA_3G::getBattVoltage(uint16_t *v) {
  float f;
  boolean b = sendParseReply(F("AT+CBC"), F("+CBC: "), &f, ',', 2);
  *v = f*1000;
  return b;
}
uint8_t FONA808::getNetworkStatus(void) {
  uint16_t status;
  if (! sendParseReply("AT+CREG?", "+CREG: ", &status, ',', 1, 500)) return 0;
  DEBUG_PRINT("Status = %d",status);
  return status;
}