#pragma once
#include "os/os_types.h"

typedef struct {
	u16 key;
	u16 data_len;
	u8  *resp_data;
}response_t;

typedef struct {
	response_t  *keys;
	u16    max_key_count;
}wait_queue_t;

#define KEY_FLAGS_IDLE 0
#define KEY_FLAGS_WAITING 1
#define KEY_FLAGS_PENDING 2

#define ACKED_KEY ((u16)0xFFFF)
void wait_queue_init(wait_queue_t *queue, int max_size);
s32 wait_queue_add(wait_queue_t *queue, u16 key);
s32 wait_queue_add_buffer(wait_queue_t *queue, u16 key, u8*buffer, u16 len);;
bool wait_queue_key_acked(wait_queue_t *queue, u16 key);
bool wait_queue_key_acked_response(wait_queue_t *queue, u16 key, u8 *data, u16 len);
s32 wait_queue_wait_key(wait_queue_t *queue, s32 index, s32 timeout);
void wait_queue_delete_key(wait_queue_t *queue, s32 index);

