Arduino Forum

Using Arduino => Programming Questions => Topic started by: NextPirate on Jan 29, 2019, 01:18 pm

Title: uploading an include file to an ESP8266
Post by: NextPirate on Jan 29, 2019, 01:18 pm
I've been search for a way to upload "settings.h" to an ESP8266 with having to flash the chip.

I have found where we can Post files to SPIFF but have yet to find how I can POST a file to where it can be used as an "include" file in the Sketch.

I tried #include </data/settings.h> but that yields an error.

The idea is that in operation the chip will be physically installed in a place that is hard to get at.  In order to update the chip with configuration settings for ht e application, I put all those settings in an Include file. 

What I want to do is to replace the Include file (Setting.h) using a call to the ESP8266.

I was following this but I could not figure out how to get the file to anyplace but in /data inthe SPIFF:

https://tttapa.github.io/ESP8266/Chap12%20-%20Uploading%20to%20Server.html (https://tttapa.github.io/ESP8266/Chap12%20-%20Uploading%20to%20Server.html)

Title: Re: uploading an include file to an ESP8266
Post by: PieterP on Jan 29, 2019, 01:22 pm
You can't.

Settings.h is added to your source code by the preprocessor, so the path is a path on your computer. Then it is compiled into an executable file.

You cannot possibly change it at runtime, you have to compile it again.

What you can do is adding a config file that you add to the SPIFFS and read it in the setup, setting some configuration variables.

Pieter
Title: Re: uploading an include file to an ESP8266
Post by: NextPirate on Jan 29, 2019, 03:11 pm
Got it.  Thanks.   :)