eth_worker.h 1.8 KB

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