#include "Particle.h" #include "dct.h" SYSTEM_MODE(SEMI_AUTOMATIC); // setActiveSim and setCredentials must be in STARTUP to take effect immediately STARTUP({ Cellular.setActiveSim(EXTERNAL_SIM); Cellular.setCredentials("teal"); }); // The order here is important because the APN needs to be set only after the SIM switch int at_ret_val = 1; void setup() { Cellular.on(); int retry_count = 3; while(at_ret_val != RESP_OK && retry_count) { delay(5000); // not resetting after UMNOPROF setting because in Gen3, // we reset as a part of putting the second/actual app firmware at_ret_val = Cellular.command(10000,"AT+UMNOPROF=1\r\n"); retry_count--; } // This clears the setup done flag on brand new devices so it won't stay in listening mode const uint8_t val = 0x01; dct_write_app_data(&val, DCT_SETUP_DONE_OFFSET, 1); // This is just so you know the operation is complete pinMode(D7, OUTPUT); digitalWrite(D7, HIGH); } void loop() { // If setting the UMNOPROF (mobile network profile) was unsuccessful, LED blinks every 1 sec if (at_ret_val != RESP_OK) { digitalWrite(D7, HIGH); delay(1000); digitalWrite(D7, LOW); delay(1000); } }