Skip to content

Commit

Permalink
fixing quality issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Strooom committed Oct 29, 2024
1 parent de69d51 commit 21280d4
Show file tree
Hide file tree
Showing 14 changed files with 256 additions and 273 deletions.
221 changes: 220 additions & 1 deletion backup/ncilegacy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1326,4 +1326,223 @@
// static void printRfProtocol(const uint8_t theProtocol);
// static void printState(const nciState theState);
// static void printDeactivationType(const NciRfDeAcivationMode theMode);
// static void printDeactivationReason(const uint8_t theReason);
// static void printDeactivationReason(const uint8_t theReason);


// RF_DISCOVER_MAP_CMD = 0x00,
// RF_DISCOVER_MAP_RSP = 0x00,

// RF_SET_LISTEN_MODE_ROUTING_CMD = 0x01

// #define RF_SET_LISTEN_MODE_ROUTING_CMD 0x01
// #define RF_SET_LISTEN_MODE_ROUTING_RSP 0x01

// #define RF_GET_LISTEN_MODE_ROUTING_CMD 0x02
// #define RF_GET_LISTEN_MODE_ROUTING_RSP 0x02
// #define RF_GET_LISTEN_MODE_ROUTING_NTF 0x02

// #define RF_DISCOVER_CMD 0x03
// #define RF_DISCOVER_RSP 0x03
// #define RF_DISCOVER_NTF 0x03

// #define RF_DISCOVER_SELECT_CMD 0x04
// #define RF_DISCOVER_SELECT_RSP 0x04

// #define RF_INTF_ACTIVATED_NTF 0x05

// #define RF_DEACTIVATE_CMD 0x06
// #define RF_DEACTIVATE_RSP 0x06
// #define RF_DEACTIVATE_NTF 0x06

// #define RF_FIELD_INFO_NTF 0x07

// #define RF_T3T_POLLING_CMD 0x08
// #define RF_T3T_POLLING_RSP 0x08
// #define RF_T3T_POLLING_NTF 0x08
// #define RF_NFCEE_ACTION_NTF 0x09
// #define RF_NFCEE_DISCOVERY_REQ_NTF 0x0A
// #define RF_PARAMETER_UPDATE_CMD 0x0B
// #define RF_PARAMETER_UPDATE_RSP 0x0B
// // 1100b - 1111b RFU

// #define NFCEE_DISCOVER_CMD 0x00
// #define NFCEE_DISCOVER_RSP 0x00
// #define NFCEE_DISCOVER_NTF 0x00
// #define NFCEE_MODE_SET_CMD 0x01
// #define NFCEE_MODE_SET_RSP 0x01
// // 0010b - 1111b RFU

// #define NCI_PROPRIETARY_ACT_CMD 0x02 // See PN7150 Datasheet, section 5.4
// #define NCI_PROPRIETARY_ACT_RSP 0x02 // See PN7150 Datasheet, section 5.4, Table 23 and 24




// ---------------------------------------------------
// NCI Status Codes. NCI Specification V1.0 - Table 94
// ---------------------------------------------------

// Generic Status Codes
#define STATUS_OK 0x00
#define STATUS_REJECTED 0x01
#define STATUS_RF_FRAME_CORRUPTED 0x02
#define STATUS_FAILED 0x03
#define STATUS_NOT_INITIALIZED 0x04
#define STATUS_SYNTAX_ERROR 0x05
#define STATUS_SEMANTIC_ERROR 0x06
// 0x07 � 0x08 RFU
#define STATUS_INVALID_PARAM 0x09
#define STATUS_MESSAGE_SIZE_EXCEEDED 0x0A
// 0x0B - 0x9F RFU

// RF Discovery Specific Status Codes
#define DISCOVERY_ALREADY_STARTED 0xA0
#define DISCOVERY_TARGET_ACTIVATION_FAILED 0xA1
#define DISCOVERY_TEAR_DOWN 0xA2
// 0xA3 - 0xAF RFU

// RF Interface Specific Status Codes
#define RF_TRANSMISSION_ERROR 0xB0
#define RF_PROTOCOL_ERROR 0xB1
#define RF_TIMEOUT_ERROR 0xB2
// 0xB3 - 0xBF RFU

// NFCEE Interface Specific Status Codes
#define NFCEE_INTERFACE_ACTIVATION_FAILED 0xC0
#define NFCEE_TRANSMISSION_ERROR 0xC1
#define NFCEE_PROTOCOL_ERROR 0xC2
#define NFCEE_TIMEOUT_ERROR 0xC3
// 0xC4 - 0xDF RFU

// Proprietary Status Codes : 0xE0 - 0xFF

// ------------------------------------------------------
// NCI RF Technologies. NCI Specification V1.0 - Table 95
// ------------------------------------------------------

#define NFC_RF_TECHNOLOGY_A 0x00
#define NFC_RF_TECHNOLOGY_B 0x01
#define NFC_RF_TECHNOLOGY_F 0x02
#define NFC_RF_TECHNOLOGY_15693 0x03
// 0x04 � 0x7F RFU
// 0x80 - 0xFE For proprietary use
// 0xFF RFU

// -------------------------------------------------------------
// NCI RF Technology and Mode. NCI Specification V1.0 - Table 96
// -------------------------------------------------------------

