Coder Social home page Coder Social logo

permalmberg / smooth Goto Github PK

View Code? Open in Web Editor NEW
319.0 18.0 31.0 16.05 MB

C++ framework for embedded programming on top of Espressif's ESP-IDF.

License: Apache License 2.0

C++ 86.16% C 4.55% CMake 4.53% Shell 1.07% HTML 3.61% Dockerfile 0.02% Python 0.06%
esp32 esp-idf espressif

smooth's Issues

Implement a Carrier for event queues

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.

Are these includes needed?

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

Add mock classes for IO

Adding mock classes for IO allows building any application also for Linux even though it uses IO.

Platform 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).

Undefined refernce to esp pthread set cfg

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

BME280 code bug

&& read_16bit(DIG_P8_REG, trimming.dig_P8) && read_16bit(DIG_P9_REG, trimming.dig_P8)

Using dig_P8 twice.

HTTP Server - why are two packets seen as the "first" packet

Run Postman at https://localhost:8443/post with the following in a request key to trigger the behaviour:

123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345

Investigate crash

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.

Build Smooth as a IDF-component

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.

Feature request

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.

  1. Do you foresee adding RMT in the near future (ie 2-3 months).
  2. If you are not adding RMT in the near future what pieces of your existing code would you recommend I look at to create an RMT io.
  3. Or is it possible to use what you current have and just add xxx to provide RMT.
  4. Have you thought about a uart io. Has similar properties: transmitter and receiver.

Thanks

HTTP Server - on packet assembly error, after the fifth error no more connections can be accepted

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

Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled. Core 1 register dump:

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

Support for websocket?

Hi, congratulations for these nice classes for the ESP32. I am currently searching for a HTTP(S) webserver software with the following attributes:

  1. esp-idf based (not Arduino)
  2. c++ based
  3. TLS cabable
  4. support for websockets (according to RFC6455)
    I see that 1. - 3. is already provided by your classes. The only thing missing for me is the support for websocket communication. Is there a plan to implement the websocket protocol also?
    Best regards
    Lothar

Allow sockets to be put in a back-off state for some time.

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.

Build system

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.

Main task and Btask not running

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?
image

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

Extend "WiFi" class with support for access point mode

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.