notification-app-api.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include <furi.h>
  2. #include <api-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(osMessageQueuePut(app->queue, &m, 0, osWaitForever) == osOK);
  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(osMessageQueuePut(app->queue, &m, 0, osWaitForever) == osOK);
  15. };
  16. void notification_message_block(NotificationApp* app, const NotificationSequence* sequence) {
  17. NotificationAppMessage m = {
  18. .type = NotificationLayerMessage,
  19. .sequence = sequence,
  20. .back_event = osEventFlagsNew(NULL)};
  21. furi_check(osMessageQueuePut(app->queue, &m, 0, osWaitForever) == osOK);
  22. osThreadYield();
  23. osEventFlagsWait(m.back_event, NOTIFICATION_EVENT_COMPLETE, osFlagsWaitAny, osWaitForever);
  24. osEventFlagsDelete(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 = osEventFlagsNew(NULL)};
  31. furi_check(osMessageQueuePut(app->queue, &m, 0, osWaitForever) == osOK);
  32. osThreadYield();
  33. osEventFlagsWait(m.back_event, NOTIFICATION_EVENT_COMPLETE, osFlagsWaitAny, osWaitForever);
  34. osEventFlagsDelete(m.back_event);
  35. };