nvram.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright (C) 2019-2020 Alibaba Group Holding Limited
  3. */
  4. #ifndef YOC_NVRAM_H
  5. #define YOC_NVRAM_H
  6. #include <stdint.h>
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. /**
  11. * This function will init nvram.
  12. *
  13. * @param[in] partname the data pair of the key, less than 64 bytes
  14. * @return 0 on success, negative error on failure.
  15. */
  16. int nvram_init(const char *partname);
  17. /**
  18. * This function will reset nvram, clear all data.
  19. *
  20. * @return 0 on success, negative error on failure.
  21. */
  22. int nvram_reset();
  23. /**
  24. * This function will get data from the factory setting area.
  25. *
  26. * @param[in] key the data pair of the key, less than 64 bytes
  27. * @param[in] len the length of the buffer
  28. * @param[out] value the buffer that will store the data
  29. * @return the length of the data value, error code otherwise
  30. */
  31. int nvram_get_val(const char *key, char *value, int len);
  32. /**
  33. * This function will set data to the factory setting area.
  34. *
  35. * @param[in] key the data pair of the key, less than 64 bytes
  36. * @param[in] value the data pair of the value, delete the pair if value == NULL
  37. * @return 0 on success, negative error on failure.
  38. */
  39. int nvram_set_val(const char *key, char *value);
  40. /**
  41. * This function will get ali iot info from factory setting area.
  42. *
  43. * @param[out] product_key output ali iot product key
  44. * @param[in&out] product_key_len in buffer len, out real len
  45. * @param[out] device_name output ali iot device name
  46. * @param[in&out] device_name_len in buffer len, out real len
  47. * @param[out] device_secret output ali iot device device secret
  48. * @param[in&out] device_secret_len in buffer len, out real len
  49. */
  50. int nvram_get_iot_info(char *product_key, uint32_t *product_key_len,
  51. char *device_name, uint32_t *device_name_len,
  52. char *device_secret, uint32_t *device_secret_len);
  53. #ifdef __cplusplus
  54. }
  55. #endif
  56. #endif