howroyd / esp32_youtube_series Goto Github PK
View Code? Open in Web Editor NEWhttps://youtube.com/playlist?list=PLowIV8ZSSsAWjoPJomVi_s1ZMghc9gNn9
License: GNU General Public License v2.0
https://youtube.com/playlist?list=PLowIV8ZSSsAWjoPJomVi_s1ZMghc9gNn9
License: GNU General Public License v2.0
Some snippet of your Main::setup code
status |= wifi.init();
if (ESP_OK == status) status |= wifi.begin();
I know that wifi.begin
will only execute esp_wifi_connect() if we are in state_e::READY_TO_CONNECT, this function is implemented this way in your code. But this is an asynchronous call, I'm a bit confused that the app_main code works (i.e. calling wifi.begin() directly after wifi.init() without waiting for the events to happen.
wifi.begin
should be called after we get back the WIFI_EVENT_STA_START as far as I know. For example in the ESP IDF code we execute the esp_wifi_connect
inside the default event loop at the time when the event happens. (Until now I'm struggling if this is a good habit, to call functions inside the default event loop?
I have seen already other implementations (nKolban), where on those events, e.g. WIFI_EVENT_STA_START semaphores are taken and wifi->init() method waits for this semaphore to be given back by the event, to make the call synchronous, such that the implementation thereafter calls wifi->begin().
The only explanation for me could be because of the higher prioritization of the default event loop vs the main loop which is 1 priority higher than the lowest priority.
Hi
I followed your youtube serie on C++ and ESP32. Understandable you did not continue it any further because it must take much of your time.
I am using bits and pieces from it in my projects.
I tried to use your DynamicQueue_t class but run into some trouble.
Is it not missing a constructor?
How do you use it from within another c++ class.
Hi (again)
I am using your DynamicQueue_t class. Testing it in a separate environment ( no wifi, mqtt etc) it works correctly,
Using DynamicQueue_t in a more complex environment I have some problems. I dont know if it a bug in the class or if I am using it in the wring way.
This setup is like this.
Generator task generates mqtt messages that are pushed into the queue. I have removed how payload is generated but basically a counter is updated by 1 every loop. This seems to be working fine according to the log output.
static void GeneratorTask (void *data) {
vTaskDelay(10 / portTICK_RATE_MS);
int i=0;
while(true){
while (! queue->full()) {
queue->send<mqtt_message_t>(mqtt_message_t {"testCounter", <payload> } );
ESP_LOGW(TAG, "%s:%d topic: %s payload: %s ", __func__, __LINE__ , "testCounder", payload.c_str());
i++;
vTaskDelay(10 / portTICK_RATE_MS);
};
}
Then I have a publisher task reading the queu and publishing data to the Mqtt broker (raspberry pi) using ESP-MQTT client.
static void publishTask(void * bas) {
mqtt_message_t message;
while(true){
vTaskDelay(10 / portTICK_RATE_MS);
while ( ! queue->empty() ) {
esp_err_t result = queue->receive<mqtt_message_t>(message);
if (ESP_OK == result) {
ESP_LOGI(TAG, "%s:%d Publishing message, topic: %s, payload: %s", __func__, __LINE__,topic.c_str(), payload.c_str());
mqtt->publish(topic, payload ) ;
} else {
ESP_LOGE(TAG,"Error in queue" );
}
vTaskDelay(1000 / portTICK_RATE_MS); //// DELAY
};
}
};
Running this with wifi and mqtt the same message is published multiple times dependent on the line marked ///DELAY.
For me it looks like the line: !queue->empty not is updated directly when reading the queue. ??? Depending on what is happening in rest of the application it is updated or not.....
The queue supposed to work so ???
If so,, how do you use it in the best way....
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.