//
//  bs_pd_packet.h
//
/////////////////////////////////////////////////////////////////////
//                                                                 //
// Copyright 1994-2024. Acroname Inc.                              //
//                                                                 //
// This software is the property of Acroname Inc.  Any             //
// distribution, sale, transmission, or re-use of this code is     //
// strictly forbidden except with permission from Acroname Inc.    //
//                                                                 //
// To the full extent allowed by law, Acroname Inc. also excludes  //
// for itself and its suppliers any liability, whether based in    //
// contract or tort (including negligence), for direct,            //
// incidental, consequential, indirect, special, or punitive       //
// damages of any kind, or for loss of revenue or profits, loss of //
// business, loss of information or data, or other financial loss  //
// arising out of or in connection with this software, even if     //
// Acroname Inc. has been advised of the possibility of such       //
// damages.                                                        //
//                                                                 //
// Acroname Inc.                                                   //
// www.acroname.com                                                //
// 720-564-0373                                                    //
//                                                                 //
/////////////////////////////////////////////////////////////////////
#ifndef BS_PD_PACKET_H
#define BS_PD_PACKET_H

#include <stdint.h>

#if defined(__cplusplus)
#include <vector>
#endif//defined(__cplusplus)

#ifdef _WIN32
#ifndef aUNUSED
#define aUNUSED
#endif
#else
#ifndef aUNUSED
#define aUNUSED             __attribute((unused))
#endif
#endif

typedef enum BS_PD_Packet_Direction {
    kBS_PD_Packet_Direction_Invalid,
    kBS_PD_Packet_Direction_Transmit,
    kBS_PD_Packet_Direction_Receive,

    kBS_PD_Packet_Direction_UNKNOWN,
    kBS_PD_Packet_Direction_LAST
} BS_PD_Packet_Direction_t;


static const char* BS_PDLog_Packet_Direction_Strings[kBS_PD_Packet_Direction_LAST] aUNUSED = {
    "Invalid",
    "TX",
    "RX",
    "Unknown"
};


typedef enum BS_PD_Packet_SOP {
    kBS_PD_Packet_SOP,
    kBS_PD_Packet_SOP_P,
    kBS_PD_Packet_SOP_P_P,
    kBS_PD_Packet_SOP_P_DEBUG,
    kBS_PD_Packet_SOP_P_P_DEBUG,

    kBS_PD_Packet_SOP_UNKNOWN,
    kBS_PD_Packet_SOP_LAST
} BS_PD_Packet_SOP_t;

static const char* BS_PD_Packet_SOP_Strings[kBS_PD_Packet_SOP_LAST] aUNUSED = {
    "SOP",
    "SOP\'",
    "SOP\'\'",
    "SOP\' Debug",
    "SOP\'\' Debug",
    "Unknown"
};


#if defined(__cplusplus)

typedef struct BS_PD_Packet {
    
    BS_PD_Packet() :
        channel(0),
        seconds(0),
        uSeconds(0),
        direction(BS_PD_Packet_Direction_t::kBS_PD_Packet_Direction_Invalid),
        sop(BS_PD_Packet_SOP_t::kBS_PD_Packet_SOP_UNKNOWN),
        payload(std::vector<uint8_t>()),
        event(0) {}

    BS_PD_Packet(uint8_t channel,
                 uint32_t seconds,
                 uint32_t uSeconds,
                 BS_PD_Packet_Direction_t direction,
                 BS_PD_Packet_SOP_t sop,
                 std::vector<uint8_t> payload,
                 uint32_t event = 0) // 0 = pdEventNone
                 :
                 channel(channel),
                 seconds(seconds),
                 uSeconds(uSeconds),
                 direction(direction),
                 sop(sop),
                 payload(payload),
                 event(event) {}

    uint8_t channel;
    uint32_t seconds;
    uint32_t uSeconds;
    BS_PD_Packet_Direction_t direction;
    BS_PD_Packet_SOP_t sop;
    std::vector<uint8_t> payload;
    uint32_t event;
} BS_PD_Packet_t;

#endif//defined(__cplusplus)


#endif // BS_PD_PACKET_H
