permalmberg / smooth Goto Github PK
View Code? Open in Web Editor NEWC++ framework for embedded programming on top of Espressif's ESP-IDF.
License: Apache License 2.0
C++ framework for embedded programming on top of Espressif's ESP-IDF.
License: Apache License 2.0
Since the filesystem drivers only support X amount of files (`esp_vfs_fat_sdmmc_mount_config_t.max_files) open at anyone time, any time a file is opened, a lock should be obtained and held until the file is closed.
Templating on the socket type, header and content chunk sizes results in increased code size since C++ creates distinct classes for each. Same goes for IRequestHandler<MaxHeaderSize, ContentChuckSize>.
The Queue<T>
class (and compositions thereof) can be enhanced to allow more than one type to be queued. In short, this is accomplished by using a Carrier-class and a base class that 'executes' the carried event via a known interface.
Change return value to std::tuple<bool, int>
to avoid casting max_file_descriptor in SocketDispatcher::tick()
Per
First off I am no where near your experience as a C++ programmer, I still am a novice.
I was looking thru the code to try an understand how Task Event Queue works (still trying to figure it out) and saw some includes that I had questions on. There may be reason why you include stuff that I am not aware of (maybe future enhancements?) but here is what i have found so far.
TaskEventQueue.h
//
// Created by permal on 6/27/17.
//
#pragma once
#include <smooth/core/Task.h>
#include "ITaskEventQueue.h"
#include "IEventListener.h"
#include "Link.h" //// <----- is this required
#include "QueueNotification.h"
#include <smooth/core/logging/log.h>
QueueNotification.h
//
// Created by permal on 10/18/17.
//
#pragma once
#include
#include
#include
#include
#include <condition_variable> //////////////// <--- added ?????
#include "ITaskEventQueue.h"
#include <smooth/core/timer/ElapsedTime.h> ////////// <---- is this required
namespace smooth
{
namespace core
{
//class Task; ////////////////// <---------Is this required
QueueNotifications.cpp
//
// Created by permal on 10/18/17.
//
#include /// <----- is this required ?
#include <smooth/core/Task.h> /// <------ is this required ?
#include <smooth/core/ipc/QueueNotification.h>
#include <smooth/core/timer/ElapsedTime.h> //// <----- is this required ?
#include <smooth/core/logging/log.h>
Thanks
Adding mock classes for IO allows building any application also for Linux even though it uses IO.
Hi,
I looked at your library and I like it quite a bit.
Have you considered register Smooth with Platform IO? It would be very easy and useful. I could help with that as well since I started to work on my implementation (before finding Smooth that is).
Convert project to CMake
I am trying to build a simple hello world. I am using VSCode for IDE and have been using nkolban esp32 snippets without any problem. This is the error I am seeing on the build.
LD build/hello_world.elf
/home/ed/esp32/projects/sandbox/hello_world/build/smooth/libsmooth.a(Task.o):(.literal._ZN6smooth4core4Task5startEv+0x10): undefined reference to esp_pthread_set_cfg(esp_pthread_cfg_t const*)' /home/ed/esp32/projects/sandbox/hello_world/build/smooth/libsmooth.a(Task.o): In function
smooth::core::Task::start()':
/home/ed/esp32/esp-idf/components/smooth/include/smooth/core/Task.h:78: undefined reference to `esp_pthread_set_cfg(esp_pthread_cfg_t const*)'
collect2: error: ld returned 1 exit status
/home/ed/esp32/esp-idf/make/project.mk:405: recipe for target '/home/ed/esp32/projects/sandbox/hello_world/build/hello_world.elf' failed
make: *** [/home/ed/esp32/projects/sandbox/hello_world/build/hello_world.elf] Error 1
The terminal process terminated with exit code: 2
Any idea what is going on?
I am using commit 2f32356. as I was having problems with the latest commit. Even with this commit I had to change smooth/include/smooth/core/json/Value.h line #6 from #include <json/cJSON/cJSON.h> to #include <cJSON.h> or else compiler could not find thecJSON.h file.
Thanks
Smooth should of course support TLS.
MIMEParser should not ignore content larger than the set size, to prevent memory abuse.
Support index files in HTTP Server.
&& read_16bit(DIG_P8_REG, trimming.dig_P8) && read_16bit(DIG_P9_REG, trimming.dig_P8)
Using dig_P8 twice.
From this
(I)IPv4: www.google.com: 172.217.21.132
(V)Socket: [172.217.21.132, 443, 3, 0x55fe48b89f60]: Created socket
to this
(V)Socket: [www.google.com | 172.217.21.132, port: 443, socket id: 3, 0x55fe48b89f60]: Created socket
Run Postman at https://localhost:8443/post with the following in a request key to trigger the behaviour:
123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345
The current implementation merges the protocol and data carrier (i.e. the packet) into one. This needs to be split.
Add a message parameter to the stop() method in ISocket::stop()
and give a reason for why the socket is being closed at each call.
TLS isn't working when run on the ESP32
mbedtls_ssl_handshake returned -29056: SSL - Verification of the message MAC failed
It's seems to be a problem with the tool chain: espressif/esp-idf#3624
I (372211) MemStat: [INTERNAL]
I (372222) MemStat: 8-bit F:64700 LB:32664 M:44576 | 32-bit: F:78536 LB:32664 M:58392
I (372224) MemStat: [INTERNAL & DMA]
I (372237) MemStat: 8-bit F:64836 LB:32664 M:44576 | 32-bit: F:64836 LB:32664 M:44576
I (372239) MemStat: [SPIRAM]
I (372253) MemStat: 8-bit F:3356996 LB:3311200 M:3338372 | 32-bit: F:3353884 LB:3311200 M:3338372
I (372255) MemStat: Name Stack Min free stack
I (372260) MemStat: MainTask 25600 16316
I (372268) MemStat: SocketDispatcher 20480 2784
I (373340) Socket: [, 0, 57, 0x3fff236c]: Could not get buffer container
I (373345) Socket: [, 0, 57, 0x3fff236c]: Socket stopping
abort() was called at PC 0x401ebf8f on core 0
0x401ebf8f: __cxxabiv1::__terminate(void (*)()) at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/src/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:47
ELF file SHA256: cc3a727c7b571b062530e969af4ca4858f703abea5e0f7a2fd9071d72e7d8c6c
Backtrace: 0x400936e9:0x3ffc5230 0x40093b5c:0x3ffc5260 0x401ebf8f:0x3ffc5290 0x401ebfda:0x3ffc52b0 0x401ec053:0x3ffc52d0 0x401160e6:0x3ffc52f0 0x4011553e:0x3ffc5410 0x40116b36:0x3ffc5510 0x4010afe7:0x3ffc5540 0x40144dc6:0x3ffc5580 0x40144962:0x3ffc5670 0x400d5466:0x3ffc5730 0x40149045:0x3ffc58c0 0x400983ea:0x3ffc58e0
0x400936e9: invoke_abort at /home/permal/esp/esp-idf/components/esp32/panic.c:155
0x40093b5c: abort at /home/permal/esp/esp-idf/components/esp32/panic.c:172
0x401ebf8f: __cxxabiv1::__terminate(void (*)()) at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/src/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:47
0x401ebfda: std::terminate() at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/src/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:57
0x401ec053: __cxa_pure_virtual at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/src/gcc/libstdc++-v3/libsupc++/pure.cc:50
0x401160e6: smooth::application::network::http::HTTPServerClient::send_first_part() at ??:?
0x4011553e: smooth::application::network::http::HTTPServerClient::event(smooth::core::network::event::TransmitBufferEmptyEvent const&) at ??:?
0x40116b36: non-virtual thunk to smooth::application::network::http::HTTPServerClient::event(smooth::core::network::event::TransmitBufferEmptyEvent const&) at ??:?
0x4010afe7: smooth::core::ipc::TaskEventQueue<smooth::core::network::event::TransmitBufferEmptyEvent>::forward_to_event_listener() at ??:?
0x40144dc6: smooth::core::Task::exec() at ??:?
0x40144962: smooth::core::Task::start() at ??:?
0x400d5466: app_main at ??:?
0x40149045: main_task at /home/permal/esp/esp-idf/components/esp32/cpu_start.c:549
0x400983ea: vPortTaskWrapper at /home/permal/esp/esp-idf/components/freertos/port.c:143
CPU halted.
It currently takes six arguments, can it be simplified?
Smooth is currently built using IDF as 3rd-party library. While that is a nice separation, it brings with it extra work in keeping it functional. Try building Smooth as an IDF-component and see if that makes it easier.
Smooth must still be able to be used as a base for native Linux builds.
Per
This is not an issue with the Smooth library just a feature request.
Could you add RMT to your io's and maybe some event handling. Hopefully this is something you been thinking about doing.
Right now I have written code using Task from esp32-snippets and think it could be vastly improved with your library. I am using both RMT transmitter and an RMT receiver.
In Project Simulator I use the the RMT transmitter to simulates the transmission of a message from product XYZ. I have the RMT transmitter in a Task waiting for me to feed it std::vector<rmt_item32_t> data to send out. The simulator has a class that builds a raw message from data provided to it and another class that converts the raw message to and RMT message. This class then passes the RMT data to the RMT transmitter. The message sent out includes sync bits + message + end of message bit. I have this project working.
In Project App I use the RMT receiver in a Task that is constantly sending chucks of RMT messages received to another Task that is converting RMT bits to raw bits (sync, data, end of message) and looking for a signature that indicates that a real message has been received. In the real world the RMT receiver is constantly receiving a stream of bits (most of the time its junk). The raw byte message received is then passed to another Task to parse the message and get the data from it. I am still working on this project.
Thanks
Run this command five times (https to non-https port)
curl --verbose --cacert root_ca.crt -X POST -d"123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345" https://localhost:8080/pos
Seen in the log:
(E)Socket: [, 0, 5 0x60c000035450]: Error during receive: Bad address (14)
(V)Socket: [, 0, 5, 0x60c000035450]: Socket stopping
(V)SocketDispatcher: Shutting down socket 0x60c000035450
(V)Socket: [, 0, -1, 0x60c000035450]: Disconnected
Should IRAM_ATTR really be used and what interrupt allocation flags are currently used?
Must show internal and external memory status, i.e. free bytes.
Hello Smooth.
i'm using framework Smooth for esp32
getting below error and my esp32 gets rebooting ,
please suggest how to fix it,
**Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x4008c484 PS : 0x00060733 A0 : 0x8008c522 A1 : 0x3ffc2bb0
0x4008c484: prvCheckTasksWaitingTermination at /home/luutran/kante/esp/esp-idf/components/freertos/tasks.c:4740
A2 : 0x00000005 A3 : 0x00000001 A4 : 0x00000000 A5 : 0x3ffc24ec
A6 : 0x00000000 A7 : 0x00000001 A8 : 0x8008c46e A9 : 0x3ffc2b90
A10 : 0x3ffc0b44 A11 : 0x00000000 A12 : 0x007d317b A13 : 0x00000001
A14 : 0x00060021 A15 : 0x00000000 SAR : 0x00000000 EXCCAUSE: 0x0000001c
EXCVADDR: 0x0000004d LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000
Backtrace: 0x4008c484:0x3ffc2bb0 0x4008c51f:0x3ffc2bd0
0x4008c484: prvCheckTasksWaitingTermination at /home/luutran/kante/esp/esp-idf/components/freertos/tasks.c:4740
0x4008c51f: prvIdleTask at /home/luutran/kante/esp/esp-idf/components/freertos/tasks.c:4740
Rebooting...
ets Jun 8 2016 00:22:57
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:5736
load:0x40078000,len:7684
load:0x40080000,len:7384
Hi, congratulations for these nice classes for the ESP32. I am currently searching for a HTTP(S) webserver software with the following attributes:
If content_chunk_size is smaller than the incoming data, the protocol is unable to parse the data, resulting in incorrectly parsed URLs etc.
Sockets operating in server mode shall be closed when network reconnects occur.
Listening sockets should bre restarted (how to handle adress-in-use?).
Use case:
SocketDispatcher calls readable()
ServerSocket calls accept_request()
No ServerSocketClient available
Next tick() in SocketDispatcher, the process repeats. If accept_request() can tell SocketDispatcher to back off for that particular socket for X milliseconds, it would reduce the load of the system to allow already in-use ServerSocketClients to finish their work to be reused for the socket waiting to be accepted.
Due to recent(?) changes in the IDf CMake build system, the project_description.json
file is no longer generated which prevents us from running idf-py monitor
etc.
Per
I modified your hello world program and adding a second task and broke out the tasks into separate files.
This is my project structure.
GreetingCPPv2
|
------- CMakeList.txt
------- partitions.csv
-------- sdkconfig
------- build
------- include
|
------- GreetingCPPv2.h
-------- ATask.h
-------- BTask.h
------- main
|
------ CMakeList.txt
------ GreetingCPPv2.cpp
------- ATask.cpp
------- BTask.cpp
------ main.cpp
I can compile the program without any errors but this is the output I see. As you can see the Main Task is not running and the BTask is not running. It looks like MainTask and BTask don't finish initializing?
This is my top level CMakeList.txt
/home/ed/vscode-workspace-esp32/sandbox/GreetingCPPv2/CMakeLists.txt
This is GreetingCPPv2.h
/home/ed/vscode-workspace-esp32/sandbox/GreetingCPPv2/include/GreetingCPPv2.h
This is ATask.h
/home/ed/vscode-workspace-esp32/sandbox/GreetingCPPv2/include/ATask.h
This is BTask.h
/home/ed/vscode-workspace-esp32/sandbox/GreetingCPPv2/include/BTask.h
This is GreetingCPPv2.cpp
/home/ed/vscode-workspace-esp32/sandbox/GreetingCPPv2/main/GreetingCPPv2.cpp
This is ATask.cpp
/home/ed/vscode-workspace-esp32/sandbox/GreetingCPPv2/main/ATask.cpp
This is BTask.cpp
/home/ed/vscode-workspace-esp32/sandbox/GreetingCPPv2/main/BTask.cpp
This is main.cpp
/home/ed/vscode-workspace-esp32/sandbox/GreetingCPPv2/main/main.cpp
This is CMakeList.txt inside main directory
/home/ed/vscode-workspace-esp32/sandbox/GreetingCPPv2/main/CMakeLists.txt
Can you tell me what I did wrong?
Thanks
In my application for wifi both modes (station and access point) are needed. The current implementation of the WiFi class supports the station mode only. So, an extension of the WiFi class for access point mode is needed. I will try to implement it and provide a PR.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.