Code Monkey home page Code Monkey logo

esp32_youtube_series's People

Contributors

howroyd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

esp32_youtube_series's Issues

General Question about Default Event Loop

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.

Bugg or not using it correctly??

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

TaskMessaging

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.

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.