S&B Volcano vaporizer remote control with Pi Pico W
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

models.c 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * models.c
  3. *
  4. * Copyright (c) 2023 Thomas Buck (thomas@xythobuz.de)
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * See <http://www.gnu.org/licenses/>.
  17. */
  18. #include <stddef.h>
  19. #include <string.h>
  20. #include "config.h"
  21. #include "log.h"
  22. #include "util.h"
  23. #include "models.h"
  24. enum known_devices models_filter_name(const char *name) {
  25. if (name == NULL) {
  26. return DEV_UNKNOWN;
  27. } else if (strcmp(name, "S&B VOLCANO H") == 0) {
  28. return DEV_VOLCANO;
  29. } else if (strcmp(name, "STORZ&BICKEL") == 0) {
  30. return DEV_CRAFTY;
  31. } else {
  32. return DEV_UNKNOWN;
  33. }
  34. }
  35. int8_t models_get_serial(const uint8_t *data, size_t data_len, char *buff, size_t buff_len) {
  36. if ((data == NULL) || (data_len <= 0) || (buff == NULL) || (buff_len <= 0)) {
  37. return -1;
  38. }
  39. const size_t serial_len = 8;
  40. const size_t serial_off = 2;
  41. if ((data_len < (serial_len + serial_off)) || (buff_len < (serial_len + 1))) {
  42. return -2;
  43. }
  44. memcpy(buff, data + serial_off, serial_len);
  45. buff[serial_len] = '\0';
  46. return 0;
  47. }