Engineering and technology notes

Wvdial

[Dialer Defaults]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Modem Type = Analog Modem
ISDN = 0
Modem = /dev/ttyUSB2
Baud = 9600

[Dialer thenet]
Phone = *99***1#
Username = thenetuser
Password = thenetpw
; Username = 9180****** (If your provider use without Username)
; Password = 9180****** (If your provider use without Password)
Stupid Mode = 1
Baud = 460800
Init3 = AT+CGDCONT=1,"IP","apn.thenet.net"

[Dialer mypin]
Init4 = AT+CPIN=1234

Source: Wvdial – ArchWiki

Wvdial was last modified: June 6th, 2023 by Jovan Stosic

How to setup a USB 3G Modem on Raspberry PI using usb_modeswitch and wvdial | How To | The Fan Club | dynamic design solutions

Create the wvdial config file

  • The next step is to create a config file for wvdial so you can connect to your service provider.
  • Open a terminal window and enter:
sudo leafpad /etc/wvdial.conf
  • Replace the content of the file with the following.
[Dialer 3gconnect]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Init3 = AT+CGDCONT=1,"IP","internet"
Stupid Mode = 1
Modem Type = Analog Modem
ISDN = 0
Phone = *99#
Modem = /dev/gsmmodem
Username = { }
Password = { }
Baud = 460800
  • Replace internet with your service provider’s APN
  • Replace the Phone number if you need to dial a different code to connect.
  • Replace Username and Password if needed. To leave the username and password as blank use { }

Source: How to setup a USB 3G Modem on Raspberry PI using usb_modeswitch and wvdial | How To | The Fan Club | dynamic design solutions

How to setup a USB 3G Modem on Raspberry PI using usb_modeswitch and wvdial | How To | The Fan Club | dynamic design solutions was last modified: June 6th, 2023 by Jovan Stosic

GitHub – pixelspark/tymodem: Read status from Huawei E3372 modem using AT commands

Stick info

ATI

Queries device information

> ATI
< Manufacturer: huawei
< Model: E3372
< Revision: 21.180.01.00.00
< IMEI: XXX
< +GCAP: +CGSM,+DS,+ES

AT^VERSION?

Query firmware versions.

> AT^VERSION?
< ^VERSION:BDT:Sep 30 2014, 15:17:21
< ^VERSION:EXTS:21.180.01.00.00
< ^VERSION:INTS:
< ^VERSION:EXTD:WEBUI_17.100.18.05.1217_HILINK
< ^VERSION:INTD:
< ^VERSION:EXTH:CL2E3372HM Ver.A
< ^VERSION:INTH:
< ^VERSION:EXTU:E3372
< ^VERSION:INTU:
< ^VERSION:CFG:1004
< ^VERSION:PRL:
< ^VERSION:OEM:
< ^VERSION:INI:

AT^TBATVOLT?

Query battery voltage (not applicable for the E3372 as it is a USB-powered stick, but probably returns the USB voltage).

> AT^TBATVOLT?
< ^TBATVOLT:4458

AT^CHIPTEMP?

Query the chip temperature.

> AT^CHIPTEMP?
< ^CHIPTEMP: 304,304,65535,27,65535

SIM info

AT+COPN

Query known/supported network names.

> AT+COPN
< +COPN: "732123","Movistar"
< +COPN: "73402","DIGITEL GSM"
...

AT+CPOL?

Query preferred roaming networks.


> AT+CPOL?
+CPOL: 1,2,"26202",1,0,1,1
....
+CPOL: 62,2,"40443",1,0,1,1

AT^ICCID?

Query the ICCID (SIM card number).

> AT^ICCID?
< ^ICCID: 8931XXXXXXXXXXXXX

AT^CPBR?

Query the SIM phone book.

> AT^CPBR=?
< ^CPBR: (1-250),40,20
> AT^CPBR=1
< ^CPBR: 1,"+XXXXXXXXX",145,"XXXXXXX",0

Connection info

AT^PLMN?

Query the connected network code (MNC/MCC).

> AT^PLMN? 
< ^PLMN: mnc,mcc

AT^LOCINFO?

Query network location info.

> AT^LOCINFO?
< ^LOCINFO:XXXXX,0xXXXX,0xXX,0xXXXXXX

AT^CREG?

Query registration info, which contains (among other things) the cell ID.

