daily pastebin goal
8%
SHARE
TWEET

Untitled

a guest Feb 23rd, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <pigpio.h>
  3. #include <string.h>
  4. #include "wiegand.h"
  5.  
  6. char code[15]; // Code to be processed (could be 4 digits, could be 8)
  7.  
  8. void callback(int bits, uint32_t value)
  9. {
  10. printf("bits=%d value=%un", bits, value);
  11.  
  12. // Construct the code
  13. sprintf(code,"%s%u",code, value);
  14.  
  15. if(strlen(code)>=4){ // 4 digit pin must have been entered or card presented
  16.      printf("nCode %s has been entered of length %d",code,strlen(code));
  17. // Do authenticate stuff here
  18.      if(strcmp(code,"2345")==0){
  19.      // Open the gates
  20.      ...
  21.      }
  22. // Reset code
  23.      memset(code,0,15);
  24.  
  25. }
  26. }
  27.  
  28. int main(int argc, char *argv[])
  29. {
  30. Pi_Wieg_t * w;
  31.  
  32. if (gpioInitialise() < 0) return 1;
  33.  
  34. w = Pi_Wieg(14, 15, callback, 5);
  35. while(1){
  36. sleep(1);
  37. }
  38. Pi_Wieg_cancel(w);
  39.  
  40. gpioTerminate();
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top