/*******************************************************************************
* Project:      Amped'RF Bluetooth
* File name:    OS_BTIStruct.h
* Description:  This file describes the request and response signal structures
*               between BTI and Application.
*
* Copyright (c) 2016 Amped'RF Inc., AR Technology  All rights reserved.
*******************************************************************************/
#ifndef OS_BTISTRUCT_H
#define OS_BTISTRUCT_H



//------------------------------------------------------------------------------
//  Defines
//------------------------------------------------------------------------------
// MaxNumOfDevices should be definitely equial to BTM_SEC_MAX_DEVICE_RECORDS
// Otherwise there will be problems in flash management of device information
#define MAX_NUM_OF_DEVICES              3

#ifdef WINDOW_SIMULATOR
//BTI Service Name Length
#define AMP_SERVICE_NAME_LENGTH 6
#else
//BTI Service Name Length
#define AMP_SERVICE_NAME_LENGTH 16
#endif

//BTI Port Name Length
#define AMP_PORT_NAME_LENGTH 7

//BTI Security Pin Length
#define AMP_SEC_PIN_LENGTH 16

//BTI Device Name Length
#define AMP_DEVICE_NAME_LENGTH  6

//BTI Device Class Length
#define AMP_DEVICE_CLASS_LENGTH  3

#define AMP_OPP_MAX_SERVICENAME_LEN 19
#define AMP_OPP_MAX_DATA_TYPES      10
#define AMP_OPP_MAX_BODY_LEN        250
#define AMP_OPP_MAX_NAME_LEN        15
#define AMP_OPP_MAX_DESC_LEN        19

// $$$ -SB: Sdap Signals Will Be Changed After UPF-6
#define AMP_SDAP_MAX_SERVICE_CLASS 1

#define AMP_MAX_DEV_NAME_LEN       20
#define AMP_MAX_REM_DEV            3

#define AMP_NUM_BD_ADDRESSES       1
#define AMP_OPP_SUPPORTED_FORMATS  8

//#define AMP_SDAP_KNOWN_ATTRIBUTES  10

// Meaningful Bit Values for Device DB table information in flash
#define AMP_FLASHFLAG_DEVICEDB_NONE         0x00
#define AMP_FLASHFLAG_DEVICEDB_OVERWRITE    0x01
#define AMP_FLASHFLAG_DEVICEDB_TRUNCATED    0x02
#define AMP_FLASHFLAG_DELETE_BDADDR         0x04
#define AMP_FLASHFLAG_DELETE_ALL            0x08


#define AMP_DEFAULT_DURATION       0
#define AMP_DEFAULT_INTERVAL       0
#define AMP_DEFAULT_MTU_SIZE       0

// for tAMP_FDB_06 Type

#define AMP_RFDB_06Ptr()      ((tAMP_FDB_06 *) (TM_GetFlashReadPtr( \
                                   TM_FLASH_DYM_LM_DEFAULT_06)))

#define AMP_WFDB_06Ptr()      ((tAMP_FDB_06 *) (TM_GetFlashWritePtr( \
                                   TM_FLASH_DYM_LM_DEFAULT_06, \
                                   sizeof(tAMP_FDB_06))))

#define AMP_WFDB_06Done()     TM_FlashWriteDone(TM_FLASH_DYM_LM_DEFAULT_06)


#define BTM_SEC_SERVICE_SDP_SERVER      0
#define BTM_SEC_SERVICE_SERIAL_PORT     1
#define BTM_SEC_SERVICE_IAP             2
#define BTM_SEC_SERVICE_REMOTE_CMD      3


//------------------------------------------------------------------------------
//  Macros
//------------------------------------------------------------------------------
typedef struct tIapConnectReq{
    tBdAddr RemoteAddr;
}tIapConnectReq;

typedef struct tDiscoveryReq{
    tCod COD;
}tDiscoveryReq;

typedef struct tIapDisconnectReq{
    uint8 Node;
}tIapDisconnectReq;

typedef enum tAMP_DiscoverMode{
    eAMP_DM_Non,
    eAMP_DM_Limtied,
    eAMP_DM_General
}tAMP_DiscoverMode;

typedef enum tAMP_ConnectMode{
    eAMP_CM_Non,
    eAMP_CM_Connectable
}tAMP_ConnectMode;


typedef struct tKey {
  uint8 Byte[16];
}tKey,*tpKey;


typedef struct tDeviceDBInformation {
  uint32   Sequence;
  tBdAddr  BdAddr;
  tCod     ClassOfDevice;
  uint8    BdName[AMP_DEVICE_NAME_LENGTH];
  tKey     LinkKey;
  uint32   TrustedLevelOfServices;
  uint32   Flag;
} tDeviceDBInformation;


typedef struct tDeviceDBTable {
  uint8                 NumberOfEntries;
  tDeviceDBInformation  DeviceDBInformation[MAX_NUM_OF_DEVICES];
} tDeviceDBTable;


typedef struct {
  tDeviceDBTable        DeviceDBTable;
} tAMP_FDB_06;

//------------------------------------------------------------------------------
//
//  Types
//
//------------------------------------------------------------------------------

// Bluetooth Interface Signals
//==============================================================================
//  BTI GAP : API to GAP
//==============================================================================
// 0001: SIG_AMP_GAP_DEVICE_SETUP
typedef struct tSIG_AMPGapDeviceSetup {
  uint32 Transac;
  uint16 DiscoverableMode;      // 0 - Non; 1 - Limtied; 2 - General
  uint16 DiscoverableDuration;  // unit 625 usec
  uint16 DiscoverableInterval;  // unit 625 usec
  uint16 ConnectableMode;       // 0 - Non; 1 - Connectable
  uint16 ConnectableDuration;   // unit 625 usec
  uint16 ConnectableInterval;   // unit 625 usec
  uint8  CodMinor;              // Class of Device - Minor device class
  uint8  CodMajor;              // Class of Device - Major device class
  uint16 CodServices;           // Class of Device - Service classes
} tSIG_AMPGapDeviceSetup;

// 0002 : SIG_AMP_GAP_START_INQUIRY
typedef struct tSIG_AMPGapStartInquiry {
  uint32  Transac;
  uint8   Length;
  uint8   NoOfResonses;
  bool    Limited;
  bool    FilterNewDevices;
  tCod    FilterCod;
  tCod    FilterCodMask;
  tBdAddr FilterBdAddr;
} tSIG_AMPGapStartInquiry;

