mirror of
https://github.com/RfidResearchGroup/ChameleonMini.git
synced 2026-05-12 11:20:37 -07:00
Add Framework for autocalibrate of Sniffing Mode
(cherry picked from commit c8606be)
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include "MifareUltralight.h"
|
||||
#include "MifareClassic.h"
|
||||
#include "Reader14443A.h"
|
||||
#include "Sniff14443A.h"
|
||||
|
||||
/* Function wrappers */
|
||||
INLINE void ApplicationInit(void) {
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
//
|
||||
// Created by Zitai Chen on 25/07/2018.
|
||||
// Application layer for sniffing
|
||||
// Currently only support Autocalibrate
|
||||
//
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <LED.h>
|
||||
#include "Sniff14443A.h"
|
||||
Sniff14443Command Sniff14443CurrentCommand = Sniff14443_Do_Nothing;
|
||||
|
||||
extern bool checkParityBits(uint8_t * Buffer, uint16_t BitCount);
|
||||
static enum {
|
||||
STATE_IDLE,
|
||||
STATE_READER_DATA,
|
||||
STATE_CARD_DATA
|
||||
} SniffState = STATE_IDLE;
|
||||
|
||||
void Sniff14443AAppInit(void){
|
||||
SniffState = STATE_IDLE;
|
||||
}
|
||||
|
||||
void Sniff14443AAppReset(void){
|
||||
SniffState = STATE_IDLE;
|
||||
Sniff14443CurrentCommand = Sniff14443_Do_Nothing;
|
||||
}
|
||||
// Currently APPTask and AppTick is not being used
|
||||
void Sniff14443AAppTask(void){/* Empty */}
|
||||
void Sniff14443AAppTick(void){/* Empty */}
|
||||
|
||||
void Sniff14443AAppTimeout(void){
|
||||
Sniff14443AAppReset();
|
||||
}
|
||||
|
||||
uint16_t Sniff14443AAppProcess(uint8_t* Buffer, uint16_t BitCount){
|
||||
switch (Sniff14443CurrentCommand){
|
||||
case Sniff14443_Do_Nothing:
|
||||
return 0;
|
||||
case Sniff14443_Autocalibrate:
|
||||
// If received Reader WUPA
|
||||
if(Buffer[0] == 0x26 || Buffer[0] == 0x54){
|
||||
LED_PORT.OUTSET = LED_RED;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// Created by Zitai Chen on 25/07/2018.
|
||||
//
|
||||
|
||||
#ifndef CHAMELEON_MINI_SNIFF14443A_H
|
||||
#define CHAMELEON_MINI_SNIFF14443A_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void Sniff14443AAppInit(void);
|
||||
void Sniff14443AAppReset(void);
|
||||
void Sniff14443AAppTask(void);
|
||||
void Sniff14443AAppTick(void);
|
||||
void Sniff14443AAppTimeout(void);
|
||||
|
||||
uint16_t Sniff14443AAppProcess(uint8_t* Buffer, uint16_t BitCount);
|
||||
|
||||
typedef enum {
|
||||
Sniff14443_Do_Nothing,
|
||||
Sniff14443_Autocalibrate,
|
||||
} Sniff14443Command;
|
||||
|
||||
#endif //CHAMELEON_MINI_SNIFF14443A_H
|
||||
|
||||
@@ -261,8 +261,6 @@ ISR(CODEC_TIMER_SAMPLING_CCD_VECT) {
|
||||
|
||||
INLINE void CardSniffInit(void)
|
||||
{
|
||||
LED_PORT.OUTSET = LED_RED;
|
||||
|
||||
|
||||
/* Initialize common peripherals and start listening
|
||||
* for incoming data. */
|
||||
@@ -326,8 +324,6 @@ INLINE void CardSniffInit(void)
|
||||
|
||||
INLINE void CardSniffDeinit(void)
|
||||
{
|
||||
LED_PORT.OUTCLR = LED_RED;
|
||||
|
||||
|
||||
CODEC_TIMER_LOADMOD.CTRLA = 0;
|
||||
CODEC_TIMER_LOADMOD.INTCTRLB = 0;
|
||||
@@ -518,18 +514,17 @@ void Sniff14443ACodecTask(void)
|
||||
if(Flags.ReaderDataAvaliable){
|
||||
Flags.ReaderDataAvaliable = false;
|
||||
LogEntry(LOG_INFO_CODEC_SNI_READER_DATA, CodecBuffer, (ReaderBitCount+7)/8);
|
||||
// ReaderBitCount = 0;
|
||||
ApplicationProcess(CodecBuffer, (ReaderBitCount+7)/8);
|
||||
LEDHook(LED_CODEC_RX, LED_PULSE);
|
||||
}
|
||||
|
||||
|
||||
if (Flags.CardDataAvaliable){
|
||||
Flags.CardDataAvaliable = false;
|
||||
|
||||
// CardBitCount = removeParityBits(CodecBuffer2,CardBitCount );
|
||||
// LEDHook(LED_CODEC_RX, LED_PULSE);
|
||||
|
||||
LogEntry(LOG_INFO_CODEC_SNI_CARD_DATA_W_PARITY, CodecBuffer2, (CardBitCount + 7) / 8);
|
||||
|
||||
LEDHook(LED_CODEC_RX, LED_PULSE);
|
||||
ApplicationProcess(CodecBuffer2, (CardBitCount+7)/8);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -191,11 +191,11 @@ static const PROGMEM ConfigurationType ConfigurationTable[] = {
|
||||
.CodecInitFunc = Sniff14443ACodecInit,
|
||||
.CodecDeInitFunc = Sniff14443ACodecDeInit,
|
||||
.CodecTaskFunc = Sniff14443ACodecTask,
|
||||
.ApplicationInitFunc = ApplicationInitDummy,
|
||||
.ApplicationResetFunc = ApplicationResetDummy,
|
||||
.ApplicationTaskFunc = ApplicationTaskDummy,
|
||||
.ApplicationTickFunc = ApplicationTickDummy,
|
||||
.ApplicationProcessFunc = ApplicationProcessDummy,
|
||||
.ApplicationInitFunc = Sniff14443AAppInit,
|
||||
.ApplicationResetFunc = Sniff14443AAppReset,
|
||||
.ApplicationTaskFunc = Sniff14443AAppTask,
|
||||
.ApplicationTickFunc = Sniff14443AAppTick,
|
||||
.ApplicationProcessFunc = Sniff14443AAppProcess,
|
||||
.ApplicationGetUidFunc = ApplicationGetUidDummy,
|
||||
.ApplicationSetUidFunc = ApplicationSetUidDummy,
|
||||
.UidSize = 0,
|
||||
|
||||
@@ -93,7 +93,7 @@ OPTIMIZATION = s
|
||||
SRC += $(TARGET).c LUFADescriptors.c System.c Configuration.c Random.c Common.c Memory.c MemoryAsm.S Button.c Log.c Settings.c LED.c Map.c AntennaLevel.c
|
||||
SRC += Terminal/Terminal.c Terminal/Commands.c Terminal/XModem.c Terminal/CommandLine.c
|
||||
SRC += Codec/Codec.c Codec/ISO14443-2A.c Codec/Reader14443-2A.c Codec/SniffISO14443-2A.c Codec/Reader14443-ISR.S
|
||||
SRC += Application/MifareUltralight.c Application/MifareClassic.c Application/ISO14443-3A.c Application/Crypto1.c Application/Reader14443A.c
|
||||
SRC += Application/MifareUltralight.c Application/MifareClassic.c Application/ISO14443-3A.c Application/Crypto1.c Application/Reader14443A.c Application/Sniff14443A.c
|
||||
SRC += $(LUFA_SRC_USB) $(LUFA_SRC_USBCLASS)
|
||||
LUFA_PATH = ../LUFA
|
||||
CC_FLAGS = -DUSE_LUFA_CONFIG_HEADER -DFLASH_DATA_ADDR=$(FLASH_DATA_ADDR) -DFLASH_DATA_SIZE=$(FLASH_DATA_SIZE) -DSPM_HELPER_ADDR=$(SPM_HELPER_ADDR) -DBUILD_DATE=$(BUILD_DATE) -DCOMMIT_ID=\"$(COMMIT_ID)\" $(SETTINGS)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "Commands.h"
|
||||
#include <stdio.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include <Settings.h>
|
||||
#include "XModem.h"
|
||||
#include "../Settings.h"
|
||||
#include "../Chameleon-Mini.h"
|
||||
@@ -16,6 +17,7 @@
|
||||
#include "../Codec/Codec.h"
|
||||
|
||||
extern Reader14443Command Reader14443CurrentCommand;
|
||||
extern Sniff14443Command Sniff14443CurrentCommand;
|
||||
|
||||
extern const PROGMEM CommandEntryType CommandTable[];
|
||||
|
||||
@@ -629,15 +631,27 @@ CommandStatusIdType CommandGetField(char* OutMessage)
|
||||
|
||||
CommandStatusIdType CommandExecAutocalibrate(char* OutMessage)
|
||||
{
|
||||
if (GlobalSettings.ActiveSettingPtr->Configuration != CONFIG_ISO14443A_READER)
|
||||
if (GlobalSettings.ActiveSettingPtr->Configuration == CONFIG_ISO14443A_READER){
|
||||
ApplicationReset();
|
||||
|
||||
Reader14443CurrentCommand = Reader14443_Autocalibrate;
|
||||
Reader14443AAppInit();
|
||||
Reader14443ACodecStart();
|
||||
CommandLinePendingTaskTimeout = &Reader14443AAppTimeout;
|
||||
return TIMEOUT_COMMAND;
|
||||
}
|
||||
else if (GlobalSettings.ActiveSettingPtr->Configuration == CONFIG_ISO14443A_SNIFF){
|
||||
ApplicationReset();
|
||||
|
||||
Sniff14443CurrentCommand = Sniff14443_Autocalibrate;
|
||||
Sniff14443AAppInit();
|
||||
CommandLinePendingTaskTimeout = &Sniff14443AAppTimeout;
|
||||
return TIMEOUT_COMMAND;
|
||||
}
|
||||
else {
|
||||
return COMMAND_ERR_INVALID_USAGE_ID;
|
||||
ApplicationReset();
|
||||
}
|
||||
|
||||
Reader14443CurrentCommand = Reader14443_Autocalibrate;
|
||||
Reader14443AAppInit();
|
||||
Reader14443ACodecStart();
|
||||
CommandLinePendingTaskTimeout = &Reader14443AAppTimeout;
|
||||
return TIMEOUT_COMMAND;
|
||||
}
|
||||
|
||||
CommandStatusIdType CommandExecClone(char *OutMessage)
|
||||
|
||||
Reference in New Issue
Block a user