blob: ce60e6b97bd0db5331823463e7b526de50ba5de3 [file] [log] [blame]
/**
* @file accessManager.h
* @author NXP Semiconductors
* @version 1.0
* @par License
*
* Copyright 2017,2020 NXP
* SPDX-License-Identifier: Apache-2.0
*
* @par Description
*
* @par History
*
*****************************************************************************/
#include "sm_types.h"
// #define AM_LOCK_UNLOCK_SUPPORT // Lock / Unlock support is not available, do NOT define
#define SERVERPORT 8040
#define MSG_SIZE 2048
#define MSG_HEADER_SIZE 4
// General Message Format
//
// [MTY]:[NAD]:[LNH]:[LNL]:[D0]:...[Dn]
// MTY: Message Type
#define MTY_WAIT_FOR_CARD 0x00
#define MTY_APDU_DATA 0x01
#define MTY_STATUS 0x02
#define MTY_ERROR_MSG 0x03
#define MTY_TERMINAL_INFO 0x04
#define MTY_INITIALIZATION_DATA 0x05
#define MTY_INFORMATION_TEXT 0x06
#define MTY_DEBUG_INFORMATION 0x07
// Additionaly defined
// Lock/Unlock command: Reserve/Release access to node to calling client
#define MTY_LOCK 0x30
#define MTY_UNLOCK 0x31
// Development commands
#define MTY_SET_UINT32 0x40
#define MTY_GET_UINT32 0x41
#ifndef NDEBUG
#define MTY_QUIT 0x50
#endif
// NAD: Node adres
// For now always 0x00
// LNH: MSB of data payload length
// LNL: LSB of data payload length
// D0 .. Dn: Optional data payload
// Specific Message Formats
// MTY_LOCK
// CMD: [MTY_LOCK]:[0x00]:[0x00]:[0x00|0x04]:{NULL}|{Timeout_in_ms(4 byte) NOT_IMPLEMENTED}
// RSP:
// In case of failure: [MTY_LOCK]:[0x00]:[0x00]:[0x01]:[failure_cause] (NOT_IMPLEMENTED)
// In case of success: [MTY_LOCK]:[0x00]:[0x00]:[0x00]
//
// MTY_UNLOCK
// CMD: [MTY_UNLOCK]:[0x00]:[0x00]:[0x00]
// RSP: [MTY_UNLOCK]:[0x00]:[0x00]:[0x00]
//
// MTY_SET_UINT32
// CMD: [MTY_SET_UINT32]:[0x00]:[0x00]:[0x05]:[idx]:{Value (4 byte)}
// RSP:
// In case of failure: [MTY_SET_UINT32]:[0x00]:[0x00]:[0x00]
// In case of success: [MTY_SET_UINT32]:[0x00]:[0x00]:[0x05]:[idx]:{Value (4 byte)}
//
// MTY_GET_UINT32
// CMD: [MTY_GET_UINT32]:[0x00]:[0x00]:[0x01]:[idx]
// RSP
// In case of failure: [MTY_SET_UINT32]:[0x00]:[0x00]:[0x00]
// In case of success: [MTY_SET_UINT32]:[0x00]:[0x00]:[0x05]:[idx]:{Value (4 byte)}
// MTY_QUIT // Only Enabled in Debug build
// CMD: [MTY_QUIT]:[0x00]:[0x00]:[0x00]
// RSP: [MTY_QUIT]:[0x00]:[0x00]:[0x00]
#define MTY_IDX 0
#define NAD_IDX 1
#define LNH_IDX 2
#define LNL_IDX 3
#define DATA_START_IDX 4
#define MCS_OK 0
#define MCS_SOCKET_FAILURE 2
#define MCS_MSG_MISMATCH 3
int handleSetUint32(uint8_t *cmdBuffer, int cmdBufferLen, uint8_t *rspBuffer, int *rspBufferLen);
int handleGetUint32(uint8_t *cmdBuffer, int cmdBufferLen, uint8_t *rspBuffer, int *rspBufferLen);
#define AM_OK 0x0000
#define AM_ARG_FAIL 0x6000
U16 amPackageApduResponse(U8 messageType, U8 nodeAddress, U8 *payload, U16 payloadLen, U8 *targetBuf, U16 *targetBufLen);