[FL-1063} LF-RFID Cli (#515)
* App lfrfid: update emulator to process external data. * App lfrfid: cleanup emulator * App lfrfid: cli interface * Lib: arguments parser lib Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
@@ -6,7 +6,7 @@ RfidTimerEmulator::RfidTimerEmulator() {
|
||||
}
|
||||
|
||||
RfidTimerEmulator::~RfidTimerEmulator() {
|
||||
std::map<Type, EncoderGeneric*>::iterator it;
|
||||
std::map<LfrfidKeyType, EncoderGeneric*>::iterator it;
|
||||
|
||||
for(it = encoders.begin(); it != encoders.end(); ++it) {
|
||||
delete it->second;
|
||||
@@ -14,38 +14,28 @@ RfidTimerEmulator::~RfidTimerEmulator() {
|
||||
}
|
||||
}
|
||||
|
||||
void RfidTimerEmulator::start(Type type) {
|
||||
void RfidTimerEmulator::start(LfrfidKeyType type, const uint8_t* data, uint8_t data_size) {
|
||||
if(encoders.count(type)) {
|
||||
current_encoder = encoders.find(type)->second;
|
||||
uint8_t em_data[5] = {0x53, 0x00, 0x5F, 0xB3, 0xC2};
|
||||
uint8_t hid_data[3] = {0xED, 0x87, 0x70};
|
||||
uint8_t indala_data[3] = {0x1F, 0x2E, 0x3D};
|
||||
|
||||
switch(type) {
|
||||
case Type::EM:
|
||||
current_encoder->init(em_data, 5);
|
||||
break;
|
||||
case Type::HID_H10301:
|
||||
current_encoder->init(hid_data, 3);
|
||||
break;
|
||||
case Type::Indala_40134:
|
||||
current_encoder->init(indala_data, 3);
|
||||
break;
|
||||
if(lfrfid_key_get_type_data_count(type) == data_size) {
|
||||
current_encoder->init(data, data_size);
|
||||
|
||||
api_hal_rfid_tim_emulate(125000);
|
||||
api_hal_rfid_pins_emulate();
|
||||
|
||||
api_interrupt_add(timer_update_callback, InterruptTypeTimerUpdate, this);
|
||||
|
||||
// TODO make api for interrupts priority
|
||||
for(size_t i = WWDG_IRQn; i <= DMAMUX1_OVR_IRQn; i++) {
|
||||
HAL_NVIC_SetPriority(static_cast<IRQn_Type>(i), 15, 0);
|
||||
}
|
||||
|
||||
HAL_NVIC_SetPriority(TIM1_UP_TIM16_IRQn, 5, 0);
|
||||
HAL_NVIC_EnableIRQ(TIM1_UP_TIM16_IRQn);
|
||||
|
||||
api_hal_rfid_tim_emulate_start();
|
||||
}
|
||||
|
||||
api_hal_rfid_tim_emulate(125000);
|
||||
api_hal_rfid_pins_emulate();
|
||||
|
||||
api_interrupt_add(timer_update_callback, InterruptTypeTimerUpdate, this);
|
||||
|
||||
for(size_t i = WWDG_IRQn; i <= DMAMUX1_OVR_IRQn; i++) {
|
||||
HAL_NVIC_SetPriority(static_cast<IRQn_Type>(i), 15, 0);
|
||||
}
|
||||
|
||||
HAL_NVIC_SetPriority(TIM1_UP_TIM16_IRQn, 5, 0);
|
||||
HAL_NVIC_EnableIRQ(TIM1_UP_TIM16_IRQn);
|
||||
|
||||
api_hal_rfid_tim_emulate_start();
|
||||
} else {
|
||||
// not found
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user