feat: Implemented do_message_dispatch

This commit is contained in:
2026-06-30 11:59:19 +01:00
parent cf4914d939
commit a5f79f5eac

View File

@@ -2,6 +2,7 @@
#include <string.h> #include <string.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h>
#include "FreeRTOS.h" #include "FreeRTOS.h"
#include "semphr.h" #include "semphr.h"
@@ -13,6 +14,13 @@
#include "nil/nil.h" #include "nil/nil.h"
#if UINTPTR_MAX > UINT32_MAX
#error "Pointers of 32-bits or less are required for incphub mailbox to function correctly."
#endif
// === Private variables === // === Private variables ===
// Global lock // Global lock
@@ -207,16 +215,23 @@ int dequeue_message_ingest(uint8_t **buffer_ptr, TickType_t max_delay)
return INCPHUB_OK; return INCPHUB_OK;
} }
int do_message_dispatch(incphub_cli_t *cli, uint8_t *buffer, size_t length, incphub_addr_t source) int do_message_dispatch(incphub_cli_t *cli, uint8_t *buffer)
{ {
//NOTE: Does not need global lock //NOTE: Does not need global lock
(void)cli; if (cli == NULL)
(void)buffer; return INCPHUB_EINVAL;
(void)length; if (buffer == NULL)
(void)source; return INCPHUB_EINVAL;
//TODO: Implement
return INCPHUB_ERR; // Try to notify
if (xTaskNotifyIndexed(cli->task, INCPHUB_TASKINDEX_MAILBOX, (uint32_t)buffer, eSetValueWithoutOverwrite) == pdFALSE)
{
// Failed because previous message has not yet been processed
return INCPHUB_EAGAIN;
}
return INCPHUB_OK;
} }
int await_message_dispatch(uint8_t **buffer_ptr, size_t *length_ptr, incphub_addr_t *source_ptr) int await_message_dispatch(uint8_t **buffer_ptr, size_t *length_ptr, incphub_addr_t *source_ptr)