RoEdAl / asterisk-chan-quectel

Asterisk channel driver for Quectel and SimCOM modules
GNU General Public License v2.0
18 stars 6 forks source link

src/tty.c:55 tty_open: [TTY] Unable to open : No such file or directory #11

Closed sparkcyf closed 5 months ago

sparkcyf commented 5 months ago

Hi, I'm using asterisk-chan-quectel at Debian 12, Asterisk 16.28.0 (debian maintained version), quectel EC20-CEFAG.

I build the driver use the command below and ensured that chan_quectel.so have been sucdessfully installed at /usr/lib/asterisk/modules/chan_quectel.so:

./make-build-dir.cmake default 162800
cmake --build build --target package
dpkg -i package/asterisk-chan-quectel_2023.12.13_2-g977d62_amd64.deb

My quectel.conf (the only change i made is enabled the uac):

[quectel0]
;audio=/dev/ttyUSB1                     ; tty port for Audio, set as ttyUSB4 for Simcom if no other dev present
data=/dev/ttyUSB2                      ; tty port for AT commands;             no default value
uac=yes  

However, when I start my quctel in the asterisk console using quectel start quectel0, I always got the following error:

=========================================================================
Connected to Asterisk 16.28.0~dfsg-0+deb11u3 currently running on debian-asterisk-charles-130 (pid = 941)
debian-asterisk-123*CLI> quectel start  quectel0
[quectel0] Start scheduled
    -- [quectel0] Trying to connect on /dev/ttyUSB2...
[Jan 30 15:59:43] WARNING[1018]: src/tty.c:55 tty_open: [TTY] Unable to open : No such file or directory
debian-asterisk-123*CLI> 

I've confirmed that this may not be a permissions issue, as I can use minicom -D /dev/ttyUSB2 to send AT command to EC20 under the asterisk user, and asterisk user have been added to the dialout and audio group. I could also use the similar config with the https://github.com/IchthysMaranatha/asterisk-chan-quectel driver , but no luck on this one.

Considering the steps I've taken and the checks I've performed, I'm still encountering issues. Could anyone please advise on how I should further investigate this problem? Thanks in advanced.

RoEdAl commented 5 months ago

Just instead of

uac=yes

type:

uac=on

There is a bug in configuration parser. For uac option the only acceptable switches are: on, off, true, false and ext. Other switches (including yes and no ones) are silently ignored. So effectively uac=yes does nothing. You are still in TTY mode.

This bug will be fixed soon.

sparkcyf commented 5 months ago

After setting uac=on, the call works like a charm! However, I also noticed that there may have some issues on receiving multi part sms using chan_quectel. In the console, I could see the ast_verb log like

https://github.com/RoEdAl/asterisk-chan-quectel/blob/977d623d6046b3c9990391795eecf11ea522d291/src/at_response.c#L1717

debian-asterisk*CLI> 
  == [quectel0][SMS:89 PART:1/3 TS:2024-02-02 15:22:57 +08:00] Got message part from 10010: [PART 1 OF THE MESSAGE]
  == [quectel0][SMS:89 PART:3/3 TS:2024-02-02 15:22:57 +08:00] Got message part from 10010: [PART 3 OF THE MSG]
  == [quectel0][SMS:89 PART:2/3 TS:2024-02-02 15:22:57 +08:00] Got message part from 10010: [PART 2 OF THE MSG]

but after that, the sms block in incoming-mobile havent executed (no more log show on the console).

I also tried receiving a short message (this msg is short so it wont be split in parts, which works well)

  == [quectel0][SMS:0 TS:2024-02-02 15:04:27 +08:00] Got message part from +8613813888888: [hello from quectel]
 [quectel0][SMS:0 PARTS:1 TS:2024-02-02 15:04:27 +08:00] Got message from +8613813888888: [hello from quectel]
    -- Executing [sms@incoming-mobile:1] NoOp("Local/sms@incoming-mobile-00000004;1", "SMS from device quectel0") in new stack
    -- Executing [sms@incoming-mobile:2] Set("Local/sms@incoming-mobile-00000004;1", "SMS_TXT=hello from quectel") in new stack
    -- Executing [sms@incoming-mobile:3] Set("Local/sms@incoming-mobile-00000004;1", "SMS_OBJTXT={"ts":"2024-02-02 15:04:27 +08:00","parts":1,"from":"+8613813888888","msg":"hello from quectel"}") in new stack

