eth_worker.h 1.7 KB

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