{"action":"created","issue":{"url":"https://api.github.com/repos/esp8266/Arduino/issues/2542","repository_url":"https://api.github.com/repos/esp8266/Arduino","labels_url":"https://api.github.com/repos/esp8266/Arduino/issues/2542/labels{/name}","comments_url":"https://api.github.com/repos/esp8266/Arduino/issues/2542/comments","events_url":"https://api.github.com/repos/esp8266/Arduino/issues/2542/events","html_url":"https://github.com/esp8266/Arduino/issues/2542","id":178562532,"number":2542,"title":"ESP-12E Node MCU will resets automatically at every time","user":{"login":"BharathTatikonda","id":21261379,"avatar_url":"https://avatars.githubusercontent.com/u/21261379?v=3","gravatar_id":"","url":"https://api.github.com/users/BharathTatikonda","html_url":"https://github.com/BharathTatikonda","followers_url":"https://api.github.com/users/BharathTatikonda/followers","following_url":"https://api.github.com/users/BharathTatikonda/following{/other_user}","gists_url":"https://api.github.com/users/BharathTatikonda/gists{/gist_id}","starred_url":"https://api.github.com/users/BharathTatikonda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BharathTatikonda/subscriptions","organizations_url":"https://api.github.com/users/BharathTatikonda/orgs","repos_url":"https://api.github.com/users/BharathTatikonda/repos","events_url":"https://api.github.com/users/BharathTatikonda/events{/privacy}","received_events_url":"https://api.github.com/users/BharathTatikonda/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-09-22T09:33:05Z","updated_at":"2016-09-22T10:19:17Z","closed_at":null,"body":"### Basic Infos\r\n\r\n#### Hardware\r\nHardware:\t\t\t?ESP-12?\r\nCore Version:      \t?2.1.0-rc2?\r\nhi, i have started ESP12-E to work with the GSM module, in this when i was running the it should be reset automatically when some messages will receives,... then it reset and restarted from first so the function is not completed,,....so, please suggest me how to disable the watchdog timer,..... when i run the program the error will be like this///.........\r\n\r\n\r\n\r\nSoft WDT reset\r\n\r\nctx: cont \r\nsp: 3ffefc90 end: 3ffeff00 offset: 01b0\r\n\r\n\r\n>>>stack>>>\r\n3ffefe50:  00000001 00000001 00000000 402030ea  \r\n3ffefe60:  00000106 00000000 000005dc 00001388  \r\n3ffefe70:  00000005 3ffe87c0 00000004 40202fe8  \r\n3ffefe80:  3ffe8517 3ffeed24 3ffeee1c 00000000  \r\n3ffefe90:  00000005 000005dc 3ffe8ba2 4020313e  \r\n3ffefea0:  4010564a feefeffe 3ffeee1c 3ffeeed0  \r\n3ffefeb0:  3fffdad0 3ffe8ba2 00000000 40202b77  \r\n3ffefec0:  3fffdad0 3ffeebe0 3ffeee1c 40201fd4  \r\n3ffefed0:  feefeffe 00000000 3ffeeec8 4020213d  \r\n3ffefee0:  feefeffe feefeffe feefeffe 4020388c  \r\n3ffefef0:  feefeffe feefeffe 3ffeeee0 40100718  \r\n<<<stack<<<\r\n\r\n   so, please suggest me how to disable the watchdog timer in the esp12-e module\r\n\r\n### Settings in IDE\r\n\r\nModule:  \t\t\t?Generic ESP8266 Module?\r\nFlash Size: \t\t?4MB/1MB?\r\nCPU Frequency:\t\t?80Mhz?\r\nFlash Mode:\t\t\t?qio?\r\nFlash Frequency:\t?40Mhz?\r\nUpload Using:\t\t?OTA / SERIAL?\r\nReset Method:\t\t?ck / nodemcu?\r\n\r\n\r\n### Sketch\r\n\r\n```cpp\r\n\r\n\r\n#include <SoftwareSerial.h>\r\n#include <Wire.h>\r\n#include <EEPROM.h>\r\n#include <string.h>\r\n#include<Esp.h>\r\n//#include \"SoftReset.h\"\r\n// Add SIM900 library here\r\n#include \"GSM_Shield_Esp.h\"\r\n\r\n\r\n// SIM900 GSM module settings\r\n//#define PIN_TX    7\r\n//#define PIN_RX      8\r\n#define RELAY 4\r\n#define BAUDRATE 9600\r\n#define MESSAGE_LENGTH 30\r\nconst int interruptPin = 14;\r\nvolatile byte state = 0;\r\n\r\n\r\n// For debugging interface\r\n#define DEBUG 1\r\n#define DELAY_TIME 1000\r\n\r\n#define PB_ENTRY_INDEX_LOCATION 1\r\n#define SMS_REPLY_LOCATION 2\r\n#define CALL_REPLY_LOCATION 3\r\n\r\n\r\n// Global Varables\r\nchar PRIMARY[16];\r\nint CallReplyFlag = true;\r\nint smsReplyFlag=false;\r\nint rebootFlag = false;\r\nchar *password = \"ABCDEF\";  // Default password\r\nbyte messageIndex = 0;\r\nchar gsmBuffer[64];\r\nchar *s = NULL;\r\nchar num[4];\r\nunsigned int PBEntryIndex = 1;\r\n// Create an instance of GPRS library\r\nGPRS gsm(13, 15, 9600);\r\n\r\n// Main function starts here\r\n\r\nvoid setup() {\r\n\r\n // wdt_disable();\r\n  // Initialize the hardware\r\n  InitHardware();\r\n  \r\n  // Setup SIM Card\r\n  SIMCardSetup();\r\n  // wdt_disable();\r\n  \r\n  // Setup SMS Service\r\n  SMSServiceSetup();  \r\n   pinMode(interruptPin,INPUT);\r\n  pinMode(RELAY,OUTPUT);\r\n  //pinMode(interruptPin, INPUT_PULLUP);\r\n  attachInterrupt(digitalPinToInterrupt(interruptPin), Alarm, FALLING);\r\n  Serial.println(\"Listening for SMS \");\r\n // wdt_enable(5000);\r\n}\r\n\r\nvoid loop() {\r\n  // Serial.println(\"Listening for SMS \");\r\n  // Wait for SMS\r\n  if(gsm.readable()) {\r\n    // Print the buffer\r\n    sim900_read_buffer(gsmBuffer,sizeof(gsmBuffer),DEFAULT_TIMEOUT);\r\n    Serial.println(gsmBuffer);\r\n    \r\n    // If incoming is SMS\r\n    // +CMTI: \"SM\", 2\r\n    messageIndex = gsm.isSMSunread();\r\n    if(messageIndex > 0) {\r\n     // wdt_disable();\r\n      Serial.println(\"handling SMS\");\r\n      handleSMS(messageIndex);\r\n      //wdt_enable(5000);\r\n      messageIndex = 0;\r\n    }\r\n    sim900_clean_buffer(gsmBuffer,sizeof(gsmBuffer));\r\n  }\r\n\r\n\r\n     if(digitalRead(interruptPin) == HIGH){\r\n       \r\n         \r\n\r\n         // void Bharath() {\r\n  // check this mobile number with the saved numbers and return the index if found\r\n  // Searching for the mobile number\r\n  char *s, *p;\r\n  char index[4];\r\n  byte i = 0;\r\n  // AT+CPBF=\"mobileNumber\"\r\n  //sim900_check_with_cmd(\"AT+CPBS=\\\"ME\\\"\\r\\n\",\"OK\\r\\n\",CMD);\r\n  sim900_send_cmd(\"AT+CPBR=\");\r\n  itoa(PBEntryIndex, num, 10);\r\n  sim900_send_cmd(num);\r\n  sim900_send_cmd(\"\\r\\n\");\r\n  sim900_clean_buffer(gsmBuffer, sizeof(gsmBuffer));\r\n  sim900_read_buffer(gsmBuffer, sizeof(gsmBuffer));\r\n  \r\n  // +CPBF: 1,\"+91XXXXXXXXXX\",145,\"TT+91XXXXXXXXXX\"\r\n  // If number is present\r\n  if(NULL != ( s = strstr(gsmBuffer, \"+CPBR:\"))) {\r\n    s = s + 10;\r\n    p = strstr((char *)(s), \"\\\"\"); //point to first ,\r\n    if(NULL != s) {\r\n      i = 0;\r\n      while (s< p) {\r\n        PRIMARY[i++] = *(s++);\r\n      }\r\n      PRIMARY[i] = '\\0';\r\n    } \r\n  }\r\n\r\n      if(CallReplyFlag){\r\n        Serial.println(\"calling\"); \r\n        Serial.println(PRIMARY);\r\n        //delay(1000);\r\n        gsm.callUp(PRIMARY);\r\n        delay(12000);\r\n        gsm.hangup();\r\n        delay(1000);\r\n      }else if(smsReplyFlag){\r\n        delay(1000);\r\n        Serial.println(\"SMS\");\r\n      //  gsm.sendSMS(PRIMARY,\"someone is coming\");\r\n        \r\n      }\r\n      }\r\n  else\r\n    delay(100);\r\n  \r\n  if (rebootFlag) {\r\n    Serial.println(\"Rebooting device\");\r\n    delay(10 * DELAY_TIME);\r\n  //  soft_restart();\r\n  }\r\n}\r\nvoid InitHardware(void) {\r\n  // Start Serial editor\r\n  Serial.begin(BAUDRATE);\r\n  Serial.println(\"initialising Hardware\");\r\n  //while(!Serial);\r\n\r\n   EEPROM.begin(512);\r\n  \r\n if (EEPROM.read(500) != 175) {\r\n    //if not load default config files to EEPROM\r\n    writeInitalConfig();\r\n  }\r\n  // Read the config settings from EEPROM\r\n  readConfig();\r\n  \r\n\r\n  // POWER ON the GSM module\r\n  while(!gsm.init()) {\r\n    Serial.println(\"Initialisation error\");\r\n    delay(2000);\r\n   // soft_restart();\r\n  }\r\n  \r\n  // Set the communication settings for SIM900\r\n  // Sent ATE0\r\n  sim900_check_with_cmd(\"ATE0\\r\\n\",\"OK\\r\\n\",CMD);\r\n  delay(DELAY_TIME);\r\n}\r\n\r\nvoid writeInitalConfig(void) {\r\n  Serial.println(\"Writing default configuration\");\r\n  EEPROM.write(500, 175);\r\n  EEPROM.write(PB_ENTRY_INDEX_LOCATION, 1); // Set default PBEntryIndex = 1\r\n  EEPROM.write(SMS_REPLY_LOCATION, 0); // SMS Reply disabled\r\n  EEPROM.write(CALL_REPLY_LOCATION, 1); // Call Reply Enabled\r\n  EEPROM.commit();\r\n}\r\n\r\nvoid readConfig(void) {\r\n  Serial.println(\"Reading config\");\r\n  PBEntryIndex = EEPROM.read(PB_ENTRY_INDEX_LOCATION);\r\n  smsReplyFlag = (EEPROM.read(SMS_REPLY_LOCATION) != 0)? true : false;\r\n  CallReplyFlag = (EEPROM.read(CALL_REPLY_LOCATION) != 0)? true : false;\r\n}\r\n\r\nvoid SIMCardSetup(void) {\r\n    \r\n  // check IMEI of device\r\n  char imei[16];\r\n  // Send AT+GSN\r\n  gsm.getIMEI(imei);\r\n  Serial.print(\"Received IMEI \");\r\n  Serial.println(imei);\r\n  \r\n  // Generate Secret PASSWORD from IMEI\r\n#ifdef DEBUG\r\n  Serial.println(\"Generating password\");\r\n#endif\r\n  GeneratePassword(imei);\r\n\r\n/* int rssi, ber;\r\n  // sent AT+CSQ\r\n  \r\n // Check for signal strength\r\n  gsm.getSignalStrength(&rssi);\r\n#ifdef DEBUG\r\n  Serial.print(\"Signal Strength is \");\r\n  Serial.println(rssi);\r\n#endif\r\n  // Check for SIM registration\r\n  // Send AT+CREG?\r\n  int networkType;\r\n  gsm.getSIMRegistration(&networkType);\r\n#ifdef DEBUG  \r\n  Serial.print(\"network type is \");\r\n  Serial.println(networkType);\r\n#endif\r\n  if(networkType == 1 || networkType == 5) {\r\n    Serial.println(\"SIM is registered\");\r\n  }\r\n  else {\r\n    Serial.println(\"SIM is not registered\");\r\n    //soft_restart();\r\n  } */\r\n} \r\n\r\nvoid GeneratePassword(char* imei) {\r\n  // think of some mechanism\r\n  \r\n#ifdef DEBUG\r\n  Serial.print(\"PASSWORD generated: \");\r\n  Serial.println(password);\r\n#endif\r\n}\r\n\r\nvoid SMSServiceSetup(void) {\r\n  // Set SMS input mode\r\n  Serial.println(\"Setting input mode\");\r\n  // send AT+CMGF=1\r\n  sim900_check_with_cmd(\"AT+CMGF=1\\r\\n\",\"OK\\r\\n\",CMD);\r\n  delay(DELAY_TIME);\r\n  \r\n  // Set the input character set\r\n  Serial.println(\"Setting character mode: GSM\");\r\n  // Send AT+CSCS=\"GSM\"\r\n  sim900_check_with_cmd(\"AT+CSCS=\\\"GSM\\\"\\r\\n\",\"OK\\r\\n\",CMD);\r\n  delay(DELAY_TIME);\r\n  \r\n  // Set SMS mode\r\n  Serial.println(\"Setting SMS message indications\");\r\n  // Send AT+CNMI=2,1,0,0,0\r\n  sim900_check_with_cmd(\"AT+CNMI=2,1,0,0\\r\\n\",\"OK\\r\\n\",CMD);\r\n  delay(DELAY_TIME);\r\n  \r\n  // Save the settings for SMS\r\n  Serial.println(\"Saving settings to memory\");\r\n  // Send AT+CSAS=0\r\n  sim900_check_with_cmd(\"AT+CSAS=0\\r\\n\",\"OK\\r\\n\",CMD);\r\n  delay(DELAY_TIME);\r\n  \r\n  Serial.println(\"SMS Service Ready\");\r\n}\r\n\r\n\r\nvoid handleSMS(byte messageIndex) {\r\n  // Get the SMS content\r\n  char message[100];\r\n  char mobileNumber[16];\r\n  char dateTime[24];\r\n  char *s, *p;\r\n  char num[4];\r\n  byte i = 0;\r\n\r\n  \r\n  // read SMS content\r\n  gsm.readSMS(messageIndex, message, MESSAGE_LENGTH,mobileNumber , dateTime);\r\n // strupr(message);\r\n#ifdef DEBUG\r\n  Serial.println(\"Printing messageIndex\");\r\n  Serial.println(messageIndex);\r\n  Serial.println(\"Printing SMS content\");\r\n  Serial.println(message);\r\n  Serial.println(\"Printing MESSAGE_LENGTH\");\r\n  Serial.println(MESSAGE_LENGTH);\r\n  Serial.println(\"Printing mobileNumber\");\r\n  Serial.println(mobileNumber);\r\n  Serial.println(\"Printing dateTime\");\r\n  Serial.println(dateTime);\r\n#endif \r\n \r\n  // delete SMS to save memory\r\n  gsm.deleteSMS(messageIndex);\r\n  \r\nif(checkIfNumberAuthorized(mobileNumber)<0){\r\n  if(NULL !=(s=strstr(message, \"REGISTER\"))){\r\n \r\n     // get the password\r\n      s = s + 8; // we are on the first digit of user password\r\n      p = strstr((char *)(s),\" \");\r\n      char userPass[7];\r\n      s++; //now s is pointing to first character of password\r\n      i = 0;\r\n      while(i < 6){\r\n        userPass[i++] = *(s++);\r\n      }\r\n      userPass[i] = '\\0';\r\n#ifdef DEBUG\r\n      Serial.print(\"User password is \");\r\n      Serial.println(userPass);\r\n#endif      \r\n      // Compare the password\r\n      if(!strcmp(userPass, password)) {\r\n        Serial.println(\"Password matched\");\r\n        int index = checkIfNumberAuthorized(mobileNumber);\r\n        if(index <= 0) {\r\n        // Make an entry into phonebook\r\n        //AT+CPBW=PBEntryIndex,\"newmobileNumber\",145,\"TTmobileNumber\"\r\n        //PBEntryIndex++;\r\n#ifdef DEBUG\r\n        Serial.print(\"PB index is \");\r\n        Serial.println(PBEntryIndex);\r\n#endif\r\n        sim900_flush_serial();\r\n        //sim900_check_with_cmd(\"AT+CPBS=\\\"ME\\\"\\r\\n\",\"OK\\r\\n\",CMD);\r\n        sim900_send_cmd(\"AT+CPBW=\");\r\n        itoa(PBEntryIndex, num, 10);\r\n        sim900_send_cmd(num);\r\n        sim900_send_cmd(\",\\\"\");\r\n        sim900_send_cmd(mobileNumber);\r\n        sim900_send_cmd(\"\\\",145,\\\"TT\");\r\n        sim900_send_cmd(mobileNumber);\r\n        sim900_send_cmd(\"\\\"\\r\\n\");\r\n        \r\n        sim900_wait_for_resp(\"OK\\r\\n\", CMD);\r\n#ifdef DEBUG\r\n        Serial.print(\"Mobile Number \");\r\n        Serial.print(mobileNumber);\r\n        Serial.println(\" Authorised\");\r\n#endif\r\n           EEPROM.write(PB_ENTRY_INDEX_LOCATION, PBEntryIndex);\r\n        }\r\n       else {\r\n#ifdef DEBUG\r\n          Serial.println(\"Password did not match\");\r\n#endif\r\n          //gsm.sendSMS(mobileNumber, \"Wrong password\");\r\n       }\r\n  }\r\n}\r\n}\r\n  else if(checkIfNumberAuthorized(mobileNumber)> 0) {\r\n  if(NULL !=(s=strstr(message, \"SMS ENABLE\"))){\r\n    smsReplyFlag= true;\r\n    CallReplyFlag= false;\r\n    //send SMS\r\n    if(smsReplyFlag){\r\n      //gsm.sendSMS(PRIMARY, \"SMS ENABLED\");\r\n      }\r\n        // Save settings to EEPROM\r\n        EEPROM.write(SMS_REPLY_LOCATION,1);\r\n        EEPROM.write(CALL_REPLY_LOCATION,0);\r\n#ifdef DEBUG\r\n      Serial.println(\"SMS ENABLED\");\r\n#endif \r\n    }\r\n    else if(NULL != strstr(message,\"SMS DISABLE\")) {\r\n      smsReplyFlag = false;\r\n      CallReplyFlag = true;\r\n      //send SMS\r\n    if(smsReplyFlag){\r\n      //gsm.sendSMS(PRIMARY, \"SMS DISABLED\");\r\n      }\r\n      // Save setting to EEPROM\r\n       EEPROM.write(SMS_REPLY_LOCATION,0);\r\n       EEPROM.write(CALL_REPLY_LOCATION,1);\r\n#ifdef DEBUG\r\n      Serial.println(\"SMS DISABLED\");\r\n#endif\r\n    }\r\n  }\r\n}\r\n\r\nint checkIfNumberAuthorized(char *mobileNumber) {\r\n  // check this mobile number with the saved numbers and return the index if found\r\n  // Searching for the mobile number\r\n  char *s, *p;\r\n  char index[4];\r\n  byte i = 0;\r\n  // AT+CPBF=\"mobileNumber\"\r\n  //sim900_check_with_cmd(\"AT+CPBS=\\\"ME\\\"\\r\\n\",\"OK\\r\\n\",CMD);\r\n  sim900_send_cmd(\"AT+CPBF=\\\"\");\r\n  sim900_send_cmd(mobileNumber);\r\n  sim900_send_cmd(\"\\\"\\r\\n\");\r\n  sim900_clean_buffer(gsmBuffer, sizeof(gsmBuffer));\r\n  sim900_read_buffer(gsmBuffer, sizeof(gsmBuffer));\r\n  \r\n  // +CPBF: 1,\"+91XXXXXXXXXX\",145,\"TT+91XXXXXXXXXX\"\r\n  // If number is present\r\n  if(NULL != ( s = strstr(gsmBuffer, \"+CPBF:\"))) {\r\n    s = s + 7;\r\n    p = strstr((char *)(s), \",\"); //point to first ,\r\n    if(NULL != s) {\r\n      i = 0;\r\n      while (s < p) {\r\n        index[i++] = *(s++);\r\n      }\r\n      index[i] = '\\0';\r\n    }\r\n    Serial.println(\"number is authorized\");\r\n    return atoi(index); \r\n  }\r\n  else {\r\n    Serial.println(\"number is not authorized\");\r\n    return -1;\r\n  }\r\n}\r\n\r\nvoid Alarm()\r\n{\r\n  state= digitalRead(interruptPin);\r\n  digitalWrite(RELAY, state);\r\n}\r\n \r\n```\r\n\r\n### Debug Messages\r\n\r\n```\r\nmessages here\r\n```\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/esp8266/Arduino/issues/comments/248863184","html_url":"https://github.com/esp8266/Arduino/issues/2542#issuecomment-248863184","issue_url":"https://api.github.com/repos/esp8266/Arduino/issues/2542","id":248863184,"user":{"login":"BharathTatikonda","id":21261379,"avatar_url":"https://avatars.githubusercontent.com/u/21261379?v=3","gravatar_id":"","url":"https://api.github.com/users/BharathTatikonda","html_url":"https://github.com/BharathTatikonda","followers_url":"https://api.github.com/users/BharathTatikonda/followers","following_url":"https://api.github.com/users/BharathTatikonda/following{/other_user}","gists_url":"https://api.github.com/users/BharathTatikonda/gists{/gist_id}","starred_url":"https://api.github.com/users/BharathTatikonda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BharathTatikonda/subscriptions","organizations_url":"https://api.github.com/users/BharathTatikonda/orgs","repos_url":"https://api.github.com/users/BharathTatikonda/repos","events_url":"https://api.github.com/users/BharathTatikonda/events{/privacy}","received_events_url":"https://api.github.com/users/BharathTatikonda/received_events","type":"User","site_admin":false},"created_at":"2016-09-22T10:19:17Z","updated_at":"2016-09-22T10:19:17Z","body":"Thank u for ur suggestion, i have checked thet one, the program will fails on when the message is reading (the program will stuck on the  \" messageIndex = gsm.isSMSunread(); \" in this funtion, ) and at some times it stucts at   \"gsm.deleteSMS(messageIndex);\" in this function....... \r\n\r\nAnd i want to try with the stack decode...."}}
{"actor":{"display_login":"BharathTatikonda"}}