Просмотр исходного кода

update:w5500状态应该统一指示

doudou 2 лет назад
Родитель
Сommit
2607cd7289
2 измененных файлов с 14 добавлено и 20 удалено
  1. 13 19
      components/ethernet/w5500/luat_lib_w5500.c
  2. 1 1
      components/ethernet/w5500/w5500.c

+ 13 - 19
components/ethernet/w5500/luat_lib_w5500.c

@@ -193,31 +193,25 @@ end)
 		break;
 /*
 @sys_pub w5500
-网线已插入
-CABLE_INSERT
+w5500状态变化
+W5500_IND
 @usage
--- 网线插入后会发一次这个消息
-sys.subscribe("CABLE_INSERT", function()
-    log.info("w5500", "CABLE_INSERT")
+sys.subscribe("W5500_IND", function(status)
+    -- status的取值有:
+    -- CABLE_INWERT 网线插入
+    -- CABLE_REMOVE 网线拔出
+    log.info("w5500 status", status)
 end)
 */
 	case W5500_CABLE_INSERT:
+		lua_pushliteral(L, "W5500_IND");
 		lua_pushliteral(L, "CABLE_INSERT");
-		lua_call(L, 1, 0);
+		lua_call(L, 2, 0);
 		break;
-/*
-@sys_pub w5500
-网线已拔出
-CABLE_REMOVE
-@usage
--- 网线拔出后会发一次这个消息
-sys.subscribe("CABLE_REMOVE", function()
-    log.info("w5500", "CABLE_REMOVE")
-end)
-*/
 	case W5500_CABLE_REMOVE:
+		lua_pushliteral(L, "W5500_IND");
 		lua_pushliteral(L, "CABLE_REMOVE");
-		lua_call(L, 1, 0);
+		lua_call(L, 2, 0);
 		break;
 	default:
 		break;
@@ -226,11 +220,11 @@ end)
 }
 
 // W5500的状态回调函数
-void w5500_nw_state_cb(int state, uint32_t ip) {
+void w5500_nw_state_cb(int state, uint32_t param) {
 	rtos_msg_t msg = {0};
 	msg.handler = l_nw_state_handler;
 	msg.arg1 = state; // READY
-	msg.arg2 = ip;
+	msg.arg2 = param;
 	luat_msgbus_put(&msg, 0);
 }
 

+ 1 - 1
components/ethernet/w5500/w5500.c

@@ -561,7 +561,7 @@ static int w5500_socket_rx(w5500_ctrl_t *w5500, uint8_t socket_id, uint8_t *data
 	return len;
 }
 
-extern void w5500_nw_state_cb(int state, uint32_t ip);
+extern void w5500_nw_state_cb(int state, uint32_t param);
 
 static void w5500_nw_state(w5500_ctrl_t *w5500)
 {