Skip to content

Instantly share code, notes, and snippets.

@jtanx
Created December 28, 2018 13:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtanx/d21a4e2262ed1d3e0938cee1efbef173 to your computer and use it in GitHub Desktop.
Save jtanx/d21a4e2262ed1d3e0938cee1efbef173 to your computer and use it in GitHub Desktop.
usbmode huawei alt mode patch
From 7b33451b684c5c2703ee8ff9a523c8384337eaa0 Mon Sep 17 00:00:00 2001
From: Jeremy Tan <jtanx@outlook.com>
Date: Thu, 27 Dec 2018 20:28:27 +0800
Subject: [PATCH] Add Huawei alt mode support
diff --git a/convert-modeswitch.pl b/convert-modeswitch.pl
index b1530bd..33f123b 100755
--- a/convert-modeswitch.pl
+++ b/convert-modeswitch.pl
@@ -68,6 +68,7 @@ my %options = (
MBIM => $mode_option,
HuaweiMode => $mode_option,
HuaweiNewMode => $mode_option,
+ HuaweiAltMode => $mode_option,
QuantaMode => $mode_option,
BlackberryMode => $mode_option,
PantechMode => $value_mode_option,
diff --git a/switch.c b/switch.c
index cc04237..df0d980 100644
--- a/switch.c
+++ b/switch.c
@@ -153,6 +153,20 @@ static void handle_huaweinew(struct usbdev_data *data, struct blob_attr **tb)
send_messages(data, msgs, ARRAY_SIZE(msgs));
}
+static void handle_huaweialt(struct usbdev_data *data, struct blob_attr **tb)
+{
+ static struct msg_entry msgs[] = {
+ {
+ "\x55\x53\x42\x43\x12\x34\x56\x78\x00\x00\x00\x00\x00\x00\x00\x11"
+ "\x06\x30\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00", 31
+ }
+ };
+
+ detach_driver(data);
+ data->need_response = false;
+ send_messages(data, msgs, ARRAY_SIZE(msgs));
+}
+
static void handle_option(struct usbdev_data *data, struct blob_attr **tb)
{
static struct msg_entry msgs[] = {
@@ -418,6 +432,7 @@ enum {
MODE_GENERIC,
MODE_HUAWEI,
MODE_HUAWEINEW,
+ MODE_HUAWEIALT,
MODE_SIERRA,
MODE_STDEJECT,
MODE_SONY,
@@ -443,6 +458,7 @@ static const struct {
[MODE_STDEJECT] = { "StandardEject", handle_standardeject },
[MODE_HUAWEI] = { "Huawei", handle_huawei },
[MODE_HUAWEINEW] = { "HuaweiNew", handle_huaweinew },
+ [MODE_HUAWEIALT] = { "HuaweiAlt", handle_huaweialt },
[MODE_SIERRA] = { "Sierra", handle_sierra },
[MODE_SONY] = { "Sony", handle_sony },
[MODE_QISDA] = { "Qisda", handle_qisda },
--
2.11.0
@Strykar
Copy link

Strykar commented Jun 7, 2021

Have you tried to get this accepted upstream to OpenWRT?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment