コード例 #1
0
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;
}
コード例 #2
0
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;
}
コード例 #3
0
int8_t Adafruit_FONA::getFMVolume() {
  uint16_t level;

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

  return level;
}
コード例 #4
0
uint8_t Adafruit_FONA::getVolume(void) {
    uint16_t reply;
    
    if (! sendParseReply(F("AT+CLVL?"), F("+CLVL: "), &reply) ) return 0;
    
    return reply;
}
コード例 #5
0
uint8_t Adafruit_FONA::getNetworkStatus(void) {
    uint16_t status;
    
    if (! sendParseReply(F("AT+CREG?"), F("+CREG: "), &status, ',', 1)) return 0;
    
    return status;
}
コード例 #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);
}
コード例 #7
0
uint8_t Adafruit_FONA::getSMSInterrupt(void) {
    uint16_t reply;

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

    return reply;
}
コード例 #8
0
uint8_t Adafruit_FONA::getRSSI(void) {
    uint16_t reply;
    
    if (! sendParseReply(F("AT+CSQ"), F("+CSQ: "), &reply) ) return 0;
    
    return reply;
}
コード例 #9
0
uint8_t Adafruit_FONA::GPRSstate(void) {
  uint16_t state;

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

  return state;
}
コード例 #10
0
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
}
コード例 #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;
}
コード例 #12
0
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;
}
コード例 #13
0
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;
}
コード例 #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);
}
コード例 #15
0
/* returns value in mV (uint16_t) */
bool Adafruit_FONA::getBattVoltage(uint16_t *v) {
    return sendParseReply(F("AT+CBC"), F("+CBC: "), v, ',', 2);
}
コード例 #16
0
bool Adafruit_FONA::getADCVoltage(uint16_t *v) {
    return sendParseReply(F("AT+CADC?"), F("+CADC: 1,"), v);
}
コード例 #17
0
/* 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;
}
コード例 #18
0
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;
}