Coder Social home page Coder Social logo

Comments (5)

antoniuschan99 avatar antoniuschan99 commented on June 19, 2024 1

Upon looking further, it might be because I'm using HTTP instead of MQTT?

I see a RMAKER_MQTT_EVENT_PUBLISHED in rmaker_common_event_handler in esp_insights_mqtt.c. Which then does a esp_event_post(INSIGHTS_EVENT, INSIGHTS_EVENT_TRANSPORT_SEND_SUCCESS, &data, sizeof(data), portMAX_DELAY);

from esp-insights.

antoniuschan99 avatar antoniuschan99 commented on June 19, 2024 1

Just tried looks good!

from esp-insights.

vikramdattu avatar vikramdattu commented on June 19, 2024

Hello @antoniuschan99 thanks for reaching out.

Does that mean there is an available event handler to retrieve the success/fail? I see in esp_insights.c line 247 an insights_event_handler() function so I have some code like this but it's failing to catch the event

Since the events go through common event handler, it does get delivered to all the subscribers in theory. Is the observation same for all the events?

5 seconds delay is good but it is not always useful as the messages are sent periodically. with minimum interval of 30 seconds.
Please remove that particular delay and go to deep_sleep after the transport send success event is received. You should also put a timeout for waiting on this event as well and go to sleep anyway. (This avoids deep_sleep logic not triggering in case of n/w issues etc). On the next boot cycle older messages will get sent on priority anyway.

PS: Waiting on transport send event also becomes less useful because of the fact you will not be able to distinguish between same event for other messages as well, which doesn't necessarily contain the heap dump you took right before.

from esp-insights.

antoniuschan99 avatar antoniuschan99 commented on June 19, 2024

Thanks for the reply. I am having trouble catching the event. Both in my implementation of the event handler and also in insights_event_handler in esp_insights.c when I have INSIGHTS_DEBUG_ENABLED in menuconfig. I don't see ESP_LOGI(TAG, "Data send success, msg_id:%d.", data ? data->msg_id : 0); get logged in the console.

The gist of the code is:

esp_insights_config_t config = {
    .log_type = ESP_DIAG_LOG_TYPE_ERROR | ESP_DIAG_LOG_TYPE_WARNING | ESP_DIAG_LOG_TYPE_EVENT,
    .node_id = "123456",
    .auth_key = insights_auth_key_start,
  };

  esp_err_t ret = esp_insights_init(&config);

  if (ret != ESP_OK) {
    ESP_LOGE(TAG, "Failed to initialize ESP Insights, err:0x%x", ret);

    return;
  }

  ret = esp_diag_heap_metrics_dump();

  if (ret != ESP_OK) {
    ESP_LOGE(TAG, "Failed to Dump Heap Metrics");

    return;
  }
}

And here are the logs.


I (2126) esp_netif_handlers: sta ip: 192.168.4.65, mask: 255.255.255.0, gw: 192.168.4.1
I (2126) WiFiConnect: Connected to IP Event Handler
I (2546) esp_rmaker_time: Initializing SNTP. Using the SNTP server: pool.ntp.org
I (2546) esp_rmaker_work_queue: Work Queue created.
I (2566) RTC_STORE: (write_at_offset): size 1025, available: 1025, filled 0, read_ptr 0, to_write 1
I (2566) RTC_STORE: (write_at_offset): size 1025, available: 1025, filled 0, read_ptr 0, to_write 8
I (2576) RTC_STORE: (write_at_offset): size 1025, available: 1025, filled 0, read_ptr 0, to_write 40
I (2586) RTC_STORE: before write_complete, filled 0, size 1025, read_offset 0, len 49
I (2596) RTC_STORE: after write_complete, filled 49, size 1025, read_offset 0, len 49
I (3216) esp_insights: =========================================
I (3226) esp_insights: Insights enabled for Node ID 123456
I (3236) esp_insights: =========================================
I (3236) RTC_STORE: (write_at_offset): size 2048, available: 2048, filled 0, read_ptr 0, to_write 1
I (3246) RTC_STORE: (write_at_offset): size 2048, available: 2048, filled 0, read_ptr 0, to_write 120
I (3256) RTC_STORE: before write_complete, filled 0, size 2048, read_offset 0, len 121
I (3266) RTC_STORE: after write_complete, filled 121, size 2048, read_offset 0, len 121
W (3236) insights_transport: connect callback not set
I (3286) esp_rmaker_work_queue: RainMaker Work Queue task started.
I (3296) esp_insights: Scheduling Insights timer for 60 seconds.
I (3306) esp_insights: Insights metrics metadata changed
I (3306) esp_insights: Insights meta data length 1099

Also, is calling esp_insights_init(&config) enough to send data to esp insights cloud, or do I need to also call esp_diag_heap_metrics_dump(). And is there also a need to call esp_insights_send_data()?

Thank you!

from esp-insights.

vikramdattu avatar vikramdattu commented on June 19, 2024

@antoniuschan99 thanks for diving deeper. That's indeed the case.
Please apply attached change, and see if this satisfies your requirement.
http_tport_status_events.patch [Edited]

from esp-insights.

Related Issues (20)

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.