eth_worker.h 1.9 KB

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