[Solved] Firmware 0.3.1 changed wifi class? can't build/verify code

Hi,

I was using WiFi.on and Wifi.off instead of sleep because I wanted to make the core wake up from sleep on button click and not after set amount of seconds.

I used

WiFi.off();
          while (WiFi.status() != WIFI_OFF) {
            SPARK_WLAN_Loop();
          }

And:

WiFi.on();
        while (WiFi.status() != WIFI_ON) {
          SPARK_WLAN_Loop() ;   
        }

My code won’t verify after the latest firmware update, yesterday it was fine.

Browsing the community I see the option to build the firmware myself instead with the web build, but its really inconvenient, should firmware updates break my code? or am I writing my code wrong?

Thanks,

1 Like

looking at the commits that made up 0.3.1, you may need to change your code as those functions were updated:

I know, but the spark documentation does not reflect the changes, it still says:

During sleep, WiFi.status() will return WIFI_OFF. Once sleep time has expired and the Wi-FI module attempts reconnection, WiFi.status() will return value WIFI_CONNECTING and WIFI_ON.

so I’m wondering if to change my code or add an include/using…

getting documentation updated in a timely fashion is something spark is not exactly famous for lol. there’s not even a changelog with the 0.3.1 commit, you’ve got to trudge through github

@tertius Same issues here, they’ll release an update pretty soon I guess.

1 Like

cc @satishgn whose been working in this area - https://github.com/spark/core-firmware/commit/1fd07f1f18bbd31e0aabcd80f7b536b00e4e62d1#diff-9bbf3796d308374957ea921ab67c7750

None of the previous compiled codes are getting validated.

@amit_singh, I just used Spark CLI (latest) to compile my MessageTorch code which uses WiFi.on() and Spark.connect() without any compile errors. I wonder if this is only a web IDE related problem?

Spark-cli compiles against the same buildfarm so I guess not?

I’ve confirmed the problem in the web ide - the WIFI_xxx enum constants have been removed in master in the commit I linked to previously. Wifi.on() is still present and so works in the IDE (which is why your code compiles.)

Add some use of WIFI_ON and you’ll see the error!

I’ve had issues like the post author, with WIFI_ON and WIFI_OFF as well as WiFi.status().

Error that I am getting today on the code already compiled on V0.2.3.

In file included from …/inc/spark_wiring.h:30:0,
from …/inc/application.h:29,
from tcp-tinker.cpp:65:
…/…/core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning “Defaulting to Release Build” [-Wcpp]
#warning “Defaulting to Release Build”
^
tcp-tinker.cpp:72:0: warning: “DEBUG” redefined [enabled by default]
void initializePin();
^
In file included from …/inc/spark_wiring.h:32:0,
from …/inc/application.h:29,
from tcp-tinker.cpp:65:
…/…/core-common-lib/SPARK_Firmware_Driver/inc/debug.h:77:0: note: this is the location of the previous definition
#define DEBUG(fmt, …)
^
tcp-tinker.cpp:222:1: error: ‘WiFi_Status_TypeDef’ does not name a type
unsigned long lastms;
^
tcp-tinker.cpp: In function ‘void initializePin()’:
tcp-tinker.cpp:403:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘int32_t {aka long int}’ [-Wformat=]
// read the pin state fron the EEPROM Emulator
^
tcp-tinker.cpp:403:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:403:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:403:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 6 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:403:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 7 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:403:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 8 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:403:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 9 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:403:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 10 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:403:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 11 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:403:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 12 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:403:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 13 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:403:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 14 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:403:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 15 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:403:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 16 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:403:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 17 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:403:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 18 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:403:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:403:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:403:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:403:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 6 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:403:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 7 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:403:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 8 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:403:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 9 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:403:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 10 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:403:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 11 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:403:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 12 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:403:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 13 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:403:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 14 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:403:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 15 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:403:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 16 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:403:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 17 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:403:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 18 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp: In function ‘void setup()’:
tcp-tinker.cpp:447:36: warning: ‘IPAddress NetworkClass::localIP()’ is deprecated (declared at …/inc/spark_wiring_network.h:36): Please use WiFi.localIP() instead [-Wdeprecated-declarations]

^
tcp-tinker.cpp: In function ‘void processInput()’:
tcp-tinker.cpp:558:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘int32_t {aka long int}’ [-Wformat=]
Serial.println(pin, DEC);
^
tcp-tinker.cpp:558:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:558:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:558:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 6 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:558:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 7 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:558:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 8 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:558:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 9 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:558:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 10 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:558:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 11 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:558:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 12 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:558:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 13 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:558:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 14 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:558:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 15 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:558:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 16 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:558:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 17 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:558:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 18 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:558:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:558:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:558:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:558:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 6 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:558:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 7 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:558:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 8 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:558:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 9 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:558:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 10 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:558:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 11 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:558:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 12 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:558:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 13 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:558:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 14 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:558:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 15 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:558:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 16 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:558:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 17 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:558:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 18 has type ‘int32_t {aka long int}’ [-Wformat=]
tcp-tinker.cpp:457:23: warning: unused variable ‘type’ [-Wunused-variable]

^
tcp-tinker.cpp:457:29: warning: unused variable ‘speed’ [-Wunused-variable]

^
tcp-tinker.cpp:457:36: warning: unused variable ‘address’ [-Wunused-variable]

^
tcp-tinker.cpp:457:45: warning: unused variable ‘stop’ [-Wunused-variable]

