eth_worker.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  1. #include "eth_worker_i.h"
  2. #include "eth_worker.h"
  3. #include "eth_save_process.h"
  4. #include <furi_hal.h>
  5. #include "dhcp.h"
  6. #include "ping.h"
  7. #include "socket.h"
  8. #include "stm32wbxx_hal_gpio.h"
  9. #include "wizchip_conf.h"
  10. #define TAG "EthWorker"
  11. static EthWorker* static_worker = NULL;
  12. EthWorker* eth_worker_alloc() {
  13. EthWorker* worker = malloc(sizeof(EthWorker));
  14. worker->config = ehternet_save_process_malloc();
  15. furi_assert(worker->config);
  16. worker->init_process = ethernet_view_process_malloc(EthWorkerProcessInit, worker->config);
  17. worker->dhcp_process = ethernet_view_process_malloc(EthWorkerProcessDHCP, worker->config);
  18. worker->stat_process = ethernet_view_process_malloc(EthWorkerProcessStatic, worker->config);
  19. worker->ping_process = ethernet_view_process_malloc(EthWorkerProcessPing, worker->config);
  20. worker->reset_process = ethernet_view_process_malloc(EthWorkerProcessReset, worker->config);
  21. worker->active_process = worker->init_process;
  22. static_worker = worker;
  23. worker->state = worker->next_state = EthWorkerStateNotAllocated;
  24. eth_log(EthWorkerProcessReset, "Finik Ethernet [START]");
  25. return worker;
  26. }
  27. void eth_worker_free(EthWorker* worker) {
  28. eth_log(EthWorkerProcessReset, "Finik Ethernet [STOP]");
  29. eth_run(worker, EthWorkerProcessExit);
  30. static_worker = NULL;
  31. furi_assert(worker);
  32. ethernet_view_process_free(worker->init_process);
  33. ethernet_view_process_free(worker->dhcp_process);
  34. ethernet_view_process_free(worker->stat_process);
  35. ethernet_view_process_free(worker->ping_process);
  36. ethernet_view_process_free(worker->reset_process);
  37. ehternet_save_process_free(worker->config);
  38. free(worker);
  39. }
  40. void eth_worker_change_state(EthWorker* worker, EthWorkerState state) {
  41. furi_assert(worker);
  42. worker->state = state;
  43. }
  44. void eth_worker_set_active_process(EthWorker* worker, EthWorkerProcess state) {
  45. furi_assert(worker);
  46. switch(state) {
  47. case EthWorkerProcessInit:
  48. worker->active_process = worker->init_process;
  49. break;
  50. case EthWorkerProcessDHCP:
  51. worker->active_process = worker->dhcp_process;
  52. break;
  53. case EthWorkerProcessStatic:
  54. worker->active_process = worker->stat_process;
  55. break;
  56. case EthWorkerProcessPing:
  57. worker->active_process = worker->ping_process;
  58. break;
  59. case EthWorkerProcessReset:
  60. worker->active_process = worker->reset_process;
  61. break;
  62. }
  63. }
  64. void eth_worker_log(EthWorker* worker, const char* str) {
  65. furi_assert(worker);
  66. ehternet_save_process_print(worker->config, str);
  67. }
  68. static EthViewProcess* get_process(EthWorker* worker, EthWorkerProcess process) {
  69. furi_assert(worker);
  70. switch(process) {
  71. case EthWorkerProcessInit:
  72. return worker->init_process;
  73. case EthWorkerProcessDHCP:
  74. return worker->dhcp_process;
  75. case EthWorkerProcessStatic:
  76. return worker->stat_process;
  77. case EthWorkerProcessPing:
  78. return worker->ping_process;
  79. case EthWorkerProcessReset:
  80. return worker->reset_process;
  81. case EthWorkerProcessActive:
  82. return worker->active_process;
  83. default:
  84. NULL;
  85. }
  86. }
  87. void eth_log(EthWorkerProcess process, const char* format, ...) {
  88. furi_assert(static_worker);
  89. va_list args;
  90. va_start(args, format);
  91. FuriString* fstring = furi_string_alloc_vprintf(format, args);
  92. const char* string = furi_string_get_cstr(fstring);
  93. va_end(args);
  94. FURI_LOG_I(TAG, "%s", string);
  95. ehternet_save_process_print(static_worker->config, string);
  96. ethernet_view_process_print(get_process(static_worker, process), string);
  97. if(process != EthWorkerProcessReset) {
  98. ethernet_view_process_print(get_process(static_worker, EthWorkerProcessReset), string);
  99. }
  100. furi_string_free(fstring);
  101. }
  102. void eth_run(EthWorker* worker, EthWorkerProcess process) {
  103. furi_assert(worker);
  104. switch(process) {
  105. case EthWorkerProcessInit:
  106. if(worker->state == EthWorkerStateNotAllocated) {
  107. worker->thread = furi_thread_alloc();
  108. furi_thread_set_name(worker->thread, "EthWorker");
  109. furi_thread_set_stack_size(worker->thread, 8192);
  110. furi_thread_set_callback(worker->thread, eth_worker_task);
  111. furi_thread_set_context(worker->thread, worker);
  112. worker->state = EthWorkerStateNotInited;
  113. worker->next_state = EthWorkerStateInit;
  114. furi_thread_start(worker->thread);
  115. }
  116. worker->state = EthWorkerStateNotInited;
  117. worker->next_state = EthWorkerStateInit;
  118. break;
  119. case EthWorkerProcessDHCP:
  120. if((uint8_t)worker->state < EthWorkerStateInited) {
  121. eth_log(EthWorkerProcessDHCP, "[error] module not inited");
  122. break;
  123. }
  124. worker->next_state = EthWorkerStateDHCP;
  125. break;
  126. case EthWorkerProcessStatic:
  127. if((uint8_t)worker->state < EthWorkerStateInited) {
  128. eth_log(EthWorkerProcessStatic, "[error] module not inited");
  129. break;
  130. }
  131. worker->next_state = EthWorkerStateStaticIp;
  132. eth_log(EthWorkerProcessStatic, "Fuck you");
  133. break;
  134. case EthWorkerProcessPing:
  135. if((uint8_t)worker->state < EthWorkerStateInited) {
  136. eth_log(EthWorkerProcessPing, "[error] module not inited");
  137. break;
  138. }
  139. worker->next_state = EthWorkerStatePing;
  140. eth_log(EthWorkerProcessPing, "Fuck you");
  141. break;
  142. case EthWorkerProcessReset:
  143. worker->next_state = EthWorkerStateNotInited;
  144. if((uint8_t)worker->state > EthWorkerStateNotAllocated) {
  145. worker->state = EthWorkerStateNotInited;
  146. }
  147. eth_log(EthWorkerProcessReset, "reset module");
  148. break;
  149. case EthWorkerProcessExit:
  150. if(worker->state != EthWorkerStateNotAllocated) {
  151. worker->next_state = EthWorkerStateStop;
  152. furi_thread_join(worker->thread);
  153. furi_thread_free(worker->thread);
  154. worker->state = EthWorkerStateNotAllocated;
  155. }
  156. break;
  157. default:
  158. break;
  159. }
  160. }
  161. /************************** Ethernet Worker Thread *****************************/
  162. static uint8_t ip_assigned = 0;
  163. static GpioPin cspin = {.port = GPIOA, .pin = GPIO_PIN_4};
  164. static GpioPin resetpin = {.port = GPIOC, .pin = GPIO_PIN_3};
  165. static void W5500_Select(void) {
  166. furi_hal_gpio_write(&cspin, false);
  167. }
  168. static void W5500_Unselect(void) {
  169. furi_hal_gpio_write(&cspin, true);
  170. }
  171. static void Callback_IPAssigned(void) {
  172. eth_log(
  173. EthWorkerProcessDHCP, "Callback: IP assigned! Leased time: %d sec", getDHCPLeasetime());
  174. ip_assigned = 1;
  175. }
  176. static void Callback_IPConflict(void) {
  177. eth_log(EthWorkerProcessDHCP, "Callback: IP conflict!");
  178. }
  179. static void W5500_ReadBuff(uint8_t* buff, uint16_t len) {
  180. furi_hal_spi_bus_rx(&furi_hal_spi_bus_handle_external, buff, len, 1000);
  181. }
  182. static void W5500_WriteBuff(uint8_t* buff, uint16_t len) {
  183. furi_hal_spi_bus_tx(&furi_hal_spi_bus_handle_external, buff, len, 1000);
  184. }
  185. static uint8_t W5500_ReadByte(void) {
  186. uint8_t byte;
  187. W5500_ReadBuff(&byte, sizeof(byte));
  188. return byte;
  189. }
  190. static void W5500_WriteByte(uint8_t byte) {
  191. W5500_WriteBuff(&byte, sizeof(byte));
  192. }
  193. static void wait_ms(int ms) {
  194. furi_delay_ms(ms);
  195. }
  196. static wiz_NetInfo gWIZNETINFO;
  197. void update_WIZNETINFO(uint8_t is_dhcp) {
  198. furi_assert(static_worker);
  199. memcpy(gWIZNETINFO.mac, static_worker->config->mac, 6);
  200. if(is_dhcp) {
  201. memset(gWIZNETINFO.ip, 0, 4);
  202. memset(gWIZNETINFO.sn, 0, 4);
  203. memset(gWIZNETINFO.gw, 0, 4);
  204. memset(gWIZNETINFO.dns, 0, 4);
  205. gWIZNETINFO.dhcp = NETINFO_DHCP;
  206. } else {
  207. memcpy(gWIZNETINFO.ip, static_worker->config->ip, 4);
  208. memcpy(gWIZNETINFO.sn, static_worker->config->mask, 4);
  209. memcpy(gWIZNETINFO.gw, static_worker->config->gateway, 4);
  210. memcpy(gWIZNETINFO.dns, static_worker->config->dns, 4);
  211. gWIZNETINFO.dhcp = NETINFO_STATIC;
  212. }
  213. }
  214. #define DHCP_SOCKET 0
  215. uint8_t ping_auto(uint8_t s, uint8_t* addr);
  216. int32_t eth_worker_task(void* context) {
  217. furi_assert(context);
  218. EthWorker* worker = (EthWorker*)context;
  219. furi_hal_power_insomnia_enter();
  220. furi_hal_spi_acquire(&furi_hal_spi_bus_handle_external);
  221. uint8_t W5500FifoSize[2][8] = {{2, 2, 2, 2, 2, 2, 2, 2}, {2, 2, 2, 2, 2, 2, 2, 2}};
  222. uint8_t dhcp_buffer[2000];
  223. reg_wizchip_spi_cbfunc(W5500_ReadByte, W5500_WriteByte);
  224. reg_wizchip_spiburst_cbfunc(W5500_ReadBuff, W5500_WriteBuff);
  225. reg_wizchip_cs_cbfunc(W5500_Select, W5500_Unselect);
  226. furi_hal_gpio_write(&resetpin, true);
  227. furi_hal_gpio_write(&cspin, true);
  228. furi_hal_gpio_init(&resetpin, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedVeryHigh);
  229. furi_hal_gpio_init(&cspin, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedVeryHigh);
  230. while(worker->next_state != EthWorkerStateStop && worker->state != EthWorkerStateStop) {
  231. if(worker->state == EthWorkerStateNotInited) {
  232. if(worker->next_state != EthWorkerStateInit &&
  233. worker->next_state != EthWorkerStateNotInited) {
  234. eth_log(EthWorkerProcessActive, "[error] try using not inited module");
  235. worker->next_state = EthWorkerStateNotInited;
  236. }
  237. if(worker->next_state == EthWorkerStateInit) {
  238. worker->state = EthWorkerStateInit;
  239. furi_hal_power_enable_otg();
  240. furi_delay_ms(300);
  241. furi_hal_gpio_write(&resetpin, false);
  242. furi_delay_ms(50);
  243. furi_hal_gpio_write(&resetpin, true);
  244. if(ctlwizchip(CW_INIT_WIZCHIP, (void*)W5500FifoSize) == -1) {
  245. eth_log(EthWorkerProcessInit, "[error] W5500 init fail");
  246. worker->state = worker->next_state = EthWorkerStateNotInited;
  247. continue;
  248. }
  249. eth_log(EthWorkerProcessInit, "W5500 inited");
  250. furi_delay_ms(50);
  251. update_WIZNETINFO(false);
  252. wizchip_setnetinfo(&gWIZNETINFO);
  253. wiz_NetInfo readed_net_info;
  254. wizchip_getnetinfo(&readed_net_info);
  255. if(memcmp(&readed_net_info, &gWIZNETINFO, sizeof(wiz_NetInfo))) {
  256. eth_log(EthWorkerProcessInit, "[error] module not detected");
  257. worker->state = EthWorkerStateNotInited;
  258. continue;
  259. }
  260. setSHAR(gWIZNETINFO.mac);
  261. wiz_PhyConf conf;
  262. wizphy_getphyconf(&conf);
  263. eth_log(
  264. EthWorkerProcessInit,
  265. "conf %d %d %d %d",
  266. conf.by,
  267. conf.mode,
  268. conf.speed,
  269. conf.duplex);
  270. eth_log(EthWorkerProcessInit, "net info setted");
  271. eth_log(
  272. EthWorkerProcessInit,
  273. "mac: %02X-%02X-%02X-%02X-%02X-%02X",
  274. gWIZNETINFO.mac[0],
  275. gWIZNETINFO.mac[1],
  276. gWIZNETINFO.mac[2],
  277. gWIZNETINFO.mac[3],
  278. gWIZNETINFO.mac[4],
  279. gWIZNETINFO.mac[5]);
  280. worker->state = EthWorkerStateInited;
  281. continue;
  282. }
  283. } else if(worker->state == EthWorkerStateInited) {
  284. if(worker->next_state == EthWorkerStateDHCP) {
  285. worker->state = EthWorkerStateDHCP;
  286. uint8_t temp = PHY_LINK_OFF;
  287. while(temp == PHY_LINK_OFF && worker->state == EthWorkerStateDHCP) {
  288. if(ctlwizchip(CW_GET_PHYLINK, (void*)&temp) == -1) {
  289. eth_log(EthWorkerProcessDHCP, "Unknown PHY link status");
  290. }
  291. furi_delay_ms(1);
  292. }
  293. if(worker->state != EthWorkerStateDHCP) {
  294. break;
  295. }
  296. reg_dhcp_cbfunc(Callback_IPAssigned, Callback_IPAssigned, Callback_IPConflict);
  297. DHCP_init(DHCP_SOCKET, dhcp_buffer);
  298. uint8_t dhcp_ret = DHCP_STOPPED;
  299. uint8_t next_cycle = 1;
  300. while(next_cycle && worker->state == EthWorkerStateDHCP) {
  301. dhcp_ret = DHCP_run();
  302. switch(dhcp_ret) {
  303. case DHCP_IP_ASSIGN:
  304. case DHCP_IP_CHANGED:
  305. case DHCP_IP_LEASED:
  306. getIPfromDHCP(gWIZNETINFO.ip);
  307. getGWfromDHCP(gWIZNETINFO.gw);
  308. getSNfromDHCP(gWIZNETINFO.sn);
  309. getDNSfromDHCP(gWIZNETINFO.dns);
  310. gWIZNETINFO.dhcp = NETINFO_DHCP;
  311. ctlnetwork(CN_SET_NETINFO, (void*)&gWIZNETINFO);
  312. eth_log(
  313. EthWorkerProcessDHCP,
  314. "DHCP IP Leased Time : %ld Sec",
  315. getDHCPLeasetime());
  316. break;
  317. case DHCP_FAILED:
  318. eth_log(EthWorkerProcessDHCP, "DHCP Failed");
  319. break;
  320. }
  321. furi_delay_ms(1000);
  322. next_cycle = (dhcp_ret == DHCP_RUNNING);
  323. }
  324. if(worker->state != EthWorkerStateDHCP) {
  325. break;
  326. }
  327. //wizchip_getnetinfo(&gWIZNETINFO);
  328. eth_log(
  329. EthWorkerProcessDHCP,
  330. "IP address:\n %d.%d.%d.%d",
  331. gWIZNETINFO.ip[0],
  332. gWIZNETINFO.ip[1],
  333. gWIZNETINFO.ip[2],
  334. gWIZNETINFO.ip[3]);
  335. eth_log(
  336. EthWorkerProcessDHCP,
  337. "SM Mask:\n %d.%d.%d.%d",
  338. gWIZNETINFO.sn[0],
  339. gWIZNETINFO.sn[1],
  340. gWIZNETINFO.sn[2],
  341. gWIZNETINFO.sn[3]);
  342. eth_log(
  343. EthWorkerProcessDHCP,
  344. "Gate way:\n %d.%d.%d.%d",
  345. gWIZNETINFO.gw[0],
  346. gWIZNETINFO.gw[1],
  347. gWIZNETINFO.gw[2],
  348. gWIZNETINFO.gw[3]);
  349. eth_log(
  350. EthWorkerProcessDHCP,
  351. "DNS Server:\n %d.%d.%d.%d",
  352. gWIZNETINFO.dns[0],
  353. gWIZNETINFO.dns[1],
  354. gWIZNETINFO.dns[2],
  355. gWIZNETINFO.dns[3]);
  356. worker->state = EthWorkerStateOnline;
  357. }
  358. } else if(worker->state == EthWorkerStateOnline) {
  359. if(worker->next_state == EthWorkerStatePing) {
  360. worker->state = EthWorkerStatePing;
  361. uint8_t* adress = static_worker->config->ping_ip;
  362. eth_log(
  363. EthWorkerProcessDHCP,
  364. "ping %d.%d.%d.%d",
  365. adress[0],
  366. adress[1],
  367. adress[2],
  368. adress[3]);
  369. const uint8_t tryes = 4;
  370. uint8_t try = 0;
  371. while(try < tryes && worker->state == EthWorkerStatePing) {
  372. try++;
  373. uint32_t start_time = furi_get_tick();
  374. uint8_t res = 3; //ping_auto(1, adress);
  375. uint32_t res_time = furi_get_tick();
  376. if(res == 3) {
  377. eth_log(
  378. EthWorkerProcessDHCP, "%d success %d ms", try, res_time - start_time);
  379. } else {
  380. eth_log(
  381. EthWorkerProcessDHCP,
  382. "%d error %d, %d",
  383. try,
  384. res,
  385. res_time - start_time);
  386. break;
  387. }
  388. }
  389. if(worker->state != EthWorkerStatePing) {
  390. break;
  391. }
  392. worker->state = EthWorkerStateOnline;
  393. } else {
  394. }
  395. }
  396. furi_delay_ms(50);
  397. }
  398. furi_hal_spi_release(&furi_hal_spi_bus_handle_external);
  399. furi_hal_power_disable_otg();
  400. furi_hal_power_insomnia_exit();
  401. return 0;
  402. }
  403. static void w5500_init() {
  404. furi_hal_spi_acquire(&furi_hal_spi_bus_handle_external);
  405. uint8_t W5500FifoSize[2][8] = {{2, 2, 2, 2, 2, 2, 2, 2}, {2, 2, 2, 2, 2, 2, 2, 2}};
  406. FURI_LOG_I(TAG, "Registering W5500 callbacks");
  407. reg_wizchip_spi_cbfunc(W5500_ReadByte, W5500_WriteByte);
  408. reg_wizchip_spiburst_cbfunc(W5500_ReadBuff, W5500_WriteBuff);
  409. reg_wizchip_cs_cbfunc(W5500_Select, W5500_Unselect);
  410. GpioPin resetpin = {.port = GPIOC, .pin = GPIO_PIN_3};
  411. furi_hal_gpio_write(&resetpin, true);
  412. furi_hal_gpio_write(&cspin, true);
  413. furi_hal_gpio_init(&resetpin, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedVeryHigh);
  414. furi_hal_gpio_init(&cspin, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedVeryHigh);
  415. }
  416. static void w5500_deinit() {
  417. furi_hal_spi_release(&furi_hal_spi_bus_handle_external);
  418. }
  419. void eth_worker_w5500(EthWorker* eth_worker) {
  420. furi_assert(eth_worker);
  421. //uint8_t temp;
  422. FURI_LOG_I(TAG, "Ehtping_Init");
  423. furi_hal_spi_acquire(&furi_hal_spi_bus_handle_external);
  424. uint8_t W5500FifoSize[2][8] = {{2, 2, 2, 2, 2, 2, 2, 2}, {2, 2, 2, 2, 2, 2, 2, 2}};
  425. FURI_LOG_I(TAG, "Registering W5500 callbacks");
  426. reg_wizchip_spi_cbfunc(W5500_ReadByte, W5500_WriteByte);
  427. reg_wizchip_spiburst_cbfunc(W5500_ReadBuff, W5500_WriteBuff);
  428. reg_wizchip_cs_cbfunc(W5500_Select, W5500_Unselect);
  429. FURI_LOG_I(TAG, "Registered W5500 callbacks");
  430. GpioPin resetpin = {.port = GPIOC, .pin = GPIO_PIN_3};
  431. furi_hal_gpio_write(&resetpin, true);
  432. furi_hal_gpio_write(&cspin, true);
  433. furi_hal_gpio_init(&resetpin, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedVeryHigh);
  434. furi_hal_gpio_init(&cspin, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedVeryHigh);
  435. FURI_LOG_I(TAG, "GPIO inited");
  436. furi_hal_power_enable_otg();
  437. furi_delay_ms(1000);
  438. //eth_worker->callback(EthCustomEventModulePowerOn, eth_worker->context);
  439. furi_delay_ms(2000);
  440. furi_hal_gpio_write(&resetpin, false);
  441. furi_delay_ms(10);
  442. furi_hal_gpio_write(&resetpin, true);
  443. FURI_LOG_I(TAG, "GPIO used");
  444. //eth_worker->callback(EthCustomEventModuleConnect, eth_worker->context);
  445. if(ctlwizchip(CW_INIT_WIZCHIP, (void*)W5500FifoSize) == -1) {
  446. FURI_LOG_I(TAG, "W5500 initialized fail.\r\n");
  447. //eth_worker->callback(EthCustomEventModuleError, eth_worker->context);
  448. }
  449. FURI_LOG_I(TAG, "W5500 initialized success.\r\n");
  450. furi_delay_ms(2000);
  451. wizchip_setnetinfo(&gWIZNETINFO);
  452. FURI_LOG_I(TAG, "W5500 info setted 1.\r\n");
  453. setSHAR(gWIZNETINFO.mac);
  454. FURI_LOG_I(TAG, "W5500 info setted 2.\r\n");
  455. //check phy status
  456. //do
  457. //{
  458. // if (ctlwizchip(CW_GET_PHYLINK, (void*)&temp) == -1)
  459. // {
  460. // FURI_LOG_I(TAG, "Unknown PHY link status.\r\n");
  461. // }
  462. // furi_delay_ms(1);
  463. //} while (temp == PHY_LINK_OFF);
  464. //FURI_LOG_I(TAG, "W5500 gWIZNETINFO success.\r\n");
  465. ////eth_worker->callback(EthCustomEventPHYConnect, eth_worker->context);
  466. FURI_LOG_I(TAG, "W5500 before delay\r\n");
  467. furi_delay_ms(2000);
  468. FURI_LOG_I(TAG, "W5500 after delay\r\n");
  469. //furi_hal_power_disable_otg();
  470. //FURI_LOG_I(TAG, "W5500 power off\r\n");
  471. ////eth_worker->callback(EthCustomEventModuleError, eth_worker->context);
  472. furi_delay_ms(2000);
  473. ////eth_worker->callback(EthCustomEventModuleConnected, eth_worker->context);
  474. furi_hal_spi_release(&furi_hal_spi_bus_handle_external);
  475. }