// 0003: SIG_AMP_GAP_CANCEL_INQUIRY
typedef struct tSIG_AMPGapCancelInquiry {
  uint32 Transac;
} tSIG_AMPGapCancelInquiry;

// 0004: SIG_AMP_GAP_REMOTE_NAME_REQ
typedef struct tSIG_AMPGapRemoteNameReq {
  uint32  Transac;
  tBdAddr BdAddr;
} tSIG_AMPGapRemoteNameReq;

// 0005: SIG_AMP_GAP_SECURITY_SETUP
typedef struct tSIG_AMPGapSecuritySetup {
  uint32      Transac;
  uint8       PairableMode;         //  0 - Non; 1 - Connectable
  uint8       ConnectOnlyPaired;    //  takes 0 or 1
  uint8       SecurityMode;         //  1 - Non; 2 - Service Level; 3 - Link Level
  uint8       PinType;
  uint8       PinLength;
  uint8       FixedPin[AMP_SEC_PIN_LENGTH];
  uint16      MinEncrKeySize;
  uint16      KeyType;
  uint16      SignallingTaskId;
} tSIG_AMPGapSecuritySetup;

// 0006: SIG_AMP_GAP_PINCODE_REPLY
typedef struct tSIG_AMPGapPinCodeReply {
  uint32  Transac;
  tBdAddr BdAddr;
  uint8   PinLength;
  uint8   VariablePin[AMP_SEC_PIN_LENGTH];
  uint8   Response;
} tSIG_AMPGapPinCodeReply;

// 0007: SIG_AMP_CREATE_DEVICE_DATABASE
typedef struct tSIG_AMPCreateDeviceDatabase {
  uint32  Transac;
  uint8   DeviceClass[AMP_DEVICE_CLASS_LENGTH];
  uint8   DeviceName[AMP_DEVICE_NAME_LENGTH];
  uint32  TrustLevel;
  tKey    LinkKey;
  tBdAddr BdAddr;
  uint32  Flag;
} tSIG_AMPCreateDeviceDatabase;

// 0008: SIG_AMP_DELETE_DEVICE_DATABASE
typedef struct tSIG_AMPDeleteDeviceDatabase {
  uint32  Transac;
  tBdAddr BdAddr;
  uint32  Flag;
} tSIG_AMPDeleteDeviceDatabase;

// 0009: SIG_AMP_GAP_AUTHORIZE_RESPONSE
typedef struct tSIG_AMPGapAuthorizeResponse {
  uint32  Transac;
  tBdAddr BdAddr;
  uint8   Response;
} tSIG_AMPGapAuthorizeResponse;

// 0010: SIG_AMP_GAP_SETUP
typedef struct tSIG_AMPGapSetup {
  uint32              Transac;
  uint16              SignallingTaskId;
} tSIG_AMPGapSetup;

// 0011: SIG_AMP_GAP_RESET_REQ
// No paramaters


// 0012: SIG_AMP_GAP_READ_BD_ADDR_REQ
typedef struct tSIG_AMPReadBdAddressReq {
  uint32              Transac;
} tSIG_AMPReadBdAddressReq;

// 0013: SIG_AMP_GAP_BOND
typedef struct tSIG_AMPGapBond {
  uint32              Transac;
  tBdAddr             BdAddr;
  uint8               PinLength;
  uint8               Pin[AMP_SEC_PIN_LENGTH];
  uint32              ServiceTrustLevel;
} tSIG_AMPGapBond;

// 0014: SIG_AMP_READ_DEVICE_DATABASE
typedef struct tSIG_AMPReadDeviceDatabase {
  uint32              Transac;
} tSIG_AMPReadDeviceDatabase;

// 0015: SIG_AMP_HOLD_MODE
typedef struct tSIG_AMPHoldMode {
  uint32              Transac;
  tBdAddr             BdAddr;
  uint16              HoldMinInterval;
  uint16              HoldMaxInterval;
} tSIG_AMPHoldMode;

// 0016: SIG_AMP_SNIFF_MODE
typedef struct tSIG_AMPSniffMode {
  uint32              Transac;
  tBdAddr             BdAddr;
  uint16              SniffMinInterval;
  uint16              SniffMaxInterval;
  uint16              SniffAttempt;
  uint16              SniffTmo;
} tSIG_AMPSniffMode;

// 0017: SIG_AMP_EXIT_SNIFF_MODE
typedef struct tSIG_AMPExitSniffMode {
  uint32              Transac;
  tBdAddr             BdAddr;
} tSIG_AMPExitSniffMode;

// 0018: SIG_AMP_PARK_MODE
typedef struct tSIG_AMPParkMode {
  uint32              Transac;
  tBdAddr             BdAddr;
  uint16              BeaconMinPeriod;
  uint16              BeaconMaxPeriod;
} tSIG_AMPParkMode;

// 0019: SIG_AMP_EXIT_PARK_MODE
typedef struct tSIG_AMPExitParkMode {
  uint32              Transac;
  tBdAddr             BdAddr;
} tSIG_AMPExitParkMode;

// 0020: SIG_AMP_SWITCH_ROLE
typedef struct tSIG_AMPSwitchRole {
  uint32              Transac;
  tBdAddr             BdAddr;
  uint8               Role;
} tSIG_AMPSwitchRole;

// 0021: SIG_AMP_ADD_SCO
typedef struct tSIG_AMPAddSco {
  uint32             Transac;
  tBdAddr            BdAddr;
  uint16             Packet;
} tSIG_AMPAddSco;

// 0022: SIG_AMP_SETUP_SYNC
typedef struct tSIG_AMPSetupSync {
  uint32             Transac;
  tBdAddr            BdAddr;
  uint32             Tx_band;
  uint32             Rx_band;
  uint16             Latency;
  uint16             Voice;
  uint8              Retrans;
  uint16             Packet;
} tSIG_AMPSetupSync;

//==============================================================================
//  BTI GAP : GAP to API
//==============================================================================
// 0001: SIG_AMP_GAP_RESULT
typedef struct tSIG_AMPGapResult {
  uint32 Transac;
  uint32 ResultCode;
} tSIG_AMPGapResult;