^
tcp-tinker.cpp:457:51: warning: unused variable ‘len’ [-Wunused-variable]

^
tcp-tinker.cpp: In function ‘void loop()’:
tcp-tinker.cpp:868:5: error: ‘WiFi_Status_TypeDef’ was not declared in this scope
client = server.available();
^
tcp-tinker.cpp:868:25: error: expected ‘;’ before 'current_wifi_status’
client = server.available();
^
tcp-tinker.cpp:869:8: error: ‘current_wifi_status’ was not declared in this scope
}
^
tcp-tinker.cpp:869:31: error: ‘WIFI_ON’ was not declared in this scope
}
^
tcp-tinker.cpp:887:6: error: ‘WiFi_Status_TypeDef’ was not declared in this scope

^
tcp-tinker.cpp:887:26: error: expected ‘;’ before ‘current_wifi_status’

^
tcp-tinker.cpp:888:9: error: ‘current_wifi_status’ was not declared in this scope

^
tcp-tinker.cpp:888:32: error: ‘WIFI_ON’ was not declared in this scope

^
tcp-tinker.cpp:895:17: error: ‘class WiFiClass’ has no member named ‘status’
// myTimer.end();
^
tcp-tinker.cpp:901:41: warning: ‘uint32_t NetworkClass::ping(IPAddress)’ is deprecated (declared at …/inc/spark_wiring_network.h:41): Please use WiFi.ping() instead [-Wdeprecated-declarations]
RGB.color(255, 0, 0);
^
tcp-tinker.cpp: In function ‘int psDigitalWrite(String)’:
tcp-tinker.cpp:957:148: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘int32_t {aka long int}’ [-Wformat=]

I had also been checking voodoo spark code. Please have a look, it is also not compiling now.

It seems some of the functions had been changes now, like Network.localIP, Ping etc.

What are the changes that are gone in to 0.3.1 Are they documented or any reference on the summary of changes available?

In file included from …/inc/spark_wiring.h:30:0,
from …/inc/application.h:29,
from voodoo.cpp:34:
…/…/core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning “Defaulting to Release Build” [-Wcpp]
#warning “Defaulting to Release Build”
^
voodoo.cpp:36:0: warning: “DEBUG” redefined [enabled by default]

^
In file included from …/inc/spark_wiring.h:32:0,
from …/inc/application.h:29,
from voodoo.cpp:34:
…/…/core-common-lib/SPARK_Firmware_Driver/inc/debug.h:77:0: note: this is the location of the previous definition
#define DEBUG(fmt, …)
^
voodoo.cpp: In function ‘void setup()’:
voodoo.cpp:299:36: warning: ‘IPAddress NetworkClass::localIP()’ is deprecated (declared at …/inc/spark_wiring_network.h:36): Please use WiFi.localIP() instead [-Wdeprecated-declarations]

^
voodoo.cpp: In function ‘void processInput()’:
voodoo.cpp:307:23: warning: unused variable ‘type’ [-Wunused-variable]
//#endif
^
voodoo.cpp:307:29: warning: unused variable ‘speed’ [-Wunused-variable]
//#endif
^
voodoo.cpp:307:36: warning: unused variable ‘address’ [-Wunused-variable]
//#endif
^
voodoo.cpp:307:45: warning: unused variable ‘stop’ [-Wunused-variable]
//#endif
^
voodoo.cpp:307:51: warning: unused variable ‘len’ [-Wunused-variable]
//#endif
^
voodoo.cpp: In function ‘int ToServoIndex(int)’:
voodoo.cpp:205:1: warning: control reaches end of non-void function [-Wreturn-type]
based on the pin number, determine the servo index for the allocated
^
voodoo.o: In function setup': /spark/compile_server/shared/workspace/worker_1/core-firmware/build/voodoo.cpp:299: undefined reference toNetworkClass::localIP()’
/spark/compile_server/shared/workspace/worker_1/core-firmware/build/voodoo.cpp:303: undefined reference to `Network’
collect2: error: ld returned 1 exit status
make: *** [8aa1b30adde1679d00f53d67e548c14fe5c5de57cb51466f243ad92fed97.elf] Error 1

Error: Could not compile. Please review your code.

@amit_singh, @mdma, I looked through the latest master source code and found the new wificlass changes. I suspect the new documentation is imminent but basically there are now class functions to get status instead of the old mechanism. For example, WiFi.ready() returns true when connected and false otherwise. So instead of:

if (WiFi.status() == WIFI_ON) {

it is now:

if (WiFi.ready()) {

There is also a corresponding WiFi.connecting() function.

1 Like

Has some algorithm changed? Since yesterday the Wifi signal strength jumps around (I have two AP). On the left, the signal is very steady, After 22h MESZ the signal gets flappy, like the device does not select the AP by signal strength. Any idee?

@zachary posted about the changes and explained how the new networking statuses and loop works:

He mentions a doc update coming (maybe today).

1 Like

It would be nice if you could select which firmware to build against using the WEB IDE. (just current or previous version).
This to avoid flashing newer firmware which could have new bugs or unexpected side effects for your code and you didn’t even notice (!) the firmware version changed, unless you check each time you flash.

1 Like

solved using WiFi.Ready instead, and I don’t check that the WiFI.off finishes disconnecting, guess I don’t really need it.

I wish that future firmware updates came after documentation or any kind of warning, but I guess it can’t be helped, I enjoy the improvements anyway :smile:, and the community responds quickly so fixing the broken parts are easy :wink:

1 Like