ConfigMacros.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. #ifndef __CONFIGMACROS_H
  2. #define __CONFIGMACROS_H
  3. #include "oled.h"
  4. #include "mba32a.h"
  5. #include "ml307a.h"
  6. #include <stdlib.h>
  7. #include "interface.h"
  8. #define BUFFER_SIZE 256
  9. #define open4G 1
  10. #define openBT 1
  11. #define updateMenu 1
  12. #define debugkeyinfo 0
  13. #define open16 11 //开字
  14. #define open16 11 //开字
  15. #define close16 12 //关字
  16. #define PDA_MODE 0x0000
  17. #define DTU_MODE 0x0001
  18. #define PRINT_MENU_STATUS(key) printf("--->%s pressed\t%d %d %x %d\n", key, menu.current, menu.up, (menu.next&0xf), menu.enter)
  19. #define PRINT_UUID(message) printf("#%s符合设置项\n",message)
  20. #define PRINT_NUUID(message) printf("%s不符合\n",message)
  21. #define Sn1InfoAddr ((uint32_t)0x8050000)
  22. #define Sn2InfoAddr ((uint32_t)0x8050100)
  23. #define Sn3InfoAddr ((uint32_t)0x8050200)
  24. #define Sn4InfoAddr ((uint32_t)0x8050300)
  25. #define serialNum1Addr ((uint32_t)0x8050400)
  26. #define serialNum2Addr ((uint32_t)0x8050500)
  27. #define serialNum3Addr ((uint32_t)0x8050600)
  28. #define serialNum4Addr ((uint32_t)0x8050700)
  29. #define resetDevAddr ((uint32_t)0x8050800)
  30. #define SysModeAddr ((uint32_t)0x8050900)
  31. #define LocDbHeadStart ((uint32_t)0x8060000)
  32. #define LocDbBodyStart ((uint32_t)0x8060800)
  33. #define EveDbHeadStart ((uint32_t)0x8070000)
  34. #define EveDbBodyStart ((uint32_t)0x8070800)
  35. //*tt808
  36. #define JLPTIP "121.199.29.128"
  37. #define JLPTPORT 7342
  38. #define XXID_zdjq 0x0102 //鉴权
  39. #define XXID_zdxt 0x0002 //心跳
  40. #define XXID_zddz 0x0200 //地址
  41. #define TCPJMFSRSA 0x001
  42. #define TCPJMFSNULL 0x000
  43. #define TT808FLAG 0x7E
  44. #define TCPHeadBYTE 0x2A
  45. #define TCPTAILBYTE 0x23
  46. #define XXID_pttyyd 0x8001 //通用应答
  47. #define XXID_ptxxtc 0x8900 //下行透传
  48. #define XXID_zdtyyd 0x0001 //终端通用应答
  49. #define YES 0x00
  50. #define NO 0x01
  51. /* WDI */
  52. #define TOGGLE_WDI_PIN(htim_instance) \
  53. do { \
  54. if ((htim_instance)->Instance == TIM2) { \
  55. HAL_GPIO_TogglePin(WDI_GPIO_Port, WDI_Pin); \
  56. } \
  57. } while(0)
  58. /* OLED显示 */
  59. #define OLED_DISPLAY(color, display) do { \
  60. OLED_Init(); \
  61. OLED_ColorTurn(color); \
  62. OLED_DisplayTurn(display); \
  63. } while(0)
  64. /* U1-U4 DMA */
  65. #define IDLE_DMA_UART(huart) \
  66. do {\
  67. __HAL_UART_ENABLE_IT(huart, UART_IT_IDLE); \
  68. } while(0)
  69. /* SYETEM init */
  70. #define START_PROCESS() \
  71. do { \
  72. printf("go\r\n"); \
  73. menu.current = 0xBB; \
  74. tipsflag = Starting; \
  75. Jump_interface(); \
  76. OLED_Refresh(); \
  77. } while(0)
  78. #define SET_MENU_STATUS(current_value, up_value, next_value, enter_value) \
  79. do { \
  80. menu.current = current_value; \
  81. menu.up = up_value; \
  82. menu.next = next_value; \
  83. menu.enter = enter_value; \
  84. refresh = true;\
  85. } while(0)
  86. typedef struct
  87. {
  88. uint8_t current; //当前状态索引号
  89. uint8_t up; //向下一个
  90. uint8_t next; //向下一个
  91. uint8_t enter; //确定
  92. uint32_t home;
  93. uint8_t PreNext;
  94. } Menu_table;
  95. #define RESET_4G_MODULE() \
  96. do { \
  97. if(reset4Gmodule) { \
  98. reset4Gmodule = false; \
  99. HAL_Delay(2000); \
  100. ML307A_Init(); \
  101. } \
  102. } while(0)
  103. typedef struct
  104. {
  105. //四位数字(施解封显示)
  106. char SN1name[5];
  107. char SN2name[5];
  108. char SN3name[5];
  109. char SN4name[5];
  110. //AT连接字符串
  111. char* SN1CONN;
  112. char* SN1ED;
  113. char* SN1DIS;
  114. char* SN2CONN;
  115. char* SN2ED;
  116. char* SN2DIS;
  117. char* SN3CONN;
  118. char* SN3ED;
  119. char* SN3DIS;
  120. char* SN4CONN;
  121. char* SN4ED;
  122. char* SN4DIS;
  123. //MAC
  124. uint16_t mac1[3];
  125. uint16_t mac2[3];
  126. uint16_t mac3[3];
  127. uint16_t mac4[3];
  128. //Status
  129. uint8_t L1status;
  130. uint8_t L2status;
  131. uint8_t L3status;
  132. uint8_t L4status;
  133. } LockInfo;
  134. typedef enum {
  135. Starting = 0,
  136. Btconn = 1,
  137. ConnOK = 2,
  138. ConnFail=3,
  139. Nosn =4,
  140. Timeout = 5,
  141. Working =6,
  142. FinshOK =7,
  143. Fail4G =8,
  144. Nosignal =9
  145. } TipsFlag;
  146. struct keys
  147. {
  148. unsigned char judge_sta; //判断按键按键按下的动作到了第几步
  149. bool key_sta; //如果按键被按下,为0
  150. bool key_flag; //如果确认被按下,为1
  151. bool long_flag; //如果确认被按下,为1
  152. uint8_t key_time;
  153. };
  154. // 定义结构体来存储对应信息
  155. struct BtMenuItem {
  156. int key;
  157. char *name;
  158. char *command;
  159. char *feedback;
  160. };
  161. // 定义一个结构体存储对应关系
  162. typedef struct {
  163. char *command;
  164. char *connected_msg;
  165. char *disconnected_msg;
  166. uint64_t mac;
  167. } MenuInfo;
  168. typedef struct
  169. {
  170. uint32_t serialNum1; //4字节流水号
  171. uint32_t serialNum2; //4字节流水号
  172. uint32_t serialNum3; //4字节流水号
  173. uint32_t serialNum4; //4字节流水号
  174. uint32_t userId; //4字节userid
  175. uint8_t Autoseal; //1字节自动施封
  176. } BtFrame;
  177. typedef enum {
  178. BtStepDefault = 0,
  179. UUIDS = 1,
  180. UUIDN = 2,
  181. UUIDW = 3,
  182. TxPower = 4
  183. } BtStep;
  184. typedef struct {
  185. uint8_t LSH;
  186. uint8_t Rtime[6];
  187. uint32_t C_Seconds;
  188. uint8_t L1Lockstatus;
  189. uint8_t L2Lockstatus;
  190. uint8_t L3Lockstatus;
  191. uint8_t L4Lockstatus;
  192. uint16_t Speed;
  193. uint32_t WD_u32;
  194. uint32_t JD_u32;
  195. } TT808;
  196. typedef struct {
  197. uint16_t LOC_InitInfo[4]; //0xFA0 //4000 * 14B
  198. uint16_t EVE_InitInfo[4]; //0x7D0 //2000 * 28B
  199. uint16_t timeStamp[2]; //时间戳(世纪秒)
  200. uint16_t WD_u16[2];
  201. uint16_t JD_u16[2];
  202. //*位置db使用
  203. uint16_t speed[1]; //速度
  204. //*状态db使用
  205. uint16_t LockSn[3]; //锁编号
  206. uint16_t OperationType[1]; //操作类型
  207. uint16_t OperationResults[1]; //操作结果
  208. uint16_t perators[2]; //操作人
  209. uint16_t ElectricityLevel[1]; //电量
  210. } Database;
  211. #endif /*__CONFIGMACROS_H*/