#define NFC_A_PASSIVE_POLL_MODE 0x00
#define NFC_B_PASSIVE_POLL_MODE 0x01
#define NFC_F_PASSIVE_POLL_MODE 0x02
#define NFC_A_ACTIVE_POLL_MODE 0x03
// RFU 0x04
#define NFC_F_ACTIVE_POLL_MODE 0x05
#define NFC_15693_PASSIVE_POLL_MODE 0x06
// 0x07 � 0x6F RFU
// 0x70 � 0x7F Reserved for Proprietary Technologies in Poll Mode
#define NFC_A_PASSIVE_LISTEN_MODE 0x80
#define NFC_B_PASSIVE_LISTEN_MODE 0x81
#define NFC_F_PASSIVE_LISTEN_MODE 0x82
#define NFC_A_ACTIVE_LISTEN_MODE 0x83
// RFU 0x84
#define NFC_F_ACTIVE_LISTEN_MODE 0x85
#define NFC_15693_PASSIVE_LISTEN_MODE 0x86
// 0x87 � 0xEF RFU
// 0xF0 � 0xFF Reserved for Proprietary Technologies in Listen Mode

// ---------------------------------------------------
// NCI RF Protocols. NCI Specification V1.0 - Table 98
// ---------------------------------------------------

#define PROTOCOL_UNDETERMINED 0x00
#define PROTOCOL_T1T 0x01
#define PROTOCOL_T2T 0x02
#define PROTOCOL_T3T 0x03
#define PROTOCOL_ISO_DEP 0x04
#define PROTOCOL_NFC_DEP 0x05
// 0x06 � 0x7F RFU
// 0x80-0xFE For proprietary use
// 0xFF RFU

// -----------------------------------------------------
// NCI RF Interfacess. NCI Specification V1.0 - Table 99
// -----------------------------------------------------

#define NFCEE_Direct_RF_Interface 0x00
#define Frame_RF_interface 0x01
#define ISO_DEP_RF_interface 0x02
#define NFC_DEP_RF_interface 0x03
// 0x04 � 0x7F RFU
// 0x80 - 0xFE For proprietary use
// 0xFF RFU

// ---------------------------------------------------------------
// NFCEE Protocol / Interfaces. NCI Specification V1.0 - Table 100
// ---------------------------------------------------------------

#define APDU 0x00
#define HCI Access 0x01
#define Type 3 Tag Command Set 0x02
#define Transparent 0x03
// 0x04 - 0x7F RFU
// 0x80 - 0xFE For proprietary use
// 0xFF RFU

// --------------------------------------------
// Bit Rates. NCI Specification V1.0 - Table 97
// --------------------------------------------

#define NFC_BIT_RATE_106 0x00
#define NFC_BIT_RATE_212 0x01
#define NFC_BIT_RATE_424 0x02
#define NFC_BIT_RATE_848 0x03
#define NFC_BIT_RATE_1695 0x04
#define NFC_BIT_RATE_3390 0x05
#define NFC_BIT_RATE_6780 0x06
// 0x07 � 0x7F RFU
// 0x80 - 0xFE For proprietary use
// 0xFF RFU

// ----------------------------------------------------------------------
// Dectivation Types for RF_DEACTIVATE_ NCI Specification V1.0 - Table 63
// ----------------------------------------------------------------------

enum class NciRfDeAcivationMode : uint8_t {
IdleMode = 0x00,
SleepMode = 0x01,
Sleep_AFMode = 0x02,
Discovery = 0x03
// 0x04 � 0xFF RFU
};

// ----------------------------------------------------------------------
// Dectivation Reason RF_DEACTIVATE_NTF NCI Specification V1.0 - Table 64
// ----------------------------------------------------------------------

#define DH_Request 0x00
#define Endpoint_Request 0x01
#define RF_Link_Loss 0x02
#define NFC_B_Bad_AFI 0x03
// 0x04 � 0xFF RFU

/* Discovery Types/Detected Technology and Mode */
#define NCI_DISCOVERY_TYPE_POLL_A 0x00
#define NCI_DISCOVERY_TYPE_POLL_B 0x01
#define NCI_DISCOVERY_TYPE_POLL_F 0x02
#define NCI_DISCOVERY_TYPE_POLL_A_ACTIVE 0x03
#define NCI_DISCOVERY_TYPE_POLL_F_ACTIVE 0x05
#define NCI_DISCOVERY_TYPE_POLL_ISO15693 0x06

enum class notificationType : uint8_t {
lastNotification = 0x00,
lastNotificationNfccLimit = 0x01,
moreNotification = 0x02
// 3 - 255 RFU
};

// ------------------------------------------------------------------------------------------
// NFC Requires the device to behave according to a certain State Machine.
// Furthermore the NCI protocol consists of Commands, to be followed by Responses
// All this behaviour is implemented with a Finite State Machine, with following states
// ------------------------------------------------------------------------------------------
6 changes: 3 additions & 3 deletions lib/nci/nci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void nci::run() {
case nciState::waitForResetDone:
if (responseTimeoutTimer.expired()) {
static constexpr uint32_t payloadLength{1};
uint8_t payloadData[payloadLength] = {ResetKeepConfig};
uint8_t payloadData[payloadLength] = {resetKeepConfig};
sendMessage(messageType::Command, groupIdentifier::Core, opcodeIdentifier::CORE_RESET_CMD, payloadData, payloadLength);
responseTimeoutTimer.start(standardResponseTimeout);
moveState(nciState::waitForCoreResetResponse);
Expand Down Expand Up @@ -276,8 +276,8 @@ bool nci::checkMessageStatus(const uint8_t receivedStatus) {
return (receivedStatus == static_cast<uint8_t>(nciStatus::ok));
}

void nci::dumpRawMessage(const uint8_t msgBuffer[], const uint8_t length) {
for (uint8_t index = 0; index < length; index++) {
void nci::dumpRawMessage(const uint8_t msgBuffer[], const uint32_t length) {
for (uint32_t index = 0; index < length; index++) {
logging::snprintf("%02X ", msgBuffer[index]);
}
logging::snprintf("\n");
Expand Down
Loading

0 comments on commit 21280d4

Please sign in to comment.