notification_app_api.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include <furi.h>
  2. #include <furi_hal.h>
  3. #include "notification.h"
  4. #include "notification_messages.h"
  5. #include "notification_app.h"
  6. void notification_message(NotificationApp* app, const NotificationSequence* sequence) {
  7. NotificationAppMessage m = {
  8. .type = NotificationLayerMessage, .sequence = sequence, .back_event = NULL};
  9. furi_check(furi_message_queue_put(app->queue, &m, FuriWaitForever) == FuriStatusOk);
  10. };
  11. void notification_internal_message(NotificationApp* app, const NotificationSequence* sequence) {
  12. NotificationAppMessage m = {
  13. .type = InternalLayerMessage, .sequence = sequence, .back_event = NULL};
  14. furi_check(furi_message_queue_put(app->queue, &m, FuriWaitForever) == FuriStatusOk);
  15. };
  16. void notification_message_block(NotificationApp* app, const NotificationSequence* sequence) {
  17. NotificationAppMessage m = {
  18. .type = NotificationLayerMessage,
  19. .sequence = sequence,
  20. .back_event = furi_event_flag_alloc()};
  21. furi_check(furi_message_queue_put(app->queue, &m, FuriWaitForever) == FuriStatusOk);
  22. furi_event_flag_wait(
  23. m.back_event, NOTIFICATION_EVENT_COMPLETE, FuriFlagWaitAny, FuriWaitForever);
  24. furi_event_flag_free(m.back_event);
  25. };
  26. void notification_internal_message_block(
  27. NotificationApp* app,
  28. const NotificationSequence* sequence) {
  29. NotificationAppMessage m = {
  30. .type = InternalLayerMessage, .sequence = sequence, .back_event = furi_event_flag_alloc()};
  31. furi_check(furi_message_queue_put(app->queue, &m, FuriWaitForever) == FuriStatusOk);
  32. furi_event_flag_wait(
  33. m.back_event, NOTIFICATION_EVENT_COMPLETE, FuriFlagWaitAny, FuriWaitForever);
  34. furi_event_flag_free(m.back_event);
  35. };