eth_worker.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #pragma once
  2. #include <stdint.h>
  3. typedef struct EthWorker EthWorker;
  4. typedef struct EthViewProcess EthViewProcess;
  5. typedef enum {
  6. EthWorkerStateNotAllocated = 0,
  7. EthWorkerStateNotInited,
  8. EthWorkerStateDefaultNext,
  9. EthWorkerStateInited,
  10. EthWorkerStateInit,
  11. EthWorkerStateModulePowerOn,
  12. EthWorkerStateModuleConnect,
  13. EthWorkerStateMACInit,
  14. EthWorkerStateStaticIp,
  15. EthWorkerStateDHCP,
  16. EthWorkerStateOnline,
  17. EthWorkerStatePing,
  18. EthWorkerStateStop,
  19. EthWorkerStateReset,
  20. } EthWorkerState;
  21. typedef enum {
  22. EthWorkerProcessInit,
  23. EthWorkerProcessDHCP,
  24. EthWorkerProcessStatic,
  25. EthWorkerProcessPing,
  26. EthWorkerProcessReset,
  27. EthWorkerProcessActive,
  28. EthWorkerProcessExit,
  29. } EthWorkerProcess;
  30. typedef enum {
  31. EthWorkerSubstateInProcess = 0,
  32. EthWorkerSubStateSuccess,
  33. EthWorkerSubStateError,
  34. } EthWorkerSubState;
  35. typedef enum {
  36. EthCustomEventUpdate = 0,
  37. EthCustomEventModuleInit,
  38. EthCustomEventModuleError,
  39. EthCustomEventModulePowerOn,
  40. EthCustomEventModuleConnect,
  41. EthCustomEventMACInit,
  42. EthCustomEventStaticIp,
  43. EthCustomEventDHCP,
  44. EthCustomEventPing,
  45. EthCustomEventTCP2UART,
  46. EthCustomEventTCP2CLI,
  47. EthCustomEventSaved,
  48. } EthCustomEvent;
  49. typedef void (*EthWorkerCallback)(EthCustomEvent event, void* context);
  50. EthWorker* eth_worker_alloc();
  51. EthWorkerState eth_worker_get_state(EthWorker* eth_worker);
  52. void eth_worker_set_active_process(EthWorker* eth_worker, EthWorkerProcess state);
  53. void eth_worker_free(EthWorker* eth_worker);
  54. void eth_worker_start(
  55. EthWorker* eth_worker,
  56. EthWorkerState state,
  57. EthWorkerCallback callback,
  58. void* context);
  59. void eth_worker_stop(EthWorker* eth_worker);
  60. void eth_worker_dhcp(EthWorker* eth_worker);
  61. void eth_worker_w5500(EthWorker* eth_worker);
  62. void eth_worker_init_process(EthWorker* eth_worker);
  63. #define PING_SOCKET 1
  64. uint8_t ping_auto_interface(uint8_t* adress);
  65. void dhcp_timer_callback(void* context);