# [SOLVED] LTE 4G ppp.conf configuration



## ThoughtCriminal (Aug 25, 2020)

Hello,

I have a Lenovo x260 with a Huawei LTE modem built in. All the hardware is working and the system picks it up with the u3g module.

So far I have found the following three links but I cannot seem to get my device to connect.

https://forums.freebsd.org/threads/3g-and-ppp-configuration.28482/
https://ogris.de/howtos/freebsd-huawei-e392.html
https://technotation.com/tag/lte/#ppp

What I am stuck on is the ppp.conf configuration. I cannot seem to get the 'set dial' part right

The script I'm using is as follows;


```
optus:
set device /dev/cuaU0.2
        enable echo
        set reconnect 10 7200
        set redial 10 0
        set timeout 0
        add default HISADDR
        set ifaddr 10.0.0.1/0 10.0.0.2/0 255.255.255.255 0.0.0.0
        set dial "ABORT BUSY ABORT NO\\sCARRIER TIMEOUT 5 \
        \"\" \
        ATH OK ATZ OK \
        ATE1 OK-AT-OK \
        AT+CGDCONT=1,\\\"IP\\\",\\\"yesinternet\\\" OK \
        ATDT*99\# TIMEOUT 30 CONNECT"
```

Am I missing something obvious? The part that doesn't seem to work is the `set dial` command string.
The log file (/var/log/ppp.log) is here;

https://dpaste.com/CUWBDRV77

From what I can see, there are multiple errors..

Thanks.


----------



## Phishfry (Aug 25, 2020)

Try my 'set dial' line.








						Solved - WWAN
					

I have a ThinkPad X61 which can take a SIM card for connecting to the Internet via the phone network. Is it possible to use FreeBSD to connect ?




					forums.freebsd.org


----------



## ThoughtCriminal (Aug 25, 2020)

I used your ppp.conf

Below is the ppp.log log

https://dpaste.com/8EAP4N3FY

here is my /etc/ppp/ppp.conf

https://dpaste.com/8R5W7GJWT


----------



## ekvz (Aug 25, 2020)

It's a long shot as i haven't seen this on Huawei devices yet but maybe it's worth trying to get an AT command reference for your particular modem. There is an Ericson one in my Thinkpad that had me pulling my hair out while trying to get it to connect until i realized it had some specialized command (AT*ENAP) to setup a connection so all one needs to do is bring up the radio (AT+CFUN), authorize with your preferred network (AT+COPS), set the apn (AT+CGDCONT) and use AT*ENAP to have a wwan0 device appear that can then be configured using a dhcp client (all of this can be scripted of course). This was on Linux and i have zero clue how it works internally or if it needs driver support but i like it very much over having to deal with a normal ppp connection so if your device supports something similar it might be worth a try.

Edit: If your device supports it it's probably not called AT*ENAP as this a non standart command which i guess is specific to Erricson.

