## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
##### Activity
• Jan 18 16:19
slaff closed #2469
• Jan 17 11:06
slaff edited #2469
• Jan 17 10:33
slaff milestoned #2469
• Jan 17 10:33
slaff opened #2469
• Jan 17 10:30
slaff unlabeled #2468
• Jan 17 10:22
slaff closed #2468
• Jan 17 10:21
slaff milestoned #2468
• Jan 15 09:36
mikee47 synchronize #2468
• Jan 14 13:06
mikee47 labeled #2468
• Jan 14 13:06
mikee47 labeled #2468
• Jan 14 13:06
mikee47 opened #2468
• Jan 13 12:24
slaff unlabeled #2467
• Jan 13 12:24
slaff closed #2467
• Jan 12 12:49
mikee47 synchronize #2467
• Jan 12 12:19
slaff labeled #2467
• Jan 12 10:52
slaff milestoned #2467
• Jan 12 10:49
mikee47 synchronize #2467
• Jan 12 10:38
mikee47 edited #2467
• Jan 12 10:32
mikee47 edited #2467
• Jan 12 10:31
mikee47 opened #2467
slaff
@slaff
I have tried to compile Basic_Blinc for ESP32 a minute ago and all was fine. I guess your ESP-IDF variables need to be set correctly.
Paste here the output from: echo \$IDF_PATH and env
kmihaylov
@kmihaylov

@slaff I did a fresh install and now I successfully compile the Basic_Blink example. I did the following:

rm -rf /opt/esp32
rm -rf /opt/esp-idf

With fresh develop branch I ran the install.sh script.

kmihaylov
@kmihaylov
What is the status of SPI with Esp32?
kmihaylov
@kmihaylov
OK I just made it with the standard SPIClass with the SpiPins struct and it works. :)
kmihaylov
@kmihaylov

Hello. I'm using SPI with two ICs. With each of them I do different beginTransaction (they use different SPI modes). In my app I use Serial.systemDebugOutput(true) and my config variable is DEBUG_VERBOSE_LEVEL = 1.

However my app rapidly switches between the two ICs and my debug output is full of Sming/Arch/Esp32/Core/SPI.cpp's

debug_i("[SPI] APB freq = %u, pre = %u, div = %u, target freq = %u, actual = %u", apbFreq, prediv.prescale,
prediv.divisor, speed.frequency, prediv.freq);

