SMS Scheduler that will automatically send and receive text messages using the Enfora 1308 GSM Modem. Please note that it uses a modified NetServices library and to set the baud rate for the GSM Modem to 19.2K.

Dependencies:   mbed

Committer:
mafischl
Date:
Thu Oct 13 17:02:29 2011 +0000
Revision:
0:d9266031f832
Child:
1:5a7cce9994a3

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mafischl 0:d9266031f832 1 //Contest Winner using GSM Modem
mafischl 0:d9266031f832 2
mafischl 0:d9266031f832 3 #include "mbed.h"
mafischl 0:d9266031f832 4 #include "NetServices/if/eth/EthernetNetIf.h"
mafischl 0:d9266031f832 5 #include "NetServices/core/ipaddr.h"
mafischl 0:d9266031f832 6 #include "NetServices/services/http/server/HTTPServer.h"
mafischl 0:d9266031f832 7 #include "NetServices/services/ntp/NTPClient.h"
mafischl 0:d9266031f832 8 #include "TextLCD.h"
mafischl 0:d9266031f832 9 #include "MODSERIAL.h"
mafischl 0:d9266031f832 10 #include <math.h>
mafischl 0:d9266031f832 11 #include <iostream>
mafischl 0:d9266031f832 12 #include <string>
mafischl 0:d9266031f832 13 #define MESSAGE_BUFFER_SIZE 1024
mafischl 0:d9266031f832 14 using namespace std;
mafischl 0:d9266031f832 15
mafischl 0:d9266031f832 16 MODSERIAL gsm(p28,p27);
mafischl 0:d9266031f832 17 //Serial gsm(p28, p27);
mafischl 0:d9266031f832 18 EthernetNetIf eth;
mafischl 0:d9266031f832 19 HTTPServer svr;
mafischl 0:d9266031f832 20 NTPClient ntp;
mafischl 0:d9266031f832 21 Serial pc(USBTX, USBRX); // PC Virtual Serial Port over USB
mafischl 0:d9266031f832 22 TextLCD lcd(p15, p16, p17, p11, p12, p20); // rs, e, d4-d7
mafischl 0:d9266031f832 23 DigitalOut heartBeat(LED1); //Heartbeat
mafischl 0:d9266031f832 24 DigitalOut led2(LED2); //Test for message process
mafischl 0:d9266031f832 25 DigitalOut wdtLED(LED4); //WatchDog Indicator
mafischl 0:d9266031f832 26 Timer t, timeOrDateTimer, clockSyncTimer, statusMessageInterruptTimer, send_SMS_Timer, GSM_Buffer_Timer;
mafischl 0:d9266031f832 27 int SMSinterval = 15; //ceil(3600/SMSperHour);
mafischl 0:d9266031f832 28 int SMScount = 0;
mafischl 0:d9266031f832 29 int TIMEZONE = 4;
mafischl 0:d9266031f832 30 int timeCount;
mafischl 0:d9266031f832 31 int statusMessage = 0;
mafischl 0:d9266031f832 32 int compareResult = 0;
mafischl 0:d9266031f832 33 int messageResponse = 0;
mafischl 0:d9266031f832 34 int mpResult = 0;
mafischl 0:d9266031f832 35 bool timeOrDate = 0;
mafischl 0:d9266031f832 36 bool statusMessageAlert = 0;
mafischl 0:d9266031f832 37 bool statusMessageInterrupt = 0;
mafischl 0:d9266031f832 38 char messageBufferIncoming[MESSAGE_BUFFER_SIZE];
mafischl 0:d9266031f832 39 char messageBufferOutgoing[MESSAGE_BUFFER_SIZE];
mafischl 0:d9266031f832 40 bool messageReceived;
mafischl 0:d9266031f832 41 LocalFileSystem local("local");
mafischl 0:d9266031f832 42
mafischl 0:d9266031f832 43
mafischl 0:d9266031f832 44 char buf[40];
mafischl 0:d9266031f832 45 char buf1[40];
mafischl 0:d9266031f832 46 char buf2= 0x1A; //CTRL+Z, Substitute character
mafischl 0:d9266031f832 47
mafischl 0:d9266031f832 48 extern "C" void mbed_mac_address(char *mac);
mafischl 0:d9266031f832 49
mafischl 0:d9266031f832 50 class Watchdog {
mafischl 0:d9266031f832 51 public:
mafischl 0:d9266031f832 52 // Load timeout value in watchdog timer and enable
mafischl 0:d9266031f832 53 void kick(float s) {
mafischl 0:d9266031f832 54 LPC_WDT->WDCLKSEL = 0x1; // Set CLK src to PCLK
mafischl 0:d9266031f832 55 uint32_t clk = SystemCoreClock / 16; // WD has a fixed /4 prescaler, PCLK default is /4
mafischl 0:d9266031f832 56 LPC_WDT->WDTC = s * (float)clk;
mafischl 0:d9266031f832 57 LPC_WDT->WDMOD = 0x3; // Enabled and Reset
mafischl 0:d9266031f832 58 kick();
mafischl 0:d9266031f832 59 }
mafischl 0:d9266031f832 60 // "kick" or "feed" the dog - reset the watchdog timer
mafischl 0:d9266031f832 61 // by writing this required bit pattern
mafischl 0:d9266031f832 62 void kick() {
mafischl 0:d9266031f832 63 LPC_WDT->WDFEED = 0xAA;
mafischl 0:d9266031f832 64 LPC_WDT->WDFEED = 0x55;
mafischl 0:d9266031f832 65 }
mafischl 0:d9266031f832 66 };
mafischl 0:d9266031f832 67
mafischl 0:d9266031f832 68 Watchdog wdt;
mafischl 0:d9266031f832 69
mafischl 0:d9266031f832 70
mafischl 0:d9266031f832 71 void messageReceive(MODSERIAL_IRQ_INFO *q) {
mafischl 0:d9266031f832 72 MODSERIAL *sys = q->serial;
mafischl 0:d9266031f832 73 sys->move(messageBufferIncoming, MESSAGE_BUFFER_SIZE);
mafischl 0:d9266031f832 74 messageReceived = true;
mafischl 0:d9266031f832 75 return;
mafischl 0:d9266031f832 76 }
mafischl 0:d9266031f832 77
mafischl 0:d9266031f832 78 int messageProcess(void) {
mafischl 0:d9266031f832 79 if (!strncmp(messageBufferIncoming, "OK", sizeof("OK")-1)) mpResult = 1;
mafischl 0:d9266031f832 80 else if (!strncmp(messageBufferIncoming, "ERROR", sizeof("ERROR")-1)) mpResult = 2;
mafischl 0:d9266031f832 81 // else if (!strncmp(messageBufferIncoming, "LED1:2", sizeof("LED1:2")-1)) led1 = !led1;
mafischl 0:d9266031f832 82
mafischl 0:d9266031f832 83 // if (!strncmp(messageBufferIncoming, "LED2:1", sizeof("LED2:1")-1)) led2 = 1;
mafischl 0:d9266031f832 84 // else if (!strncmp(messageBufferIncoming, "LED2:0", sizeof("LED2:0")-1)) led2 = 0;
mafischl 0:d9266031f832 85 // else if (!strncmp(messageBufferIncoming, "LED2:2", sizeof("LED2:2")-1)) led2 = !led2;
mafischl 0:d9266031f832 86
mafischl 0:d9266031f832 87 // else if (!strncmp(messageBufferIncoming, "LED3:1", sizeof("LED3:1")-1)) led3 = 1;
mafischl 0:d9266031f832 88 // else if (!strncmp(messageBufferIncoming, "LED3:0", sizeof("LED3:0")-1)) led3 = 0;
mafischl 0:d9266031f832 89 // else if (!strncmp(messageBufferIncoming, "LED3:2", sizeof("LED3:2")-1)) led3 = !led3;
mafischl 0:d9266031f832 90
mafischl 0:d9266031f832 91 // else if (!strncmp(messageBufferIncoming, "LED4:1", sizeof("LED4:1")-1)) led4 = 1;
mafischl 0:d9266031f832 92 // else if (!strncmp(messageBufferIncoming, "LED4:0", sizeof("LED4:0")-1)) led4 = 0;
mafischl 0:d9266031f832 93 // else if (!strncmp(messageBufferIncoming, "LED4:2", sizeof("LED4:2")-1)) led4 = !led4;
mafischl 0:d9266031f832 94 else mpResult = 1;
mafischl 0:d9266031f832 95 pc.printf("%s\r\n", messageBufferIncoming);
mafischl 0:d9266031f832 96 gsm.rxBufferFlush(); //Flush the Buffer
mafischl 0:d9266031f832 97 messageReceived = false;
mafischl 0:d9266031f832 98 return mpResult;
mafischl 0:d9266031f832 99 }
mafischl 0:d9266031f832 100
mafischl 0:d9266031f832 101 void sync_time(){
mafischl 0:d9266031f832 102 //Connect to NIST and get time
mafischl 0:d9266031f832 103 time_t ctTime;
mafischl 0:d9266031f832 104 ctTime = time(NULL);
mafischl 0:d9266031f832 105
mafischl 0:d9266031f832 106 Host server(IpAddr(), 123, "nist1-atl.ustiming.org");
mafischl 0:d9266031f832 107 ntp.setTime(server);
mafischl 0:d9266031f832 108
mafischl 0:d9266031f832 109 ctTime = time(NULL);
mafischl 0:d9266031f832 110 }
mafischl 0:d9266031f832 111
mafischl 0:d9266031f832 112 void send_SMS(){
mafischl 0:d9266031f832 113 //Send SMS Vote
mafischl 0:d9266031f832 114
mafischl 0:d9266031f832 115 gsm.printf("AT+CMGS=\"78527\"\r\n");
mafischl 0:d9266031f832 116
mafischl 0:d9266031f832 117 gsm.printf("Buzz%c\r\n",buf2);
mafischl 0:d9266031f832 118 if(messageProcess()){
mafischl 0:d9266031f832 119 statusMessageAlert = 1;
mafischl 0:d9266031f832 120 statusMessage = 5;
mafischl 0:d9266031f832 121 SMScount = SMScount + 1;
mafischl 0:d9266031f832 122 pc.printf("SMS sent: %d\r\n", SMScount);
mafischl 0:d9266031f832 123 }
mafischl 0:d9266031f832 124 else{
mafischl 0:d9266031f832 125 statusMessageAlert = 1;
mafischl 0:d9266031f832 126 statusMessage = 7; //This value will also force a auto re-send
mafischl 0:d9266031f832 127 pc.printf("SMS send failed\r\n");
mafischl 0:d9266031f832 128 }
mafischl 0:d9266031f832 129 }
mafischl 0:d9266031f832 130
mafischl 0:d9266031f832 131 int main() {
mafischl 0:d9266031f832 132 messageReceived = false;
mafischl 0:d9266031f832 133
mafischl 0:d9266031f832 134 if ((LPC_WDT->WDMOD >> 2) & 1)
mafischl 0:d9266031f832 135 wdtLED = 1; else wdtLED = 0;
mafischl 0:d9266031f832 136
mafischl 0:d9266031f832 137 // 30 second timeout on watchdog timer hardware
mafischl 0:d9266031f832 138 wdt.kick(30.0);
mafischl 0:d9266031f832 139
mafischl 0:d9266031f832 140 gsm.baud(19200);
mafischl 0:d9266031f832 141 gsm.format(8, Serial::None, 1);
mafischl 0:d9266031f832 142 gsm.attach(&messageReceive, MODSERIAL::RxAutoDetect); //Attaches Interrupts
mafischl 0:d9266031f832 143 gsm.autoDetectChar('\n'); //Set Detection to Line Feed
mafischl 0:d9266031f832 144 pc.baud(19200);
mafischl 0:d9266031f832 145
mafischl 0:d9266031f832 146 lcd.cls();
mafischl 0:d9266031f832 147 lcd.locate(0,0);
mafischl 0:d9266031f832 148 lcd.printf("----------------");
mafischl 0:d9266031f832 149 lcd.locate(0,1);
mafischl 0:d9266031f832 150 lcd.printf("----------------");
mafischl 0:d9266031f832 151 lcd.cls();
mafischl 0:d9266031f832 152 lcd.locate(0,0);
mafischl 0:d9266031f832 153 lcd.printf(" Contest Winner");
mafischl 0:d9266031f832 154 lcd.locate(0,1);
mafischl 0:d9266031f832 155 lcd.printf(" Please Wait");
mafischl 0:d9266031f832 156 wait(2);
mafischl 0:d9266031f832 157 lcd.cls();
mafischl 0:d9266031f832 158 lcd.locate(0,0);
mafischl 0:d9266031f832 159 lcd.printf("Setting up...\n");
mafischl 0:d9266031f832 160 pc.printf("Program Started, setting up Ethernet Connection...\r\n");
mafischl 0:d9266031f832 161 EthernetErr ethErr = eth.setup();
mafischl 0:d9266031f832 162 if(ethErr)
mafischl 0:d9266031f832 163 {
mafischl 0:d9266031f832 164 lcd.printf("Error %d in setup.\n", ethErr);
mafischl 0:d9266031f832 165 pc.printf("Error %d in setup.\r\n", ethErr);
mafischl 0:d9266031f832 166 return -1;
mafischl 0:d9266031f832 167 }
mafischl 0:d9266031f832 168 wdt.kick();
mafischl 0:d9266031f832 169
mafischl 0:d9266031f832 170 // Set-UP GSM Modem
mafischl 0:d9266031f832 171
mafischl 0:d9266031f832 172 pc.printf("Setting up GSM Modem\r\n");
mafischl 0:d9266031f832 173 lcd.locate(0,0);
mafischl 0:d9266031f832 174 lcd.printf("GSM Modem Setup");
mafischl 0:d9266031f832 175 wait(1);
mafischl 0:d9266031f832 176
mafischl 0:d9266031f832 177 gsm.printf("AT\r\n"); //Check Connection
mafischl 0:d9266031f832 178 wait(0.5);
mafischl 0:d9266031f832 179 messageProcess(); //Process incoming message
mafischl 0:d9266031f832 180
mafischl 0:d9266031f832 181 gsm.printf("AT+CSMP=17,167,0,0\r\n"); //Set Text Parameters
mafischl 0:d9266031f832 182 wait(0.5);
mafischl 0:d9266031f832 183 messageProcess(); //Process incoming message
mafischl 0:d9266031f832 184
mafischl 0:d9266031f832 185 gsm.printf("AT+CSCA?\r\n"); //Check Service Center
mafischl 0:d9266031f832 186 wait(0.5);
mafischl 0:d9266031f832 187 messageProcess(); //Process incoming message
mafischl 0:d9266031f832 188
mafischl 0:d9266031f832 189 gsm.printf("AT+CMGF=1\r\n"); //Set format to Text Mode
mafischl 0:d9266031f832 190 wait(0.5);
mafischl 0:d9266031f832 191 messageProcess(); //Process incoming message
mafischl 0:d9266031f832 192
mafischl 0:d9266031f832 193 gsm.printf("AT+CNMI=1,1,0,0,0\r\n"); //Set the new messages indicator
mafischl 0:d9266031f832 194 wait(0.5);
mafischl 0:d9266031f832 195 messageProcess(); //Process incoming message
mafischl 0:d9266031f832 196
mafischl 0:d9266031f832 197 gsm.printf("AT+CSAS\r\n"); //Save the Current Setup, REGLED will light SOLID
mafischl 0:d9266031f832 198 wait(3.0);
mafischl 0:d9266031f832 199 messageProcess(); //Process incoming message
mafischl 0:d9266031f832 200
mafischl 0:d9266031f832 201 lcd.locate(0,0);
mafischl 0:d9266031f832 202 lcd.printf("Setup OK ");
mafischl 0:d9266031f832 203 pc.printf("Setup Done\r\n");
mafischl 0:d9266031f832 204 wait(1);
mafischl 0:d9266031f832 205 wdt.kick();
mafischl 0:d9266031f832 206
mafischl 0:d9266031f832 207 //Define RPC Controls
mafischl 0:d9266031f832 208 //Base::add_rpc_class<DigitalOut>(p21);
mafischl 0:d9266031f832 209
mafischl 0:d9266031f832 210
mafischl 0:d9266031f832 211 //Add RPC Handler
mafischl 0:d9266031f832 212 svr.addHandler<SimpleHandler>("/");
mafischl 0:d9266031f832 213 svr.addHandler<RPCHandler>("/rpc"); //Default handler
mafischl 0:d9266031f832 214 pc.printf("Handlers installed\r\n");
mafischl 0:d9266031f832 215 svr.bind(80);
mafischl 0:d9266031f832 216
mafischl 0:d9266031f832 217 lcd.locate(0,0);
mafischl 0:d9266031f832 218 lcd.printf("Listening...");
mafischl 0:d9266031f832 219 pc.printf("Connection is live, listening on port 80\r\n");
mafischl 0:d9266031f832 220
mafischl 0:d9266031f832 221 wdt.kick();
mafischl 0:d9266031f832 222 //Connect to NIST and get time
mafischl 0:d9266031f832 223 time_t ctTime;
mafischl 0:d9266031f832 224 sync_time(); //sync time for the first time
mafischl 0:d9266031f832 225
mafischl 0:d9266031f832 226
mafischl 0:d9266031f832 227 statusMessageAlert = 1;
mafischl 0:d9266031f832 228 statusMessage = 1;
mafischl 0:d9266031f832 229
mafischl 0:d9266031f832 230
mafischl 0:d9266031f832 231 pc.printf("Time was synced to NIST\r\n");
mafischl 0:d9266031f832 232 wdt.kick();
mafischl 0:d9266031f832 233
mafischl 0:d9266031f832 234 timeOrDateTimer.start();
mafischl 0:d9266031f832 235 clockSyncTimer.start();
mafischl 0:d9266031f832 236 Timer tm;
mafischl 0:d9266031f832 237 t.start();
mafischl 0:d9266031f832 238 tm.start();
mafischl 0:d9266031f832 239 send_SMS_Timer.start();
mafischl 0:d9266031f832 240 GSM_Buffer_Timer.start();
mafischl 0:d9266031f832 241
mafischl 0:d9266031f832 242 while(true)
mafischl 0:d9266031f832 243 {
mafischl 0:d9266031f832 244 ctTime = time(NULL) - (TIMEZONE*60*60); //Update clock and adjust for timezone
mafischl 0:d9266031f832 245 char buffer[32];
mafischl 0:d9266031f832 246
mafischl 0:d9266031f832 247 if(statusMessageAlert){
mafischl 0:d9266031f832 248 statusMessageInterruptTimer.start();
mafischl 0:d9266031f832 249 statusMessageAlert = 0;
mafischl 0:d9266031f832 250 statusMessageInterrupt = 1;
mafischl 0:d9266031f832 251 }
mafischl 0:d9266031f832 252
mafischl 0:d9266031f832 253 if(statusMessageInterrupt){ //Status Messages to be displayed where Date/Time
mafischl 0:d9266031f832 254 lcd.locate(0,0);
mafischl 0:d9266031f832 255 if(statusMessage==0){
mafischl 0:d9266031f832 256 lcd.printf("System is OK ");
mafischl 0:d9266031f832 257 }
mafischl 0:d9266031f832 258 else if(statusMessage==1){
mafischl 0:d9266031f832 259 lcd.printf("Clock Sync..DONE");
mafischl 0:d9266031f832 260 }
mafischl 0:d9266031f832 261 else if(statusMessage==2){
mafischl 0:d9266031f832 262 lcd.printf("Clock Sync..FAIL");
mafischl 0:d9266031f832 263 }
mafischl 0:d9266031f832 264 else if(statusMessage==3){
mafischl 0:d9266031f832 265 lcd.printf("GSM Modem OK ");
mafischl 0:d9266031f832 266 }
mafischl 0:d9266031f832 267 else if(statusMessage==4){
mafischl 0:d9266031f832 268 lcd.printf("GSM Modem Error ");
mafischl 0:d9266031f832 269 }
mafischl 0:d9266031f832 270 else if(statusMessage==5){
mafischl 0:d9266031f832 271 lcd.printf("Message Sent ");
mafischl 0:d9266031f832 272 }
mafischl 0:d9266031f832 273 else if(statusMessage==6){
mafischl 0:d9266031f832 274 lcd.printf("Message Received");
mafischl 0:d9266031f832 275 }
mafischl 0:d9266031f832 276 else if(statusMessage==7){ //SMS Send Failed, force auto re-send
mafischl 0:d9266031f832 277 lcd.printf("Msg Send Error ");
mafischl 0:d9266031f832 278 }
mafischl 0:d9266031f832 279 else if(statusMessage==8){
mafischl 0:d9266031f832 280 lcd.printf("Msg Recv Error ");
mafischl 0:d9266031f832 281 }
mafischl 0:d9266031f832 282 }
mafischl 0:d9266031f832 283
mafischl 0:d9266031f832 284 else{
mafischl 0:d9266031f832 285 if(timeOrDate){
mafischl 0:d9266031f832 286 strftime(buffer, 32, "%X", localtime(&ctTime));
mafischl 0:d9266031f832 287 lcd.locate(0,0);
mafischl 0:d9266031f832 288 lcd.printf("%s (-%d:00)", buffer, TIMEZONE);
mafischl 0:d9266031f832 289 }
mafischl 0:d9266031f832 290 else{
mafischl 0:d9266031f832 291 strftime(buffer, 32, "%a %b %d, %Y", localtime(&ctTime));
mafischl 0:d9266031f832 292 lcd.locate(0,0);
mafischl 0:d9266031f832 293 lcd.printf("%s", buffer);
mafischl 0:d9266031f832 294 }
mafischl 0:d9266031f832 295 }
mafischl 0:d9266031f832 296
mafischl 0:d9266031f832 297 Net::poll();
mafischl 0:d9266031f832 298 timeCount = t.read();
mafischl 0:d9266031f832 299
mafischl 0:d9266031f832 300 //Timers
mafischl 0:d9266031f832 301
mafischl 0:d9266031f832 302 if(timeCount > 0){
mafischl 0:d9266031f832 303 heartBeat = !heartBeat;
mafischl 0:d9266031f832 304 t.stop();
mafischl 0:d9266031f832 305 t.reset();
mafischl 0:d9266031f832 306 t.start();
mafischl 0:d9266031f832 307 }
mafischl 0:d9266031f832 308
mafischl 0:d9266031f832 309 if(timeOrDateTimer > 3){
mafischl 0:d9266031f832 310 timeOrDate = !timeOrDate;
mafischl 0:d9266031f832 311 timeOrDateTimer.stop();
mafischl 0:d9266031f832 312 timeOrDateTimer.reset();
mafischl 0:d9266031f832 313 timeOrDateTimer.start();
mafischl 0:d9266031f832 314 }
mafischl 0:d9266031f832 315
mafischl 0:d9266031f832 316 if(send_SMS_Timer > SMSinterval){
mafischl 0:d9266031f832 317 statusMessage = 0;
mafischl 0:d9266031f832 318 send_SMS();
mafischl 0:d9266031f832 319 send_SMS_Timer.stop();
mafischl 0:d9266031f832 320 send_SMS_Timer.reset();
mafischl 0:d9266031f832 321 send_SMS_Timer.start();
mafischl 0:d9266031f832 322 }
mafischl 0:d9266031f832 323
mafischl 0:d9266031f832 324 if(clockSyncTimer > 3600){ //Re-Sync every hour
mafischl 0:d9266031f832 325 sync_time();
mafischl 0:d9266031f832 326 pc.printf("Time was synced to NIST\r\n");
mafischl 0:d9266031f832 327 clockSyncTimer.stop();
mafischl 0:d9266031f832 328 clockSyncTimer.reset();
mafischl 0:d9266031f832 329 clockSyncTimer.start();
mafischl 0:d9266031f832 330 statusMessageAlert = 1;
mafischl 0:d9266031f832 331 statusMessage = 1;
mafischl 0:d9266031f832 332 }
mafischl 0:d9266031f832 333
mafischl 0:d9266031f832 334 if(GSM_Buffer_Timer > (25*SMSinterval)){
mafischl 0:d9266031f832 335 gsm.printf("AT+CMGD= 1, 1\r\n"); //Clears out entire buffer
mafischl 0:d9266031f832 336 pc.printf("GSM Buffer Cleared\r\n");
mafischl 0:d9266031f832 337 GSM_Buffer_Timer.stop();
mafischl 0:d9266031f832 338 GSM_Buffer_Timer.reset();
mafischl 0:d9266031f832 339 }
mafischl 0:d9266031f832 340
mafischl 0:d9266031f832 341 if(statusMessageInterruptTimer > 2){
mafischl 0:d9266031f832 342 statusMessageInterrupt = 0;
mafischl 0:d9266031f832 343 statusMessageInterruptTimer.stop();
mafischl 0:d9266031f832 344 statusMessageInterruptTimer.reset();
mafischl 0:d9266031f832 345 }
mafischl 0:d9266031f832 346
mafischl 0:d9266031f832 347 if (messageReceived) { //Handle received messages
mafischl 0:d9266031f832 348 messageProcess();
mafischl 0:d9266031f832 349 statusMessageAlert = 1;
mafischl 0:d9266031f832 350 statusMessage = 6;
mafischl 0:d9266031f832 351 }
mafischl 0:d9266031f832 352
mafischl 0:d9266031f832 353 wdt.kick();
mafischl 0:d9266031f832 354 }
mafischl 0:d9266031f832 355
mafischl 0:d9266031f832 356 return 0;
mafischl 0:d9266031f832 357 }