user_config.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. #ifndef USER_CONFIG_H__
  2. #define USER_CONFIG_H__
  3. #include "define.h"
  4. #include "param.h"
  5. #include "user_fsd.h"
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. #ifndef DEV_ADDR_SIZE
  10. #define DEV_ADDR_SIZE 6
  11. #endif
  12. typedef enum{
  13. NET_NULL=0,
  14. NET_189_TEST=1,
  15. NET_189_IOT=2,
  16. NET_189_AEP=3,
  17. NET_CMCC_ONENET=4,
  18. NET_CMCC_ANDLINK=5
  19. }net_type_e;
  20. typedef enum{
  21. NO_PCBA=0,
  22. REG_OK=1,
  23. NO_REG=2,
  24. UNREG=3,
  25. NO_TEST=4,
  26. NO_CHECK=5,
  27. LOCKED=6,
  28. REG_NULL=0xFF,
  29. }dev_reg_stat_e;
  30. typedef struct{
  31. dev_reg_stat_e reg_stat;
  32. uint8_t mac_lic[DEV_ADDR_SIZE];
  33. uint8_t pcba_setlic[DEV_ADDR_SIZE];
  34. uint8_t pcba_lic[DEV_ADDR_SIZE];
  35. uint8_t production_setlic[DEV_ADDR_SIZE];
  36. uint8_t production_lic[DEV_ADDR_SIZE];
  37. uint8_t devaddr[DEV_ADDR_SIZE];
  38. bool mainmacstat;
  39. uint8_t mainmacaddr[DEV_ADDR_SIZE];
  40. uint32_t heart_interval;
  41. uint32_t unixtime;
  42. net_type_e net_type;
  43. bool nbstat;
  44. uint8_t imei[8];
  45. uint8_t imsi[8];
  46. uint8_t ccid[10];
  47. }__attribute__((packed)) user_config_param_s;
  48. #define USER_CONFIG_STAT_DEFAULT_CONFIG \
  49. { \
  50. .reg_stat=NO_TEST, \
  51. .mac_lic={0}, \
  52. .pcba_setlic={0}, \
  53. .pcba_lic={0}, \
  54. .production_setlic={0}, \
  55. .production_lic={0}, \
  56. .devaddr={0}, \
  57. .mainmacstat=false, \
  58. .mainmacaddr={0}, \
  59. .heart_interval=WORK_INTERVAL, \
  60. .nbstat=false, \
  61. .imei={0}, \
  62. .imsi={0}, \
  63. .ccid={0}, \
  64. }
  65. typedef enum{
  66. USER_CONFIG_NULL,
  67. USER_CONFIG_READ,
  68. USER_CONFIG_READ_TIMEOUT,
  69. USER_CONFIG_READ_OK,
  70. USER_CONFIG_ERASE,
  71. USER_CONFIG_ERASE_TIMEOUT,
  72. USER_CONFIG_ERASE_OK,
  73. USER_CONFIG_WRITE,
  74. USER_CONFIG_WRITE_TIMEOUT,
  75. USER_CONFIG_WRITE_OK,
  76. }USER_CONFIG_WORK_STAT;
  77. typedef void (*user_config_write_finish_func)(bool stat);
  78. typedef void (*user_config_read_finish_func)(bool stat);
  79. typedef struct{
  80. USER_CONFIG_WORK_STAT work_stat;
  81. uint8_t timeout_count;
  82. user_config_write_finish_func write_finish_func;
  83. user_config_read_finish_func read_finish_func;
  84. uint8_t *user_config_data;
  85. int user_config_data_len;
  86. }user_config_work_s;
  87. #define USER_CONFIG_WORK_DEFAULT_CONFIG \
  88. { \
  89. .work_stat=USER_CONFIG_NULL, \
  90. .timeout_count=0, \
  91. .write_finish_func=NULL, \
  92. .read_finish_func=NULL, \
  93. .user_config_data=NULL, \
  94. }
  95. typedef enum
  96. {
  97. USER_CONFIG_QUEUE_INT=0,
  98. USER_CONFIG_QUEUE_TIME=1,
  99. }USER_CONFIG_QUEUE_TYPE;
  100. void Set_User_Config_Queue(USER_CONFIG_QUEUE_TYPE type);
  101. void User_Config_Read_Config(void);
  102. void User_Config_Write_Config(void);
  103. void Set_user_config_Queue(USER_CONFIG_QUEUE_TYPE type);
  104. void user_config_timers_init(void);
  105. void set_user_config_work_finish_func(user_config_write_finish_func func);
  106. void set_user_config_read_finish_func(user_config_read_finish_func func);
  107. void set_user_config_param_init(user_config_param_s *param);
  108. void set_user_config_data(uint8_t *user_config_data,int len);
  109. extern user_config_param_s user_config_param;
  110. #ifdef __cplusplus
  111. }
  112. #endif
  113. #endif // USER_CONFIG_H__
  114. /** @} */