/**
 * Message definitions for communication between:
 * - test controller
 * - ivs
 * - ul processing
 * - dl processing
 * - psap
 *
 * @copyright 2008, Research In Motion Ltd.
 *
 * @version $Id: //depot/main/dsp/ecall/c/testlab/msg.h#9 $
 */

#ifndef __MSG_H__
#define __MSG_H__

#include "rimtypes.h"
#include "modem.h"
#include "audio.h"

/* System constants */
#define ERROR_MAX_LENGTH         (300)
#define ERROR_PATTERN_MAX_LENGTH (300)

typedef enum {
    MsgChReset,
    MsgIvsReset,
    MsgPsapReset,
    MsgReady,
    MsgPsapTx,
    MsgPsapRx,
    MsgPcmData,
    MsgError,
    MsgIdCount
} MsgId;

typedef struct {
    Ord8  codec;
    Ord8  codecMode;
    Ord8  vad;
    Int32 delay1;
    Int32 delay2;
    char  errorPattern[ERROR_PATTERN_MAX_LENGTH+1];
    Int32 errorPatternIndex;
} DataChReset;

typedef struct {
    Ord32 n;                    /* The number of bytes in the MSD */
    Ord8  msd[MSD_MAX_LENGTH];  /* The bytes of the MSD */
} DataIvsReset;

typedef struct {
    Ord8 dummy;
} DataPsapReset;

typedef struct {
    Ord8 dummy;
} DataPsapTx;

typedef struct {
    Ord32 n;                    /* The number of bytes in the MSD */
    Ord8  msd[MSD_MAX_LENGTH];  /* The bytes of the MSD */
} DataPsapRx;

typedef struct {
    Int16 pcm[PCM_LENGTH];
} DataPcmData;

typedef struct {
    char msg[ERROR_MAX_LENGTH+1];  /* +1 for '\0' string termination */
} DataError;

/* Order must correspond to MsgId enum */
static const int MsgDataSize[MsgIdCount] = {
    sizeof(DataChReset),
    sizeof(DataIvsReset),
    sizeof(DataPsapReset),
    0,
    sizeof(DataPsapTx),
    sizeof(DataPsapRx),
    sizeof(DataPcmData),
    sizeof(DataError)
};

typedef struct {
    Ord8 id;
    union {
        DataChReset   chReset;
        DataIvsReset  ivsReset;
        DataPsapReset psapReset;
        DataPsapTx    psapTx;
        DataPsapRx    psapRx;
        DataPcmData   pcmData;
        DataError     error;
    } u;
} Msg;

#endif