my extensions.conf (mainly copied from README.md):

[incoming-mobile]
exten => _.,1,Dial(SIP/70/13800138001)
exten => s,n,Hangup()

exten => sms,1,NoOp(SMS from device ${JSON_DECODE(QUECTEL,name)})
same => n,Set(SMS_TXT=${JSON_DECODE(SMS,msg)})
same => n,Set(SMS_OBJTXT=${SMS})
same => n,GotoIf($[${EXISTS(${SMS_TXT})}]?smstxt:smsempty)
same => n(smstxt),Verbose(2, [${JSON_DECODE(QUECTEL,name)}] Incoming SMS from ${CALLERID(num)} [${JSON_DECODE(SMS,ts)}]: ${SMS_TXT})

same => n,Goto(smsbye)
same => n(smsempty),Verbose(2, [${JSON_DECODE(QUECTEL,name)}] Empty incoming SMS from ${CALLERID(num)})
same => n(smsbye),Hangup

exten => ussd,1,NoOp(USSD from device ${JSON_DECODE(QUECTEL,name)})
same => n,Set(USSD_TXT=${JSON_DECODE(USSD,ussd)})
same => n,Verbose(2, [${JSON_DECODE(QUECTEL,name)}] Incoming USSD [${JSON_DECODE(USSD,type_description)}]: ${USSD_TXT})
same => n,Hangup

exten => report,1,NoOp(Report from device ${JSON_DECODE(QUECTEL,name)})
same => n,Set(REPORT_SUBJECT=${JSON_DECODE(REPORT,subject)})
same => n,Set(REPORT_DIRECTION=${JSON_DECODE(REPORT,direction)})
same => n,Set(REPORT_SUCCESS=${JSON_DECODE(REPORT,success)})
same => n,Set(REPORT_JSON=${JSON_DECODE(REPORT,report)})
same => n,Set(REPORT_INFO=${JSON_DECODE(REPORT_JSON,info)})
same => n,GotoIf($[${REPORT_SUCCESS} = 1]?reportsuccess:reportfail)
same => n(reportsuccess),Verbose(2,${JSON_DECODE(QUECTEL,name)} - ${REPORT_SUBJECT} - ${REPORT_DIRECTION} - ${CALLERID(num)} - ${REPORT_INFO})
same => n,Goto(reportbye)
same => n(reportfail),Verbose(1,${JSON_DECODE(QUECTEL,name)} - ${REPORT_SUBJECT} - ${REPORT_DIRECTION} - ${CALLERID(num)} - ${REPORT_INFO})
same => n,Goto(reportbye)
same => n,Hangup

[Outbound-mobile]
exten => _.,1,Dial(Quectel/quectel0/${EXTEN})
same => n,Hangup()
RoEdAl commented 5 months ago

I belive this multipart SMS issue is caused by non sequential order of receiving parts (e.g. 1,3,2). If parts of the SMS arrived sequentially, it would be sent to the dial plan. Try 2-parts SMS for example.

This is a bug of course. It will be fixed soon.

sparkcyf commented 5 months ago

I belive this multipart SMS issue is caused by non sequential order of receiving parts (e.g. 1,3,2). If parts of the SMS arrived sequentially, it would be sent to the dial plan. Try 2-parts SMS for example.

This is a bug of course. It will be fixed soon.

