-
-
Save technobly/bd545861df0478428551200e64a50c63 to your computer and use it in GitHub Desktop.
Switch between AT&T, T-Mobile and Auto modes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// INFO ON HOW TO DETERMINE CARRIER INFO | |
// https://github.com/particle-iot/askengineering/issues/262#issuecomment-235049060 | |
#include "Particle.h" | |
retained int netw = 0; | |
STARTUP(System.enableFeature(FEATURE_RETAINED_MEMORY); | |
System.enableFeature(FEATURE_RESET_INFO);) | |
SerialLogHandler logHandler(LOG_LEVEL_ALL); | |
SYSTEM_MODE(SEMI_AUTOMATIC); | |
/* This function is called once at start up ----------------------------------*/ | |
void setup() | |
{ | |
waitFor(Serial.isConnected,10000); | |
// If we don't shut down due to Soft Power Off, make sure to deactivate PDP context sanely | |
if (System.resetReason() != RESET_REASON_POWER_MANAGEMENT) { | |
Serial.println("Disconnecting"); | |
Cellular.on(); | |
Cellular.command(100000,"AT+UPSDA=0,4\r\n"); | |
// Cellular.command(10000,"AT+CPWROFF\r\n"); | |
} | |
Serial.println("Turning on"); | |
Cellular.on(); | |
if (++netw > 2) netw = 0; | |
if (netw == 0) { | |
Cellular.command(100000,"AT+COPS=2\r\n"); | |
Cellular.command(100000,"AT+COPS=4,2,\"310410\"\r\n"); | |
} | |
else if (netw == 1) { | |
Cellular.command(100000,"AT+COPS=2\r\n"); | |
Cellular.command(100000,"AT+COPS=4,2,\"310260\"\r\n"); | |
} | |
else if (netw == 2) { | |
Cellular.command(100000,"AT+COPS=2\r\n"); | |
Cellular.command(100000,"AT+COPS=0\r\n"); // automatic | |
} | |
Serial.println("Connecting"); | |
Cellular.connect(); | |
Particle.connect(); | |
waitUntil(Particle.connected); | |
delay(6000); | |
if (netw == 0) { | |
Serial.println("\r\nAT&T 310410"); | |
Serial.println("AT&T 310410"); | |
Serial.println("AT&T 310410"); | |
Serial.println("AT&T 310410"); | |
Serial.println("AT&T 310410"); | |
Serial.println("AT&T 310410\r\n"); | |
} else if (netw == 1) { | |
Serial.println("\r\nT-mobile 310260"); | |
Serial.println("T-mobile 310260"); | |
Serial.println("T-mobile 310260"); | |
Serial.println("T-mobile 310260"); | |
Serial.println("T-mobile 310260"); | |
Serial.println("T-mobile 310260\r\n"); | |
} | |
else if (netw == 2) { | |
Serial.println("\r\ndefault automatic"); | |
Serial.println("default automatic"); | |
Serial.println("default automatic"); | |
Serial.println("default automatic"); | |
Serial.println("default automatic"); | |
Serial.println("default automatic\r\n"); | |
} | |
} | |
void loop() | |
{ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment