wdoekes / asterisk-chan-dongle

chan_dongle channel driver for Huawei UMTS cards, works with Asterisk 14+
Other
296 stars 104 forks source link

SMSDB error upon sending SMS #150

Closed fsdgadfase closed 2 years ago

fsdgadfase commented 2 years ago

I am unable to send sms messages using dongle sms. The action returns the following error: "[dongle0] SMSDB error". Issue #94 mentioned this to and the provided solution is to delete /var/lib/asterisk/smsdb.sqlite3. Unfortunately, non such file exists on my system.

I would hazard a guess and say that this database was not created in the setup. Is it possible to do this after setup?

Asterisk 15 on Debian 9 and a Huawei E1750.

wdoekes commented 2 years ago

That error originates here:

https://github.com/wdoekes/asterisk-chan-dongle/blob/3d046f7d6842298c6838b5ce5b51d495d383b158/at_command.c#L298-L312

So, either smsdb_get_refid fails, or smsdb_outgoing_add fails.

If either of them fails, I expect logs (WARNING or ERROR) just before it. Check your logs and report back.

If you have no such logs, then the only place without a reported error would be:

        } else if (sqlite3_step(put_outgoingmsg_stmt) != SQLITE_DONE) {
                res = -1;

Add some logging there and see it get reached.

fsdgadfase commented 2 years ago

Hi wdoekes,

Thank you for your reply.

When executing dongle sms dongle1 my_number test, the following appears in /var/log/asterisk/warning.log:

[Oct 22 10:00:46] WARNING[21041] smsdb.c: Error executing SQL (BEGIN TRANSACTION): (null)
[Oct 22 10:00:46] WARNING[21041] smsdb.c: Couldn't bind key to stmt: library routine called out of sequence
[Oct 22 10:00:46] WARNING[21041] smsdb.c: Error executing SQL (COMMIT): (null)

/var/log/asterisk/error.log remained empty.

I couldn't help but notice that /var/log/asterisk/warning.log also contained this message: [Oct 22 09:42:39] WARNING[1837] db.c: Couldn't execute statment: SQL logic error or missing database

Could the absence of smsdb.sqlite3 be the culprit?

wdoekes commented 2 years ago

Maybe start by fixing that "db.c" warning first.

Possibly you lack write (asterisk) permissions on /var/lib/asterisk or something.

wdoekes commented 2 years ago

Also, I suspect the DB init fails but you're not seeing that:

--- a/chan_dongle.c
+++ b/chan_dongle.c
@@ -1766,7 +1766,8 @@ static int public_state_init(struct public_state * state)
            /* register our channel type */
            if(ast_channel_register(&channel_tech) == 0)
            {
-               smsdb_init();
+               if (smsdb_init() != 0)
+                   ast_log(LOG_ERROR, "Unable to init smsdb\n");
                cli_register();

                app_register();
fsdgadfase commented 2 years ago

I am afraid I have wasted your time terribly... chown asteriskhost:asteriskhost /var/lib/asterisk/ resolved the issue.

Thank you for helping out.

Anyway, I am happy to report that the Huawei E1750 works on the Asterisk 15. The imei and imsi numbers aren't reported by dongle discovery:

; discovered device
[dc__](defaults)
;audio=/dev/ttyUSB3
;data=/dev/ttyUSB4
imei=
imsi=

That is no issue though as I have made the following udev rules:

ACTION=="add", ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1001", ENV{ID_USB_INTERFACE_NUM}=="01", OWNER="asteriskhost", SYMLINK+="huawei_audio_port"
ACTION=="add", ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1001", ENV{ID_USB_INTERFACE_NUM}=="02", OWNER="asteriskhost", SYMLINK+="huawei_at_port"

So my dongle.conf looks like this:

[dongle0](defaults)
audio=/dev/huawei_audio_port
data=/dev/huawei_at_port