sumnone.com

Totally Nothing...Do-Dads and Fix-Its For the Web.

Permanently Unlock a Huawei E153 Modem using only One Tool

Recently my 3G modem USB dongle/stick died and I didn't want to buy another while my main one was in repair for one to two months. (Normally I use my Nokia C5 in this case, but I seem to be getting a lot of disconnects lately from it that I don't get from the 3G/HSDPA sticks.)  I had a spare Huawei E153 lying around that was not as fast (max 3.6Mbps), but still good enough for what I need.  However, it was locked to another internet provider. I finally figured out how to unlock it permanently, but it basically took me all night.  So, this blog is to hopefully save you some time. 

For a while I used Huawei Modem Unlockerv 5.8.1b. However, this is a temporary unlock and will basically lock again after the modem is unplugged and plugged back in again. 

There are other similar posts that mention the QualComm QPST app as well as the Huawei Flasher. But, this method only requires Huawei Flasher Application 1.6 found here (I believe the earlier version of the flasher didn't have the NV Items Backup): 

Huawei Flasher Application 1.6 

You will also need the firmware update file: 

E153Update_11.609.18.00.00.B427.zip 

This tool is a little buggy, but at the end of the day, it gets the job done. If you're lucky, you can probably eliminate some of the steps that I encountered.  But, if you're unlucky (like me), you'll be presented with this error upon launching the application:  

 

Click Continue, otherwise, the application will quit.  All that error is saying is that the automatic modem detection function of your 3G modem is going to fail and you'll have to specify the COM ports manually in the ports.ini file (found in the same directory as the exe).  I started dissecting the error before I finally noticed the author's comments in the left hand window: 

If you have problem with com ports edit "ports.ini" file

 

============================================

N_PORT is port that program will use for read info

D_PORT is port that program will use for flash modem

============================================

 

Example:

N_PORT=COM1

D_PORT=COM5

So here's the trick, at least for me...and also the good news. Even though the app doesn't work exactly correct, the author does fail-safe checks before doing any work on the modem.  So, if you get the com ports wrong (as I did many times), it should not screw up your modem. 

My E153 is originally on COM19 according to Windows.  Before the app writes the firmware to the modem, the app resets the modem (i.e. unplug, replug, via the app), and mine connected back on COM22...at which point it does the firmware write to the device on port 23.  So.... here's what my ports.ini file looks like: 

N_PORT=COM20

D_PORT=COM23

 Each port that the modem shows connected on in Windows pre-reset and post-reset is incremented once.  I'm not sure exactly why, but whatever.  So, here is how you should work through this process. 

1)  Your first focus should be the N_Port.  If your N_Port is successful, you'll get a readout like this when you click the Read Modem Info button: 

File ini found

------------------------------------------------------------------------------

N_PORT=COM20

D_PORT=COM23

------------------------------------------------------------------------------

Reading info at COM20 ...OK

------------------------------------------------------------------------------

Firmware:  11.609.18.00.00

Hardware: E153u-2CD1E153M Ver.A

Imei: 35237404725082-7

------------------------------------------------------------------------------

NOTE: It is absolutely crucial that you do an NV Items backup to maintain your IMEI number for later restoral back to the device. When I tried it from the NV Items > Backup menu I received this error after the progress indicator is only about 5 percent: 

Index and length must refer to a location within the string.

Parameter name: length

However, once you get to the writing the firmware stage, you will immediately be prompted to do an NVbackup and that process worked successfully for me and is also the backup I restored back to my device.  You will be prompted to do the NVBackup immediately after you choose Flash Modem > Normal Mode.  (I had also done a backup from QPST, so was fearless to move forward. If you do not get a successful backup before the firmware write stage, install QPST and backup that way.)

2) In the menu bar, now choose Select Firmware > Extract from EXE and browse to the place where you stored your E153Update_11.609.18.00.00.B427.exe file (If you downloaded it as a zip, extract the zip file somewhere first before doing this step). You will then be presented with a second window where you want to extract the files.  The files are extracted to a subfolder, so you can put them anywhere and the app is now aware of the location. 

