12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include "impl/util.h"
  2. #include "light.h"
  3. #include "helpers.h"
  4. #include <stdio.h> //snprintf
  5. #include <stdlib.h> // malloc, free
  6. #include <dirent.h> // opendir, readdir
  7. #include <inttypes.h> // PRIu64
  8. bool impl_util_init(light_device_enumerator_t *enumerator)
  9. {
  10. light_device_t *util_device = light_create_device(enumerator, "test", NULL);
  11. light_create_device_target(util_device, "dryrun", impl_util_dryrun_set, impl_util_dryrun_get, impl_util_dryrun_getmax, impl_util_dryrun_command, NULL);
  12. return true;
  13. }
  14. bool impl_util_free(light_device_enumerator_t *enumerator)
  15. {
  16. return true;
  17. }
  18. bool impl_util_dryrun_set(light_device_target_t *target, uint64_t in_value)
  19. {
  20. LIGHT_NOTE("impl_util_dryrun_set: writing brightness %" PRIu64 " to utility target %s", in_value, target->name);
  21. return true;
  22. }
  23. bool impl_util_dryrun_get(light_device_target_t *target, uint64_t *out_value)
  24. {
  25. LIGHT_NOTE("impl_util_dryrun_get: reading brightness (0) from utility target %s", target->name);
  26. *out_value = 0;
  27. return true;
  28. }
  29. bool impl_util_dryrun_getmax(light_device_target_t *target, uint64_t *out_value)
  30. {
  31. LIGHT_NOTE("impl_util_dryrun_getmax: reading max. brightness (255) from utility target %s", target->name);
  32. *out_value = 255;
  33. return true;
  34. }
  35. bool impl_util_dryrun_command(light_device_target_t *target, char const *command_string)
  36. {
  37. LIGHT_NOTE("impl_util_dryrun_command: running custom command on utility target %s: \"%s\"", target->name, command_string);
  38. return true;
  39. }