0
votes

Problem:


    pi@raspberrypi:~ $ echo "Test" | sudo gammu sendsms TEXT +937********

    If you want break, press Ctrl+C...
    Sending SMS 1/1....waiting for network answer..error 500, message reference=-1
    Unknown error.

or even I run the script, it fails sms.py


    import gammu
    import sys

    # Create state machine object 
    sm = gammu.StateMachine()
    # Read ~/.gammurc
    sm.ReadConfig()
    # Connect to phone
    sm.Init()

    message= {
        'Text': sys.argv[1],
        'SMSC': { 'Location': 1},
        'Number': sys.argv[2]
    }
    print(message)

    sm.SendSMS(message)
    print("Message Sent...")

output is


    pi@raspberrypi:~ $ sudo python sms.py "Test Message" 00937********
    {'Text': 'Test Message', 'SMSC': {'Location': 1}, 'Number': '00937********'}
    Traceback (most recent call last):
        File "sms.py", line 18, in 
        sm.SendSMS(message)
    gammu.ERR_UNKNOWN: {'Text': u'Unknown error.', 'Code': 27, 'Where': 'SendSMS'}

Gammu monitor


    SIM phonebook: 0 used, 254 free
    Own numbers: 0 used,   1 free
    Battery level: 0 percent
    Charge state: powered from battery
    Signal strength: -79 dBm
    Network level: 51 percent
    SIM SMS status: 2 used, 0 unread, 70 locations
    Phone SMS status: 0 used, 0 unread, 20 locations
    Network state: requesting network
    Packet network state: requesting network
    GPRS: detached

dmesg | grep tty


    [0.000000] Kernel command line: coherent_pool=1M 8250.nr_uarts=0 cma=64M cma=256M video=HDMI-A-1:1920x1080M@60,margin_left=48,margin_right=48,margin_top=48,margin_bottom=48 smsc95xx.macaddr=DC:A6:32:48:2A:DE vc_mem.mem_base=0x3ec00000 vc_mem.mem_size=0x40000000  console=tty1 root=PARTUUID=d9b3f436-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles
    [0.000265] console [tty1] enabled
    [0.878196] fe201000.serial: ttyAMA0 at MMIO 0xfe201000 (irq = 34, base_baud = 0) is a PL011 rev2
    [2.523260] systemd[1]: Created slice system-getty.slice.
    [11.364721] usb 1-1.2: GSM modem (1-port) converter now attached to ttyUSB0
    [11.364939] usb 1-1.2: GSM modem (1-port) converter now attached to ttyUSB1
    [11.365131] usb 1-1.2: GSM modem (1-port) converter now attached to ttyUSB2

Here how to know to which ttyUSB0/1/2 our dongle is connected?

gammu --identify


    Warning: No configuration file found!
    Warning: No configuration read, using builtin defaults!
    Device: /dev/ttyUSB0
    Manufacturer: Huawei
    Model: E303 (E303)
    Firmware: 22.157.59.00.00
    IMEI: 864567010180944
    SIM IMSI: 412500242818912

gammu --debug textalldate --debug-file /home/pi/gammu.log identify

sudo gammu-config

gammu-config command is used to set the configurations and these configurations can be found in ~/.gammurc file too

sudo gammu --networkinfo

sudo gammu getallsms

Check permissions of /dev/ttyUSB*


    pi@raspberrypi:~ $ ls -l /dev/ttyUSB*
    crw-rw---- 1 root dialout 188, 0 Jan 15 12:59 /dev/ttyUSB0
    crw-rw---- 1 root dialout 188, 1 Jan 15 12:57 /dev/ttyUSB1
    crw-rw---- 1 root dialout 188, 2 Jan 15 12:57 /dev/ttyUSB2

based on above details, the user using gammu have to be member of dialout group.


    pi@raspberrypi:~ $ id
    uid=1000(pi) gid=1000(pi) groups=1000(pi),4(adm),20(dialout),24(cdrom),27(sudo),29(audio),44(video),46(plugdev),60(games),100(users),105(input),109(netdev),997(gpio),998(i2c),999(spi)

Luckily I am member of dialout group.

pi@raspberrypi:~ $ sudo usermod -a -G dialout pi
1

1 Answers

0
votes

I found the issue. It is because the wvdial is not configured properly. First make sure to set proper configuration for wvdial and set it in gsm text mode.

To properly configure the wvdial mode follow steps in this post https://stackoverflow.com/a/59697399/8403256