Do I misunderstand how DEBUG_VERBOSE_LEVEL is used (in combination with Serial.setDebugOutput() or there is some other reason that debug_i() is always printed?

Mike
@mikee47
By default, libraries don't get recompiled when DEBUG_VERBOSE_LEVEL changes (to provide a little more control over behaviour). Try make Sming-build all
kmihaylov
@kmihaylov

@mikee47 thanks, I supposed it works the way you told me, but I thought that with some magic it obeys the project's variables.

Wondering if I can change the global SPI instance default pins. I play with ESP32-WROVER and there's some mismatch with the default pins in SPIClass::BusInfo.

If I create another instance, it works well, but for compliance with some external libraries I would like to preserve the use of the global "SPI" object so I wouldn't modify the library to pass a reference to a custom SPI object.

Mike
@mikee47
@kmihaylov I've created a PR #2360, so you should be able to call SPI.setup() to achieve what you need.
kmihaylov
@kmihaylov
Thank you, I'll give it a try.
kmihaylov
@kmihaylov

Hello. With ESP32 I use sensor_vp, sensor_vn and other input only pins. I do not have any issues with these pins, however some error messages are printed on the Serial output:

entry 0x40080618
E (506) gpio: gpio_set_level(215): GPIO output gpio_num error
E (636) gpio: gpio_set_level(215): GPIO output gpio_num error
E (636) gpio: gpio_set_level(215): GPIO output gpio_num error

I also did

gpio_config_t config;
config.mode = GPIO_MODE_INPUT;
config.pull_up_en = GPIO_PULLUP_DISABLE;
config.pull_down_en = GPIO_PULLDOWN_DISABLE;
config.intr_type = GPIO_INTR_NEGEDGE;
gpio_config(&config);

which has the same effect.

Mike
@mikee47
Can you be more explicit? Are you calling pinMode, analogRead, etc...
slaff
@slaff
@/all we will release at the end of the month Sming v4.4. Help us find bugs by testing the latest develop version on your devices and report any issues. You can read more about the new features from here: SmingHub/Sming#2298
slaff
@slaff
@/all we have a new release 4.4.0 - https://github.com/SmingHub/Sming/releases/tag/4.4.0 Enjoy.

This release is code-named "M32". Where "M" and "32" stand for high-quality contributions and improved ESP32 support.
Thanks to @mikee47's and his fantastic work.

Some of the highlights in this release:

• Improved ESP32 support with support for different ESP32 variants.
• Moved from IDF v.4.1 to IDF v.4.3.
• Asynchronous Graphics Library.
• Support for LittleFS.
• Sming Host Emulator: allows running the main logic in the Host emulator while running parts of the hardware dependent code directly on a real micro-controller

And a lot more.

vesley
@vesley
Hello @mikee47, could you please explain how the SectionTemplate is working? How has a template to look like? How to replace content in the template with dynamic content? I looked into the Basic_IFS example, but this one is using IFS as file system. How can I use the SectionTemplate with SPIFFS? I'm testing on a WeMos D1 mini. Thanks in advance.
Mike
@mikee47

Hi @vesley.

IFS is a virtual filesystem and the initFileSystem() function demonstrates mounting a SPIFFS volume in a spiffs subdirectory, with a LittleLFS volume in littlefs. It uses a read-only FWFS root filesystem so that critical files are protected from corruption.

To mount a simple SPIFFS volume requires just a spiffs_mount() call. In the sample, edit the fstest() function and comment out initFileSystem();, uncomment spiffs_mount();

If you want to create a default filesystem image, place the files in a project directory (e.g. 'files') and run make SPIFF_FILES=files. This will get written to your device with a make flash. You can flash it separately with make flashpart PART=spiffs0.

The SectionTemplate is currently lacking proper documentation but here's a brief explanation.
The IFS::DirectoryTemplate class inherits from SectionTemplate and provides the data source for the output. It does this by implementing the nextRecord and getValue methods.

The Basic_IFS sample uses one of three template files depending on the requesteed listing format.
If you take a look in resource/listing.html you'll find three separate sections, marked {SECTION} {/SECTION}.
These are indexed starting at #0 and DirectoryTemplate expects this to contain the page header, section 1 the content and 2 the footer.

The nextRecord method is called before a new content record is about to be output. Here's the annotated DirectoryTemplate implementation:

// Return true if we have a new valid record, false if not
bool nextRecord() override
{
// Content section we fetch the next directory record, if there is one
if(sectionIndex() == 1) {
return directory->next();
}

// This code emits the header and footer sections exactly once
// Returning false suppresses their output completely
return recordIndex() < 0;
}

This sets up the directory information record. The actual directory information is returned from the getValue implementation:

String getValue(const char* name);

Let me know if you have any other questions!

vesley
@vesley
Thanks for the help @mikee47 . It seems that everything that I need is in Sming, I just have to use it :). One more question. I have created a component/library, with some basic web server functionality, which I want to use in several ESP home projects. Is it possible to add the template (listing.html) in the component? So that when I use the component/library it will include the template without the need to add it in every project.
Mike
@mikee47

The Basic_IFS sample uses PROJECT_DIR to qualify file paths,
but for re-usable components useCOMPONENT_PATH instead:

IMPORT_FSTR(listing_html, COMPONENT_PATH "/resource/listing.html")
vesley
@vesley
COMPONENT_PATH did the trick :).
I found a issue with the html template. In the header section I put a <style> tag with some simple CSS:

