diff options
author | Cristian Maglie <c.maglie@bug.st> | 2013-04-03 13:51:04 +0200 |
---|---|---|
committer | Cristian Maglie <c.maglie@bug.st> | 2013-04-03 13:51:04 +0200 |
commit | ee90e68e86dd61d86f5d17b69080338328765b22 (patch) | |
tree | e620c0edc2690ab789b665e567910640597aa6fe /libraries/GSM/GSM3ShieldV1BandManagement.cpp | |
parent | 0ecdc5ebc96ad4c7c548c438a03d9ce00679db8b (diff) | |
parent | f50c307be280dc6ece9e70c43b301c1db36291a0 (diff) |
Merged 1.0.5
Merge remote-tracking branch 'arduino/master' into ide-1.5.x
Conflicts:
app/src/processing/app/Base.java
build/shared/revisions.txt
hardware/arduino/avr/cores/arduino/malloc.c
hardware/arduino/cores/arduino/avr-libc/malloc.c
hardware/arduino/cores/arduino/malloc.c
todo.txt
Diffstat (limited to 'libraries/GSM/GSM3ShieldV1BandManagement.cpp')
-rw-r--r-- | libraries/GSM/GSM3ShieldV1BandManagement.cpp | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/libraries/GSM/GSM3ShieldV1BandManagement.cpp b/libraries/GSM/GSM3ShieldV1BandManagement.cpp new file mode 100644 index 0000000..94dec9a --- /dev/null +++ b/libraries/GSM/GSM3ShieldV1BandManagement.cpp @@ -0,0 +1,67 @@ +#include <GSM3ShieldV1BandManagement.h> + +GSM3ShieldV1BandManagement::GSM3ShieldV1BandManagement(bool trace): modem(trace) +{ + quectelStrings[UNDEFINED]=""; + quectelStrings[EGSM_MODE]="\"EGSM_MODE\""; + quectelStrings[DCS_MODE]="\"DCS_MODE\""; + quectelStrings[PCS_MODE]="\"PCS_MODE\""; + quectelStrings[EGSM_DCS_MODE]="\"EGSM_DCS_MODE\""; + quectelStrings[GSM850_PCS_MODE]="\"GSM850_PCS_MODE\""; + quectelStrings[GSM850_EGSM_DCS_PCS_MODE]="\"GSM850_EGSM_DCS_PCS_MODE\""; +} + +GSM3_NetworkStatus_t GSM3ShieldV1BandManagement::begin() +{ + // check modem response + modem.begin(); + + // reset hardware + modem.restartModem(); + + return IDLE; +} + +String GSM3ShieldV1BandManagement::getBand() +{ + String modemResponse=modem.writeModemCommand("AT+QBAND?", 2000); + + for(GSM3GSMBand i=GSM850_EGSM_DCS_PCS_MODE;i>UNDEFINED;i=(GSM3GSMBand)((int)i-1)) + { + if(modemResponse.indexOf(quectelStrings[i])>=0) + return quectelStrings[i]; + } + + Serial.print("Unrecognized modem answer:"); + Serial.println(modemResponse); + + return ""; +} + +bool GSM3ShieldV1BandManagement::setBand(String band) +{ + String command; + String modemResponse; + bool found=false; + + command="AT+QBAND="; + for(GSM3GSMBand i=EGSM_MODE;((i<=GSM850_EGSM_DCS_PCS_MODE)&&(!found));i=(GSM3GSMBand)((int)i+1)) + { + String aux=quectelStrings[i]; + if(aux.indexOf(band)>=0) + { + command+=aux; + found=true; + } + } + + if(!found) + return false; + // Quad-band takes an awful lot of time + modemResponse=modem.writeModemCommand(command, 15000); + + if(modemResponse.indexOf("QBAND")>=0) + return true; + else + return false; +}
\ No newline at end of file |