eth_worker.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #pragma once
  2. #include "eth_device.h"
  3. typedef struct EthWorker EthWorker;
  4. typedef enum {
  5. EthWorkerStateNotInited = 0,
  6. EthWorkerStateModuleInit,
  7. EthWorkerStateModulePowerOn,
  8. EthWorkerStateModuleConnect,
  9. EthWorkerStateMACInit,
  10. EthWorkerStateStaticIp,
  11. EthWorkerStateDHCP,
  12. EthWorkerStatePing,
  13. EthWorkerStateStop,
  14. } EthWorkerState;
  15. typedef enum {
  16. EthWorkerSubstateInProcess = 0,
  17. EthWorkerSubStateSuccess,
  18. EthWorkerSubStateError,
  19. } EthWorkerSubState;
  20. typedef enum {
  21. EthCustomEventUpdate = 0,
  22. EthCustomEventModuleInit,
  23. EthCustomEventModulePowerOn,
  24. EthCustomEventModuleConnect,
  25. EthCustomEventMACInit,
  26. EthCustomEventStaticIp,
  27. EthCustomEventDHCP,
  28. EthCustomEventPing,
  29. EthCustomEventTCP2UART,
  30. EthCustomEventTCP2CLI,
  31. EthCustomEventSaved,
  32. } EthCustomEvent;
  33. typedef void (*EthWorkerCallback)(EthCustomEvent event, void* context);
  34. EthWorker* eth_worker_alloc();
  35. EthWorkerState eth_worker_get_state(EthWorker* eth_worker);
  36. void eth_worker_free(EthWorker* eth_worker);
  37. void eth_worker_start(
  38. EthWorker* eth_worker,
  39. EthWorkerState state,
  40. EthWorkerCallback callback,
  41. void* context);
  42. void eth_worker_stop(EthWorker* eth_worker);