Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add context argument to sl_zigbee_af_event_t #18

Open
Xeenych opened this issue Aug 28, 2024 · 0 comments
Open

Add context argument to sl_zigbee_af_event_t #18

Xeenych opened this issue Aug 28, 2024 · 0 comments

Comments

@Xeenych
Copy link

Xeenych commented Aug 28, 2024

In order to interact with high-level code it will be very useful to add void* dtaCtx field to sl_zigbee_af_event_t struct as shown:

event-queue.h

typedef struct Event_s {
.....
  // Owned by the end user
  void *dataPtr;                        // a generic pointer
  void *dataCtx;
} sli_zigbee_event_t;

then in sl_zigbee_system_common.h line 186 add void* parameter to function signature:

void sli_zigbee_af_event_internal_init(sl_zigbee_af_event_t *event,
                                       const char *event_name,
                                       void *handler,
                                       uint8_t network_index,
                                       uint8_t endpoint,
                                       void *ctx) {
.....
  event->dataCtx = ctx;
}

and on lines 175-179:

 if (is_endpoint_event) {
    ((void (*)(uint8_t))(event->dataPtr))(sli_zigbee_af_event_get_endpoint(event));
  } else {
    ((void (*)(sl_zigbee_af_event_t *, void *))(event->dataPtr))(event, event->dataCtx);
  }

then in zigbee_app_framework_event.h on lines 136-143 add NULL as last parameter:

#if (SL_ZIGBEE_EVENT_DEBUG_ENABLED)
  #define sl_zigbee_af_event_init(event, handler) \
  sli_zigbee_af_event_internal_init((event), (#event), (void *)(handler), 0xFF, 0xFF, NULL)
#else
  #define sl_zigbee_af_event_init(event, handler) \
  sli_zigbee_af_event_internal_init((event), NULL, (void *)(handler), 0xFF, 0xFF, NULL)
#endif // SL_ZIGBEE_EVENT_DEBUG_ENABLED
#endif // DOXYGEN_SHOULD_SKIP_THIS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant