
#include "grifo_aesa_fw_if.h"

#include <stdint.h>

using namespace aesa;
/*
0	CTI Major FW Version	0 to 0xFF
1	CTI Minor FW Version	0 to 0xFF
2	Plank 1 Major FW Version	0 to 0xFF
3	Plank 1 Minor FW Version	0 to 0xFF
--	-- other Planks version data --	--
--	-- other Planks version data -- 	--
64	Plank 32 Major FW Version	0 to 0xFF
65	Plank 32 Minor FW Version	0 to 0xFF
66	CTI Major NVM Version	0 to 0xFF
67	CTI Minor NVM Version	0 to 0xFF
68	Plank 1 Beam Table Version	0 to 0xFF
69	Plank 1 NVM Version	0 to 0xFF
--	-- other Planks version data --	--
--	-- other Planks version data --	--
130	Plank 32 Beam Table Version	0 to 0xFF
131	Plank 32 NVM Version	0 to 0xFF
*/

int grifo_fw::aesa_decode_message_id(const char** msg_name, const void* src, unsigned int /*size*/)
{
    const uint8_t* raw_data=reinterpret_cast<const uint8_t*>(src);
    uint8_t response=raw_data[0];

    //unsigned int expected_size=0;
    const char* name="?";

    *msg_name="?";

    switch (response)
    {
    case CTI_STATUS_RSP:
        name="CTI_STATUS";
        break;
    case CTI_IMU_STATUS_RSP:
        name="CTI_IMU_STATUS";
        break;
    case CTI_EXTENDED_STATUS_RSP:
        name="CTI_EXTENDED_STATUS";
        break;
    case CTI_ETI_READBACK_RSP:
        name="CTI_ETI_READBACK";
        break;
    case CTI_INIT_RESPONSE_RSP:
        name="CTI_INIT_RESPONSE";
        break;
    case CTI_INIT_STATUS_RSP:
        name="CTI_INIT_STATUS";
        break;
    case AESA_STATUS_RSP:
        name="AESA_STATUS";
        break;
    case AESA_FIRMWARE_STATUS_RSP:
        name="AESA_FIRMWARE_STATUS";
        //expected_size=sizeof(aesa_firmware_status_t);
        break;
    case AESA_BROADCAST_STATUS_RSP:
        name="AESA_BROADCAST_STATUS";
        //expected_size=sizeof(aesa_broadcast_status_t);
        break;
    case RFIF_STATUS_RSP:
        name="RFIF_STATUS";
        break;
    case RFIF_FIRMWARE_STATUS_RSP:
        name="RFIF_FIRMWARE_STATUS";
        break;
    case RFIF_TIME_SYNC_STATUS_RSP:
        name="RFIF_TIME_SYNC_STATUS";
        break;
    case RFIF_BIT_STATUS_RSP:
        name="RFIF_BIT_STATUS";
        break;
    case RFIF_NVM_DATA_RSP:
        name="RFIF_NVM_DATA";
        break;
    case RFIF_ETI_READ_BACK_RSP:
        name="RFIF_ETI_READ_BACK";
        break;
    case PLANK_STATUS_RSP:
        name="PLANK_STATUS";
        break;
    case PLANK_EXTENDED_STATUS_RSP:
        name="PLANK_EXTENDED_STATUS";
        break;
    default:
        return -1;
    }

    *msg_name=name;
    return response;
}