As the curly brackets {} are reserved as markers to replace content in the template, the CSS code is wrongly parsed in the template. The CSS code in the browser looks like this:
<style>td { padding_ 0 10px; }</style>
Mike
@mikee47
You could switch to double braces {{tag}} instead, just requires a call to tmpl->setDoubleBraces(true) but that's actually quite fiddly...
To do that, the {SECTION} and {/SECTION} tags should be left unchanged, but everything else replace { with {{ and } with }}. In addition, double braces do not apply inside conditional expressions so {!ifeq:{!count:1}} gets changed to {{!ifeq:{!count:1}}}.
If I added escaping support, such as \{ would that break HTML?
Mike
@mikee47
@vesley I've thought of a simpler solution and implemented in PR #2400: just add a space after the '{' character.
vesley
@vesley
Thanks @mikee47. As a workaround I added a marker in the template and set the value in the getValue() method. It is working too :).
vesley
@vesley
Hello @mikee47, hello @slaff, I'm trying to implement the file upload in the webserver. In the example HttpServer_FirmwareUpload I found how to setup the webserver to handle multipart/form-data data. But I'm not sure which Stream to use to read and store the file content on the file system. I also could not found how to retrieve the name of the uploaded file. Is it also possible to check the file size before storing the file on the file system, so that I can avoid uploads of bigger files?
slaff
@slaff

But I'm not sure which Stream to use to read and store the file content on the file system.

@vesley You can use FileStream and in the constructor specify the desired name as the first parameter and as flags the following should work: File::CreateNewAlways | File::WriteOnly.

slaff
@slaff

Not at the moment. But should be doable. The headers of every part in a multipart message are available and could be passed to a checker callback.

Vity
@Vity01
Hi, I would like to run Sming with CLion, but the documentation is not useful much especially for a beginner
• where are the Makefiles for copy&paste located?
• where is the CMakeLists.txt located?
Mike
@mikee47
Hi @Vity01 unfortunately that information is totally out of date! The build is driven via makeso if it's possible to set up an external make project with CLion that's the way to go.
Vity
@Vity01
@mikee47 ok, thanks for the info
Mike
@mikee47
To get intelliense (or whatever the equivalent for CLion is) will require setting up a list of the correct #include paths. For vscode we have a tool to handle that (run make ide-vscode from a sample project directory and have a look in .vscode/c_cpp_properties.json. Something similar could be done for CLion perhaps?
Vity
@Vity01
I don't know , I am a Java developer so the CLion is more acceptable for me than Eclipse IDE which is very unfriendly to anyone :-)
Mike
@mikee47
I use vscode, very nice.
Vity
@Vity01
hmms, maybe I will give it a try
meanwhile maybe you can help me with this error - I am not sure what is wrong
I fetched the BME library - both Adafruit_Sensor and Adafruit_BME280_Library, but I get this linkage error from unknown reason
Mike
@mikee47
Vity
@Vity01
no, it's something new :-). I used to use Sming last time 3 years ago ...
excellent, it works now, thank you very much
Mike
@mikee47
It's changed quite a lot! Maybe have a browse though some of the sample applications to get a feel for how it goes together. Also see https://sming.readthedocs.io/en/stable/_inc/Sming/building.html.
Vity
@Vity01
I browsed the doc but I obviously missed this part, thank you
Vity
@Vity01
I have a question related to the Sming BME280 library - it seems to be outdated against official github https://github.com/adafruit/Adafruit_BME280_Library
Does Sming requires some code updates/patches to get it work or I can use the library directly? Where are the optional Sming libraries located in Github?
3 years ago there was some initiative to be able to use Arduino libs without additional modification.
Mike
@mikee47
That particular library doesn't require patches at its current version. I've just updated it to latest and it's missing Adafruit_I2CDevice so would require some work to get it there. I guess the question ATM is whether the later versions have bugfixes or features you require?
Vity
@Vity01
I just need it to make (their) examples compilable
Vity
@Vity01
there might be a side effect for other Adafruit libs in Sming
Vity
@Vity01

I found another issue with the flashing on Windows make flash

...
ESPTOOL2 out/Esp8266/debug/firmware/rom0.bin
SSL support disabled
make[1]: Nothing to be done for application'.
Killing Terminal to free COM5
make: [kill_term] Error 127 (ignored)
WriteFlash 0x00000=out/Esp8266/debug/firmware/rboot.bin 0x000fa000=out/Esp8266/debug/firmware/partitions.bin 0x00002000=out/Esp8266/debug/firmware/rom0.bin  0x000fc000=/C/tools/Sming/Sming/Arch/Esp8266/Components/esp8266/ESP8266_NONOS_SDK/bin/esp_init_data_default.bin
Traceback (most recent call last):
File "c:\tools\Sming\Sming\Components\Storage\Tools\hwconfig\hwconfig.py", line 114, in <module>
main()
File "c:\tools\Sming\Sming\Components\Storage\Tools\hwconfig\hwconfig.py", line 106, in main
output = globals()['handle_' + args.command](args, config, part)
File "c:\tools\Sming\Sming\Components\Storage\Tools\hwconfig\hwconfig.py", line 52, in handle_flashcheck
filesize = os.path.getsize(filename)
File "c:\Python310\lib\genericpath.py", line 50, in getsize
return os.stat(filename).st_size
FileNotFoundError: [WinError 3] The system cannot find the path specified: '/C/tools/Sming/Sming/Arch/Esp8266/Components/esp8266/ESP8266_NONOS_SDK/bin/esp_init_data_default.bin'
make: *** [flash] Error 1

The file c:\tools\Sming\Sming\Arch\Esp8266\Components\esp8266\ESP8266_NONOS_SDK\bin\esp_init_data_default.bin is there, but it looks like it's used somewhere where the path is not inflated into Windows path

Mike
@mikee47
I've started a PR #2407 which updates the library. Also, only requires #include <Adafruit_BME280_Library>. Perhaps you could test it?