## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
• Create your own community
##### Activity
• 16:00
mikee47 synchronize #2472
• 14:45
mikee47 synchronize #2472
• 14:27
mikee47 synchronize #2472
• Jan 24 10:02
slaff labeled #2472
• Jan 24 10:02
slaff milestoned #2472
• Jan 24 09:32
mikee47 opened #2472
• Jan 24 09:08
slaff unlabeled #2471
• Jan 24 09:08
slaff closed #2471
• Jan 24 09:03
slaff labeled #2471
• Jan 24 09:03
slaff milestoned #2471
• Jan 21 16:10
mikee47 synchronize #2471
• Jan 21 16:03
mikee47 synchronize #2471
• Jan 21 16:02
mikee47 opened #2471
• Jan 21 14:55
slaff unlabeled #2470
• Jan 21 14:55
slaff closed #2470
• Jan 21 09:03
slaff unlabeled #2470
• Jan 21 09:03
slaff labeled #2470
• Jan 20 16:39
mikee47 synchronize #2470
• Jan 20 16:34
mikee47 synchronize #2470
• Jan 20 14:48
mikee47 synchronize #2470
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

I also could not found ... the name of the uploaded file ... the file size

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
https://sming.readthedocs.io/en/stable/tools/clion.html?highlight=clion
• where are the Makefiles for copy&paste located?
• where is the CMakeLists.txt located?
Can somebody help please?
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
Did you add COMPONENT_DEPENDS := Adafruit_BME280_Library to your project's component.mk file?
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
the Ada_BME280 library requires also https://github.com/adafruit/Adafruit_Sensor and https://github.com/adafruit/Adafruit_BusIO
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'.
make[1]: Leaving directory /c/tools/Sming/samples/Basic_Blink'
Killing Terminal to free COM5
/bin/sh: : command not found
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?
Re. problem with flashing, the 'file not found' relates to '/C/tools/...' but previous info. indicates path should be '/c/tools/...'. Windows doesn't care but Make does. I suspect this is related to #2000. Try a make config-clean clean components-clean then rebuild.
Mike
@mikee47
Ignore that last comment. The problem is in Components/Storage/Tools/hwconfig/hwconfig.py line 52, requires filesize = os.path.getsize(fixpath(filename)). NB. I develop on Windows but haven't encountered this problem - I switched to WSL2 as it's considerably faster. I'll get a fix submitted shortly once I've checked it.
Vity
@Vity01
@mikee47 thanks for the PR, I will try it , it looks like I am not unable to build up I2C and I hope the newer library contains some fix
Yeah, meanwhile I disabled the filesize safety check - it will work for you in WSL2 because /c/ path works there
Mike
@mikee47
@Vity01 I've identified the likely problem with the new BME280 library, changes pushed to update/adafruit-bme280 branch. You'll need a git pull. Also updated adafruit libraries so will requiremake submodules-clean before building.
1 reply
vesley
@vesley
Hello @slaff, FileStream worked, but I have two problems with the file upload.
1. When I initialize the FileStream in the fileUploadMapper, I don't have the file name. I put a static name for testing, but I want to store the file with the name provided by the multipart/form-data request.
2. Before persisting the file I want to check if there is enough storage space on the SPIFFS file system and if the file name is not bigger than 32 characters (as SPIFFS doesn't allow filenames with more than 32 characters). If this conditions are not met I want not to store the file.
Is there a way to achieve what I want with Sming?
16 replies
Vity
@Vity01
hurray 97% for v4.5.0 :-)
slaff
@slaff

gpio: gpio_set_level(215): GPIO output gpio_num error

Should be fixed in the latest develop

slaff
@slaff
@/all We are planning a new release for 25th of December. Please test the code in the latest develop branch and let us know if you have noticed some issues.
vesley
@vesley
Hello @mikee47 & @slaff, is it possible to add a new method signature for HttpResourceTree::setDefault, which allows to register a default path and a plugin or a list of plugins? I want to secure all registered paths with basic authentication. Currently there is no way to secure the default path.
vesley
@vesley

Hello @mikee47 & @slaff, is it possible to add a new method signature for HttpResourceTree::setDefault, which allows to register a default path and a plugin or a list of plugins? I want to secure all registered paths with basic authentication. Currently there is no way to secure the default path.

I found out that I can use

server.path.set("*", handler, plugin)

to set a handler for the default path with a plugin.

slaff
@slaff
@/all Merry Christmas everyone - we have a present for you: https://github.com/SmingHub/Sming/releases/tag/4.5.0
Mike
@mikee47
@slaff Awesome teamwork and Merry Christmas to all !