3) Uncheck the 06.bin 00060000 0003C860 and then choose Flash Modem > Normal Mode, you will first be prompted to do an NV Items Backup, choose Yes if you do not have a successful NV Items backup.  This is extremely important. Once the NV Items backup is done or if you choose No (because you already have a NV Items backup), the program will prompt you to choose OK once the 3G modem is reset.  (This is where my modem changed COM ports. So, be aware). Assuming your write is successful, you'll be presented with an error while writing the second to last bin: 

Writing 08.bin (0x00D7159C)FAIL (Ack 0x03) 

NOTE: If your D_PORT COM port is not correct in your ports.ini file, this is where it will fail. The program will stop responding, but eventually comes back with an error.  If it cannot write to the device because the port is wrong, you'll need to start over at step one.  However, make note of the new COM port and update your ports.ini file accordingly.  You will also need to unplug your device now and plug it back in and make sure it's back on the original COM port. 

 

4)  If you try and Read Modem Info now, it will fail because your modem has changed COM ports.  So, unplug your device and plug it back in and verify it's on the original COM port, in my case COM19.  Now try and Read Modem Info.  At this point you should notice that your IMEI is zeroed out when reading your device: 

Imei: 00000000000000-0 

This is why it's extremely important to get an NV Items Backup as it will restore your Imei.

5)  Now click NV Items > Restore and choose your backup file.  If you were prompted during the firmware write phase, it will be in the same directory as the exe file.  The file has a time stamp and ends with a .bck extension. The backup is restored and the modem will reset one last time without changing COM ports: 

At this point you are done.  And you can use your Mobile Partner app or internet provider branded app to create a new profile and connect to any internet provider. 

If you're not aware how to connect to another internet provider in your application, simply go to Tools > Options > Profile Management and then click New.  Provide a name, the APN, the access number (if it's not correct) and choose Save. 

I would love to know other people's experiences with this app, especially if your COM ports are changing during the process.  Also, this process will probably work for many modems.  However, you'll want to use the correct firmware file for the process, and...I don't know if un-checking the 06 bin is universally applicable.  However, I think you're safe to try as you can write the firmware as many times as you want once you figure out the method to the madness.

Easiest way to retrieve UserId as an Int with SimpleMembership ASP.NET MVC

I just spent hours trying to figure this, so I figured I'd write a little post on it to hopefully make life easier for someone else.  So, the goal was to select records from my table where the current logged in userid is equal to the userid in my table.  Simple, right?  I looked through many sites including those recommending to get the guid, some to convert, make another call to the db, session wrapper, etc..  All of these seem incredibly complex for what I want to do.  Why would I want a guid, when the user table isn't even a guid AND my table isn't a guid?  Both are ints, so why is this so hard and why would Microsoft convert it to a guid anyway when it's currently a single digit number?  This is also real easy if you want the username, but for some reason exponentially more difficult if you want the userid.  Turns out, it's not if you know what you're doing.

Anyway, the easiest way to do this is:

using WebMatrix.WebData;

using <your project name here>.Filters;

...

[InitializeSimpleMembership]

...

int uId = WebSecurity.GetUserId(User.Identity.Name);

or you may need to use in place of User.Identity.Name:

HttpContext.Current.User.Identity.Name

WebSecurity.GetUserId is part of WebMatrix.WebData.  I had come across the WebSecurity.GetUserId or WebSecurity.CurrentUserId a couple times (CurrentUserId will not work if I read the description correctly), but none tied it back to WebMatrix.WebData.

Keep in mind, my project thus far is pretty generic and based on the C# MVC4 Internet Project template.  The only thing I've added is a model, controller and some views to pull data from my table (all based on templates as well).

Good luck, I hope this solution finds you quicker than it did me.