list.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #ifndef __LIST_H__
  4. #define __LIST_H__
  5. #include "stdbool.h"
  6. #include "esp_attr.h"
  7. typedef enum {
  8. LORA_INFO_NONE = 0,
  9. LORA_INFO_VERSION,
  10. LORA_INFO_GET_CHART,
  11. LORA_INFO_RSSI,
  12. LORA_INFO_BATT,
  13. LORA_INFO_REPLY,
  14. LORA_INFO_GET_TIME,
  15. LORA_INFO_STATUS,
  16. LORA_INFO_DUR,
  17. LORA_INFO_END,
  18. } LORA_INFO_TYPE_e;
  19. typedef struct queue
  20. {
  21. bool flag;
  22. uint32_t num;
  23. }LORA_POOL_t;
  24. extern RTC_FAST_ATTR LORA_POOL_t lora_pool[LORA_INFO_END];
  25. typedef struct node {
  26. int n; /* data field(s) */
  27. char * data; //数据
  28. char cmd; //发送的命令
  29. int len; //发送的长度
  30. /* float b;
  31. * char c;
  32. * ... etc.
  33. */
  34. struct node *next; /* pointer to next element */
  35. }Node;
  36. #if 0
  37. Node *newNode(int ); /* physically creates a new node */
  38. #else
  39. Node *newNode(int x,int cmd,char *data,int len);
  40. #endif
  41. /* N.B. this function is called by other functions because does not take care
  42. * of inserting the Node in the list, but delegates this operation to other
  43. * functions, such as *Insert functions */
  44. Node *preInsert(Node *, int,int,char *,int); /* inserts a new item at the top of the list */
  45. Node *orderInsert(Node *, int ,int,char *,int); /* inserts a new element in order, according to a key field */
  46. Node *postInsert(Node *, int ,int,char *,int); /* inserts a new item at the end of the list */
  47. Node *findNode(Node *, int ); /* find a node in the list */
  48. Node *deleteNode(Node *, int ); /* deletes a node corresponding to the inserted key */
  49. Node *deleteList(Node *); /* deletes a list */
  50. void printList(Node *); /* prints all the nodes in the list */
  51. void MergeSort(Node **); /* sorting algorithm */
  52. Node *Merge(Node *, Node *); /* merges two sorted linked lists */
  53. void Split(Node *, Node **, Node **); /* split the nodes of the list into two sublists */
  54. int countNodes(Node *); /* returns the number of nodes in the list */
  55. Node* copyList( Node* originalList);
  56. int countClockNodes_byCMD(Node *top,char type_cmd);
  57. Node *deleteNode_head(Node *top);
  58. #define MAX_MSG_ID_NUM 1000
  59. int allocateMsgIdNum();
  60. void deallocateMsgIdNum(int idNum);
  61. #if 0
  62. void wait_Send_Data_Insert(int msgid,uint8_t *data,int len);
  63. #endif
  64. void wait_Send_Data_Delete(int msgid);
  65. #endif