// 0002: SIG_AMP_GAP_INQUIRY_RESULT
typedef struct tSIG_AMPGapInquiryResult {
  uint32              Transac;
  tBdAddr             BdAddr;
  tPageScanRepMode    PageScanRepMode;
  tPageScanPeriodMode PageScanPeriodMode;
  tPageScanMode       PageScanMode;
  tCod                Cod;
  tClkOffset          ClockOffset;
} tSIG_AMPGapInquiryResult;

// 0003: SIG_AMP_GAP_REMOTE_NAME_CON
typedef struct tSIG_AMPGapRemoteNameCon {
  uint32              Transac;
  tBdAddr             BdAddr;
  uint32              ResultCode;
  uint8               Name[LM_NAME_SIZE+1];
} tSIG_AMPGapRemoteNameCon;

// 0004: SIG_AMP_GAP_PIN_CODE_REQUEST
typedef struct tSIG_AMPGapPinCodeRequest {
  uint32              Transac;
  tBdAddr             BdAddr;
} tSIG_AMPGapPinCodeRequest;

// 0005: SIG_AMP_GAP_AUTHORIZE_REQUEST
typedef struct tSIG_AMPGapAuthorizeRequest {
  uint32              Transac;
  uint8               ServiceName[AMP_SERVICE_NAME_LENGTH];
  tBdAddr             BdAddr;
} tSIG_AMPGapAuthorizeRequest;

// 0006: SIG_AMP_GAP_ABORT_SECURITY
typedef struct tSIG_AMPGapAbortSecurity {
  uint32              Transac;
  tBdAddr             BdAddr;
} tSIG_AMPGapAbortSecurity;

// 0007: SIG_AMP_GAP_AUTH_COMPLETE
typedef struct tSIG_AMPGapAuthComplete {
  uint32              Transac;
  tBdAddr             BdAddr;
  int                 Status;
}tSIG_AMPGapAuthComplete;

// 0008: SIG_AMP_GAP_RESET_CON
typedef struct tSIG_AMPResetCon {
  uint32    Transac;
  uint16    CmdTokenNum;
  uint16    DataTokenNum;
  uint16    SPPMaxDataLen;
  uint16    ObexMaxDataLen;
}tSIG_AMPResetCon;


// 0010: SIG_AMP_GAP_READ_BD_ADDR_RES
typedef struct tSIG_AMPReadBdAddressRes {
  uint32              Transac;
  tBdAddr             BdAddr;
  uint32              ResultCode;
}tSIG_AMPReadBdAddressRes;

// 0011: SIG_AMP_GAP_DEVICE_DB_RESULT
typedef struct tSIG_AMPDeviceDBResult {
  uint32  Transac;
  uint8   DeviceClass[AMP_DEVICE_CLASS_LENGTH];
  uint8   DeviceName[AMP_DEVICE_NAME_LENGTH];
  uint32  TrustLevel;
  tKey    LinkKey;
  tBdAddr BdAddr;
}tSIG_AMPDeviceDBResult;

// 0012: SIG_AMP_GAP_LINK_KEY_NOTIFY
typedef struct tSIG_AMPGapLinkKeyNotify {
  uint32  Transac;
  tKey    LinkKey;
  tBdAddr BdAddr;
  uint8   KeyType;
} tSIG_AMPGapLinkKeyNotify;

// 0013: SIG_AMP_MODE_CHANGE_RESULT
typedef struct tSIG_AMPModeChangeResult {
  uint32  Transac;
  uint32  ResultCode;
  tBdAddr BdAddr;
  uint8   Mode;
  uint16  Interval;
} tSIG_AMPModeChangeResult;

// 0014: SIG_AMP_GAP_LL_CONN_DOWN
typedef struct tSIG_AMPGapLLConnDown {
  uint32  Transac;
  tBdAddr BdAddr;
}tSIG_AMPGapLLConnDown;

// 0013: SIG_AMP_SWITCH_ROLE_RESULT
typedef struct tSIG_AMPSwitchRoleResult {
  uint32  Transac;
  uint32  ResultCode;
  tBdAddr BdAddr;
  uint8   Role;
} tSIG_AMPSwitchRoleResult;

//==============================================================================
//  BTI SPP : API to SPP
//==============================================================================
// 0001: SIG_AMP_SPP_SEND
typedef struct tSIG_AMPSppSend {
  uint32              Transac;
  uint16              PortHandle;
  uint16              ByteSend;
  tBufferHeader       *pDataHdr;
} tSIG_AMPSppSend;


// 0002: SIG_AMP_SPP_LISTEN_REQ
typedef struct tSIG_AMPSppListenRequest {
  uint32              Transac;
  uint8               ServiceName[AMP_SERVICE_NAME_LENGTH];
  uint8               PortName[AMP_PORT_NAME_LENGTH];
} tSIG_AMPSppListenRequest;

// 0003: SIG_AMP_SPP_CONNECT_REQ
typedef struct tSIG_AMPSppConnectRequest {
  uint32              Transac;
  uint8               ServiceName[AMP_SERVICE_NAME_LENGTH];
  uint8               PortName[AMP_PORT_NAME_LENGTH];
  tBdAddr             BdAddr;
  uint32              ServiceId;
} tSIG_AMPSppConnectRequest;

// 0004: SIG_AMP_SPP_DISCONNECT_REQ
typedef struct tSIG_AMPSppDisconnectRequest {
  uint32              Transac;
  uint8               PortName[AMP_PORT_NAME_LENGTH];
  uint8               SppRole;       // Server is 1, Client is 0
} tSIG_AMPSppDisconnectRequest;

// 0005: SIG_AMP_SPP_SETUP
typedef struct tSIG_AMPSppSetup {
  uint32          Transac;
  uint16          SignallingTaskId;
  uint16          DataTaskId;
} tSIG_AMPSppSetup;

// 0007: SIG_AMP_SPP_GENERIC_LISTEN_REQ
typedef struct tSIG_AMPSppGenericListenRequest {
  uint32              Transac;
  uint8               ServiceName[AMP_SERVICE_NAME_LENGTH];
  uint8               PortName[AMP_PORT_NAME_LENGTH];
  uint8               ProfileId;
  uint8               ConfigOptions;
  uint8               SCN;
} tSIG_AMPSppGenericListenRequest;

