Changeset 17971
- Timestamp:
- 09/23/14 19:08:30 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Arduino/GSM/doms/doms.ino
r17970 r17971 27 27 28 28 29 #define USE_WIRE29 //#define USE_WIRE 30 30 #define USE_ETH 31 31 //#define USE_LSM 32 //#define USE_GSM32 #define USE_GSM 33 33 34 34 #include <SPI.h> … … 69 69 GSM_SMS sms; 70 70 byte gsmStatus = -1; // -1 : unknown 71 bool use_gsm = false; 71 72 #endif 72 73 … … 134 135 { 135 136 #ifdef USE_GSM 136 if( gsmStatus==GSM_READY ) 137 if (use_gsm && gsmStatus==GSM_READY) 138 { 139 // user wants us to use GSM, and GSM seems to be okay. 137 140 checkForSms(); 138 else 139 { 140 // try to connect to DSM network again. 141 } else if (use_gsm && gsmStatus!=GSM_READY) 142 { 143 // user wants us to use GSM, but it's not yet okay, 144 // so we try to connect to GSM network. 141 145 gsmStatus = gsmAccess.begin(PINNUMBER); 146 } else if (!use_gsm && gsmStatus!=-1) 147 { 148 // user does NOT want us to use GSM, but we seem to be connected, 149 // so let's shut it down. 150 gsmAccess.shutdown(); 151 // since there is no dedicated 'GSM_SHUTDOWN' status, we simply use -1. 152 gsmStatus = -1; 153 } else 154 { 155 // user does NOT want us to use GSM and GSM seems to be down .. 156 // so we don't do anything. 142 157 } 143 158 #else … … 183 198 client.println(message); 184 199 break; 200 case 'g': 201 use_gsm = true; 202 break; 203 case 'G': 204 use_gsm = false; 205 break; 206 case 's': 207 printStatus(client, true); 208 break; 185 209 //case 'p': 186 210 //digitalWrite(9, HIGH); … … 204 228 c.println("h help"); 205 229 c.println("q quit"); 230 c.println("g/G en-/disable GSM"); 231 c.println("s status"); 206 232 c.println(); 207 233 c.println("d direction"); … … 210 236 #endif 211 237 } 238 239 void printStatus( 240 #ifdef USE_ETH 241 EthernetClient &c, 242 #endif 243 bool print_via_serial 244 ) 245 { 246 #ifdef USE_ETH 247 c.print("use_gsm: "); c.println(use_gsm); 248 c.print("gsmStatus: "); c.println(gsmStatus); 249 #endif 250 if (print_via_serial) 251 { 252 Serial.print("use_gsm: "); Serial.println(use_gsm); 253 Serial.print("gsmStatus: "); Serial.println(gsmStatus); 254 } 255 } 256 212 257 213 258 void checkForSms()
Note:
See TracChangeset
for help on using the changeset viewer.