chore: Apply code formatting on entire codebase for consistent style

This commit is contained in:
icex2
2023-04-06 15:39:53 +02:00
committed by icex2
parent a1a849aef3
commit 031836ef0e
186 changed files with 2446 additions and 1979 deletions
+54 -37
View File
@@ -8,9 +8,9 @@
#include <stdint.h>
#include <stdio.h>
#include "aciomgr/manager.h"
#include "aciodrv/device.h"
#include "aciodrv/icca.h"
#include "aciomgr/manager.h"
#include "bemanitools/eamio.h"
@@ -23,22 +23,23 @@
#define NUMBER_OF_EMULATED_READERS 2
#define INVALID_NODE_ID -1
static const uint8_t eam_io_keypad_mappings[16] = {EAM_IO_KEYPAD_DECIMAL,
EAM_IO_KEYPAD_3,
EAM_IO_KEYPAD_6,
EAM_IO_KEYPAD_9,
0xFF,
0xFF,
0xFF,
0xFF,
EAM_IO_KEYPAD_0,
EAM_IO_KEYPAD_1,
EAM_IO_KEYPAD_4,
EAM_IO_KEYPAD_7,
EAM_IO_KEYPAD_00,
EAM_IO_KEYPAD_2,
EAM_IO_KEYPAD_5,
EAM_IO_KEYPAD_8};
static const uint8_t eam_io_keypad_mappings[16] = {
EAM_IO_KEYPAD_DECIMAL,
EAM_IO_KEYPAD_3,
EAM_IO_KEYPAD_6,
EAM_IO_KEYPAD_9,
0xFF,
0xFF,
0xFF,
0xFF,
EAM_IO_KEYPAD_0,
EAM_IO_KEYPAD_1,
EAM_IO_KEYPAD_4,
EAM_IO_KEYPAD_7,
EAM_IO_KEYPAD_00,
EAM_IO_KEYPAD_2,
EAM_IO_KEYPAD_5,
EAM_IO_KEYPAD_8};
static struct ac_io_icca_state eam_io_icca_state[NUMBER_OF_EMULATED_READERS];
@@ -119,7 +120,8 @@ bool eam_io_init(
for (uint8_t i = 0; i < NUMBER_OF_EMULATED_READERS; i++) {
icca_node_id[i] = INVALID_NODE_ID;
for (uint8_t nid = 0; nid < aciomgr_get_node_count(acio_manager_ctx); ++nid) {
for (uint8_t nid = 0; nid < aciomgr_get_node_count(acio_manager_ctx);
++nid) {
if (check_if_icca(nid)) {
bool existing_reader = false;
@@ -139,7 +141,8 @@ bool eam_io_init(
icca_is_slotted[i] = aciodrv_icca_is_slotted(device, nid);
icca_last_nonbusy_state[i] = 0;
log_misc("ICC reader %d is_slotted: %d", nid, icca_is_slotted[i]);
log_misc(
"ICC reader %d is_slotted: %d", nid, icca_is_slotted[i]);
if (!aciodrv_icca_init(device, icca_node_id[i])) {
log_warning("Initializing icca %d failed", i);
@@ -187,25 +190,28 @@ uint8_t eam_io_get_sensor_state(uint8_t unit_no)
if (icca_is_slotted[unit_no]) {
if ((eam_io_icca_state[unit_no].sensor_state &
AC_IO_ICCA_SENSOR_MASK_BACK_ON) > 0) {
AC_IO_ICCA_SENSOR_MASK_BACK_ON) > 0) {
sensors |= (1 << EAM_IO_SENSOR_BACK);
}
if ((eam_io_icca_state[unit_no].sensor_state &
AC_IO_ICCA_SENSOR_MASK_FRONT_ON) > 0) {
AC_IO_ICCA_SENSOR_MASK_FRONT_ON) > 0) {
sensors |= (1 << EAM_IO_SENSOR_FRONT);
}
} else {
// wavepass readers always report (EAM_IO_SENSOR_BACK + EAM_IO_SENSOR_FRONT) + type
// but because we can't report status_code back directly
// and libacio actually just ignores the sensor_state other then the type
// we just return this state like we're a slotted reader so the emulation takes card of it
if (eam_io_icca_state[unit_no].status_code == AC_IO_ICCA_STATUS_GOT_UID) {
// wavepass readers always report (EAM_IO_SENSOR_BACK +
// EAM_IO_SENSOR_FRONT) + type but because we can't report status_code
// back directly and libacio actually just ignores the sensor_state
// other then the type we just return this state like we're a slotted
// reader so the emulation takes card of it
if (eam_io_icca_state[unit_no].status_code ==
AC_IO_ICCA_STATUS_GOT_UID) {
sensors |= (1 << EAM_IO_SENSOR_BACK);
sensors |= (1 << EAM_IO_SENSOR_FRONT);
}
// continue reporting last state during busy
if (eam_io_icca_state[unit_no].status_code == AC_IO_ICCA_STATUS_BUSY_NEW) {
if (eam_io_icca_state[unit_no].status_code ==
AC_IO_ICCA_STATUS_BUSY_NEW) {
sensors = icca_last_nonbusy_state[unit_no];
} else {
icca_last_nonbusy_state[unit_no] = sensors;
@@ -243,18 +249,28 @@ bool eam_io_card_slot_cmd(uint8_t unit_no, uint8_t cmd)
switch (cmd) {
case EAM_IO_CARD_SLOT_CMD_CLOSE:
response = aciodrv_icca_set_state(
device, icca_node_id[unit_no], AC_IO_ICCA_SLOT_STATE_CLOSE, NULL);
device,
icca_node_id[unit_no],
AC_IO_ICCA_SLOT_STATE_CLOSE,
NULL);
case EAM_IO_CARD_SLOT_CMD_OPEN:
response = aciodrv_icca_set_state(
device, icca_node_id[unit_no], AC_IO_ICCA_SLOT_STATE_OPEN, NULL);
device,
icca_node_id[unit_no],
AC_IO_ICCA_SLOT_STATE_OPEN,
NULL);
case EAM_IO_CARD_SLOT_CMD_EJECT:
response = aciodrv_icca_set_state(
device, icca_node_id[unit_no], AC_IO_ICCA_SLOT_STATE_EJECT, NULL);
device,
icca_node_id[unit_no],
AC_IO_ICCA_SLOT_STATE_EJECT,
NULL);
case EAM_IO_CARD_SLOT_CMD_READ:
response = aciodrv_icca_read_card(device, icca_node_id[unit_no], NULL) &&
response =
aciodrv_icca_read_card(device, icca_node_id[unit_no], NULL) &&
aciodrv_icca_get_state(
device, icca_node_id[unit_no], &eam_io_icca_state[unit_no]);
@@ -281,17 +297,18 @@ bool eam_io_poll(uint8_t unit_no)
if (response && !icca_is_slotted[unit_no]) {
// we handle wavepass a bit differently to handle polling felica
if (eam_io_icca_state[unit_no].status_code != AC_IO_ICCA_STATUS_BUSY_NEW) {
if (eam_io_icca_state[unit_no].status_code !=
AC_IO_ICCA_STATUS_BUSY_NEW) {
++icca_poll_counter[unit_no];
}
// we must manually call this every few polls to actually update the felica state
// we don't do it every poll, since card polling isn't that time sensitive of an operation
// libacio does it every 5ish polls after the last AC_IO_ICCA_STATUS_BUSY_NEW message
// we must manually call this every few polls to actually update the
// felica state we don't do it every poll, since card polling isn't that
// time sensitive of an operation libacio does it every 5ish polls after
// the last AC_IO_ICCA_STATUS_BUSY_NEW message
if (icca_poll_counter[unit_no] >= IDLE_RESPONSES_BETWEEN_FELICA_POLLS) {
response = aciodrv_icca_poll_felica(
aciomgr_port_checkout(acio_manager_ctx),
icca_node_id[unit_no]);
aciomgr_port_checkout(acio_manager_ctx), icca_node_id[unit_no]);
aciomgr_port_checkin(acio_manager_ctx);
icca_poll_counter[unit_no] = 0;