// 0009: SIG_AMP_SPP_ADD_PORT_REQ
typedef struct tSIG_AMPSppGenericListenRequest tSIG_AMPSppAddPortRequest;

// 0003: SIG_AMP_SPP_GENERIC_CONNECT_REQ
typedef struct tSIG_AMPSppGenericConnectRequest {
  uint32              Transac;
  uint8               ServiceName[AMP_SERVICE_NAME_LENGTH];
  uint8               PortName[AMP_PORT_NAME_LENGTH];
  tBdAddr             BdAddr;
  uint8               ProfileId;
} tSIG_AMPSppGenericConnectRequest;

// 0010: SIG_AMP_SPP_SERVICE_REQ
typedef struct tSIG_AMPSppServiceRequest {
  uint32              Transac;
  uint8               ServiceName[AMP_SERVICE_NAME_LENGTH];
  uint8               ProfileId;
  uint8               ConfigOptions;
} tSIG_AMPSppServiceRequest;


//==============================================================================
//  BTI SPP : SPP to API
//==============================================================================
// 0001: SIG_AMP_SPP_RECV
typedef struct tSIG_AMPSppRecv {
  uint32              Transac;
  uint16              PortHandle;
  uint16              BytesRead;
  tBufferHeader       *pDataHdr;
} tSIG_AMPSppRecv;

// 0002: SIG_AMP_SPP_CONNECT_STATUS
typedef struct tSIG_AMPSppResultByPortHandle {
  uint32              Transac;
  uint16              Handle;
  uint16              Status;
} tSIG_AMPSppResultByPortHandle;

typedef struct tSIG_AMPSppResultByPortHandle tSIG_AMPSppConnectStatus;


// 0003: SIG_AMP_SPP_LISTEN_CON
typedef struct {
  uint32              Transac;
  uint8               PortName[AMP_PORT_NAME_LENGTH];
  uint16              Handle;
  uint16              Status;
  tBdAddr             BdAddr;
} tSIG_AMPSppListenCon, tSIG_AMPSppConnectCon;

//typedef struct tSIG_AMPSppResultByBothNameAndHandle tSIG_AMPSppListenCon;

// 0004: SIG_AMP_SPP_CONNECT_CON
//typedef struct tSIG_AMPSppResultByBothNameAndHandle tSIG_AMPSppConnectCon;

// 0005: SIG_AMP_SPP_DISCONNECT_IND
typedef struct tSIG_AMPSppResultByPortName {
  uint32              Transac;
  uint8               PortName[AMP_PORT_NAME_LENGTH];
  uint16              Status;
  uint8               SppRole;  // Server is 1, Client is 0
} tSIG_AMPSppResultByPortName;

typedef struct tSIG_AMPSppResultByPortName tSIG_AMPSppDisconnectInd;

// 0006: SIG_AMP_SPP_DISCONNECT_CON
typedef struct tSIG_AMPSppResultByPortName tSIG_AMPSppDisconnectCon;

// 0007: SIG_AMP_SPP_SETUP_RESULT
typedef struct tSIG_AMPSppSetupResult {
  uint32 Transac;
  uint32 ResultCode;
} tSIG_AMPSppSetupResult;

//==============================================================================
//  BTI DUN/FAX : APPLICATION to DUN/FAX
//==============================================================================
// 0001: SIG_AMP_DUN_LISTEN_REQ
typedef struct tSIG_AMPDunListenReq {
  uint32              Transac;
  uint8               ConfigOptions;
  uint16              ModemEventMask;
  uint8               ServiceName[AMP_SERVICE_NAME_LENGTH];
} tSIG_AMPDunListenReq;

// 0002: SIG_AMP_DUN_CONNECT_REQ
typedef struct tSIG_AMPDunConnectReq {
  uint32              Transac;
  uint8               ConfigOptions;
  uint16              ModemEventMask;
  uint8               ServiceName[AMP_SERVICE_NAME_LENGTH];
  tBdAddr             BdAddr;
} tSIG_AMPDunConnectReq;

// 0003: SIG_AMP_DUN_SEND_DATA_REQ
typedef struct tSIG_AMPDunSendDataReq {
  uint32              Transac;
  uint16              ByteSend;
  tBufferHeader       *pDataHdr;
} tSIG_AMPDunSendDataReq;

// 0004: SIG_AMP_DUN_CLOSE_REQ
typedef struct tSIG_AMPDunCloseReq {
  uint32              Transac;
} tSIG_AMPDunCloseReq;

// 0005: SIG_AMP_DUN_SHUTDOWN_REQ
typedef tSIG_AMPDunCloseReq tSIG_AMPDunShutdownReq;

// 0006: SIG_AMP_DUN_SETUP_REQ
typedef tSIG_AMPSppSetup tSIG_AMPDunSetupReq;

// 0007: SIG_AMP_DUN_FLOW_CONTROL_REQ
typedef struct tSIG_AMPDunFlowControlReq {
  uint32          Transac;
  bool            Enable;
} tSIG_AMPDunFlowControlReq;

//==============================================================================
//  BTI DUN : DUN to APPLICATION
//==============================================================================
// 0001: SIG_AMP_DUN_RESULT_IND
typedef tSIG_AMPSppSetupResult tSIG_AMPDunResultInd;

// 0002: SIG_AMP_DUN_OPEN_CON
typedef struct tSIG_AMPDunOpenCon
{
  uint32 Transac;
  tBdAddr  BdAddr;
}tSIG_AMPDunOpenCon;

// 0003: SIG_AMP_DUN_CLOSE_CON
typedef tSIG_AMPDunCloseReq tSIG_AMPDunCloseCon;

// 0004: SIG_AMP_DUN_RECV_IND
typedef struct tSIG_AMPDunRecvInd {
  uint32              Transac;
  uint16              BytesRead;
  tBufferHeader       *pDataHdr;
} tSIG_AMPDunRecvInd;

// 0005: SIG_AMP_DUN_MODEM_STATUS_IND
typedef struct tSIG_AMPDunModemStatusInd {
  uint32              Transac;
  uint32              Event;
}tSIG_AMPDunModemStatusInd;

// 0006: SIG_AMP_DUN_ERROR_IND
typedef struct tSIG_AMPDunErrorInd {
  uint32              Transac;
  uint16              ErrorCode;
}tSIG_AMPDunErrorInd;

