summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsakumisu <[email protected]>2025-12-03 17:26:50 +0800
committersakumisu <[email protected]>2025-12-03 17:27:28 +0800
commit006123c29676013f2e9a13e1535fa6bb09e07be3 (patch)
tree5815233018fefa7f2857ec4bc61f7fc25cfa48c5
parent670bde36718d5fd110dbc22237513120b0fb6407 (diff)
update: remove old bl616 wifi driver, add new api
Signed-off-by: sakumisu <[email protected]>
-rw-r--r--CMakeLists.txt1
-rw-r--r--cherryusb.cmake4
-rw-r--r--demo/usbh_bl616_wifi_cli.c182
-rw-r--r--platform/idf/usbh_net.c1
-rw-r--r--platform/lwip/usbh_lwip.c102
5 files changed, 182 insertions, 108 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b194e3cc..daaaae79 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -56,7 +56,6 @@ elseif(ESP_PLATFORM)
OR CONFIG_CHERRYUSB_HOST_CDC_NCM
OR CONFIG_CHERRYUSB_HOST_ASIX
OR CONFIG_CHERRYUSB_HOST_RTL8152
- OR CONFIG_CHERRYUSB_HOST_BL616
)
idf_component_get_property(lwip lwip COMPONENT_LIB)
target_compile_definitions(${lwip} PRIVATE "-DPBUF_POOL_BUFSIZE=1600")
diff --git a/cherryusb.cmake b/cherryusb.cmake
index 5734745b..540ce97f 100644
--- a/cherryusb.cmake
+++ b/cherryusb.cmake
@@ -246,9 +246,6 @@ if(CONFIG_CHERRYUSB_HOST)
if(CONFIG_CHERRYUSB_HOST_PL2303)
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/vendor/serial/usbh_pl2303.c)
endif()
- if(CONFIG_CHERRYUSB_HOST_BL616)
- list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/vendor/wifi/usbh_bl616.c)
- endif()
if(CONFIG_CHERRYUSB_HOST_AOA)
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/aoa/usbh_aoa.c)
endif()
@@ -258,7 +255,6 @@ if(CONFIG_CHERRYUSB_HOST)
OR CONFIG_CHERRYUSB_HOST_CDC_NCM
OR CONFIG_CHERRYUSB_HOST_ASIX
OR CONFIG_CHERRYUSB_HOST_RTL8152
- OR CONFIG_CHERRYUSB_HOST_BL616
)
if("${CONFIG_CHERRYUSB_OSAL}" STREQUAL "idf")
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/platform/idf/usbh_net.c)
diff --git a/demo/usbh_bl616_wifi_cli.c b/demo/usbh_bl616_wifi_cli.c
new file mode 100644
index 00000000..125a2639
--- /dev/null
+++ b/demo/usbh_bl616_wifi_cli.c
@@ -0,0 +1,182 @@
+#include "usbh_core.h"
+#include "usbh_cdc_acm.h"
+#include "shell.h"
+
+static USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t cdc_buffer[8 * 1024];
+
+int wifi_scan(int argc, char **argv)
+{
+ struct usbh_cdc_acm *cdc_acm_class = usbh_find_class_instance("/dev/ttyACM0");
+ uint32_t len;
+ int ret;
+
+ if (cdc_acm_class == NULL) {
+ printf("cdc acm class not found\r\n");
+ return -1;
+ }
+
+ len = snprintf((char *)cdc_buffer, sizeof(cdc_buffer), "ap_scan\r\n");
+ ret = usbh_cdc_acm_bulk_out_transfer(cdc_acm_class, cdc_buffer, len, 3000);
+ if (ret < 0) {
+ printf("wifi scan failed1, ret:%d\r\n", ret);
+ return -1;
+ }
+
+ ret = usbh_cdc_acm_bulk_in_transfer(cdc_acm_class, cdc_buffer, sizeof(cdc_buffer), 3000);
+ if (ret < 0) {
+ printf("wifi scan failed2, ret:%d\r\n", ret);
+ return -1;
+ }
+ cdc_buffer[ret] = '\0';
+ printf("%s\r\n", cdc_buffer);
+ return 0;
+}
+CSH_CMD_EXPORT(wifi_scan, wifi_scan);
+
+int wifi_scan_result(int argc, char **argv)
+{
+ struct usbh_cdc_acm *cdc_acm_class = usbh_find_class_instance("/dev/ttyACM0");
+ uint32_t len;
+ int ret;
+
+ if (cdc_acm_class == NULL) {
+ printf("cdc acm class not found\r\n");
+ return -1;
+ }
+
+ len = snprintf((char *)cdc_buffer, sizeof(cdc_buffer), "ap_scan_result {\"offset\":0, \"count\":0}\r\n");
+ ret = usbh_cdc_acm_bulk_out_transfer(cdc_acm_class, cdc_buffer, len, 3000);
+ if (ret < 0) {
+ printf("wifi scan failed1, ret:%d\r\n", ret);
+ return -1;
+ }
+
+ ret = usbh_cdc_acm_bulk_in_transfer(cdc_acm_class, cdc_buffer, sizeof(cdc_buffer), 3000);
+ if (ret < 0) {
+ printf("wifi scan failed2, ret:%d\r\n", ret);
+ return -1;
+ }
+ cdc_buffer[ret] = '\0';
+ printf("%s\r\n", cdc_buffer);
+ return 0;
+}
+CSH_CMD_EXPORT(wifi_scan_result, wifi_scan_result);
+
+int wifi_connect(int argc, char **argv)
+{
+ struct usbh_cdc_acm *cdc_acm_class = usbh_find_class_instance("/dev/ttyACM0");
+ uint32_t len;
+ int ret;
+
+ if (cdc_acm_class == NULL) {
+ printf("cdc acm class not found\r\n");
+ return -1;
+ }
+
+ if (argc < 3) {
+ printf("please input correct command: wifi_connect ssid password\r\n");
+ return -1;
+ }
+
+ len = snprintf((char *)cdc_buffer, sizeof(cdc_buffer), "ap_connect {\"ssid\":\"%s\", \"password\":\"%s\"}\r\n", argv[1], argv[2]);
+ ret = usbh_cdc_acm_bulk_out_transfer(cdc_acm_class, cdc_buffer, len, 3000);
+ if (ret < 0) {
+ printf("wifi connect failed1, ret:%d\r\n", ret);
+ return -1;
+ }
+ ret = usbh_cdc_acm_bulk_in_transfer(cdc_acm_class, cdc_buffer, sizeof(cdc_buffer), 3000);
+ if (ret < 0) {
+ printf("wifi connect failed2, ret:%d\r\n", ret);
+ return -1;
+ }
+ cdc_buffer[ret] = '\0';
+ printf("%s\r\n", cdc_buffer);
+ return 0;
+}
+CSH_CMD_EXPORT(wifi_connect, wifi_connect);
+
+int wifi_disconnect(int argc, char **argv)
+{
+ struct usbh_cdc_acm *cdc_acm_class = usbh_find_class_instance("/dev/ttyACM0");
+ uint32_t len;
+ int ret;
+
+ if (cdc_acm_class == NULL) {
+ printf("cdc acm class not found\r\n");
+ return -1;
+ }
+
+ len = snprintf((char *)cdc_buffer, sizeof(cdc_buffer), "ap_disconnect\r\n");
+ ret = usbh_cdc_acm_bulk_out_transfer(cdc_acm_class, cdc_buffer, len, 3000);
+ if (ret < 0) {
+ printf("wifi disconnect failed1, ret:%d\r\n", ret);
+ return -1;
+ }
+ ret = usbh_cdc_acm_bulk_in_transfer(cdc_acm_class, cdc_buffer, sizeof(cdc_buffer), 3000);
+ if (ret < 0) {
+ printf("wifi disconnect failed2, ret:%d\r\n", ret);
+ return -1;
+ }
+ cdc_buffer[ret] = '\0';
+ printf("%s\r\n", cdc_buffer);
+ return 0;
+}
+CSH_CMD_EXPORT(wifi_disconnect, wifi_disconnect);
+
+int wifi_status(int argc, char **argv)
+{
+ struct usbh_cdc_acm *cdc_acm_class = usbh_find_class_instance("/dev/ttyACM0");
+ uint32_t len;
+ int ret;
+
+ if (cdc_acm_class == NULL) {
+ printf("cdc acm class not found\r\n");
+ return -1;
+ }
+
+ len = snprintf((char *)cdc_buffer, sizeof(cdc_buffer), "ap_status\r\n");
+ ret = usbh_cdc_acm_bulk_out_transfer(cdc_acm_class, cdc_buffer, len, 3000);
+ if (ret < 0) {
+ printf("wifi status failed1, ret:%d\r\n", ret);
+ return -1;
+ }
+
+ ret = usbh_cdc_acm_bulk_in_transfer(cdc_acm_class, cdc_buffer, sizeof(cdc_buffer), 3000);
+ if (ret < 0) {
+ printf("wifi status failed2, ret:%d\r\n", ret);
+ return -1;
+ }
+ cdc_buffer[ret] = '\0';
+ printf("%s\r\n", cdc_buffer);
+ return 0;
+}
+CSH_CMD_EXPORT(wifi_status, wifi_status);
+
+int wifi_version(int argc, char **argv)
+{
+ struct usbh_cdc_acm *cdc_acm_class = usbh_find_class_instance("/dev/ttyACM0");
+ uint32_t len;
+ int ret;
+
+ if (cdc_acm_class == NULL) {
+ printf("cdc acm class not found\r\n");
+ return -1;
+ }
+
+ len = snprintf((char *)cdc_buffer, sizeof(cdc_buffer), "sys_version\r\n");
+ ret = usbh_cdc_acm_bulk_out_transfer(cdc_acm_class, cdc_buffer, len, 3000);
+ if (ret < 0) {
+ printf("wifi status failed1, ret:%d\r\n", ret);
+ return -1;
+ }
+
+ ret = usbh_cdc_acm_bulk_in_transfer(cdc_acm_class, cdc_buffer, sizeof(cdc_buffer), 3000);
+ if (ret < 0) {
+ printf("wifi status failed2, ret:%d\r\n", ret);
+ return -1;
+ }
+ cdc_buffer[ret] = '\0';
+ printf("%s\r\n", cdc_buffer);
+ return 0;
+}
+CSH_CMD_EXPORT(wifi_version, wifi_version); \ No newline at end of file
diff --git a/platform/idf/usbh_net.c b/platform/idf/usbh_net.c
index 222cf1eb..b4febf76 100644
--- a/platform/idf/usbh_net.c
+++ b/platform/idf/usbh_net.c
@@ -21,7 +21,6 @@
// #define CONFIG_USBHOST_PLATFORM_CDC_NCM
// #define CONFIG_USBHOST_PLATFORM_ASIX
// #define CONFIG_USBHOST_PLATFORM_RTL8152
-// #define CONFIG_USBHOST_PLATFORM_BL616
struct usbh_net_netif_glue {
esp_netif_driver_base_t base;
diff --git a/platform/lwip/usbh_lwip.c b/platform/lwip/usbh_lwip.c
index 7b3f7c62..02eef59f 100644
--- a/platform/lwip/usbh_lwip.c
+++ b/platform/lwip/usbh_lwip.c
@@ -35,7 +35,6 @@
// #define CONFIG_USBHOST_PLATFORM_CDC_NCM
// #define CONFIG_USBHOST_PLATFORM_ASIX
// #define CONFIG_USBHOST_PLATFORM_RTL8152
-// #define CONFIG_USBHOST_PLATFORM_BL616
ip_addr_t g_ipaddr;
ip_addr_t g_netmask;
@@ -545,104 +544,3 @@ void usbh_rtl8152_stop(struct usbh_rtl8152 *rtl8152_class)
netif_remove(netif);
}
#endif
-
-#ifdef CONFIG_USBHOST_PLATFORM_BL616
-#include "usbh_bl616.h"
-
-struct netif g_bl616_netif;
-static err_t usbh_bl616_linkoutput(struct netif *netif, struct pbuf *p)
-{
- int ret;
- (void)netif;
-
- usbh_lwip_eth_output_common(p, usbh_bl616_get_eth_txbuf());
- ret = usbh_bl616_eth_output(p->tot_len);
- if (ret < 0) {
- return ERR_BUF;
- } else {
- return ERR_OK;
- }
-}
-
-void usbh_bl616_eth_input(uint8_t *buf, uint32_t buflen)
-{
- usbh_lwip_eth_input_common(&g_bl616_netif, buf, buflen);
-}
-
-static err_t usbh_bl616_if_init(struct netif *netif)
-{
- LWIP_ASSERT("netif != NULL", (netif != NULL));
-
- netif->mtu = 1500;
- netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP;
- netif->state = NULL;
- netif->name[0] = 'E';
- netif->name[1] = 'X';
- netif->output = etharp_output;
- netif->linkoutput = usbh_bl616_linkoutput;
- return ERR_OK;
-}
-
-void usbh_bl616_sta_connect_callback(void)
-{
-}
-
-void usbh_bl616_sta_disconnect_callback(void)
-{
- struct netif *netif = &g_bl616_netif;
-
- netif_set_down(netif);
-}
-
-void usbh_bl616_sta_update_ip(uint8_t ip4_addr[4], uint8_t ip4_mask[4], uint8_t ip4_gw[4])
-{
- struct netif *netif = &g_bl616_netif;
-
- IP4_ADDR(&netif->ip_addr, ip4_addr[0], ip4_addr[1], ip4_addr[2], ip4_addr[3]);
- IP4_ADDR(&netif->netmask, ip4_mask[0], ip4_mask[1], ip4_mask[2], ip4_mask[3]);
- IP4_ADDR(&netif->gw, ip4_gw[0], ip4_gw[1], ip4_gw[2], ip4_gw[3]);
-
- netif_set_up(netif);
-}
-
-void usbh_bl616_run(struct usbh_bl616 *bl616_class)
-{
- struct netif *netif = &g_bl616_netif;
-
- netif->hwaddr_len = 6;
- memcpy(netif->hwaddr, bl616_class->sta_mac, 6);
-
- IP4_ADDR(&g_ipaddr, 0, 0, 0, 0);
- IP4_ADDR(&g_netmask, 0, 0, 0, 0);
- IP4_ADDR(&g_gateway, 0, 0, 0, 0);
-
- netif = netif_add(netif, &g_ipaddr, &g_netmask, &g_gateway, NULL, usbh_bl616_if_init, tcpip_input);
- netif_set_down(netif);
- netif_set_default(netif);
-
- dhcp_handle = usb_osal_timer_create("dhcp", 200, dhcp_timeout, netif, true);
- if (dhcp_handle == NULL) {
- USB_LOG_ERR("timer creation failed! \r\n");
- while (1) {
- }
- }
- usb_osal_timer_start(dhcp_handle);
-
- usb_osal_thread_create("usbh_bl616", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_bl616_rx_thread, NULL);
-}
-
-void usbh_bl616_stop(struct usbh_bl616 *bl616_class)
-{
- struct netif *netif = &g_bl616_netif;
-
- (void)bl616_class;
-
- netif_set_down(netif);
- netif_remove(netif);
-}
-
-// #include "shell.h"
-
-// CSH_CMD_EXPORT(wifi_sta_connect, );
-// CSH_CMD_EXPORT(wifi_scan, );
-#endif \ No newline at end of file