Firmware with SoftAp not compiling

Hi,

my firmware works fine.

Now I’d like to add the SoftAp mechanism.

But when I add the sample code, it won’t compile anymore.

I’m getting different errors, depending on where in my firmware I place the code.

For example these errors:

src/Tomatotent.cpp:13:1: error: 'String' does not name a type
String currentScreen = "homeScreen";

if I don’t include Particle.h it says:

src/Tomatotent.ino:3:30: error: 'ResponseCallback' has not been declared
src/Tomatotent.ino:3:65: error: 'Reader' has not been declared
src/Tomatotent.ino:3:79: error: 'Writer' has not been declared

I can get the Softap sample to work fine standalone, without any other code.

But when using it in my existing firmware it won’t work.

Does someone know why its not compiling?

My code is here.

Since String is defined in Particle.h you need to have that header included before you use any of the types declared therein. In your code you have it further down.

Particle.h first followed by all other #include statements. They should be heading your sources (hence header files) not be preceded by any variable definitions.

However, as always I’d recommend not to use String (ever).

ok thanks.

I put all the header to tthe front.

Now it says:

./inc/Arduino.h:22:2: error: #error isnan is not defined please ensure this header is included before any STL headers
 #error isnan is not defined please ensure this header is included before any STL headers

Do you know why that is?

Code is here

I’d expect #include "math.h" may help here.

But where does Arduino.h come from?

It seems to be coming from SPI.h.

Here is a firmware snapshot.

It works fine by itself.

But when I include anything that uses wire communication like SPI or I2C the weird math error shows up.

For example the SHT20 or XPT2046 libraries.

(Including math.h didn't fix it.)

/inc/Arduino.h:22:2: error: #error isnan is not defined please ensure this header is included before any STL headers
 #error isnan is not defined please ensure this header is included before any STL headers
  ^
In file included from ./inc/SPI.h:1:0,
                 from lib/XPT2046_Touch/src/XPT2046_Touch.h:5,
                 from src/main.cpp:3:
./inc/Arduino.h:173:1: error: expected ';' before 'using'
 using std::isinf

Do you know why there is this conflict?

As it seems there are some compiler directives that get a bit confused in Adafruit_ILI9341.
I managed to get your project to compile by adding #include <Arduino.h> after #include <Particle.h> in all the headers that also use Adafruit_ILI9341.
That may be something for @peekay123 who is maintaining the Adafruit_ILI9341 library (I wasn’t yet able to reproduce it with a simple test code).

This is the Web IDE project I trested with
https://go.particle.io/shared_apps/5c974bbc5b752a000ad1c052
(don’t mind the double files - these are only artefacts of a known Web IDE glitch)

1 Like

thank you,

it is the ported SHT20.

Yea, I realised that after I posted (hence my edit above).
It’s just that it isn’t too good practice to have one name for the library (SHT20) and another for the main header file (DFRobot_SHT20.h), hence I got confused.


Update:
I’ve done some more investigating and found some peculiarity with the Adafruit_ILI9341 include which I can’t wrap my head round yet.
I found out that you only need the #include <Arduino.h> in the main .ino file.
However with this order of includes the project builds

#include <Particle.h>
#include <Arduino.h>
#include <softap_http.h>
#include <Adafruit_ILI9341.h>

but this way not!

#include <Particle.h>
#include <Arduino.h>
#include <Adafruit_ILI9341.h>
#include <softap_http.h>

// neither does this
#include <Particle.h>
//#include <Arduino.h>
#include <softap_http.h>
#include <Adafruit_ILI9341.h>

which shouldn’t be.

2 Likes

this works. brilliant, thanks a lot!

1 Like