// 0007: SIG_AMP_DUN_SETUP_RESULT_IND
typedef tSIG_AMPSppSetupResult tSIG_AMPDunSetupResultInd;

// 0008: SIG_AMP_DUN_FLOW_CONTROL_STATUS_IND
typedef tSIG_AMPDunFlowControlReq tSIG_AMPDunFlowControlStatusInd;


//==============================================================================
//  BTI LAP : API to LAP
//==============================================================================
// 0001: SIG_AMP_LAP_SEND
typedef struct tSIG_AMPSppSend tSIG_AMPLapSend;


// 0002: SIG_AMP_LAP_LISTEN_REQ
typedef struct tSIG_AMPSppListenRequest tSIG_AMPLapListenRequest;

// 0003: SIG_AMP_LAP_CONNECT_REQ
typedef struct tSIG_AMPSppConnectRequest tSIG_AMPLapConnectRequest;

// 0004: SIG_AMP_LAP_DISCONNECT_REQ
typedef struct tSIG_AMPSppDisconnectRequest  tSIG_AMPLapDisconnectRequest;

// 0005: SIG_AMP_LAP_SETUP
typedef struct tSIG_AMPSppSetup tSIG_AMPLapSetup;

//==============================================================================
//  BTI LAP : LAP to API
//==============================================================================
// 0001: SIG_AMP_LAP_RECV
typedef struct tSIG_AMPSppRecv  tSIG_AMPLapRecv;

// 0002: SIG_AMP_LAP_CONNECT_STATUS
typedef struct tSIG_AMPSppResultByPortHandle tSIG_AMPLapResultByPortHandle;

typedef struct tSIG_AMPSppResultByPortHandle tSIG_AMPLapConnectStatus;


// 0003: SIG_AMP_LAP_LISTEN_CON
typedef struct tSIG_AMPSppResultByBothNameAndHandle  tSIG_AMPLapResultByBothNameAndHandle;

typedef struct tSIG_AMPSppResultByBothNameAndHandle tSIG_AMPLapListenCon;

// 0004: SIG_AMP_LAP_CONNECT_CON
typedef struct tSIG_AMPSppResultByBothNameAndHandle tSIG_AMPLapConnectCon;

// 0005: SIG_AMP_LAP_DISCONNECT_IND
typedef struct tSIG_AMPSppResultByPortName  tSIG_AMPLapResultByPortName;

typedef struct tSIG_AMPSppResultByPortName tSIG_AMPLapDisconnectInd;

// 0006: SIG_AMP_LAP_DISCONNECT_CON
typedef struct tSIG_AMPSppResultByPortName tSIG_AMPLapDisconnectCon;

// 0007: SIG_AMP_LAP_SETUP_RESULT
typedef struct tSIG_AMPSppSetupResult tSIG_AMPLapSetupResult;


//==============================================================================
//  BTI PAN : BTI to PAN
//==============================================================================
// SIG_AMP_PAN_AMP_TO_API_BASE + 0001: SIG_AMP_PAN_LISTEN_REQUEST
// sizoef(tSIG_AMPPanListen)= 10 Bytes
typedef struct tSIG_AMPPanListenRequest{
  uint32              Transac;
  uint8               SrcUuid[16];
  uint16              Psm;
} tSIG_AMPPanListenRequest;


// SIG_AMP_PAN_AMP_TO_API_BASE + 0002: SIG_AMP_PAN_CONNECT_REQUEST
// sizoef(tSIG_AMPPanConnect)= 16 Bytes
typedef struct tSIG_AMPPanConnectRequest {
  uint32              Transac;
  tBdAddr             DstAddr;
  uint16              Psm;
  uint8               SrcUuid[16];
  uint8               DstUuid[16];
} tSIG_AMPPanConnectRequest;

// SIG_AMP_PAN_AMP_TO_API_BASE + 003: SIG_AMP_PAN_DISCONNECT_REQUEST
// sizoef(tSIG_AMPPanDisconnectRequest)= 6 Bytes
typedef struct tSIG_AMPPanDisconnectRequest {
  uint32              Transac;
  tBdAddr             DstAddr;
  uint16              ChannelId; // remove ?
} tSIG_AMPPanDisconnectRequest;

// SIG_AMP_PAN_AMP_TO_API_BASE + 004: SIG_AMP_PAN_UNITDATA_REQUEST
// sizoef(tSIG_AMPPanUnitDataRequest)= 12 Bytes
typedef struct tSIG_AMPPanUnitDataRequest {
  tSysBufHdr       *pBuf;
  uint32              Transac;
  //
  // stream the following variables into buffer area
  //
  //tBdAddr             DstAddr;
  //uint16              ChannelId;
  uint16              DataSize;
} tSIG_AMPPanUnitDataRequest;

//
// SIG_AMP_PAN_AMP_TO_API_BASE + 005: SIG_AMP_PAN_GET_BUF_REQUEST
// sizoef(tSIG_AMPPanGetBufRequest)= 8 Bytes
typedef struct tSIG_AMPPanGetBufRequest {
  uint32              Transac;
  uint32              BufSize;
}tSIG_AMPPanGetBufRequest;

// SIG_AMP_PAN_SETUP_REQUEST
typedef struct tSIG_AMPPanSetupRequest {
  uint32          Transac;
  uint16          SignallingTaskId;
  uint16          DataTaskId;
} tSIG_AMPPanSetupRequest;


//==============================================================================
//  BTI PAN : BNEP  to API
//==============================================================================

// SIG_AMP_PAN_API_TO_AMP_BASE + 0001: SIG_AMP_PAN_LISTEN_CONFIRM
// sizoef(tSIG_AMPPanListen)= 32 Bytes
typedef struct tSIG_AMPPanListenConfirm{
  uint32              Transac;
  uint8               DstUuid[16];
  uint16              Psm;     // remove ?
  uint16              Result;
  tBdAddr             DstAddr;
  uint16              ChannelId; // remove ?

} tSIG_AMPPanListenConfirm;

// SIG_AMP_PAN_API_TO_AMP_BASE + 002: SIG_AMP_PAN_CONNECT_CONFIRM
// sizoef(tSIG_AMPPanConnectConfirm)= 32 Bytes
typedef struct tSIG_AMPPanConnectConfirm {
  uint32              Transac;
  uint8               DstUuid[16];
  uint16              Psm;
  uint16              Result;
  tBdAddr             DstAddr;
  uint32              ChannelId;
} tSIG_AMPPanConnectConfirm;

