Unable to run the WiFi.off() command, it is the same thing with the System.sleep().
Does running the system under the SYSTEM_MODE(MANUAL) causes this?
WiFi.off(). —> SOS red led, hard reset.
Spark.Sleep() —> SOS red led, hard reset.
Unable to run the WiFi.off() command, it is the same thing with the System.sleep().
Does running the system under the SYSTEM_MODE(MANUAL) causes this?
WiFi.off(). —> SOS red led, hard reset.
Spark.Sleep() —> SOS red led, hard reset.
Hi peekay123,
This is the shell of the code where the SOS happens.
I am guessing; i think it is related to stack exhaustion due to array of Strings that i am using.
#include "WebServer.h"
#include "Thermal.h"
#include "string.h"
/* This creates an instance of the webserver. By specifying a prefix
* of "", all pages will be at the root of the server. */
#define PREFIX ""
#define adalogo_width 75
#define adalogo_height 75
#define adaqrcode_width 135
#define adaqrcode_height 135
extern char* itoa(int a, char* buffer, unsigned char radix);
WebServer webserver(PREFIX, 80);
long lastTime = 0;
int led0 = D0;
int led1 = D1;
int l_barcode=0;
int l_printer_busy =0;
//int l_led1_status=0;
//long l_timer=0;
int l_block = 5;
String a_block[5] = {""};
long l_orders = 10;
String a_orders[10] = {""};
String a_done[10] = {""};
int l_wifi_rc =0;
int l_assoc =3;
String a_assoc[3]={""};
String a_interval[3]={""};
int l_times = 0;
int l_limit = 0;
int l_now = 0;
char c_barcode_1[32];
char c_barcode_2[100];
char c_barcode_3[32];
String sys_status="";
String s_i_obj ="";
String s_i_tot ="";
String s_taken ="";
int l_no_request_times =0;
int l_server_busy=0;
//SYSTEM_MODE(SEMI_AUTOMATIC);
SYSTEM_MODE(MANUAL);
//SYSTEM_MODE(AUTOMATIC);
void helloCmd(WebServer &server, WebServer::ConnectionType type, char *, bool)
{
l_no_request_times =0;
if (type == WebServer::POST)
{
//do some stuff here
server.httpSuccess();
server.print("some string to send");
}
else if (type == WebServer::GET)
{
//do some stuff here
server.httpSuccess();
server.print("some string to send");
}
else
{
server.httpSuccess();
server.printP("nothing");
}
}
void arr_SendPulse()
{
//digitalWrite(led0, LOW);
//delay(5);
digitalWrite(led0, HIGH);
delay(5);
digitalWrite(led0, LOW);
//delay(5);
}
bool arr_Tick()
{
if(lastTime+3000<millis())
{
if( l_no_request_times<10)
{
lastTime = millis();
l_no_request_times += 1;
}
else
{
l_wifi_rc += 1;
l_no_request_times=0;
//SOS here.
WiFi.off();
arr_WiFIConnect();
}
arr_SendPulse();
return true;
}
else
{
return false;
}
}
void arr_WiFIConnect()
{
WiFi.on();
WiFi.connect();
int i = 0;
while ((WiFi.ready() != true) && (i < 500))
{ // Loop until connected or 5000ms
delay(10);
i++;
}
}
void setup()
{
pinMode(led0, OUTPUT);
arr_SendPulse();
arr_WiFIConnect();
//Serial1.begin(19200);
//Serial.begin(9600);
webserver.setDefaultCommand(&helloCmd);
webserver.addCommand("index.html", &helloCmd);
webserver.begin();
lastTime = millis() - 5000;
}
void loop()
{
if (Spark.connected())
{
Spark.process();
}
else
{
if(arr_Tick()==true)
{
if(l_now>0)
{
l_now =1;
//do some stuff here
l_now =0;
}
}
//else
{
//if(l_server_busy==0)
//if(l_now==0)
{
l_server_busy=1;
char buff[1000];
int len = 1000;
webserver.processConnection(buff, &len);
l_server_busy =0;
}
}
}
}
Hi @prodders, I actually had tried to withdraw my comment since I figured out the problem
…anyways, I am using a Photon. I had WiFi.off() triggered by a button press, and it turned out I had an issue with my code where it was being called multiple times in a row because of a loop and the fact that the button would be held down for more than a fraction of a second. This was causing it to red SOS on me. Adding a slight delay() after the initial button press seems to have done the trick.