Core should keep running or be able to start even w/o Cloud access

The local toolchain really is much better, especially when it took minutes to flash each time.

I was thinking to simplify implementation, just remove the initial checking for connectivity with a define if possible? Then Spark.connect() could be called with a condidtion.

Or update the firmware to have limited retries to the cloud on 1st run?

If the reconnect is kept blocking that should be ok as it will ensure that the spark is always connected to wifi if required. If no wifi is required wifi can just be undefined.

Just hoping for a quick fix temporarily!

I’ve found that while Spark.disconnect() ensures the code on the core doesn’t stop executing, the WiFi connection still stalls after a few hours and requries a reset. I didn’t notice it in my initial tests as I wasn’t using the network.

Hopefully the guys at texas instruments will be able to assist with this problem, as… well I hate to say it, but my ten cores are useless until this is working :frowning:

1 Like

Is there any further update on this issue? Has this been fixed?

Yesterday I complied the new code using the WebIDE, but I am still facing the same issue. If the core is not connected to Net, TCPServer/Client within the loop does not work.

@amit_singh this issue has been resolved but yet to be pushed to the WebIDE.

It should be available in 1-2 weeks though.. Unless you don't mind compiling locally then that would be available to you. :smile:

More information about the new features here:

1 Like

Not able to retrieve IP address using Network.localIP(); after including “spark_disable_wlan.h” and “spark_disable_cloud.h”. Though I am able to get the IP if I exclude “spark_disable_wlan.h” and “spark_disable_cloud.h”.

sample code…

#include "application.h"
#include "spark_disable_wlan.h"
#include "spark_disable_cloud.h"

WiFi_Status_TypeDef last_wifi_status;

// variable to store the local IP Address
char myIpString[24];



void setup()
{

  last_wifi_status = WiFi.status();
  WiFi.on();
  Spark.connect();
  
  //Get the local IP address. 
  myIp = Network.localIP();
  sprintf(myIpString, "%d.%d.%d.%d", myIp[0], myIp[1], myIp[2], myIp[3]);

  Spark.variable("localIP", myIpString, STRING);

}

Hi @amit_singh,

An IP is only available if you are connected via WiFi (breathing cyan).

Since disabling wifi means you are not connected to the router :slight_smile:

You will need to check if you are connected 1st before checking for IP

1 Like

With WiFI.on(); I am enabling the wifi and The spark core is getting connected to the router (Breathing Green --> IP address has been assigned). I am able to ping the Ping the Spark core with that IP but I am not able to get the value using Network.localIP();

Second Scenario:

I am calling both WiFi.on(); and Spark.connect() and I am getting breathing Cyan (Connected to Cloud). When I call the Spark Variable, it is not returning IP address.

If I remove both the Wlan and Clound… .h call and use the same code, IP is getting returned when I call the Spark Variable.

Spark.variable as in through API?

For the 1st case, it’s true you cannot get through Spark.variable since only Wifi.on() and Spark.disconnect();?

The core needs to be connected to the spark cloud to get the IP through the API to read the Spark.Variable


Scenario 2 is more interesting…

It should work in this case. Do you happen to have the Spark-CLI? Would be nice to see what functions and variable is available when you are connected.

OR

you can use:

https://api.spark.io/v1/devices/core_id?access_token=XXX

to see if the Spark.variable you used for the IP is shown

Yes, I meant Spark API.

The Code I pasted is for Scenario 2. It is not working.

But the same code without including the Wlan and Cloud disable .h files is working fine.

I am pasting the exact code…

#include “application.h”
#include “spark_disable_wlan.h”
#include “spark_disable_cloud.h”

WiFi_Status_TypeDef last_wifi_status;

// variable to store the local IP Address
char myIpString[24];

void setup()
{

last_wifi_status = WiFi.status();
WiFi.on();
Spark.connect();

//Get the local IP address.
IPAddress myIp = Network.localIP();
sprintf(myIpString, “%d.%d.%d.%d”, myIp[0], myIp[1], myIp[2], myIp[3]);

Spark.variable(“localIP”, myIpString, STRING);

}

This is giving compilation error.

Oh yeah i realized! working on it :slight_smile:

#include "application.h"
#include "spark_disable_wlan.h"
#include "spark_disable_cloud.h"
WiFi_Status_TypeDef last_wifi_status;

// variable to store the local IP Address
char myIpString[24];

void setup()
{

last_wifi_status = WiFi.status();
WiFi.on();
Spark.connect();

Spark.variable("localIP", myIpString, STRING);
}
void loop()
{
//Get the local IP address.
IPAddress myIp = Network.localIP();
sprintf(myIpString, "%d.%d.%d.%d", myIp[0], myIp[1], myIp[2], myIp[3]);
}

Thanks. I tried that and and it is working. But my question is why IP is not getting retrieved in the first call in the setup {} and this is happening when wlan and cloud disable…h files are included. The same code is working without any problem if I exclude these files.

Also, why Network.localIP(); needs to be called repeatedly within a loop to get a value.

I suspect this is the combination of wanting the setup/loop code to run regardless of network / cloud status. Establishing a Wifi / network connection and getting a DHCP lease take some time, so if your code is running immediately, it’ll be a few moments before you have an IP. :smile:

Thanks,
David

I echo what @dave mentioned and that’s what i was thinking when i figured how to modify your code.

One thing i didn’t do is check the status of the myIpString

You can do a check like if (myIpString == "0.0.0.0" && WiFi.status() == WIFI_ON)

so the code doesn’t run forever.

But i see no harm in doing so :smiley:

1 Like

Yes, It makes sense. Thanks a lot @Dave and @kennethlimcp for your inputs.

1 Like

Hi,

I am trying to start up the Spark without connection to the WiFI and Cloud. I have included “spark_disable_wlan.h” and “spark_disable_cloud.h” to the beginning of my firmware, it nicely starts without connecting. Later on in my firmware I connect to WiFi and that works perfectly. After that I tried to connect to the Cloud but that fails, the RGB led start flashing red for a while and the program seems to hang. Here is the code snipped:

WiFi_Status_TypeDef wifiStatus;
bool cloudStatus;

WiFi.on(); // Startup WiFi connection
do {
	yellowLed->on();
	wifiStatus = WiFi.status();
	delay(500);
	yellowLed->off();
	delay(500);
}
while (wifiStatus != WIFI_ON); // Repeat until WiFi is connected

Spark.connect(); // Connect to the Spark Cloud
do {
	yellowLed->on();
	cloudStatus = Spark.connected();
	delay(500);
	yellowLed->off();
	delay(500);
}
while (cloudStatus == false); // Repeat until Spark Cloud is connected

The yellowLed->on() and off() are just for me to show where I am in my code and manupulates an external Led.
Any idea what could be wrong?

Thanks,
Henk

1 Like

Not sure if the do while is causing the issue… try a non-blocking way just to be sure?

I already did, only the Spark.connect() but that gave the same failure.
Thanks,
Henk