// SIG_AMP_PAN_API_TO_AMP_BASE + 003: SIG_AMP_PAN_DISCONNECT_CONFIRM
// sizoef(tSIG_AMPPanDisconnectConfirm)= 8 Bytes
typedef struct tSIG_AMPPanDisconnectConfirm{
  uint32              Transac;
  tBdAddr             DstAddr;
  uint32              ChannelId;
  uint16              Result;
} tSIG_AMPPanDisconnectConfirm;

// SIG_AMP_PAN_API_TO_AMP_BASE + 004: SIG_AMP_PAN_DISCONNECT_INDICATION
// sizoef(tSIG_AMPPanEvent)= 4 Bytes
typedef struct tSIG_AMPPanDisconnectIndication{
  tBdAddr           DstAddr;
  uint32            ChannelId;
  uint16            Reason;
} tSIG_AMPPanDisconnectIndication;

// SIG_AMP_PAN_API_TO_AMP_BASE + 004: SIG_AMP_PAN_EVENT
// sizoef(tSIG_AMPPanEvent)= 4 Bytes
typedef struct tSIG_AMPPanEvent{
  tBdAddr           DstAddr;
  uint32            ChannelId;
  uint16            Event;
} tSIG_AMPPanEvent;

// SIG_AMP_PAN_API_TO_AMP_BASE + 005: SIG_AMP_PAN_UNITDATA_INDICATION
// sizoef(tSIG_AMPPanUnitDataIndication) = 8 bytes

typedef struct tSIG_AMPPanUnitDataIndication {
  tSysBufHdr         *pBuf;
  uint32              DataSize;
  tBdAddr             DstAddr;
  tBdAddr             SrcAddr;

  //tBufferHeader       *pDataHdr;
} tSIG_AMPPanUnitDataIndication;

// SIG_AMP_PAN_API_TO_AMP_BASE + 006: SIG_AMP_PAN_ERROR
// sizoef(tSIG_AMPPanError)= 4 Bytes
typedef struct tSIG_AMPPanError{
  uint32            Transac;
  uint16            ErrorCode;
} tSIG_AMPPanError;


//
// SIG_AMP_PAN_API_TO_AMP_BASE + 007: SIG_AMP_PAN_GET_BUF_CONFIRM
// sizoef(tSIG_AMPPanGetBufConfirm)= 8 Bytes
typedef struct tSIG_AMPPanGetBufConfirm{
  uint32              Transac;
  tBufferHeader       *pDataHdr;
}tSIG_AMPPanGetBufConfirm;

// SIG_AMP_PAN_SETUP_CONFIRM
typedef struct tSIG_AMPPanSetupConfirm {
  uint32 Transac;
  uint32 ResultCode;
} tSIG_AMPPanSetupConfirm;

//
// there might be send_data_response signal in future
// to tell when data is delivered to
// hci layer
//SIG_AMP_PAN_API_TO_AMP_BASE + 004
typedef struct tSIG_AMPPanSendDataConfirm{
  uint32 Transac;
  uint32 Status;
} tSIG_AMPPanSendDataConfirm;


//********************* Object Push Profile *********************************/
//==============================================================================
//  BTI OPP : API to OPP
//==============================================================================

// 0001: SIG_AMP_OPP_SETUP
typedef struct tSIG_AMPSppSetup tSIG_AMPOppSetup;


// ***************** Server Signals *********************************************

// 0002: SIG_AMP_OPP_SERVER_REGISTER_REQ
typedef struct tSIG_AMPOppServerRegisterReq
{
  uint32            Transac;
  uint16            SignallingTaskId;                     // (4 ,0 )
  uint8             ServiceNameLen;
  uint8             ServiceName[AMP_OPP_MAX_SERVICENAME_LEN+1];
  uint16            ProfileVersionNo;
  uint8             DataTypeCount;
  uint8             DataTypes[AMP_OPP_MAX_DATA_TYPES];
}tSIG_AMPOppServerRegisterReq;

// 0003: SIG_AMP_OPP_SERVER_PUSH_OBJECT_CON
typedef struct tSIG_AMPOppServerPushObjectCon
{
  uint32            Transac;
  uint32            ServerHandle;
  uint32            SessionHandle;
  uint8             RspCode;
}tSIG_AMPOppServerPushObjectCon;

// 0004: SIG_AMP_OPP_SERVER_PULL_OBJECT_CON
typedef struct tSIG_AMPOppServerPullObjectCon
{
  uint32            Transac;
  uint32            ServerHandle;
  uint32            SessionHandle;
  uint8             RspCode;
  bool              Final;
  uint32            BodyLen;
  uint8             Body[AMP_OPP_MAX_BODY_LEN];
  bool              TotalLengthPresent;
  uint32            TotalLength;
}tSIG_AMPOppServerPullObjectCon;


// 0005:  SIG_AMP_OPP_SERVER_UNREGISTER_REQ
typedef struct tSIG_AMPOppServerUnRegisterReq
{
  uint32            Transac;
  uint32            ServerHandle;
}tSIG_AMPOppServerUnRegisterReq;


// 0006:  SIG_AMP_OPP_SERVER_ABORT_CON
typedef struct tSIG_AMPOppServerAbortCon
{
  uint32            Transac;
  uint32            ServerHandle;
  uint32            Session_handle;
  uint8             ObexError;
  uint8             RspCode;
}tSIG_AMPOppServerAbortCon;


// 0007:  SIG_AMP_OPP_SERVER_CLOSE_CON
typedef struct tSIG_AMPOppServerAbortCon tSIG_AMPOppServerCloseCon;

// 0008:  SIG_AMP_OPP_SERVER_OPEN_CON
typedef struct tSIG_AMPOppServerOpenCon
{
  uint32            Transac;
  uint32            ServerHandle;
  uint32            Session_handle;
  uint8             ObexError;
  uint8             RspCode;
  uint16            Mtu;
}tSIG_AMPOppServerOpenCon;

// ********************** Client Signals ****************************************

// 0008:  SIG_AMP_OPP_CLIENT_OPEN_REQ
typedef struct tSIG_AMPOppClientOpenReq
{
  uint32            Transac;
  uint16            SignallingTaskId;
  uint8             Scn;      // Service channel number
  tBdAddr           DstAddr;  // Addr of the Object Push Server
}tSIG_AMPOppClientOpenReq;

