Example program demonstrating proper powering down of Telit radio and putting the processor into STOP mode.

Dependencies:   WakeUp mbed mtsas SpiFlash25

Fork of Dragonfly_Cellular_Ping_Example by MultiTech

Revision:
4:91a322a2ec86
Parent:
3:90cf39b6ed0d
Child:
5:e493656a4a1a
--- a/main.cpp	Mon Feb 29 14:53:33 2016 +0000
+++ b/main.cpp	Mon Feb 29 19:28:01 2016 +0000
@@ -7,8 +7,8 @@
  *
  * There are two methods for properly powering off the cellular radio
  *  1) Software shutdown
- *      - use Cellular::sendBasicCommand() to issue AT#SH to the radio and make sure it is successful
- *      - poll vdd1_8_mon - when the radio powers off this line will go to 0 (at least 10s after AT#SH)
+ *      - use Cellular::sendBasicCommand() to issue AT#SHDN to the radio and make sure it is successful
+ *      - poll vdd1_8_mon - when the radio powers off this line will go to 0 (at least 10s after AT#SHDN)
  *      - drop the radio_reset line to 0 (pin PC_13) so the radio control chip doesn't attempt to restart the radio
  *      - (optional) drop the radio_pwr line to 0
  *          + this eliminates all current draw from the radio when it is powered off but increases the time it takes to reconnect to the network
@@ -19,6 +19,8 @@
  *          + this eliminates all current draw from the radio when it is powered off but increases the time it takes to reconnect to the network
  *
  * NOTE: This example changes the baud rate of the debug port to 115200 baud!
+ * NOTE: A SIM card is required for GSM radios to connect to the network!
+ * NOTE: CDMA cellular radios need to be provisioned before use!
  */
 
 #include "mbed.h"
@@ -98,6 +100,7 @@
         int tries = 0;
         
         while (radio->sendBasicCommand("AT", 1000) != MTS_SUCCESS) {
+            wait(1);
             tries++;
             if (tries % 25 == 0) {
                 logWarning("no response from radio after 25 tries (total tries %d) - resetting radio", tries);
@@ -105,8 +108,9 @@
                 wait_ms(10);
                 radio_reset = 1;
             }
-            wait(1);
+            printf(".");
         }
+        printf("\r\n");
         
         logInfo("setting APN");
         if (radio->setApn(apn) != MTS_SUCCESS)
@@ -129,13 +133,21 @@
         // power down the radio
         logInfo("powering down radio");
         radio_reset = 0;
-        logInfo("waiting for vdd1_8_mon to go low");
+        logInfo("waiting up to 30s for vdd1_8_mon to go low");
         tmr.reset();
         tmr.start();
         // wait up to 30s for the radio to shut down
-        while (vdd1_8_mon != 0 && tmr.read() < 30)
-            wait_ms(500);
+        while (vdd1_8_mon != 0 && tmr.read() < 30) {
+            wait(1);
+            printf(".");
+        }
         tmr.stop();
+        printf("\r\n");
+        if (vdd1_8_mon != 0 && tmr.read() >= 30) {
+            logError("radio did not shut down! aborting iteration");
+            continue;
+        }
+            
         logInfo("radio powered off after %fs", tmr.read());
         radio_pwr = 0;
         logInfo("putting regulator in 100mA mode");