Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <pigpio.h>
- #include <string.h>
- #include "wiegand.h"
- char code[15]; // Code to be processed (could be 4 digits, could be 8)
- void callback(int bits, uint32_t value)
- {
- printf("bits=%d value=%un", bits, value);
- // Construct the code
- sprintf(code,"%s%u",code, value);
- if(strlen(code)>=4){ // 4 digit pin must have been entered or card presented
- printf("nCode %s has been entered of length %d",code,strlen(code));
- // Do authenticate stuff here
- if(strcmp(code,"2345")==0){
- // Open the gates
- ...
- }
- // Reset code
- memset(code,0,15);
- }
- }
- int main(int argc, char *argv[])
- {
- Pi_Wieg_t * w;
- if (gpioInitialise() < 0) return 1;
- w = Pi_Wieg(14, 15, callback, 5);
- while(1){
- sleep(1);
- }
- Pi_Wieg_cancel(w);
- gpioTerminate();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement