The Huawei HiLink modules provide access to the HTTP API for Huawei USB modems. The E3531 modem is specifically supported but the modules may work for other Huawei USB dongles that provide the HiLink HTTP interface.
The modules provide access to the HiLink API which is not the same as accessing the dongle through AT commands over a serial device.
The API allows you read and send SMS messages, start and stop your data connection and monitor your data usage. This module provides the interface for the only currently tested USB device.
Data Connection Notes
Additionally, with the new version, you can simply obtain the unlock code without the need of downloading any software. Using their interactive website, you can just generate a respective Huawei E3131 unlock code. All you got to do is follow these easy steps: 1. Visit the page for Huawei Code Calculator’s new algorithm right here. Huawei Laptopi-Fi E3531. The Huawei Laptopi-Fi E3531 has been specially designed to give you a seamless Internet browsing experience. With this datacard, you can experience an amazing download speed of 21.6 Mbps HSPA+ and upload speed of HSUPA 5.76 Mbps. The E3531 comes with Micro-SD card slot that makes it the most modern connectivity solution.
- Download E3531I-1 software and user manual, repair E3531I-1 screen and battery, provide frequently asked questions service.
- Modems comes with outdated software and drivers and one need to keep it updated manually. As, you might already know that latest version comes with various bugs fixed and one should must update his PC with latest software and drivers to keep enjoying uninterrupted internet. Above all mentioned Huawei dongle drivers can be downloaded from.
- Jun 08, 2021 Download huawei e3531 and lots of software. Accessibility of some features may vary across regions. On one home network unlock pin or any devices. Today, i have come with unlocking solution of huawei e3531 modem. And then mtk may vary across regions. Driver miracast laptop for Windows 8.1. Download huawei hilink modem latest.
General Method Responses
All methods except the new constructor return a response hash. If the response contains the element code then there has been an error. Details of the error may be in the message element of the response.
The code returned may be an error code from the HiLink API itself or it may be an HTTP response code if there is some problem with connection to the API. For example the response may contain the following:
A successful response will never contain a code element.
Requests that successfully return information contain the information in the response hash.
Successful command requests return a simple success hash
A successful request or command will never return a code element in the response. A request or command that encounters an error will always return a code element in the reponse.
Methods
- ConstructorLoginDataSMSMain InformationDevice ControlAccess ControlData Traffic MonitoringGeneric MethodsData ProfilesFixed HiLink Configuration Values
Create a new instance of the class
The HiPi::Huawei::E3531 uses a default ip address 0f 192.168.8.1 for the modem interface. If you are experimenting with the modules for use with a different model, you may specify a different ip address in the contructor.
If you specify 'debug' in the constructor, the modules will dump full request and respose details to STDOUT.
If your E3531 has a password set, many of the methods require you to login.
The login method can be called routinely in your code as it will only attempt to login if your device requires it.
The default username and password for the E3531 are 'admin' and 'admin'.
Successful $response is a success hash
You should not need to logout unless you have a long running session that times out. The logout method logs you out of the API and clears your session.
Successful $response is a success hash
Connect modem to the network
Successful $response is a success hash
See : Data Connection Notes
Disconnect modem from the network
Successful $response is a success hash
See : Data Connection Notes
Set mobile data on
Successful $response is a success hash
See : Data Connection Notes
Set mobile data off
Successful $response is a success hash
See : Data Connection Notes
Get the basic status of the modem
On success, the returned $response will be a hash with the keys as follows:
Of particular interest is the ConnectionStatus value that indicates the current data connection status.
You can import the following constants to check the current value of ConnectionStatus
- HILINK_CONNSTATUS_CONNECTING ( 900, connecting )
- HILINK_CONNSTATUS_CONNECTED ( 901, connected )
- HILINK_CONNSTATUS_DISCONNECTED ( 902, disconnected )
- HILINK_CONNSTATUS_DISCONNECTING ( 903, disconnecting )
See : Data Connection Notes
Get the current mobile data status of the modem.
On success, the returned $response will be a hash with the value dataswitch:
- dataswitch 0 : mobile data is switched off
- dataswitch 1 : mobile data is switched on
See : Data Connection Notes
Return the contents of the SMS inbox.
Successful $response will contain hash with the following values
Messages with an Smstat value of 0 are unread. You can mark a message as read by calling $hilink->set_sms_read( $index )
using the Index value of the message.
You can delete a message by calling $hilink->delete_sms( $index )
using the Index value of the message.
Returns the contents of the SMS outbox
Successful $response will contain hash with the following values
You can delete a message by calling $hilink->delete_sms( $index )
using the Index value of the message.
Returns ant draft messages stored on your device
Successful $response will contain hash with the following values
You can delete a message by calling $hilink->delete_sms( $index )
using the Index value of the message.
You can send SMS messages to one or more recipients using this method.
$recipients can be a string containing the recipient number or a reference to an array of strings containing multiple numbers.
$message must be a Perl string containing your message. Do not pass encoded octets. The SMS will be sent as 1 or more GSM 03.38 encoded texts if all characters can be represented in the GSM 03.38 encoding.
If all characters cannot be represented in the GSM 03.38 encoding the SMS will be sent as 1 or more texts encoded as UCS-2. When encoding as UCS-2, any characters that cannot be encoded are replaced with '?'.
You can force encoding in GSM 03.38 by setting the following flag: $hilink->force_gsm(1)
If this flag is set, the message is encoded as GSM 03.08 with any characters that cannot be encoded replaced with '?'.
On success $response is a hash containing the following values.
Set an SMS message in the inbox as read using its 'Index' value.
On success $response is a hash containing the following values.
Delete an SMS message using its 'Index' value.
On success $response is a hash containing the following values.
Provides a list of SMS message counts. Onlt the 'Local' values seem useful.
On success $response is a hash containing the following values.
Returns basic information about your device.
On success $response is a hash containing the following values.
Returns information about your device
On success $response is a hash containing the following values.
A wrapper around get_device_info() to return just the serial number.
On success $response is a hash containing the following values.
Provides current notification status. Assume the HiLink web app must display notifications.
On success $response is a hash containing the following values.
Returns the connection information. Some of these values can be set in the HiLink web app.
On success $response is a hash containing the following values.
Get current network information
On success $response is a hash containing the following values.
Get current signal information
On success $response is a hash containing the following values.
Reboot the device. You will loose access to the device while it reboots.
On success $response is a hash containing the following values.
Shut down the device. This will disconnect the modem.
On success $response is a hash containing the following values.
Restore all settings to the factory defaults. You will lose all your SMS information, traffic settings and the admin password will be reset to the default.
Note that if the device is password protected, you will need to login to access this method. This means this method cannot be used to recover from a forgotten password.
On success $response is a hash containing the following values.
If your device is password protected, and you have forgotten your password, the device_restore method is not available to you. This method allows you to reset the device to factory defaults including the password by passing the Serial Number of your device.
Note that as with the device_restore method all of your SMS data and any settings will be lost.
On success $response is a hash containing the following values.
WARNING: Not all versions of the E3531 firmware implement this method so it seems possible that if you change the password and forget it, an E3531 that does not have this method would be permanently locked.
Returns the current login status of this session.
If 'State' is 0 then either no login is required or the current session is already logged in.
You should not need to call this method yourself. The login method calls this method first to see if login is actually required.
On success $response is a hash containing the following values.
Returns if the device is set to require a login to access methods such as send_sms or get_inbox
On success $response is a hash containing the following values.
Whether the device requires login can be set by calling set_password_required( $bool )
Sets if the device requires a password or not. Pass 1 to switch on, 0 to switch off.
If the device currently requires a password, you must be logged in to call this method.
For some versions of the E3531 the HiLink web app does not allow modification of the password or setting the password required. This may be because if you forget the password there appears to be no way to reset the device if the device_serial_restore method is not implemented.
This module will check if your E3531 HiLink web app allows modification of passwords and therefore supports device_serial_restore. If it does not then calling this method will return an error.
If you want to ignore this safety measure and use passwords on such a device, you can override the safety in the module constructor but be aware that if you change a password and forget it then you will be locked out of your device.
If your device doesn't support device_serial_restore then you must also be certain that the default password is still 'admin' before you switch passwords on. If it isn't, you will be locked out.
On success $response is a hash containing the following values.
To override safety and use passwords on a device that does not support device_serial_restore
If you are using passwords you can change the admin user password using this method.
On success $response is a hash containing the following values.
For some versions of the E3531 the HiLink web app does not allow modification of the password or setting the password required. This may be because if you forget the password there appears to be no way to reset the device if the device_serial_restore method is not implemented.
This module will check if your E3531 HiLink web app allows modification of passwords and therefore supports device_serial_restore. If it does not then calling this method will return an error.
If you want to ignore this safety measure and change passwords on such a device, you can override the safety in the module constructor but be aware that if you change a password and forget it then you will be locked out of your device.
To override safety and change passwords on a device that does not support device_serial_restore
Called by set_password_required and change_password methods, this method returns if the HiLink web app allows modification of the password settings and therefore if it is safe for this module to alter password settings.
On success $response is a hash containing the following values.
Returns data traffic statistics
On success $response is a hash containing the following values.
Return data traffic statistics for the current month as defined in the data plan.
On success $response is a hash containing the following values.
Reset all traffic counters to zero
On success $response is a hash containing the following values.
Returns the current monthly data plan stored on the device as set in the HiLink web app.
On success $response is a hash containing the following values.
Set the data plan details
$day : a day number between 1 and 31
$limit : monthly limit. Append the suffix 'MB' or 'GB' to a number
$threshold : notification threshold percentage. A number between 1 and 100
On success $response is a hash containing the following values.
Turn the data plan off
On success $response is a hash containing the following values.
If you investigate the HiLink API further and find additional useful resources, you can access them using the generic_get method.
On success $response is a hash containing the values returned from the call. For example
If you investigate the HiLink API further and find additional useful resources, you can set them using the generic_post_xml method.
On success $response is a hash containing the values returned from the call. For example
Retrun the data profile information
On success $response is a hash containing the following values
Get the fixed device configuration. This appears to determine what is available in the HiLink web app.
On success $response is a hash containing the values returned from the call. For example
Get the fixed global configuration. This appears to determine what is available in the HiLink web app.
On success $response is a hash containing the values returned from the call. For example
Data Connection Notes
To connect to the internet
- Data must be switched on
- You must be connected to the network
To switch data on
To connect to network
If data is switched on the modem will connect on demand anyway, disconnecting after the configured inactivity period has passed.
You may disconnect the modem yourself using the command
The modem will connect again on demand unless you switch data off
Even if data is switched off and the modem is disconnected, the interface and default routes will still be configured. To remove the interface completely you have to identify the interface that connects to the USB modem. Testing on a Pi3+ which has its own ethernet interface, the USB modem always configured as eth1. You may develop a more precise way of identifying the interface by, for example, creating udev rules or looking for the IP4 MAC address, which for the E3531 always appears to be 00:1e:10:1f:00:00
To bring the interface back up
USING THE HUAWEI E3531 USB DONGLE FOR ELEPHANT DETECTION DEVICE MOBILE CONNECTIVITY
Earlier we looked at setting up the Huawei E303 USB dongle for mobile connectivity. Here we'll look at setting up the E3531 model in two modes. These dongles are really low-cost compared to HATs! This one was only £21!
1.
So first of all let's get started by setting this as HiLink CDC-Ether mode for PPP via eth2 over 2G/3G to connect to the internet. Then we can change it to serial modem if we want later on.
The E3531 will then have the following ID in this case: 12d1:14dc , with 12d1 being the vendor ID, and 14dc being the HiLink CDC-Ethernet model/mode ID.
Let's connect the E3531 to the USB port on the pi! Now run the 'lsusb' command to list usb devices attached to pi. Hopefully you'll get the following:
As you can see we got ID 12d1:14dc so that's great. It's in HiLink-CDC-Ethernet mode! That's supposed to be the default state for the E3531 so you don't need to worry about it being stuck in mass storage mode like the E303.
Now we can use the Huawei HiLink to set everything up to connect to our carrier. Go to the web-browser, and access http://192.168.8.1 . Then you'll get the home html file giving your status:
Then you can go along to settings and enter your carrier information. So once you get connect, you are all ready to access the internet using PPP via eth1! That was all quite easy!
2.
Next, let's switch it to a serial modem so we can send AT commands to get out SMS messages in lower connectivity scenarios. We'll be wanting to access it as tty/USBx
We need to switch our E3531 mode from 12d1:14dc to modem mode i.e. 12d1:1001 with 3x virtual serial ports. Let's get started by downloading and installing usb-modeswitch:
No let's make a file containing our switch mode instructions. The instructions are:
TargetVendor=0x12d1
TargetProduct=0x1f01
MessageContent='55534243123456780000000000000011062000000100000000000000000000'
The message content depends on the firmware of your E3531, so honesty, the above might not work and you'll have to experiment/research to find a message that does :-(
Right, so let's make the file for usb-modeswitch to use:
Now after reboot, we can issue the following command: 'lsusb' and we should see the new ID as 12d1:1001 so the E3531 has switched to serial modem mode!
If we issue the command ls /dev/tty* we'll see our virtual serial ports: ttyUSB0, ttyUSB1 and ttyUSB2! Great!
3.
Now we can go ahead and connect to the virtual serial ports and issue some AT commands! I used cu 'call up another system' (https://linux.die.net/man/1/cu) to do this.
So after you've installed it, execute it with following arguments to connect to ttyUSB0:
Now I went ahead and sent some AT commands. Sadly they don't echo, so you can't see them!
The first was 'AT' and I got back OK. Then I issued 'AT+CMGF=1' which tells the modem to act in SMS mode, and got back CMS ERROR 302, which is operation not allowed. Then I tried to send an SMS with 'AT+CMGS='+443283870634' <CR>' which returned an error code of CMS ERROR 302 again! These errors are likely due to the SIM card requiring a PIN or PIN2. If the SIM is blocked, the error would be due to SIM required PUK or PUK2 (personal unblocking codes).
You can send a PIN using AT+CPIN='0000' <CR>. Note that carriers will block the SIM after 3x incorrect PIN attempts, and you will need to use a PUK or PUK2 to unblock it. All the carriers have default PIN codes.
* It turned out that the error was due to me not entering AT+CMGF=1 correctly, not a PIN problem after all!
You can find a full list of error codes here: http://www.smssolutions.net/tutorials/gsm/gsmerrorcodes/
Huawei E3531 Software Download
4.
Ok, let's get started with doing this using python instead of cu:
Here's some rough code to send an SMS:
GitHub here: https://github.com/nksheridan/elephantAI/blob/master/test_send_sms.py
So, after running that, we are able to send an SMS! The phone numbers have to be entered in + then country code, then number format e.g +441234123123
CONCLUSION
So we are all ready to deploy the E3531 as a mobile connectivity solution to the elephant detection devices, and we've got the code we need to notify local people via SMS of elephants being present!
We'll cover using PPP to alert people via twitter in another log (if there's time, or as a future development). In this PPP scenario, we'd could send tweets (or DMs) which included the images of suspected elephants to the local people (users). We could also send this data to a computer in the village that would plot the location of elephants onto google maps/custom maps. In addition, the computer could output to a big physical map sign containing LEDs corresponding to elephant detection devices (these lighting up!). This computer again could comprise a raspberry pi!
In a more advanced PPP scenario I have envisaged, the input of local people could be leveraged to improve the accuracy of our elephant detector by enabled a supervised training system. Here's what it would look like:
1. Elephant detector tweets/DMs image of suspected elephant
2. Local people tweet back with hashtags #yeselephant #noelephant #type_is_lone #type_is_calf
Huawei E3531 Software Update
#type_is_herd #type_is_male #type_is_female according to what they identify in the image
3. Database of images containing elephants confirmed by users is created by elephant detection device
4. Images being stored along with their class labels that were provided via the hashtags (e.g. #type_is_calf , #type_is_herd etc.)
5. On a weekly or monthly basis, the elephant detection devices will upload their databases of images to the cloud (e.g. to an Amazon EC2 virtual machine)
6. Transfer learning will be performed on the virtual machine using our existing dataset with these additional images. Thus improving the accuracy of our elephant detector model!
Huawei E3531 Modem Unlocker
7. The new model will be sent to the elephant detection device from the cloud-based virtual machine, and be used for future detection.
Huawei E3531 Firmware 22.318.05.00.00
This process will be repeated on a weekly or monthly basis, thus providing on-going improvements in accuracy of the elephant detector!
Unlock Huawei E3531 Modem
* please see the future directions log for this and other improvement ideas!