taler-xotp_fw

xOTP generator firmware
Log | Files | Refs | Submodules | README

xtotpStateMachine.h (1851B)


      1 /**
      2  * @file xtotpStateMachine.h
      3  * @author Adrian STEINER (steia19@bfh.ch)
      4  * @brief State machine of the totp device
      5  * @version 0.1
      6  * @date 17-02-2025
      7  *
      8  * @copyright (C) 2025 Adrian STEINER
      9  * This program is free software: you can redistribute it and/or modify
     10  * it under the terms of the GNU General Public License as published by
     11  * the Free Software Foundation, either version 3 of the License, or
     12  * (at your option) any later version.
     13  *
     14  * This program is distributed in the hope that it will be useful,
     15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     17  * GNU General Public License for more details.
     18  *
     19  * You should have received a copy of the GNU General Public License
     20  * along with this program.  If not, see <https: //www.gnu.org/licenses/>.
     21  *
     22  */
     23 #ifndef XTOTP_STATE_MACHINE_H
     24 #define XTOTP_STATE_MACHINE_H
     25 
     26 #ifdef __cplusplus
     27 extern "C" {
     28 #endif
     29 
     30 #include "xtotp.h"
     31 
     32 #include "inputInterface.h"
     33 
     34 /**
     35  * @brief State callback protoype
     36  *
     37  * @param appData the user data
     38  * @param inputState the current input state
     39  * @param inputButton the current input button position
     40  *
     41  */
     42 typedef void (*stateCB)(xtotp_Data *appData,
     43                         inputLevelState inputState,
     44                         inputButtonPos inputButton);
     45 
     46 /**
     47  * @brief State machine handler
     48  *
     49  */
     50 typedef struct {
     51   stateCB entryAction;
     52   stateCB runAction;
     53 } stateHandler;
     54 
     55 /**
     56  * @brief Process the state machine
     57  *
     58  * @param appData User and app data
     59  * @param inputState Input state (low/high)
     60  * @param inputButton Input button
     61  */
     62 void xtotp_processStateMachine(xtotp_Data *appData,
     63                                inputLevelState inputState,
     64                                inputButtonPos inputButton);
     65 
     66 #ifdef __cplusplus
     67 }
     68 #endif
     69 
     70 #endif /* XTOTP_STATE_MACHINE_H*/