< AT+CREG?
> +CREG: 2,1,"XXXX","XXXX"

AT+COPS?

Query network operator info:

> AT+COPS?
< +COPS: 0,0,"NAME OF MNO",7

AT^CSNR?

Query signal-to-noise level.

> AT^CSNR?
< ^CSNR: -145,-32

AT^CERRSI?

Query received signal strength indications (RSSI).

> AT^CERSSI?
< ^CERSSI:0,0,0,0,255,-90,-7,15,32639,32639,32639

AT^DSFLOWQRY

Query flow (traffic) statistics.

> AT^DSFLOWQRY
< ^DSFLOWQRY:00000010,0000000000060A85,000000000003CC18,00000010,0000000000060A85,000000000003CC18

Source: GitHub – pixelspark/tymodem: Read status from Huawei E3372 modem using AT commands

GitHub – pixelspark/tymodem: Read status from Huawei E3372 modem using AT commands was last modified: June 6th, 2023 by Jovan Stosic

How to compile Linux kernel modules

Example: hello.c module

1) hello.c – It is C source code. Copy following code and save to hello.c
$ mkdir demo; cd demo
$ vi hello.c

2)Add following c source code to it:

#include <linux/module.h>       /* Needed by all modules */
#include <linux/kernel.h>       /* Needed for KERN_INFO */
#include <linux/init.h>         /* Needed for the macros */

static int __init hello_start(void)
{
printk(KERN_INFO "Loading hello module...\n");
printk(KERN_INFO "Hello world\n");
return 0;
}

static void __exit hello_end(void)
{
printk(KERN_INFO "Goodbye Mr.\n");
}

module_init(hello_start);
module_exit(hello_end);

This is an example modified from original source for demonstration purpose.

3) Save the file. Create new Makefile as follows:
$ vi Makefile
Append following make commands:

obj-m = hello.o
KVERSION = $(shell uname -r)
all:
        make -C /lib/modules/$(KVERSION)/build M=$(PWD) modules
clean:
        make -C /lib/modules/$(KVERSION)/build M=$(PWD) clean

4) Save and close the file.

5) Compile hello.c module:
$ make

6) Become a root user (use su or sudo) and load the module:
$ su -
# insmod hello.ko

If you get error message:

insmod: ERROR: could not insert module hello.ko: Invalid module format

then reinstall kernel headers with:

sudo apt update && sudo apt upgrade
sudo apt remove --purge linux-headers-*
sudo apt autoremove && sudo apt autoclean
sudo apt install linux-headers-generic

Note you can see message on screen if you are logged in as root under run level 3.

7) Verify that module loaded using the lsmod command:
# lsmod | less

8) See message in /var/log/message file using the tail command or less command:
# tail -f /var/log/syslog

9) Unload the module using the rmmod command:
# rmmod hello

10) Load module when Linux system comes up. File /etc/modules use to load kernel boot time. This file should contain the names of kernel modules that are to be loaded at boot time, one per line. First copy your module to /lib/modules/$(uname -r)/kernel/drivers. Following are suggested steps:

(a) Create directory for hello module:
# mkdir -p /lib/modules/$(uname -r)/kernel/drivers/hello
(b) Copy module:
# cp hello.ko /lib/modules/$(uname -r)/kernel/drivers/hello/
(c) Edit /etc/modules file under Debian Linux:
# vi /etc/modules
(d) Add following line to it:
hello
(e) Reboot to see changes. Use lsmod or dmesg command to verify module loaded or not.
cat /proc/modules
OR
# lsmod | less

 

Source: How to compile Linux kernel modules – nixCraft

How to compile Linux kernel modules was last modified: June 5th, 2023 by Jovan Stosic

Install Intell Xmm7360-pci (Fibocom LTE L780 module) modem

$ git clone https://github.com/xmm7360/xmm7360-pci.git
$ cd xmm7360-pci
$ make && make load

-If your sim has pin enabled, run echo "AT+CPIN=\"0000\"" | sudo tee -a /dev/ttyXMM1. Replace 0000 with your pin code.
# python3 rpc/open_xdatachannel.py --apn your.apn.here
# echo "nameserver 1.1.1.1" >> /etc/resolv.conf
# ip link set wwan0 up

Source: Xmm7360-pci – ArchWiki

Install Intell Xmm7360-pci (Fibocom LTE L780 module) modem was last modified: June 5th, 2023 by Jovan Stosic