Advertisement
Guest User

Untitled

a guest
Nov 5th, 2020
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. // gcc `libusb-config --cflags` `libusb-config --libs` -Ilibrary -O -g -D LINUX -o yubikey-touch yubikey-touch.c littleWire.o littleWire_util.o littleWire_servo.o opendevice.o `libusb-config --libs`
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include "littleWire.h"
  6. #include "littleWire_util.h"
  7.  
  8. #define TOUCH PIN2
  9.  
  10. unsigned char version;
  11. int total_lwCount;
  12. int i;
  13.  
  14. int main(int argc, char **argv) {
  15. littleWire *lw = NULL;
  16.  
  17. total_lwCount = littlewire_search();
  18.  
  19. if (total_lwCount == 1) {
  20. printf("> 1 Little Wire device is found with serialNumber: %d\n", lwResults[0].serialNumber);
  21. } else if(total_lwCount > 1) {
  22. printf("> %d Little Wire devices are found\n", total_lwCount);
  23. printf("> #id - serialNumber\n");
  24. for (i = 0; i < total_lwCount; i++) {
  25. printf("> %2d - %3d\n", i, lwResults[i].serialNumber);
  26. }
  27. } else if (total_lwCount == 0) {
  28. printf("> Little Wire could not be found!\n");
  29. exit(EXIT_FAILURE);
  30. }
  31.  
  32. /* Connects to the first littleWire device the computer can find. */
  33. // lw = littleWire_connect();
  34.  
  35. /* Connects to the spesific littleWire device by array id. */
  36. lw = littlewire_connect_byID(0);
  37.  
  38. /* Connects to the spesific littleWire with a given serial number. */
  39. /* If multiple devices have the same serial number, it connects to the last one it finds */
  40. // lw = littlewire_connect_bySerialNum(126);
  41.  
  42. if (lw == NULL) {
  43. printf("> Little Wire connection problem!\n");
  44. exit(EXIT_FAILURE);
  45. }
  46.  
  47. version = readFirmwareVersion(lw);
  48. printf("> Little Wire firmware version: %d.%d\n", ((version & 0xF0) >> 4), (version&0x0F));
  49. if (version < 0x12) {
  50. printf("> This example requires the new 1.2 version firmware. Please update soon.\n");
  51. return 0;
  52. }
  53.  
  54. /* In order to change the serial number of the current connected device, use the following function. */
  55. /* You need to unplug-plug to see the change. */
  56. /* Serial numbers have to be between 100-999 */
  57. // changeSerialNumber(lw,152);
  58.  
  59. if (argc == 0) {
  60. return 0;
  61. }
  62.  
  63. pinMode(lw, TOUCH, INPUT);
  64. digitalWrite(lw, TOUCH, LOW);
  65. pinMode(lw, TOUCH, OUTPUT);
  66. delay(atoi(argv[1]));
  67. pinMode(lw, TOUCH, INPUT);
  68.  
  69. if (lwStatus < 0) {
  70. printf("> lwStatus: %d\n", lwStatus);
  71. printf("> Connection error: %s\n", littleWire_errorName());
  72. return 0;
  73. }
  74. return 0;
  75. }
  76.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement