Download the PHP package hsp-dev/huawei-api without Composer
On this page you can find all versions of the php package hsp-dev/huawei-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hsp-dev/huawei-api
More information about hsp-dev/huawei-api
Files in hsp-dev/huawei-api
Package huawei-api
Short Description A barebones API to interact with the Huawei E5180 router
License MIT
Homepage https://github.com/HSPDev/Huawei-E5180-API
Rated 5.00 based on 1 reviews
Informations about the package huawei-api
Huawei E5180 API
This project will let you interface with your Huawei E5180 Cube router easily.
This router is deployed by 3 DK, as "home routers" for their 4G connections.
You can get it for free if you order a 100GB or above package from 3.
Link where I bought mine: https://www.3.dk/mobiler-tablets/modems-routere/huawei/huawei-e5180-cube
No advertisement or affiliation or anything, I wouldn't even really recommend the router. It got great speeds, but the WiFi is not the greatest, and I've seen it overload multiple times when you have lots of clients on your (W)LAN. The 4G link holds, but the LAN/WiFi/Router portion is really bad, so I personally use it with a D-link DIR-810l as router, with it's WAN port connected to the Huawei routers single LAN port, so it can focus on just delivering 4G Internet.
Features
- Send SMS through the mobile network
- Receive SMS (you need to pool for this periodically)
- Delete SMS (to avoid filling it up)
- Query router status (lots of info)
- Query traffic statistics (decent amount of info)
- Get the current PLMN (which network you are on)
- Get craddle status (hardware info, battery and such if yours have one)
- Get WLAN clients
- Check the device for notifications (Including SMS and updates)
- Query LED status (the big blue one on top)
- Turn the LED on or off.
What could you use this for? Do you want a free inbound SMS gateway for your home? Now you got it, if you have this router. I know 3.dk currently charges me 0.20 DKK for outbound SMS, as of 19-06-2015, but be sure to check with your own provider before sending SMS. I could also easily imaging your provider being mad at you if you suddenly used this as a commercial gateway, sending and receiving thousands of SMS messages.
If you like me, live in the country without good internet through wire, and want a 4G router like this, you could also make your own interface to keep your bandwidth bills in check.
Also, the blue LED is quite fun to play with. You can tap the top, to turn it on and off, so I already have plans for letting me know if I have new emails by turning the LED blue.
Documentation
How do I use this library?
Simply include the composer autoloader into your project after installation, as you are used to, and proceed to make a Router object. Set the address of your router and login. Now every other function listed here SHOULD work, at least on E5180. I can't talk about any other routers compliance.
This will get the current status off the blue LED on top, either true or false, for on/off. If this seems to work, try the following line instead:
Every time you run the script now, it should turn the LED on or off, depending on it's current state.
Now let's try something else.
Which should return something like the following, which shows that I'm currently on the "3 DK"" network. You can look up PLMN lists to get the numeric codes.
What about some SMS?
In my case it returned this, meaning I have no new messages.
That can't be true. Let's send some to our router. You can probably find the phone number for your router on your bills, sometimes in the web interface or maybe by simple logging into the web interface and sending yourself a message. After sending my router a SMS I got this result instead:
Have a look inside the Router.php class to find out what methods you can use, it's very well documented, but I will throw a list here anyway.
- login($username, $password) username is almost always "admin". "password" is the one for the web interface.
- getStatus() gives info about the routers status.
- getTrafficStats() gives traffic info
- getMonthStats() does the same for the current month (if you have setup limits)
- getNetwork() gives info about the current network. Can't find the bars anywhere tho.
- getCraddleStatus() lots of more info. I suspect you can get battery status here, if your device has one.
- getSmsCount() DOES NOT RETURN AN integer, but also an XML object.
- getWlanClients() gets a list of WlanClients, if they have IP 0.0.0.0 they are disconnected.
- getNotifications() does what it says.
- setLedOn(boolean $on) call with "true" to turn on, and "false" for off.
- getLedStatus() true/false for LED status.
- isLoggedIn() true/false to check if logged in.
- getInbox($page = 1, $count = 20, $unreadPreferred = false) defaults are fine for most tinkering. page/count for pagination.
- deleteSms($index) provide with SMS index for deleting. Returns true if not found also.
- sendSms($receiver, $message) Pretty self explanatory. Might return true and not send anyway. There is an API to query for send status, but I didn't worry about it.
I don't promise that these will work like advertised or at all, just have fun. It should get you started.
Huawei Router API Error codes
Sometimes if you are experimenting with the Huawei API and trying to talk with it, you will get a random error code back. This sucks, to say it politely, as there is absolutely no information on what is going wrong. Therefore, I've gotten hold of this list of error codes for the Huawei API, which I know is true for the E5180 and probably other devices too. So if you just googled "Huawei Router API Error" or something like that, congratulations, today is your lucky day. Please note that not all codes are in here, but most of them are.