// 0009:  SIG_AMP_OPP_CLIENT_PUSH_OBJECT_REQ
// Temp $$$-SK
// We assume all the data is given at one short here. No segmentation needed
typedef struct tSIG_AMPOppClientPushObjectReq
{
  uint32            Transac;
  uint32            ClientHandle;
	uint32            SessionHandle;
	bool              Final;                       // Currently we should not use this
  uint32            NameLength;
  uint8             Name[AMP_OPP_MAX_NAME_LEN+1];
  uint32            BodyLen;
	uint8             Body[AMP_OPP_MAX_BODY_LEN];
  bool              TotalLengthPresent;
  uint32            TotalLength;
}tSIG_AMPOppClientPushObjectReq;

// 0010:  SIG_AMP_OPP_CLIENT_PULL_OBJECT_REQ
typedef struct tSIG_AMPOppClientPullObjectReq
{
  uint32            Transac;
  uint32            ClientHandle;
	uint32            SessionHandle;
	uint8             DataType;
}tSIG_AMPOppClientPullObjectReq;

// 0011:  SIG_AMP_OPP_CLIENT_EXCHANGE_OBJECTS_REQ
typedef struct tSIG_AMPOppClientExchangeObjectReq
{
  uint32            Transac;

}tSIG_AMPOppClientExchangeObjectReq;


// 0012:  SIG_AMP_OPP_CLIENT_ABORT_REQ
typedef struct tSIG_AMPOppClientAbortReq
{
  uint32            Transac;
  uint32            ClientHandle;
	uint32            SessionHandle;
}tSIG_AMPOppClientAbortReq;

// 0013:  SIG_AMP_OPP_CLIENT_CLOSE_REQ
typedef struct tSIG_AMPOppClientAbortReq tSIG_AMPOppClientCloseReq;




//==============================================================================
//  OPP : BTI to API


// 0001:  SIG_AMP_OPP_SETUP_RESULT
typedef struct tSIG_AMPOppResult {
  uint32 Transac;
  uint32 ResultCode;
  uint32 ObexStatus;
}tSIG_AMPOppResult;

// ******************** Server signals *****************************************

// 0002:  SIG_AMP_OPP_SERVER_PUSH_OBJECT_IND
// $$$-SK
// Application will do the assembly of the data. The reason behind this we do not
// know how much memory we need to pre-allocate to do the assembly and right now
// the max we can get is 400 bytes.
typedef struct tSIG_AMPOppServerPushObjectInd
{
  uint32            Transac;
  uint32            ServerHandle;
	uint32            SessionHandle;
	bool              Final;
  bool              TotalLengthPresent;
  uint32            TotalLength;
  uint32            NameLength;
  uint8             Name[AMP_OPP_MAX_NAME_LEN+1];
  uint32            BodyLen;
	uint8             Body[AMP_OPP_MAX_BODY_LEN];

}tSIG_AMPOppServerPushObjectInd;


// 0003:  SIG_AMP_OPP_SERVER_PULL_OBJECT_IND
typedef struct tSIG_AMPOppServerPullObjectInd
{
  uint32            Transac;
  uint32            ServerHandle;
	uint32            SessionHandle;
	uint8             DataType;
}tSIG_AMPOppServerPullObjectInd;


// 0004:  SIG_AMP_OPP_SERVER_ABORT_IND
typedef struct tSIG_AMPOppServerAbortInd
{
  uint32            Transac;
  uint32            ServerHandle;
	uint32            SessionHandle;
}tSIG_AMPOppServerAbortInd;


// 0005:  SIG_AMP_OPP_SERVER_CLOSE_IND
typedef struct tSIG_AMPOppServerAbortInd tSIG_AMPOppServerCloseInd;

// 0006:  SIG_AMP_OPP_SERVER_UNREGISTER_RSP
typedef struct tSIG_AMPOppServerUnRegisterRsp
{
  uint32            Transac;
  uint32            ResultCode;
  uint32            ObexStatus;
  uint32            ServerHandle;
}tSIG_AMPOppServerUnRegisterRsp;

// 0007:  SIG_AMP_OPP_SERVER_REGISTER_RSP
typedef struct tSIG_AMPOppServerRegisterRsp
{
  uint32            Transac;
  uint32            ResultCode;
  uint32            ObexStatus;
  uint32            SdpHandle;
  uint32            ServerHandle;
}tSIG_AMPOppServerRegisterRsp;


// 0008:  SIG_AMP_OPP_SERVER_OPEN_IND
// sizoef(tSIG_AMPOppServerOpenInd)= 37 Bytes
typedef struct tSIG_AMPOppServerOpenInd
{
  uint32            Transac;
  uint32            ServerHandle;
	uint32            SessionHandle;
  uint16            Mtu;
}tSIG_AMPOppServerOpenInd;


// ******************** Client Signals ******************************************

// 0008:  SIG_AMP_OPP_CLIENT_PUSH_OBJECT_RSP
// sizoef(tSIG_AMPOppClientPushObjectRsp)= 37 Bytes
typedef struct tSIG_AMPOppClientPushObjectRsp
{
  uint32            Transac;
  uint32            ClientHandle;
  uint32            SessionHandle;
  uint8             ObexError;
  uint8             RspCode;
  uint32            DescrLength;
  uint8             Description[AMP_OPP_MAX_DESC_LEN+1];
}tSIG_AMPOppClientPushObjectRsp;

// 0009:  SIG_AMP_OPP_CLIENT_PULL_OBJECT_RSP
// sizoef(tSIG_AMPOppClientPullObjectRsp)= 37 Bytes
typedef struct tSIG_AMPOppClientPullObjectRsp
{
  uint32            Transac;
  uint32            ClientHandle;
  uint32            SessionHandle;
  uint8             ObexError;
  uint8             RspCode;
	bool              Final;
  uint32            DescrLength;
  uint8             Description[AMP_OPP_MAX_DESC_LEN+1];
  uint32            NameLength;
  uint8             Name[AMP_OPP_MAX_NAME_LEN+1];
  bool              TotalLengthPresent;
  uint32            TotalLength;
  uint32            BodyLen;
	uint8             Body[AMP_OPP_MAX_BODY_LEN];
}tSIG_AMPOppClientPullObjectRsp;

