How to read SMS using a GSM modem
Equipment and specifications:
- Khadas VIM4 (SKU: KVIM4-N-02)
- Quectel EM06 4G LTE Module (SKU: K-LTE-002) (EM06-E - EMEA / APAC / Brazil)
- New M2X Extension (SKU: KM2X-V-002)
- 30W USB-C Adapter (SKU: KP30W-EU-002) (EU + USB-C Cable)
- Free telecom SIM Card (EU)
- Ubuntu 22.04.3 LTS jammy (installed via OOWOW)
- mmcli 1.20.0 (included in the above version of Ubuntu)
- gnokii 0.6.31
Just FYI, arm yourself with patience because you could face several timeouts.
- Activate the GSM modem, unlock SIM card, and make sure it's registered to a cellular tower
khadas@Khadas:~$ sudo ifconfig wwan0 up
khadas@Khadas:~$ mmcli -L
/org/freedesktop/ModemManager1/Modem/1 [Quectel] EM06-E
khadas@Khadas:~$ mmcli -m 1 | grep "state:"
| state: locked
| power state: on
khadas@Khadas:~$ sudo mmcli -i 0 --pin=1234
successfully sent PIN code to the SIM
khadas@Khadas:~$ mmcli -m 1 | grep "state:"
| state: registered
| power state: on
| packet service state: attached
- Use
gnokii
to determine what memory types are available, and read any stored SMS
khadas@Khadas:~$ sudo gnokii --config /etc/.gnokiirc --showsmsfolderstatus
GNOKII Version 0.6.31
No. Name Id #Msg
========================================================
0 Internal memory ME 20
1 Combined ME and SIM phonebook MT 20
2 SIM card SM 0
3 SMS Status Reports SR 0
I will be using MT
since it combines ME
and SIM phonebook.
- Read SMS number 20 (because I have 20 messages).
khadas@Khadas:~$ sudo gnokii --config /etc/.gnokiirc --getsms MT 20
GNOKII Version 0.6.31
20. Inbox Message (Read)
Date/time: 07/01/2024 21:26:48 +0100
Sender: +XXXXXXXXXXX Msg Center: +XXXXXXXXXXX
Text:
I think it works
- Read SMS messages from 10 to 16
khadas@Khadas:~$ sudo gnokii --config /etc/.gnokiirc --getsms MT 10 16
GNOKII Version 0.6.31
Lockfile /var/lock/LCK..ttyUSB2 is stale. Overriding it...
10. Inbox Message (Read)
Date/time: 07/01/2024 15:06:32 +0100
Sender: +XXXXXXXXXXX Msg Center: +XXXXXXXXXXX
Text:
Hello Khadas
11. Inbox Message (Read)
Date/time: 07/01/2024 15:12:34 +0100
Sender: +XXXXXXXXXXX Msg Center: +XXXXXXXXXXX
Text:
Hejejdhe
Getting SMS failed (location 12 from MT memory)! (Command timed out.)
13. Inbox Message (Read)
Date/time: 07/01/2024 16:08:05 +0100
Sender: +XXXXXXXXXXX Msg Center: +XXXXXXXXXXX
Text:
Teskdjdjd
14. Inbox Message (Read)
Date/time: 07/01/2024 16:11:49 +0100
Sender: +XXXXXXXXXXX Msg Center: +XXXXXXXXXXX
Text:
Urjri
15. Inbox Message (Read)
Date/time: 07/01/2024 16:12:23 +0100
Sender: +XXXXXXXXXXX Msg Center: +XXXXXXXXXXX
Text:
Hshsus
16. Inbox Message (Read)
Date/time: 07/01/2024 16:12:28 +0100
Sender: +XXXXXXXXXXX Msg Center: +XXXXXXXXXXX
Text:
Ududud
For some reason SMS number 12 timed out. I really don't know what's going on with this GSM modem but a lot of times I am having timeouts for a lot of operations it's really frustrating almost impossible to think about creating something that will be stable enough for a production environment.
Sources: