Well after some finagling I think I’ve managed to answer my own question…
Here is some code to print to the serial monitor the following:
- list of network carriers that the Electron can currently see (
AT+COPS=?
)
- list of network carriers that are stored in memory on the uBlox (
AT+COPN
)
- list of preferred network carriers currently being used by the uBlox (
AT+CPOL?
)
Unfortunately, it appears that not all data is being output to the serial monitor when AT+COPN
is used (there are weird gaps and inconsistencies in output).
Here is the code that I used:
#include "Particle.h"
int callbackFunc(int type, const char* buf, int len, char* crap)
{
Serial.write((uint8_t*)buf, len); //For some reason the buffer needs to be cast as uint8_t*
return WAIT;
}
void printResponse(int response){
String respStr = "Response of ";
switch(response){
case NOT_FOUND:
respStr += "NOT_FOUND";
break;
case WAIT:
respStr += "WAIT";
break;
case RESP_OK :
respStr += "RESP_OK ";
break;
case RESP_ERROR :
respStr += "RESP_ERROR ";
break;
case RESP_PROMPT :
respStr += "RESP_PROMPT ";
break;
case RESP_ABORTED :
respStr += "RESP_ABORTED ";
break;
}
Serial.println(respStr);
}
void setup()
{
Serial.begin(9600);
//Wait for serial monitor to become available
while(!Serial.available());
while(Serial.available()){
Serial.read();
};
char noNeedForThisVariable[1] = "";
String myCommand = "AT+COPS=?\r\n";
Serial.println("--------------------------------------------------");
Serial.println("----> Sending command: " + myCommand);
int response = Cellular.command(callbackFunc, noNeedForThisVariable, 180000, myCommand);
printResponse(response);
myCommand = "AT+COPN\r\n";
Serial.println("--------------------------------------------------");
Serial.println("----> Sending command: " + myCommand);
response = Cellular.command(callbackFunc, noNeedForThisVariable, 180000, myCommand);
printResponse(response);
myCommand = "AT+CPOL?\r\n";
Serial.println("--------------------------------------------------");
Serial.println("----> Sending command: " + myCommand);
response = Cellular.command(callbackFunc, noNeedForThisVariable, 180000, myCommand);
printResponse(response);
}
void loop()
{
// your loop code
}
and here is the output to the serial monitor:
--------------------------------------------------
----> Sending command: AT+COPS=?
+COPS: (2,"CAN Rogers Wireless Inc.","ROGERS","302720",2),(2,"CAN Rogers Wireless Inc.","ROGERS","302720",0),(1,"Bell","Bell","302610",2),(1,"TELUS","TELUS","302220",2),,(0-5),(0-2)
OK
Response of RESP_OK
--------------------------------------------------
----> Sending command: AT+COPN
+UUSORD: 0,33
+CIEV: 2,2
+CIEV: 2,1
+CIEV: 2,2
+CIEV: 2,1
+CIEV: 2,2
+COPN: "363020","DIGICEL"
+COPN: "363001","SETAR GSM"
+COPN: "412001","AF AWCC"
+COPN: "412050","Etisalat Af"
+COPN: "412040","MTN AF"
+COPN: "412020","ROSHAN"
+COPN: "631002","UNITEL"
+COPN: "365840","LIME"
+COPN: "276001","AMC - AL"
+COPN: "276003","EAGLE AL"
+COPN: "276004","PLUS AL"
+COPN: "276002","Vodafone AL"
+COPN: "213003","MOBILAND"
+COPN: "362069","ANT CURACAO TELECOM GSM"
+COPN: "362091","ANT"
+COPN: "362051","Telcell GSM"
+COPN: "424003","du"
+COPN: "424002","ETISALAT"
+COPN: "722310","CLARO ARGENTINA"
+COPN: "722341","AR PERSONAL"
+COPN: "722010","Movistar"
+COPN: "722007","Movistar"
+COPN: "283001","Beeline AM"
+COPN: "283005","MTS ARM"
+COPN: "283010","Orange AM"
+COPN: "544110","Bluesky Communications"
+COPN: "344030","APUA imobile"
+COPN: "344930","Cingular"
+COPN: "344920","LIME"
+COPN: "505002","YES OPTUS"
+COPN: "505001","Telstra Mobile"
+COPN: "505006","3TELSTRA"
+COPN: "505003","vodafone AU"
+COPN: "232001","A1"
+COPN: "232012","A1"
+COPN: "232010","3 AT"
+COPN: "232005","3 AT"
+COPN: "232003","T-Mobile A"
+COPN: "232007","telering"
+COPN: "40
+COPN: "400004","AZ Nar"
COPN: "642001","BDI ECONET,"TELECEL-BDI"
+COPN: "2060r"
+COPN: "616004","BELL BEGloBenin"
+COPN: "616003",OPN: "470003","Banglalink"
+COPN: "470004","BGD bMobile"
,"Mtel"
+COPN: "426001","BATELCO"
+COPN"364039","BaTelCell"
+tel"
+COPN: "257004","life:) B "702067","BTL"
+COPN+COPN: "736001","VIVA"
+COP","Claro"
+COPN: "724034","CTBC"
9","Nextel Brasil 3G"
+COPN: "IM BRASIL"
+COPN: "724004",: "724006","VIVO"
+COPN: "7 "342600","LIME"
+COPN: "3427om"
+COPN: "402011","BT B-N: "652001","BW MASCOM"
+COP"NationLink"
+COPN: "623002","Telecel"
N: "302270","Eastlink"
+COPN: ""Execulink Telecom"
+COPN: : "302720","CAN Rogers Wir302220","TELUS"
+COPN: "30278015","OnAir"
+COPN: "228003","Or
+COPN: "730003","CLARO CHL"
N: "730009","Nextel 3G"
+COPN:HL VTR"
+COPN: "46000 CI"
+COPN: "612004",1","MTN CAM"
+COPN: "62 DRC"
+COPN: "630086","COPN: "630088","CD Smart"
+COSCELL CD"
+COPN: "629007","GO"
+COPN: RI"
+COPN: "625001","CPV MOVEL"
+COPN: "625002","CPV T+"
+C: "712001","I.C.E."
+COPN: "346140","LIME"
+COPN:230001","T-Mobile CZ"
+COPN: "230002","O2 -E-Plus"
+COPN: "262007","o2 - "262002","Vngular"
+COPN: "238006","3
+COPN: "238002","Telenor DK"70002","C
+COPN: "603002","Djezzy"
+COPN: "6030CNT"
+COPN: "740000","MovistPN: "602002","vodvodafone ES"
+COPN: "2103","Tele2 EE"
+COPN+COPN: "244003","DNA"
IGICEL"
+COPN: "542001","FJ VODAFOcom"
+COPN: "208088","F - 40001","F-Orange"
+COPN: "208009","F SFR"
+COPN: "208013","F01","Foroya Tele"
TISALAT GAB"
+COPN: "62800PN: "234033","EE"
+COP "234020","3 UK"
+COPN: "901
+COPN: "234028","Marathon"
+COPN: "234055","SuPMN UK"
+COPN: "234015","vEO"
+COPN: "282004",07","Glo Ghana"
+COPN: "620003","tiGO"
+COPN: " "266009","Shine"
+COPN: "611001","Or2","AFRICELL"
+COPN: "607003"OPN: "632003","Oranni"
+COPN: "202001","GR COSMOTE"
+COPN: N: "202009","WINeenland"
+COPN: "7040+COPN: "340002,"China Mobile HK"
+COPN: "4"
+COPN: "454018","CSL"
W-HKT"
+COPN: "454020","SmarTone HK"
+COPN: "
+COPN: "708001","CLARO HND"002","Tele2 HR"
+COPN: "21901OPN: "216030","Telekom HU"
+COPN: "2160010000","ACeS"
+COPN: "510011","IND XL"
+COPN: "510089",N: "510001","IND INDOSAT"
,"Aircel"
+COPN: 405801","Aircel"
+COPN: "405805","Aircel"
+COPN: "COPN: "404038","CellOne"
ellOne"
+COPN: "404057","CellOne"
"404073","CellOne"
+COPN: "4040
+COPN: "404055","CellOne"
+COPN: "4",OPN: "404058","CellOne"
lOne"
+COPN: "404010","IND airtel"
PN: "405053","I405056","IND airtel"
+COPN: "40IND airtel"
+COPN: "4l"
+COPN: "40404090","IND airtel"
+COP095","IND airtel"
+COPN: "4 airtel"
+COPN: "40584,"IDEA"
+COPN: "404056","IDEA"
,"IDEA"
+COPN: "404024""IDEA"
+COPN: "404089","ID
+COPN: "405852","IDEA"
+COPN:DEA"
+COPN: "405849","IDEA"
+COPN: 59","IN Loop"
+COPN: "405854"COPN: "405873","IN Loop"
+COPN: Loop"
+COPN: "405867","IN Loop"
+COPN: "4"405857","IN L
+COPN: "405865","IN L"IN Loop+COPN: "404069","IN-DOLPHIN"
+009","Relian
+COPN: "405022","Reliance"
+COPN: "4050001","Reliance"
+COPN: "405018","Relianc
+COPN: "405005","Reliance"5020","Reliance"
+COPN: "e"
+COPN: "404052","Reliance"
+COPN: "405039","TATA38","TATA DOCOMO"
+COPN:ATA DOCOMO"
+COPN: "40504OCOMO"
+COPN: "405044","TATA DOCO
+COPN: "4OPN: "405041","TATA DOCOMO"
8","IN UNITECH"
+IN UNITECH"
+
+COPN: "405824","VIDEOCON837","VIDEOCON"
+COPN: "405843","VI
+COPN:5841","VIDEOCON"
+COPN: "4058PN: "405838","VIDEOCON"
+COPN: "405823","VIDEOCON"
+COPNfone IN"
+CON"
+COPN: "404088","Vodafone IN+COPN: "404015","Vodafone: "404084","Vodafone 750","Vodafone IN"
+CVodafone IN"
+COPN: "40 IN"
+COPN: "272003","IRL - MET035","MTN Irancell"
+COPN: "432020","IRN 18030","IRAQNACOPN: "274011","NOVA IS"
minn"
+COPN: "425002"COPN: "425003","IL Pelephone"
+COPN: "22,"I TIM"
+COPN "338050","DIGICEL"
+COPN:"Orange JO"
+COPN: "4160"440010","JP DOCOMO"
+COPN: "440020","SoftBank"
+COPN: e KZ"
+COPN: "a Ltd"
+COPN: "639002","SafPN: "437009","O!"
+COPN: "43ard"
+COPN: "456006","SMA,"Beeline KH"
+COPN: "456008","Metfone"
+COPN: "467005lus"
+COPN: "450005","KOR SOPN: "419003","KT WATANIYA"
+COPN: "457: "457003","Unitel"
ebanon"
+COPN: "4150estar Cell"
+COPN: "618004"58110","LIME"
+COPN: "358050","DIGICEL"
+COPN: "2OPN: "295001","Sacom LeCOPN: "270099","L Orange-LU"
+COPN: "27"LV LMT"
+COPN: "24704","CTM"
+COPN: "4550
+COPN: "604002","inwi"
+COPN: "2OLDCELL"
+COPN: "259005","U: "646002","Orangoo"
+CN: "334020","TELCEL"
+COPN: "294002","ONE MK"
+COPN: "294001","T-Mobile MK"
+COPN: "294 MKD"
+COPN: "6
+COPN: "27802197002","Telekom.me"
+COPN: "297001","Telenor"
biCITEL"
+COPN: "643001","MOZ - mCel"
+COPN: "643003","MOVITN: "6091","CELLPLUS-MRU"
+COPN: "617010","EMTEL-MRU"COPN: "650010","CELTEL,"MY CELCOM"
+COPN: "5020PN: "649001","MTC NAM02","CELTEL"
+COPN: "614004","Ora Telecom"
+COPN: "621020",""
+COPN: "621710300","MOVISTARNbile NL"
+COPN: "204004","vodafone NL"Norway"
+COPN: "530005","Telecom NZ"
+COPN: "530"OMAN MOBILE"
+COPN: "4220N: "410003","PK-UFONE""+Movil - C&W PAN"
+COPN: "714003","CLARO PA"
+ar"
+COPN: "716010","CLARO PER"15","VietGlobe Telecom-PH"
+COPN:
+COPN: "537001","PNGBMobile"
Plus"
+COPN: "260002","T-M
+COPN: "330110","PR Claro"
+COPN: "268006","MEO"
+COPN:"vodafone P"
+COPN: Personal"
+COPN: "74taniya Mobile"
"
+COPN: "647000","Oran1001","MH-NTA"
+CO.Mobil"
+COPN: "226001","RO Vodafone ROGO"
+COPN: "250035","MO50003","ROSTELECOM"
+COPNOSTELECOM"
+COPN: "250099","Be7, RUS SMARTS"
+C
+COPN: "6420003","Mobily-KSA"
+COPN: "42000OPN: "634001","Zain SDN"
+COPN: "651","SN ALIZE"
+COPN: "608003"1"
+COPN: "525002","SingTel"
+COPN: "525007" "525005","STARHUB"
+COPN: "540002","Bemobile"
+COPN: "5400EL SL"
+COPN: "619004","SLE COMIUM"
+COPN: COPN: "706002","Digicel"
+COPN"SMT"
+COPN: "63703"
+COPN: "637071","SOMTEL"
+COPN: ""220003","mt:s"
+COPN: "220001","TeleTEL"
+COPN: "413002","SRI DIALOPN: "659003","Gemtel"
+Cmovel"
+COPN: "746003","DIGICEL"
+COPN: "746004","OPN: "231001","Orange SK"
+,"Si.mobPN: "240002","3 SE"
+COPN: "240004","SWEDEN"
+COPN:bile"
+COPN: "240005","Sweden 3G"
"653010L"
+COPN: "376350","LI003","Tigo TD"
+COPN: "62-TOGO CELL"
+COPN: "52"520002","TH CAT"
+riNet"
+COPN: "5220099","TRUE"
+COPN: "436PN:1","MTS TM"
+COPN: "514002","TLS-TT"
+COPN: "374TUNISIE TELECOM"
+COPN: "286003","ATR"
+COPN: "466068","ACeS"
+COPN: "4+COPN: "466088","KG66089","VIBO"
+COPN: "640005","celOPN: ""MTN-UGANDA"
+COPN: "641014","WaridTel"
+COPN: "255006","life:)"
N: "255002","Beeline UA"
RO URUGUAY"
+COPN:PN: "310640","USA AE Airadigm","AT&T"
+COPN: "310380","AT&T"
","USAC1ECI"
+COPN: "310630"
+COPN: "311040","+COPN: "311500","MOSAIC"
+COP: "311370","GCI"
+COPN: "310190"Indigo"
+CO,"BigSkyUS"
+CO90","USA - Immix Wireless"
ook"
+COPN: "310290","NE10460","USA1L"
+COPN: "312"311710","Northeast Wireless"
+COPN: "310740","U080","Pine C140","GTA"
+COPN: "310320"e"
+COPN: "310200","T-Mobile"
+COPN: "31310580","T-Mobile"
+COPN: "31le"
+COPN: "310490","SunC0240","T-Mobileobile"
+COPN: "310390","Celllar"
+COPN
+COPN: "310890","Verizon"
+COPN: ,"WestLink"
+COPN: "31
+COPN: "434004","Beeline UZ","DIGITEL G
+COPN: "348570","CCT BoaCOPN: "452001","VN MobiFone"
COPN: "541005","Digicel"
+L"
+COPN: "421004","Y-Tele"655007","Cell C"
+COPA"
+COPN: "645001","ZM 48001","ZW NET*ONE"
+COPN: "648003","TELEC021","Seanet"
+CME ERROR: operation not
Response of RESP_ERROR
--------------------------------------------------
----> Sending command: AT+CPOL?
+CREG: 5,"CF35","12222E",2
+CGREG: 5,"CF35","12222E",2,"01"
+CPOL: 1,0,"CAN Rogers Wireless Inc.",1,0,1
+CPOL: 2,0,"O2 - UK",1,0,1
+CPOL: 3,0,"vodafone UK",1,0,1
+CPOL: 4,0,"o2 - de",1,0,1
+CPOL: 5,0,"E-Plus",1,0,1
+CPOL: 6,0,"O2 - CZ",1,0,1
+CPOL: 7,0,"T-Mobile CZ",1,0,1
+CPOL: 8,0,"O2-IRL",1,0,1
+CPOL: 9,0,"vodafone IE",1,0,1
+CPOL: 10,0,"O2 - SK",1,0,1
+CPOL: 11,0,"Telekom SK",1,0,1
+CPOL: 12,0,"334030",1,0,1
+CPOL: 13,0,"TELCEL",1,0,1
+CPOL: 14,0,"VIVO",1,0,1
+CPOL: 15,0,"VIVO",1,0,1
+CPOL: 16,0,"VIVO",1,0,1
OK
Response of RESP_OK