SMS forward with 4G dongle
4G dongle
The dongle used is: Alcatel IK42UC . In lsusb, it should show:
1 | 1bbb:00b6 T & A Mobile Phones Mobilebroadband |
Find the ttyUSB port
It should create 3 usb devices under ls /dev/ttyUSB*. Alcatel dongles have 3 slots/ports, and one of them will accpet at commands. Can try one by one to find out which one is accepting the command.
config file
1
2
3
4
5
6sudo nano /etc/gammurc
[gammu]
device = /dev/ttyUSB0 #Will start with 0
connection = at115200
logformat = textallstatus command
1
sudo gammu networkinfo
Run the command and see if it returns anything. If not, modify the config to another ttyUSB port and try again.
Force to Tmobile
ATT has a whitelist, so I have to force the dongle to use Tmobile network for my roamming sim card.
Connect to dongle console:
1 | sudo screen /dev/ttyUSBX 115200 #Replace with the port found above. |
And run the commond in console to force Tmobile:
1 | AT+COPS=1,2,"310260" |
Note: 310260 instructs the hardware to seek out T-Mobile US
In my case, after the command to force TMO, I got
1 | +CREG: 5,"3AFD","2CAD104", 7 |
The 5 means registered and roaming.
To safely close interactive serial terminal without turning off the modem:
- Ctrl + A
- Press K (Kill)
- Confirm by pressing Y
We only need to do this once as it is written to the dongle’s internal disk and will remain after reboot.
Auto link to the correct ttyUSB device
Run
1 | udevadm info --query=property --name=/dev/ttyUSBX | grep -E "ID_USB_INTERFACE_NUM|DEVNAME" |
On the ttyUSB device that worked above. Note its ID_USB_INTERFACE_NUM.
Create a mapping rule by:
1 | sudo nano /etc/udev/rules.d/99-alcatel-modem.rules |
Enter the content:
1 | SUBSYSTEM=="tty", ATTRS{idVendor}=="1bbb", ATTRS{idProduct}=="00b6", ENV{ID_USB_INTERFACE_NUM}=="00", SYMLINK+="unicom_modem" |
- idVendor and idProduct are from the lsusb info
- ID_USB_INTERFACE_NUM is from the udevadm info
- SYMLINK is your picked name for this symbolic link. In my case, a new device mapping name /dev/unicom_modem will be created pointing to the actual ttyUSB port.
Save file and apply the change by:
1 | sudo udevadm control --reload-rules |
Modify the gammu config to:
1 | sudo nano /etc/gammurc |
and try sudo gammu networkinfo again. It should work the same with the new link.
use gammu-smsd to auto receive sms
Install gammu-smsd:
1 | sudo apt install gammu-smsd |
Config sudo nano /etc/gammu-smsdrc:
1 | [gammu] |
A few things:
- MultipartTimeout is a delay in case a long message is cut into pieces. We wait until all message are received to process
- RunOnReceive is the script to run when receiving a sms
- InitCommand is the command to force TMO in case the dongle is reset for some reason.
Script to parse and forward sms to telegram
File located at: /usr/local/bin/telegram-forward.sh. Can change to other location if needed. Remember to add execute permision.
1 | #!/bin/bash |
Enable gammu-smsd service
1 | sudo systemctl stop gammu-smsd |