// 0010:  SIG_AMP_OPP_CLIENT_EXCHANGE_OBJECTS_RSP
// sizoef(tSIG_AMPOppClientExchangeObjectRsp)= 37 Bytes
typedef struct tSIG_AMPOppClientExchangeObjectRsp
{
  uint32            Transac;
}tSIG_AMPOppClientExchangeObjectRsp;

// 0011:  SIG_AMP_OPP_CLIENT_ABORT_RSP
// sizoef(tSIG_AMPOppClientAbortRsp)= 37 Bytes
typedef struct tSIG_AMPOppClientPushObjectRsp tSIG_AMPOppClientAbortRsp;

// 0012:  SIG_AMP_OPP_CLIENT_CLOSE_RSP
// sizoef(tSIG_AMPOppClientCloseRsp)= 37 Bytes
typedef struct tSIG_AMPOppClientPushObjectRsp tSIG_AMPOppClientCloseRsp;

// 0013:  SIG_AMP_OPP_CLIENT_OPEN_RSP
// sizoef(tSIG_AMPOppClientOpenRsp)= 37 Bytes
typedef struct tSIG_AMPOppClientPushObjectRsp tSIG_AMPOppClientOpenRsp;

//********************* Service Discovery Application Profile *********************************/
//==============================================================================
//  BTI SDAP : BTI to SDAP API
//==============================================================================

// $$$ - SB: The signal interface for sdap needs to be changed after upf-6.
// 0001: SIG_AMP_SDAP_SETUP
// sizoef(tSIG_AMPSDAPSetup)= 8 Bytes
typedef struct tSIG_AMPGapSetup tSIG_AMPSdapSetup;

// 0002: SIG_AMP_SDAP_SERVICE_SEARCH_REQ
// sizoef(tSIG_AMPSdapServiceSearchReq)= 37 Bytes
typedef struct tSIG_AMPSdapServiceSearchReq
{
  uint32            Transac;
  tBdAddr           BdAddr[AMP_NUM_BD_ADDRESSES];
  uint16            ServiceClass[AMP_SDAP_MAX_SERVICE_CLASS];
  uint16            AttributeId;
  /*
	//uint8		          TypeOfDevice;
  //uint32        		NumberOfSeconds;
  //uint32            NumberOfServiceClasses;
  //uint32            NumberOfKnownServiceClasses;
  //uint32            NumberOfUnknownServiceClasses;
	//uint16          	LanguageBaseId;
  //uint32            NumberOfUnknownAttributes;
  //uint16            KnownAttributes[AMP_SDAP_KNOWN_ATTRIBUTES];
  */
}tSIG_AMPSdapServiceSearchReq;


typedef struct tSIG_AMPSdapEnumerateRemDevReq
{
	/* Class of Device filtering type */
  uint32            Transac;
	uint8		CodFilter;			/* Indicates what CoD filters to use */
  uint8   MajorDevClass_Cod;  // only least significant 5 bits are used
  uint8   MinorDevClass_Cod;  // only least significant 6 bits are used
  uint16  MajorServClass_Cod; // Only least significant 11 bits are used


	bool		LimitedInq;		/* TRUE = search for devices in limited
										discovery mode */

	/* Stop Rules */
	uint32	NumDevices;		/* This indicates the maximum number of
										devices to return */
	uint32	NumSeconds;		/* This indicates the maximum number of
										seconds (approximately) that SDAP
										should spend searching for devices */

	/* Misc Parameters */
	bool		WantDevName;		/* If set, SDAP will return the device
										name to the calling application
										*/
} tSIG_AMPSdapEnumerateRemDevReq;

typedef struct tSIG_AMPSdapRemDevListConsumed
{
  uint32  Transac;
  uint8   Status;
}tSIG_AMPSdapRemDevListConsumed;


typedef struct tSIG_AMPSaveReconnectInfo
{
  tBdAddr  BdAddr;
  uint16 PortHandle;
}tSIG_AMPSaveReconnectInfo;

/*
typedef struct tSIG_ReconnectInfo
{
  tBdAddr  BdAddr;
  char     ServiceName[AMP_SERVICE_NAME_LENGTH];
  uint8    ProfileID;
} tSIG_ReconnectInfo;
*/

//==============================================================================
//  BTI SDAP : SDAP API to BTI

// 0001:  SIG_AMP_SDAP_RESULT
typedef struct tSIG_AMPGapResult tSIG_AMPSdapResult;

// 0002: SIG_AMP_SDAP_SERVICE_SEARCH_CON
// sizoef(tSIG_AMPSdapServiceSearchReq)= 37 Bytes
typedef struct tSIG_AMPSdapServiceSearchCon
{
  uint32            Transac;
  uint16            Status;
  tBdAddr           BdAddr;
  uint16            ServiceClass;
  uint16            DeviceClass;
  uint8             MajorDeviceClass;
  uint8             MinorDeviceClass;
  uint32        		NumberOfProtocolDescriptor;
  uint32            ProtocolDescriptor; //BitMap of Protocols
  uint16            L2CapPsm;
  uint8             RfcommScn;
  uint8             ServiceName[AMP_SERVICE_NAME_LENGTH];
//  uint32      			NumberSupportedFormats;
//  uint8             SupportedFormats[BTI_OPP_SUPPORTED_FORMATS];
}tSIG_AMPSdapServiceSearchCon;

typedef struct tRemDev
{
  tBdAddr             BdAddr;
  uint16              ServiceClass;
  uint8               MajorDeviceClass;
  uint8               MinorDeviceClass;
  uint16              DevNameLen;
  uint8               DevName[AMP_MAX_DEV_NAME_LEN];
}tRemDev;



typedef struct tSIG_AMPSdapRemDevListCon
{
  uint32            Transac;
  uint16            Status;
  uint8             NumDevices;
  tRemDev           RemDevList[AMP_MAX_REM_DEV];
}tSIG_AMPSdapRemDevListCon;


typedef struct tSIG_AMP_GPIO_Interrupt
{
  uint32            Transac;
  uint16            Source;
  bool              Value;
}tSIG_AMP_GPIO_Interrupt;


#endif //OS_BTISTRUCT_H
//------------------------------------------------------------------------------
// End of OS_BTIStruct.h
