eth_worker.h 1.7 KB

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