Open raulMrello opened 5 years ago
mdf_event_loop_send(event.id, NULL);
as follows)
- mdf_event_loop_send(event.id, &event.info);
The space of event
has been released when event.info
is used, causing memory access exceptions.
- Use static variable caching
c Stiatic mesh_event_t s_event_info = {0x0}; Memcpy(&s_event_info, &event.info, sizeof(mesh_event_t)); Mdf_event_loop_send(event.id, &event.info);`
When using this method, when multiple ESP-MESH events are received at the same time, the parameters of the event will be modified.
- Call the upper callback function directly
c Mdf_event_loop(event.id, &event.info);
With this method, the use of the upper callback function must be very careful. If there is a blocking operation or a large stack is needed, it will affect the normal operation of ESP-MESH.
- Add a list of events to buffer
Since the event parameters of ESP-MESH are relatively large, the buffer queue will only occupy a large amount of memory. This scheme is pending, and this scheme may be used afterwards. If you have a better method, please give us suggestions.The application layer does not have to use the parameters of the event.
- The parameters of the event can basically be obtained through other APIs. If you receive the level change, you can get it directly through esp_mesh_get_layer()
;
- Many of the parameters of the event are applications that serve the scheme of manual networking. No need to care.
About MDF_EVENT_MWIFI_CHILD_DISCONNECTED: The event of ESP-MESH can only get the information of the direct child node. If there is a device under the child node, you will not know its disconnection. If you want to get all the offline devices, you need to store the devices connected to the current device. When there is a child node disconnection event, you can get the number of connections under the device again to compare with the previous ones to determine which devices are disconnected. Using this method will consume memory (number of devices × 6 Bytes), if you think this solution is feasible, I will provide you with an example of use or directly into the corresponding interface in mwifi.c
Hello, I just came across the same issue. Where I need to access the important details of the mesh at application level. which is not really accessible unless I put my code inside the library code.
For example: If I like to access the network state at application level callback function to know whether it's a rootless mesh or not I can't really do it.
case MESH_EVENT_NETWORK_STATE:
g_rootless_flag = event.info.network_state.is_rootless;
if (g_rootless_flag) {
// My code here
}
Or even if we can have enough get functions to access those details would be good. As for now there are lot of important details of the mesh that we can't really access at application level.
Please reply. Thank you.
Hi, @Jigar3690 . mdf_event_loop can already pass the underlying event information. see https://github.com/espressif/esp-mdf/blob/1c76187faaf16d40a574fc7c0c98122e93dee746/components/mwifi/mwifi.c#L288
3. About MDF_EVENT_MWIFI_CHILD_DISCONNECTED: The event of ESP-MESH can only get the information of the direct child node. If there is a device under the child node, you will not know its disconnection. If you want to get all the offline devices, you need to store the devices connected to the current device. When there is a child node disconnection event, you can get the number of connections under the device again to compare with the previous ones to determine which devices are disconnected. Using this method will consume memory (number of devices × 6 Bytes), if you think this solution is feasible, I will provide you with an example of use or directly into the corresponding interface in mwifi.c
Hello, I'm interested in such example. I'm using PSRAM so memory should not be an issue.
Not sure how much has changed since then or if I simply missed some API that can provide information about currently connected / disconnected nodes.
Environment
git rev-parse --short HEAD
to get the commit id.): 0c64172Problem Description
Default mwifi event handler
static void esp_mesh_event_cb(mesh_event_t event)
hides important information about the event when it forwards to application level event handlers:At
mwifi.c
line 128 the event handler forwards the event to upper handlers at application level, as shown below:As you can see the second argument is NULL, so event information is hidden to those upper handlers at app level.
Expected Behavior
Event information should be forwarded, replacing:
With the event information:
Steps to reproduce
static mdf_err_t event_loop_cb(mdf_event_loop_t event, void *ctx){...
Related stuff
As event information defined in file
esp_mesh.h
includes different event information:... this will allow to have higher control of the handled mesh event at application level.