-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsp_ATcom_19feb.ino
More file actions
764 lines (689 loc) · 18.5 KB
/
sp_ATcom_19feb.ino
File metadata and controls
764 lines (689 loc) · 18.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
//#include "SmsGsmLib.h"
/*
* sp_ATcom_19feb.ino
*
* Created: 2/19/2016 7:50:38 AM
* Author: Anuj
*/
#include "SoftwareSerial.h"
#include "EEPROM.h"
SoftwareSerial SIMSerial(2,3); // RX, TX
#define DEVICE 8 // Relay to this
#define RSTTRIGGER 12 // connected to reset switch(tak switch) // pin 18 atmega(pb-4)// pulled down
#define ADDR 5 // EEPROM address for digital pin status
#define ADDR4RESUME 9 // EEPROM address for Power resume status
#define ADDRMOTION 11 // EEPROM address for MOTION status (Enable/Disable)
#define SENDPIN 5
#define RECEIVEPIN 6
//#define DEBUG // To enable/disable serial print debug
enum sms_type_enum
{
SMS_UNREAD,
SMS_READ,
SMS_ALL,
SMS_LAST_ITEM
};
int8_t answer;
int8_t answer1;
int ThreeAlert=0;
int Motion_detect_pin = 9;
int pirState = HIGH; // we start, assuming no MOTION detected
int pirConnected = 15; // To check if PIR connected or not
//byte active = 0;
//byte reg_info = 0;
byte ad_val = 0;
byte latch_try_count = 0;
byte loop_count = 0;
boolean started=false; // GSM Modem status check Flag
boolean chkON=false; // Detect CapSwitch ON
boolean chkOFF=false; // Detect CapSwitch OFF
boolean round_robin=false; // for manual switch
//boolean pirState = true; // we start, assuming no MOTION detected
long time = 0;
int CapSwitchstate = LOW;
boolean yes;
boolean previous = false;
const int debounce PROGMEM = 200; // 200
byte SM_sent = 0;
char n[20];
char currentINFO[30];
char localsmsbuffer[6];
char aux_string[30];
char phone_number[]="9910130022"; // "9910130022" Server GSM pool no
char SMS_buff[40];
const int currentPin = 0;
const unsigned long sampleTime = 100000UL;
const unsigned long numSamples = 250UL;
const unsigned long sampleInterval = sampleTime/numSamples;
//const int adc_zero = 613;
int adc_zero;
unsigned long tat;
unsigned long req_time;
void setup()
{
//digitalWrite(RSTPULSE, HIGH); // very imp
delay(200);
adc_zero = determineVQ(currentPin);
//Serial.begin(115200);
SIMSerial.begin(4800);
//Serial.println("Con N/W");
delay(1000);
while( (sendATcommand("AT+CREG?", "+CREG: 0,1", 500) || sendATcommand("AT+CREG?", "+CREG: 0,5", 500)) == 0 )
{
delay(100);
//Serial.print(".");
}
answer1 = sendATcommand("AT", "OK", 500);
delay(10);
answer = sendATcommand("AT+CMGF=1", "OK", 1000); // sets the SMS mode to text
if (answer1 == 1 || answer == 1)
{
started=true;
}
else
{
started=false;
}
delsms();
pinMode(DEVICE, OUTPUT);pinMode(RSTTRIGGER, INPUT);
//pinMode(RSTPULSE, OUTPUT);
pinMode(Motion_detect_pin, INPUT); digitalWrite(Motion_detect_pin, LOW);
pinMode(SENDPIN, OUTPUT);
pinMode(RECEIVEPIN, INPUT_PULLUP);
pinMode(pirConnected, INPUT); digitalWrite(pirConnected, LOW);
pinMode(16, OUTPUT);pinMode(17, OUTPUT); //14 to 19
digitalWrite(16,LOW);
digitalWrite(17,LOW);
Deviceinfo();
//Serial.println(freeRam());
delay(100);
Relayrebootfunc();
}
void (* resetFunc) (void) = 0;
/*
int read_sms()
{
char sms_text[100];
int x = 0;
sendATcommand("AT+CMGF=1", "OK", 1000); // sets the SMS mode to text
sendATcommand("AT+CPMS=\"SM\",\"SM\",\"SM\"", "OK", 1000); // selects the memory
//Serial.println("AT+CNMI=3,3,0,0"); // set module to send SMS data to serial out upon receipt
//Serial.println("AT+CNMI=2,2,0,0,0"); // set module to send SMS data to serial out upon receipt
memset(SMS_buff,0,sizeof(SMS_buff));
answer = sendATcommand("AT+CMGR=1", "+CMGR:", 2000); // reads the first SMS
if (answer == 1)
{
answer = 0;
while(SIMSerial.available() == 0); // this cleans up _ anuj
// this loop reads the data of the SMS
do{
// if there are data in the UART input buffer, reads it and checks for the answer
if(SIMSerial.available() > 0){
sms_text[x] = SIMSerial.read();
x++;
// check if the desired answer (OK) is in the response of the module
if (strstr(sms_text, "OK") != NULL)
{
answer = 1;
}
}
}while(answer == 0); // Waits for the answer with time out
sms_text[x] = '\0';
Serial.print(sms_text);
sprintf(SMS_buff,"%s", sms_text); // loading sms_text to SMS_buff
}
else
{
Serial.print("error ");
Serial.println(answer, DEC);
}
}
*/
void delsms(){
int i;
for (i=0; i<10; i++){ //do it max 10 times
int posALL=IsSMSPresent(SMS_ALL);
if (posALL!=0){
if (DeleteSMS(posALL)==1){
}
else{
//
}
}
}
}
void Relayrebootfunc(){ // This is a redirect to previous state
if(started){
if ((EEPROM.read(ADDR4RESUME) == 1)&&(EEPROM.read(ADDR) == 1)){
CapSwitchstate=HIGH;
ad_val = 1;
send_sms("ACK ON_","INIT_", "0.00");
digitalWrite(DEVICE,CapSwitchstate);
EEPROM.write(ADDR, ad_val);
led_green();
}
else {
CapSwitchstate=LOW;
ad_val = 0;
send_sms("ACK OFF_", "INIT_", "0.00");
digitalWrite(DEVICE,CapSwitchstate);
EEPROM.write(ADDR, ad_val);
led_off();
}
}
}
void Exfunc(){
int pos=0; // SMS position counter
if(started){
pos=IsSMSPresent(SMS_UNREAD);
if(pos){
loop_count = 0 ; // If pos=1 it means any mess received and if so then no network issue. Hence loop_count = 0;
int SMSread;
int returntext;
for (SMSread=0; SMSread < 3; SMSread++){ // Reading an incoming message without MSISDN check
returntext=GetSMS(pos,n,SMS_buff,40);
//read_sms();
if (returntext == 2){
//Serial.println("check pass");
req_time = millis();
break;
}
}
//Serial.println(SMS_buff);
String checkauth = (String)SMS_buff;
String keyword = checkauth.substring(0,3); // extract keyword
String uid = checkauth.substring(4,11); // extract session id
keyword.toCharArray(localsmsbuffer,4);
if(!strcmp(localsmsbuffer,"ON ")){ // ||checkauth.indexOf("ON") >= 0
CapSwitchstate=HIGH;
SM_sent = send_sms("ACK ON_", uid, "_0.00");
tat=millis()-req_time;
if (SM_sent == 1){
ad_val = 1;
digitalWrite(DEVICE,CapSwitchstate);
delay(2);
led_green();
round_robin = false;
delay(2);
EEPROM.write(ADDR, ad_val);
}
else {
led_red();
round_robin = true;
}
delsms();
}
else if(!strcmp(localsmsbuffer,"OFF")){ // ||checkauth.indexOf("OFF") >= 0
//sensordata();
CapSwitchstate=LOW;
//for (int SenseC=0;SenseC<3;SenseC++){
sensordata();
//}
uid = uid + "_";
SM_sent = send_sms("ACK OFF_", uid, currentINFO);
tat=millis()-req_time;
if (SM_sent == 1){
ad_val = 0;
digitalWrite(DEVICE,CapSwitchstate);
delay(2);
led_off();
round_robin = false;
delay(2);
EEPROM.write(ADDR, ad_val);
}
else {
led_red();
round_robin = true;
}
delsms();
}
else if(!strcmp(localsmsbuffer,"111")){
SM_sent = send_sms("PDSTATE 111_", uid, "");
if (SM_sent == 1){
delay(100);
PowerResume("111");
}
else {
}
delsms();
}
else if(!strcmp(localsmsbuffer,"000")){
SM_sent = send_sms("PDSTATE 000_", uid, "");
if (SM_sent == 1){
delay(100);
PowerResume("000");
}
else {
}
delsms();
}
else if(!strcmp(localsmsbuffer,"RST")){
HWflush("RST ",uid);
}
else if(!strcmp(localsmsbuffer,"MEN")){
if(!digitalRead(pirConnected)){ // 1 = DISCONNECTED / 0 = CONNECTED
SM_sent = send_sms("MEN ", uid, "");
if (SM_sent == 1){
//Motionstate=1;
EEPROM.write(ADDRMOTION, 1);
delay(10);
}
else {
}
delsms();
}
//else if(check_pir_connection){
else{
SM_sent = send_sms("MDC ", uid, "");
delsms();
}
}
else if(!strcmp(localsmsbuffer,"MDA")){
SM_sent = send_sms("MDA ", uid, "");
if (SM_sent == 1){
//Motionstate=0;
EEPROM.write(ADDRMOTION, 0);
delay(10);
}
else {
}
delsms();
}
else if(!strcmp(localsmsbuffer,"REG")){
String LOCstring =""; // try with charbuff[x] insted of string
//SIMSerial.println("AT+CENG=2,1"); // CELL, "arfn,rxl,rxq,mcc,mnc,bsic,cellid,rla,txp,lac,TA"
SIMSerial.println("AT+CENG=3"); // MCC,MNC,LAC,CID,BSIC,RXL info
delay (1000); // 1000
SIMSerial.println("AT+CENG?"); //use ln or even \r
delay (2000); // 1000 // 2000 has effected a to get full response
char inchar1;
for (int m=0; m<82; m++){ // 63
inchar1 = SIMSerial.read();
if (inchar1 == '\r' || inchar1 == '=' || inchar1 == '\n' ||
inchar1 == '/r' || inchar1 == 'O'|| inchar1 == 'K' ||
inchar1 == '+' || inchar1 == 'C' || inchar1 == 'E'||
inchar1 == 'N' || inchar1 == 'G' || inchar1 == ':' ||
inchar1 == ' ' || inchar1 == '?'){
//do nothing
}
else {
LOCstring = LOCstring + inchar1;
}
}
//Serial.println(LOCstring);
String LOCbuf = "REG ";
//LOCbuf = LOCbuf + LOCstring.substring(19,36);
//LOCbuf = LOCbuf + LOCstring.substring(5,24);
LOCbuf = LOCbuf + LOCstring.substring(12,28);
//Serial.println(LOCbuf);
SM_sent = send_sms("",LOCbuf,"");
delsms();
}
else {
delsms(); // new change
}
memset(SMS_buff,0,sizeof(SMS_buff)); // clear sms buffer
while( SIMSerial.available() > 0) SIMSerial.read(); // clear ring buffer
SM_sent = 0; // set sms flag false
loop_count = 0; // to reset n/w check mechanism counter
}
}
}
void TacSwitch()
{
if(started){
//String uid = "SWT";
//int return_val=0;
digitalWrite(SENDPIN, LOW); // send pin shorts with receive pin on press
int readvalue = digitalRead(RECEIVEPIN);
if (readvalue == 0){yes = true;}
else {yes = false;}
if(yes == true && previous == false && millis() - time>debounce){
if(CapSwitchstate == LOW){
CapSwitchstate = HIGH;
chkON=true;
chkOFF=false;
}
else{
CapSwitchstate = LOW;
chkOFF=true;
chkON=false;
}
time = millis();
if(chkON){
if (CapSwitchstate == HIGH){
led_green();
ad_val = 1;
EEPROM.write(ADDR, ad_val);
digitalWrite(DEVICE,CapSwitchstate);
//return_val = sms.SendSMS(ack,"ACK ON_SWT_0.00");
SM_sent = send_sms("ACK ON_", "SWT_", "0.00");
if (SM_sent == 1){
led_green();
round_robin = false;
loop_count = 0; // to reset n/w check mechanism counter
}
else {
if (EEPROM.read(ADDR) == 1){
led_red();
round_robin = true;
}
}
}
chkON=false;
}
if(chkOFF){
if (CapSwitchstate == LOW){
led_off();
//char* cur_val;
ad_val = 0;
EEPROM.write(ADDR, ad_val);
digitalWrite(DEVICE,CapSwitchstate);
sensordata();
////for (int SenseC=0;SenseC<3;SenseC++){
//// currentAmps = sensordata();
////}
SM_sent = send_sms("ACK OFF_", "SWT_", currentINFO);
if (SM_sent == 1){
led_off();
round_robin = false;
loop_count = 0; // to reset n/w check mechanism counter
}
else {
if (EEPROM.read(ADDR) == 0){
led_red();
//led_off();
round_robin = true;
}
}
}
chkOFF=false;
}
}
previous = yes;
delay(10);
SM_sent = 0;
}
}
void sensordata(){
unsigned long currentAcc = 0;
unsigned int count = 0;
unsigned long prevMicros = micros() - sampleInterval ;
while (count < numSamples){
if (micros() - prevMicros >= sampleInterval){
int adc_raw = analogRead(currentPin) - adc_zero;
currentAcc += (unsigned long)(adc_raw * adc_raw);
++count;
prevMicros += sampleInterval;
}
}
float rms = sqrt((float)currentAcc/(float)numSamples) * (50 / 1023.0); // 75.7576
rms = rms - 0.07;
//rms = rms - 0.31;
if (rms < 0.00){
rms = 0.00;
}
char tmp[10];
dtostrf(rms,1,2,tmp);
//dtostrf(rms,1,2,currentINFO);
//Serial.println(tmp);
sprintf(currentINFO,"%s", tmp);
//currentAmps.toCharArray(replyINFO,30);
//return tmp;
}
int determineVQ(int SensorPIN) {
//estimating avg. quiscent voltage
long VQ = 0;
//read 5000 samples to stabilize value
for (int i=0; i<5000; i++) {
VQ += analogRead(SensorPIN);
delay(1);//depends on sampling (on filter capacitor), can be 1/80000 (80kHz) max.
}
VQ /= 5000;
map(VQ, 0, 1023, 0, 5000);
return int(VQ);
}
/*
void balanceinfo(String ussd){
char sendUSSD[30];
ussd.toCharArray(sendUSSD,30);
gsm.SimpleWriteln(sendUSSD); //bal - (F("AT+CUSD=1,\"*121#\"")) // sms - (F("AT+CUSD=1,\"*131*3#\""))
delay(5000);
char resp[105];
gsm.read(resp,105);
sms.SendSMS(ack,resp);
//return 1;
}
*/
void Deviceinfo(){
String imeistring = "DIMEI ";
SIMSerial.println("AT+GSN"); //IMEI Info
delay (500);
char inchar;
for (int m=0; m<25; m++){
inchar = SIMSerial.read();
////String temp PROGMEM = (String)serialnumber;
if (inchar == '\r' || inchar == '=' || inchar == '\n' ||
inchar == '/r' || inchar == 'O' || inchar == 'K' ||
inchar == 'A' || inchar == 'T' || inchar == '+' ||
inchar == 'G' || inchar == 'S' || inchar == 'N' || inchar == ' '){
//do nothing
}
else {
imeistring = imeistring + inchar;
}
}
while( SIMSerial.available() > 0) SIMSerial.read();
delay(10);
SM_sent = send_sms("",imeistring,"");
}
void HWflush(char *ACKresp_text, String id){
digitalWrite(DEVICE, LOW);
led_off();
SM_sent = send_sms(ACKresp_text,id,"");
if (SM_sent == 1){
led_off();
ad_val = 0; // plug off
EEPROM.write(ADDR, ad_val);
//Motionstate=0; // MOTION sens off
EEPROM.write(ADDRMOTION, 0);
//PResume=1;
EEPROM.write(ADDR4RESUME, 1);
delay(20);
resetFunc(); //call reset
//digitalWrite(RSTPULSE, LOW); // actual controller reset
}
else{
led_red();
}
}
void PowerResume(char* logic){
if (!strcmp(logic,"111")){
//PResume=1;
EEPROM.write(ADDR4RESUME, 1);
}
else if (!strcmp(logic,"000")){
//PResume=0;
EEPROM.write(ADDR4RESUME, 0);
}
}
void motionsence(){
digitalWrite(Motion_detect_pin,LOW);
if (digitalRead(Motion_detect_pin) == HIGH) { // check if the input is HIGH (intruder detected) from PIR
if (pirState == LOW) {
//Serial.println("M-on");
for (ThreeAlert=0;ThreeAlert<2;ThreeAlert++){
//sms.SendSMS(ack,"INTRUDER");
SM_sent = send_sms("INTRUDER","","");
delay(20);
}
digitalWrite(Motion_detect_pin,LOW);
EEPROM.write(ADDRMOTION, 0);
ThreeAlert=0;
pirState = HIGH;
delay(10);
}
}
else {
delay(100);
if (pirState == HIGH){
digitalWrite(Motion_detect_pin,LOW);
//Serial.println("M-off");
pirState = LOW;
//MotionVal= 0;
}
}
}
void network_status()
{
while( (sendATcommand("AT+CREG?", "+CREG: 0,1", 500) || sendATcommand("AT+CREG?", "+CREG: 0,5", 500)) == 0 )
{
//Serial.println("Reg failed");
delay (10);
SIMSerial.println("AT+CFUN=1,1");
latch_try_count ++;
if (latch_try_count == 5)
{
//Serial.println("Limit exceeded");
//network_check = false;
latch_try_count = 0;
break;
}
delay (120000); // wait for 2mins for the n/w to reattach
}
latch_try_count = 0;
loop_count = 0;
}
void led_green()
{
digitalWrite(16,LOW); // Green // //pin 25 vcc
digitalWrite(17,LOW); // pin 26 gnd
delay(2);
digitalWrite(16,HIGH);// Green // //pin 25 vcc
//delay(2);
//digitalWrite(A3,LOW); // pin 26 gnd
}
void led_red()
{
digitalWrite(16,LOW); //pin 25 gnd
digitalWrite(17,LOW); // Red // pin 26 vcc
delay(2);
//digitalWrite(A2,LOW); //pin 25 gnd
//delay(2);
digitalWrite(17,HIGH); // Red // pin 26 vcc
}
void led_off()
{
//delay(5);
digitalWrite(16,LOW);
//delay(2);
digitalWrite(17,LOW); // Off //
}
int send_sms(char* ACKresp_text, String id, char* Load_Current)
{
sendATcommand("AT+CMGF=1", "OK", 1000); // sets the SMS mode to text
byte ret_val = 0;
sprintf(aux_string,"AT+CMGS=\"%s\"", phone_number);
answer = sendATcommand(aux_string, ">", 2000); // send the SMS number
if (answer == 1)
{
char SMSsendBuf[50];
String finalack = ACKresp_text + id + Load_Current;
finalack.toCharArray(SMSsendBuf,50);
SIMSerial.println(SMSsendBuf);
SIMSerial.write(0x1A);
answer = sendATcommand("", "OK", 20000);
if (answer == 1)
{
//Serial.println("Sent.");
ret_val = 1;
}
else
{
//Serial.println("Not Sent.");
ret_val = 0;
}
}
else
{
//Serial.print("error ");
//Serial.println(answer, DEC);
ret_val = 0;
}
return ret_val;
}
int8_t sendATcommand(char* ATcommand, char* expected_answer, unsigned int timeout){
uint8_t x=0, answer=0;
char response[100];
unsigned long previous;
memset(response, '\0', 100); // Initialize the string with null
delay(100);
while( SIMSerial.available() > 0) SIMSerial.read(); // Clean the input buffer
SIMSerial.println(ATcommand); // Send the AT command
x = 0;
previous = millis();
// this loop waits for the answer
do{
// if there are data in the UART input buffer, reads it and checks for the asnwer
if(SIMSerial.available() != 0){
response[x] = SIMSerial.read();
x++;
// check if the desired answer is in the response of the module
if (strstr(response, expected_answer) != NULL)
{
answer = 1;
}
}
// Waits for the asnwer with time out
}while((answer == 0) && ((millis() - previous) < timeout));
return answer;
}
void loop()
{
if (EEPROM.read(ADDRMOTION)){
if(!digitalRead(pirConnected)){ // 0 = PIR Connected // 1 = PIR Not Connected
motionsence();
}
}
//Serial.println("loop");
TacSwitch();
//currentAmps = sensordata();
Exfunc();
if (digitalRead(RSTTRIGGER)){
HWflush("RST ","");
}
if (round_robin == true){
String uid = "SWT_";
int return_val;
if (EEPROM.read(ADDR) == 1){
//int return_val = sms.SendSMS(ack,"ACK ON_SWT_0.00");
return_val = send_sms("ACK ON_", uid, "0.00");
if (return_val == 1){
led_green();
round_robin = false;
}
else{
led_red();
round_robin = true;
}
}
else if (EEPROM.read(ADDR) == 0){
//return_val = sms.SendSMS(ack,"ACK OFF_SWT_0.00");
return_val = send_sms("ACK OFF_", uid, "0.00");
if (return_val == 1){
led_off();
round_robin = false;
}
else{
led_red();
round_robin = true;
}
}
}
//sensordata();
if (loop_count >= 213) // 213*looptime(283) = Scan every min
{
network_status();
}
loop_count++;
}