Edit2: From a quick search it seems at least some Huawei devices have a command called AT^NDISUP (see 18.1 in http://download-c.huawei.com/download/downloadCenter?downloadId=51047&version=120450&siteCode) which is similar. It can take a couple more options likely rendering AT+CGDCONT redundant but i think there is a good chance your device supports that. Searching for Huawei + ndisup should also get you some more or less fitting examples.


----------



## ThoughtCriminal (Aug 25, 2020)

Cool, thank you ekvz

I can get a ppp terminal amd AT+CGMM outputs


```
ME906s-158
```
  which is the document you posted!

Did you have to install  any firmware to get your device working? Just a thought.. I think my module hardware is fine, I just need to flesh out the AT commands.


----------



## ekvz (Aug 25, 2020)

ThoughtCriminal said:


> Cool, thank you ekvz
> 
> I can get a ppp terminal amd AT+CGMM outputs
> 
> ...



Haha wow, what a coincidence! Now it only also needs to work. Good luck!


----------



## ekvz (Aug 25, 2020)

ThoughtCriminal said:


> Did you have to install  any firmware to get your device working? Just a thought.. I think my module hardware is fine, I just need to flesh out the AT commands.



Sorry, it seems i somehow missed that part. No, i didn't need to install anything besides what is needed to get the modem device detected (which you obviously already have since you can run AT commands). The thing is that i have Linux on my laptop and i don't know if there is anything special in the driver to make the wwan device appear after the appropriate AT commands have been passed to the modem or if it is using some generic approach that is likely to work in every OS where the device is detected.

I'd use comms/minicom for experimentation.

First reset/bring up the device with `AT+CFUN=6,1`. I am not entirely sure here as the meaning of the first number might slightly differ for Huawei. With my Erricson device 5,1 would reset it and put it in a state where it only does 2G while 6,1 would reset and support 3G afterwards. From the Huawei reference there doesn't seem be anything like 7,1 (at least not in a way that would imply a higher standard) so i guess 6,1 translates to "full capabilities" or something similar and therefore includes LTE.

Then try to make sure you have a network connection. `AT+COPS?` should return something like 0,2,"12345". The last part is the network id. Its likely to use the numeric code (5 digits long number) by default but the reply can have different formats. Just see that it isn't a single number like 0 or 1. It might take a bit after the reset to find a network though so retrying `AT+COPS?` a couple of times is not a bad idea.

If nothing happens in like a minute or two try `AT+COPS=?` to list the available networks (i vaguely remember this reply being able to be cut off in miniterm due spanning multiple lines so maybe dump the output to a file if the network you are looking for seems missing). Its probably best to check the reference as to what the individual numbers mean. There should be one that tells you if the network is available to your SIM card, one being the numeric 5 digit network code and likely another showing what kind of service to expect. You can use this to make the device try this network with `AT+COPS=1,2,"12345"` (12345 being whatever ID your target network has) and if that gets an OK reply use `AT+COPS?` again to see if it worked. There is also `AT+CREG` but luckily it does not seem to be needed to touch this.

At this point i'd select the APN with `AT+CGDCONT=` but i guess you can skip this and do `AT^NDISUP=1,1,"yourapn"`. In theory and if everything went fine the wwan device should appear now. I am not sure where to look though (/dev, ifconfig or dmesg maybe?). I also don't know if the 1,1 parameter is enough to make it work as the command is quite different from the `AT*ENAP` i am using but i've seen it used like this in examples so that's what i'd start with. Just keep in mind that this doesn't necessarily has to work on FreeBSD so if you can't figure it out it might just very well be not supported.

By the way: If you didn't notice this yourself yet on Huawei there is also `AT^SYSCFG` or in your case `AT^SYSCFGEX` which lets you configure a lot of connection parameters. It's quite handy but also very easy to set something that makes your device not connect at all. While i think(!) a reboot should be enough to revert this to default settings i am not entirely sure and i'd always write down the current parameters before playing with this.


----------



## KBK (Aug 25, 2020)

Hello

```
set device /dev/cuaU0.2
```
Are you sure about the device number? After reboot try `ls -l /dev/cuaU*`

Remove: enable echo , set reconnect 10 7200 , set redial 10 0
ppp is a protocol, the implementation is OS related, and any option can create a problem: add later.

```
set timeout 0
```
You are adding the default route before get a route and also before send apt, name (authname) and password (authkey)

```
add default HISADDR
        set ifaddr 10.0.0.1/0 10.0.0.2/0 255.255.255.255 0.0.0.0
        set dial "ABORT BUSY ABORT NO\\sCARRIER TIMEOUT 5 \
        \"\" \
        ATH OK ATZ OK \
        ATE1 OK-AT-OK \
        AT+CGDCONT=1,\\\"IP\\\",\\\"yesinternet\\\" OK \
        ATDT*99\# TIMEOUT 30 CONNECT"
```
the phone number *99\#  looks strange to me.


A working example can be this, any ISP setup:

```
any:
 set device /dev/cuaU0.0
 set timeout 0
 set dial "ABORT BUSY ABORT NO\\sCARRIER TIMEOUT 5 \
        \"\" \
        AT OK-AT-OK \
        AT+CPIN="" OK-AT-OK \
        ATH OK-AT-OK \
        ATE1 OK-AT-OK \
        AT+CGDCONT=1,\\\"IP\\\",\\\"APN\\\" OK \
        \\dATD*99# TIMEOUT 40 CONNECT"
 set authname " "
 set authkey " "
 set ifaddr 10.0.0.1/0 10.64.64.64 255.255.255.255 0.0.0.0
 add default HISADDR
```
Check the /dev/cuaU0 number, can be different if you do not kill ppp: `su -m root -c "killall -9 ppp"`
Start the modem with: `su -m root -c "/usr/sbin/ppp -ddial any"`
To run at startup add in /etc/rc.conf add:

```
ppp_enable="YES"
ppp_mode="ddial"
ppp_profile="any"
```


----------



## ThoughtCriminal (Aug 26, 2020)

Thank you both for getting back to me on this..
The device is definitely /dev/cuaU0.2
I can launch `ppp` and drop into a terminal with `term` 
The command that keeps failing is
`ATD*99# CONNECT`

I keep getting "NO CARRIER"


----------



## KBK (Aug 26, 2020)

Hello
Sorry to ask silly questions: is the card data enabled?
Did you disable the PIN?  You can use it with: AT+CPIN="1234" OK-AT-OK \
I disable the PIN putting the card in a mobile.
Create and read the ppp log file: /var/log/ppp.log can point the problem.
The FreeBSD's ppp man explain howto create the log.
Try also tail -f /var/log/messages

A modem definition can prevent some errors but is not really required to connect.


----------



## ThoughtCriminal (Aug 26, 2020)

I doubt that is the issue. Prior to installing FreeBSD I was running Linux Mint 20 and the Mobile Broadband worked out of the box so to speak. I tried to get the equvalent of ppp.conf from a linux box but Linux has a different range of configuration files.


----------



## ThoughtCriminal (Aug 26, 2020)

I'm not sure what I've done. But when I issue the `term` from the `ppp` console, text just starts streaming down the screen, see below;




How do I stop this output from scrolling up the screen?
Also I have the manual and am going through it. There is a section called: AT^MTCARRIER-Switch the Operator Carrier
could this be why I am getting NO CARRIER? Because of this setting not being correct?

Thank you.


----------



## ekvz (Aug 26, 2020)

RSSI is the signal strength. HCSQ is probably a custom Huawei version of CSQ which i think stands for "Check Service Quality". I haven't seen the latter one being reported automatically but the RSSI spam is quite common with mobile modems. It's usually just on one of the multiple "port" devices those modems create though (kinda like the first port is for data and dialing while the second is for displaying info - does not have to be in this order).

Does your modem have different ports (i don't know what they would be called in FreeBSD but maybe something like /dev/cuaU0.0 - /dev/cuaU0.2)? If so maybe the config got switched to the one automatically displaying info? If not there should also be a command to turn the automatic display off. You would have to check the command reference for this though. Side note: If there are multiple ports registered by the modem and this is the automatic info one there is a good chance that's also the reason why dialing won't work.

As for the `AT^MTCARRIER`. I haven't seen this one before but all those `AT^` commands are Huawei specific. I'd check the command reference as to what it means. Maybe it will yield a clue as to what's going on.

I'd also make sure that there isn't any process running that might be spamming the device with commands requesting the connection info but i guess that is rather unlikely.


----------



## ThoughtCriminal (Aug 26, 2020)

I know what I did... I ran `stty -f /dev/cuaU0.2 raw`
so to fix I ran `stty -f /dev/cuaU0.2 sane`

Also, the devices run from /dev/cuaU0.0 to /dev/cuaU0.4


----------



## ekvz (Aug 26, 2020)

Have you tried them all yet? As i said there is a good chance only a single one works for dialing. Also the HCSQ output seems to suggest that your modem is connected (as in receives service - not as in is online sadly) to a LTE network.


----------



## ThoughtCriminal (Aug 26, 2020)

Hi,

Well I feel like an idiot. I tried all of the /dev/cuaU* devices and now it works when using /dev/cuaU0.0


----------



## ekvz (Aug 27, 2020)

ThoughtCriminal said:


> Hi,
> 
> Well I feel like an idiot. I tried all of the /dev/cuaU* devices and now it works when using /dev/cuaU0.0



You aren't the first person to feel this way after trying to get a mobile modem working. That's something you can be sure of


----------



## ThoughtCriminal (Aug 27, 2020)

Thanks mate 

I feel like I am among friends. Now I can help the next person to have the same issue.


----------



## ekvz (Aug 27, 2020)

ThoughtCriminal said:


> Thanks mate
> 
> I feel like I am among friends. Now I can help the next person to have the same issue.



On top of that you now have a matching command reference. Stuff like `AT^SYSCFG` is super handy when dealing with a flaky network and as far as i know (at least a bunch of) those newer Huawei devices have some pretty neat diagnostics (beyond the basic RSSI display / CSQ output) builtin. Being able to map the surrounding area for networks, cells or signal strengths is priceless when figuring out which SIM cards are actually worth getting in an unknown area.


----------

