Skip to content

Instantly share code, notes, and snippets.

@stefanocoding
Created February 24, 2018 03:43
Show Gist options
  • Save stefanocoding/923931ae84333e2db7d60aafbb5a4f7b to your computer and use it in GitHub Desktop.
Save stefanocoding/923931ae84333e2db7d60aafbb5a4f7b to your computer and use it in GitHub Desktop.
Make modem Huawei E397B work on Mac OS X
  1. Install the Connection Manager that is launched when you connect the modem to the Mac
  2. Download the source of usb_modeswitch from here http://www.draisberghof.de/usb_modeswitch/ (at the moment of writing this the file appears with the name usb-modeswitch-2.5.2.tar.bz2)
  3. Run make in the directory of the source you downloaded
  4. Run sudo ./usb_modeswitch -v12d1 -p1505 -X in the same directory

If the last step returns an error (I don't remember the error now, but I was getting an error related to usb_modeswitch not being able to take control of the modem to perfom changes):

  1. Unplug the modem and plug it again
  2. As soon as you plug the modem again, run sudo ./usb_modeswitch -v12d1 -p1505 -X repatedly until you get a successful result
  3. Open Connection Manager and your modem is going to be detected
@nirlanka
Copy link

I needed to install some things not mentioned here, but required by the make script.

  • brew install libusb-compat for libusb 1.x` library
  • brew install pkg-config for using it

However, I seem to be stuck at:

Look for default devices ...
 No devices in default mode found. Nothing to do. Bye!

... even though I tried it repeatedly before the CD image loads.

But thanks for the info!

@nirlanka
Copy link

nirlanka commented Oct 13, 2018

Continuing on my struggle...

I got this to almost work for my slightly different model. (Still didn't get the internet connection working).

I ran ./usb_modeswitch -c dongle.conf -WX with the config file dongle.conf:

DefaultVendor=0x12d1
DefaultProduct=0x1505

TargetVendor=0x12d1
TargetProductList="140b,140c,1506,150f,150a"
HuaweiNewMode=1

Then I can see HuaweiMobile-Modem in the New Connection dialog in Network settings.

ls /dev|grep HUAWEI shows...

cu.HUAWEIMobile-Modem
cu.HUAWEIMobile-Pcui
tty.HUAWEIMobile-Modem
tty.HUAWEIMobile-Pcui

lsusb (installed with brew install lsusb) shows...

Bus 020 Device 033: ID 12d1:1506 Huawei Technologies Co., Ltd. HUAWEI Mobile 
Bus 000 Device 001: ID 1d6b:PTLP Linux Foundation USB 3.0 Bus 
Bus 000 Device 001: ID 1d6b:CIAR Linux Foundation USB 3.1 Bus 

Thanks again for pointing me in the direction of usb_modeswitch πŸ‘ πŸ˜„

@nirlanka
Copy link

Adding *99# as the telephone number was all I needed to connect, which works perfectly. πŸ˜„

@stefanocoding
Copy link
Author

@nirmall I'm very sorry that I didn't reply to your question! I was having issues configuring the same modem on Ubuntu, so I came to my notes here to see if it was useful for this case too, when I noticed your comments. I never got a notification about it. 😞
I'm glad to know you figured out the way to solve your problem and thanks for adding more information which may be useful for people in the same situation πŸ˜ƒ

@stefanocoding
Copy link
Author

It looks that it works as expected: isaacs/github#21 πŸ€·β€β™‚οΈ

@Kyshman
Copy link

Kyshman commented Feb 23, 2019

@nirmall and @stefanocoding How did you guys overcome the PKG_CONFIG_PATH environment pitfall?

I have installed the pre-requisites though mine were via Macports. I have set the PKG_CONFIG_PATH environment variable to where the libusb.h is located but my make still fails with:

Package libusb-1.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libusb-1.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libusb-1.0' found
In file included from usb_modeswitch.c:59:
./usb_modeswitch.h:26:10: fatal error:
'libusb.h' file not found
#include <libusb.h>
^~~~~~~~~~
1 error generated.
make: *** [usb_modeswitch] Error 1

Any pointers?

@stefanocoding
Copy link
Author

@Kyshman you probably aren't going to get this notification, but answering your question: I didn't get that error. Maybe @nirmall can point you in the right direction, because he installed that package.
Anyway, I'm not sure if you have to set that environment variable when the libusb library is installed in the default location like /usr/local or /usr.

@LarkinZero
Copy link

I got this error with commad :sudo ./usb_modeswitch -v 12d1 -p 1f01 -V 12d1 -P 14dc -J -W

libusb: error [darwin_claim_interface] USBInterfaceOpen: another process has device opened for exclusive access
Could not claim interface (error -3). Skip message sending

@stefanocoding
Copy link
Author

@LarkinZero that error is telling you that some other program is using the device. Maybe you have some driver or similar that is taking control of your USB device? If that's the case, you have to uninstall that driver or unload it, and then run usb_modeswitch.

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