Hello, I've found that the https://github.com/RoEdAl/asterisk-chan-quectel/issues/11#issuecomment-1923205774 issue may relevant to the condition check inside smsdb_put function. After modified that condition ( https://github.com/RoEdAl/asterisk-chan-quectel/pull/12 ), receiving multi part messages works without problem:

  == [quectel0][SMS:152 PART:2/3 TS:2024-02-03 15:00:00 +08:00] Got message part from 10010: [中国联通APP,足不出户办业务、交话费,指尖一点查余额、查流量,点击 link ,畅享便利【]
  == [quectel0][SMS:152 PART:3/3 TS:2024-02-03 15:00:00 +08:00] Got message part from 10010: [中国联通】]
  == [quectel0][SMS:152 PART:1/3 TS:2024-02-03 15:00:00 +08:00] Got message part from 10010: [返程高峰至,疫情仍未止。请不要放松警惕,勤洗手,少聚会,详细数据点击查看 link\r 让服务更有温度! 使用]
 [quectel0][SMS:152 PARTS:3 TS:2024-02-03 15:00:00 +08:00] Got message from 10010: [返程高峰至,疫情仍未止。请不要放松警惕,勤洗手,少聚会,详细数据点击查看 link\r 让服务更有温度! 使用中国联通APP,足不出户办业务、交话费,指尖一点查余额、查流量,点击 link ,畅享便利【中国联通】]
    -- Executing [sms@incoming-mobile:1] NoOp("Local/sms@incoming-mobile-00000002;1", "SMS from device quectel0") in new stack
    -- Executing [sms@incoming-mobile:2] Set("Local/sms@incoming-mobile-00000002;1", "SMS_TXT=返程高峰至,疫情仍未止。请不要放松警 让服务更有温度! 使用中国联通APP,足不出户办业务、交话费,指尖一点查余额、查流量,点击 lin k ,畅享便利【中国联通】") in new stack
    -- Executing [sms@incoming-mobile:3] Set("Local/sms@incoming-mobile-00000002;1", "SMS_OBJTXT={"ts":"2024-02-03 15:00:00 +08:00","ref":152,"parts":3,"from":"10010","msg":"返程高峰至,疫情仍未止。请不要放松警惕,勤洗手,少聚会,详细数据点击查看 link\r 让服务更有温度! 使用中国联通APP,足不出户办业务、交话费,指尖一点查余额、查流量,点击 link ,畅享便利【中国联通】"}") in new stack
    -- Executing [sms@incoming-mobile:4] GotoIf("Local/sms@incoming-mobile-00000002;1", "1?smstxt:smsempty") in new stack
    -- Goto (incoming-mobile,sms,5)
    -- Executing [sms@incoming-mobile:5] Verbose("Local/sms@incoming-mobile-00000002;1", "2, [quectel0] Incoming SMS from 10010 [20 让服务更有温度! 使       > ??中国联通APP,足不出户办业务、交话费,指尖一点查余额、查流量,点击 link ,畅享便利【中国联通】") in new stack
  ==  [quectel0] Incoming SMS from 10010 [2024-02-03 15:00:00 +08:00]: 返程高峰至,疫情仍未止。请不要放松警惕,勤洗手,少聚会,详细 让服务更有温度! 使用中国联通APP,足不出户办业务、交话费,指尖一点查余额、查流量,点击 link ,畅享便利【中国联通】
    -- Executing [sms@incoming-mobile:6] Goto("Local/sms@incoming-mobile-00000002;1", "smsbye") in new stack
    -- Goto (incoming-mobile,sms,8)
    -- Executing [sms@incoming-mobile:8] Hangup("Local/sms@incoming-mobile-00000002;1", "") in new stack
  == Spawn extension (incoming-mobile, sms, 8) exited non-zero on 'Local/sms@incoming-mobile-00000002;1'
    -- Executing [h@incoming-mobile:1] Dial("Local/sms@incoming-mobile-00000002;1", "SIP/70/13888888888") in new stack
    -- Caller hung up before dial.
  == Spawn extension (incoming-mobile, h, 1) exited non-zero on 'Local/sms@incoming-mobile-00000002;1'
RoEdAl commented 5 months ago

Change approved. Thank you.