eth_worker.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. EthWorkerStateInited,
  9. EthWorkerStateInit,
  10. EthWorkerStateModulePowerOn,
  11. EthWorkerStateModuleConnect,
  12. EthWorkerStateMACInit,
  13. EthWorkerStateStaticIp,
  14. EthWorkerStateDHCP,
  15. EthWorkerStateOnline,
  16. EthWorkerStatePing,
  17. EthWorkerStateStop,
  18. } EthWorkerState;
  19. typedef enum {
  20. EthWorkerProcessInit,
  21. EthWorkerProcessDHCP,
  22. EthWorkerProcessStatic,
  23. EthWorkerProcessPing,
  24. EthWorkerProcessReset,
  25. EthWorkerProcessActive,
  26. EthWorkerProcessExit,
  27. } EthWorkerProcess;
  28. typedef enum {
  29. EthWorkerSubstateInProcess = 0,
  30. EthWorkerSubStateSuccess,
  31. EthWorkerSubStateError,
  32. } EthWorkerSubState;
  33. typedef enum {
  34. EthCustomEventUpdate = 0,
  35. EthCustomEventModuleInit,
  36. EthCustomEventModuleError,
  37. EthCustomEventModulePowerOn,
  38. EthCustomEventModuleConnect,
  39. EthCustomEventMACInit,
  40. EthCustomEventStaticIp,
  41. EthCustomEventDHCP,
  42. EthCustomEventPing,
  43. EthCustomEventTCP2UART,
  44. EthCustomEventTCP2CLI,
  45. EthCustomEventSaved,
  46. } EthCustomEvent;
  47. typedef void (*EthWorkerCallback)(EthCustomEvent event, void* context);
  48. EthWorker* eth_worker_alloc();
  49. EthWorkerState eth_worker_get_state(EthWorker* eth_worker);
  50. void eth_worker_set_active_process(EthWorker* eth_worker, EthWorkerProcess state);
  51. void eth_worker_free(EthWorker* eth_worker);
  52. void eth_worker_start(
  53. EthWorker* eth_worker,
  54. EthWorkerState state,
  55. EthWorkerCallback callback,
  56. void* context);
  57. void eth_worker_stop(EthWorker* eth_worker);
  58. void eth_worker_dhcp(EthWorker* eth_worker);
  59. void eth_worker_w5500(EthWorker* eth_worker);
  60. void eth_worker_init_process(EthWorker* eth_worker);