karasevIA 2 years ago
parent
commit
19f7020787

+ 8 - 1
eth_worker.c

@@ -29,6 +29,9 @@ EthWorker* eth_worker_alloc() {
 
     worker->state = worker->next_state = EthWorkerStateNotAllocated;
 
+    worker->timer = furi_timer_alloc(dhcp_timer_callback, FuriTimerTypePeriodic, NULL);
+    furi_timer_start(worker->timer, 1000);
+
     eth_log(EthWorkerProcessReset, "Finik Ethernet [START]");
 
     return worker;
@@ -48,6 +51,10 @@ void eth_worker_free(EthWorker* worker) {
     ethernet_view_process_free(worker->ping_process);
     ethernet_view_process_free(worker->reset_process);
     ehternet_save_process_free(worker->config);
+
+    furi_timer_stop(worker->timer);
+    furi_timer_free(worker->timer);
+
     free(worker);
 }
 
@@ -460,7 +467,7 @@ int32_t eth_worker_task(void* context) {
                 furi_delay_ms(10);
                 if(divider++ % 100 == 0) {
                     eth_log(EthWorkerProcessDHCP, "DHCP process %d", divider / 100);
-                    if(divider > 400) {
+                    if(divider > 2000) {
                         DHCP_stop();
                         eth_log(EthWorkerProcessDHCP, "DHCP Stop by timer");
                         eth_set_force_state(EthWorkerStateInited);

+ 1 - 0
eth_worker.h

@@ -75,3 +75,4 @@ void eth_worker_init_process(EthWorker* eth_worker);
 
 #define PING_SOCKET 1
 uint8_t ping_auto_interface(uint8_t* adress);
+void dhcp_timer_callback(void* context);

+ 7 - 0
eth_worker_dhcp.c

@@ -0,0 +1,7 @@
+#include "eth_worker.h"
+#include <furi_hal.h>
+#include <dhcp.h>
+
+void dhcp_timer_callback(void* context) {
+    DHCP_time_handler();
+}

+ 1 - 0
eth_worker_i.h

@@ -20,6 +20,7 @@ struct EthWorker {
     EthWorkerState next_state;
     EthWorkerSubState sub_state;
     EthWorkerCallback callback;
+    FuriTimer* timer;
 };
 
 void eth_worker_change_state(EthWorker* eth_worker, EthWorkerState state);

+ 0 - 2
eth_worker_ping.c

@@ -1,7 +1,5 @@
 #include "eth_worker.h"
 #include <furi_hal.h>
-#include <socket.h>
-#include <dhcp.h>
 #include <ping.h>
 
 uint8_t ping_count(uint8_t s, uint16_t pCount, uint8_t* addr);

+ 0 - 2
lib/ioLibrary_Driver/Internet/DHCP/dhcp.c

@@ -239,8 +239,6 @@ void (*dhcp_ip_update)(void) =
 void (*dhcp_ip_conflict)(void) =
     default_ip_conflict; /* handler to be called when the IP address from DHCP server is conflict */
 
-void reg_dhcp_cbfunc(void (*ip_assign)(void), void (*ip_update)(void), void (*ip_conflict)(void));
-
 char NibbleToHex(uint8_t nibble);
 
 /* send DISCOVER message to DHCP server */

+ 2 - 2
lib/ioLibrary_Driver/Internet/DHCP/dhcp.h

@@ -58,8 +58,8 @@ extern "C" {
 #define _DHCP_DEBUG_
 
 /* Retry to processing DHCP */
-#define MAX_DHCP_RETRY 2 ///< Maximum retry count
-#define DHCP_WAIT_TIME 10 ///< Wait Time 10s
+#define MAX_DHCP_RETRY 3 ///< Maximum retry count
+#define DHCP_WAIT_TIME 7 ///< Wait Time 10s
 
 /* UDP port numbers for DHCP */
 #define DHCP_SERVER_PORT 67 ///< DHCP server port number