smsgammu

gammu phones tables with multiple modem port


EDIT: I know, after some research, this problem caused by IMEI field in phones tables as primary, if we using modem pool like wavecome with 16 port, gammu detect just one IMEI

i have 1 modem connected with 16 port of sim card,each config connected to same database on my server,send and receive sms all working like a charm, each port have smsd services, like

gammu-smsd -c /etc/gammu-smsdrc-modem1 --pid /var/run/gammu-smsdrc-modem1 --daemon
gammu-smsd -c /etc/gammu-smsdrc-modem2 --pid /var/run/gammu-smsdrc-modem2 --daemon

each port have their own PhoneID, like modem1 and modem2, the problem is why phones tables in gammu databases keep replacing the data with last gammu-smsd services run ?

ex: if i run the first config, then phones tables will contains all informations , like signal, IMEI from 1st port, but when i run 2nd gammu-smsd data from 1st port will gone, changed from 2nd port config

here is my smsdrc config from modem1 /etc/gammu-smsdrc-modem1

[gammu]
port = /dev/ttyUSB0
model =
connection = at115200
synchronizetime = yes
logfile = /var/log/gammu-smsdrc-modem1
logformat = nothing
use_locking =
gammuloc =

[smsd]
service=sql
logfile=/var/log/gammu-smsdrc-modem1
debuglevel=0
Driver=native_mysql
User=root
Password=root
PC=localhost
Database=test
PhoneID=modem1

here is my smsd config from modem2 /etc/gammu-smsdrc-modem2

[gammu]
port = /dev/ttyUSB1
model =
connection = at115200
synchronizetime = yes
logfile = /var/log/gammu-smsdrc-modem2
logformat = nothing
use_locking =
gammuloc =

[smsd]
service=sql
logfile=/var/log/gammu-smsdrc-modem2
debuglevel=0
Driver=native_mysql
User=root
Password=root
PC=localhost
Database=test
PhoneID=modem2

Solution

  • after some reading on API Doc of gammu, i have figure it out, yes like the first one, it because i use one modem with 16 port of sim card, gammu just detect singel IMEI even the modem have 16 port, quick answer for my question is no configureable file can handle that problem, so we have to modify some line og code from smsd/services/sql.c

    if (SMSDSQL_option(Config, SQL_QUERY_DELETE_PHONE, "delete_phone",
        "DELETE FROM phones WHERE ", ESCAPE_FIELD("IMEI"), " = %I", NULL) != ERR_NONE) {
        return ERR_UNKNOWN;
    }
    
    .......
    .......
    .......
    
    if (SMSDSQL_option(Config, SQL_QUERY_UPDATE_RECEIVED, "update_received",
        "UPDATE phones SET ",
            ESCAPE_FIELD("Received"), " = ", ESCAPE_FIELD("Received"), " + 1"
            " WHERE ", ESCAPE_FIELD("IMEI"), " = %I", NULL) != ERR_NONE) {
        return ERR_UNKNOWN;
    }
    

    the final code will be

    if (SMSDSQL_option(Config, SQL_QUERY_DELETE_PHONE, "delete_phone",
        "DELETE FROM phones WHERE ", ESCAPE_FIELD("ID"), " = %P", NULL) != ERR_NONE) {
        return ERR_UNKNOWN;
    }
    
    .......
    .......
    .......
    
    if (SMSDSQL_option(Config, SQL_QUERY_UPDATE_RECEIVED, "update_received",
        "UPDATE phones SET ",
            ESCAPE_FIELD("Received"), " = ", ESCAPE_FIELD("Received"), " + 1"
            " WHERE ", ESCAPE_FIELD("ID"), " = %P", NULL) != ERR_NONE) {
        return ERR_UNKNOWN;
    }
    

    and recompile gammu as usual, and modify phones tables to set ID as Primary key, i'm not expert in c, hope some one can made a good change for better result, but for me it's enough for temp used.