eth_worker.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. EthWorkerStateReset,
  20. } EthWorkerState;
  21. typedef enum
  22. {
  23. EthWorkerProcessInit,
  24. EthWorkerProcessDHCP,
  25. EthWorkerProcessStatic,
  26. EthWorkerProcessPing,
  27. EthWorkerProcessTraceroute,
  28. EthWorkerProcessReset,
  29. EthWorkerProcessActive,
  30. EthWorkerProcessExit,
  31. } EthWorkerProcess;
  32. typedef enum {
  33. EthWorkerSubstateInProcess = 0,
  34. EthWorkerSubStateSuccess,
  35. EthWorkerSubStateError,
  36. } EthWorkerSubState;
  37. typedef enum {
  38. EthCustomEventUpdate = 0,
  39. EthCustomEventModuleInit,
  40. EthCustomEventModuleError,
  41. EthCustomEventModulePowerOn,
  42. EthCustomEventModuleConnect,
  43. EthCustomEventMACInit,
  44. EthCustomEventStaticIp,
  45. EthCustomEventDHCP,
  46. EthCustomEventPing,
  47. EthCustomEventTCP2UART,
  48. EthCustomEventTCP2CLI,
  49. EthCustomEventSaved,
  50. } EthCustomEvent;
  51. typedef void (*EthWorkerCallback)(EthCustomEvent event, void* context);
  52. EthWorker* eth_worker_alloc();
  53. EthWorkerState eth_worker_get_state(EthWorker* eth_worker);
  54. void eth_worker_set_active_process(EthWorker* eth_worker, EthWorkerProcess state);
  55. void eth_worker_free(EthWorker* eth_worker);
  56. void eth_worker_start(
  57. EthWorker* eth_worker,
  58. EthWorkerState state,
  59. EthWorkerCallback callback,
  60. void* context);
  61. void eth_worker_stop(EthWorker* eth_worker);
  62. void eth_worker_dhcp(EthWorker* eth_worker);
  63. void eth_worker_w5500(EthWorker* eth_worker);
  64. void eth_worker_init_process(EthWorker* eth_worker);
  65. #define PING_SOCKET 1
  66. uint8_t ping_auto_interface(uint8_t* adress);
  67. uint8_t traceroute_auto(uint8_t *adress);
  68. void dhcp_timer_callback(void *context);