wdoekes / asterisk-chan-dongle

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

GSM <->SIP Asterisk 18.14.0 FreeBSD 13.1 Huawei E169 #163

Closed VasOleMil closed 1 year ago

VasOleMil commented 1 year ago

No audio from GSM to SIP, modem is working well with Windows 10 and provider program on the same machine, audio present in both directions regardless of caller. Asterisk installed from ports, SIP<->SIP connection works fine.

making sequence:

    ./bootstrap
    ./configure LDFLAGS="-L /usr/local/lib" --with-astversion=18.14.0 (command asterisk -V)
    add in Makefile block usage, line 43: CFLAGS = -g -O2 -O6 -Wno-out-of-line-declaration -fblocks ...
    add in the end of makefile line LIBS = /usr/local/lib/libiconv.so
    gmake and copy your file to asterisk modules or use gmake install
    pw groupmod dialer -m asterisk

CLI check:

CLI> dongle show devices
ID           Group State      RSSI Mode Submode Provider Name  Model      Firmware          IMEI             IMSI             Number        
vodafone     1     Free       2    5    4       Vodafone UA    E169       11.314.17.00.00   35963801387****  25501515034****  Unknown  
CLI> dongle show device settings vodafone
------------- Settings ------------
  Device                  : vodafone
  Audio                   : /dev/cuaU0.1
  Data                    : /dev/cuaU0.2
  IMEI                    : 35963801387****
  IMSI                    : 25501515034****
  Channel Language        : en
  Context                 : vodafone-incoming
  Exten                   : +38095*******
  Group                   : 1
  RX gain                 : 0
  TX gain                 : 0
  U2Diag                  : 0
  Use CallingPres         : Yes
  Default CallingPres     : Presentation Allowed, Passed Screen
  Auto delete SMS         : Yes
  Disable SMS             : No
  Reset Dongle            : Yes
  Call Waiting            : auto
  DTMF                    : relax
  Minimal DTMF Gap        : 45
  Minimal DTMF Duration   : 80
  Minimal DTMF Interval   : 200
  Initial device state    : start
CLI> dongle show device state vodafone
-------------- Status -------------
  Device                  : vodafone
  State                   : Free
  Audio                   : /dev/cuaU0.1
  Data                    : /dev/cuaU0.2
  Voice                   : Yes
  SMS                     : Yes
  Manufacturer            : huawei
  Model                   : E169
  Firmware                : 11.314.17.00.00
  IMEI                    : 35963801387****
  IMSI                    : 25501515034****
  GSM Registration Status : Registered, home network
  RSSI                    : 14, -85 dBm
  Mode                    : WCDMA
  Submode                 : WCDMA
  Provider Name           : Vodafone UA
  Location area code      : 79
  Cell ID                 : 713B197
  Subscriber Number       : Unknown
  SMS Service Center      : +38050000501
  Tasks in queue          : 0
  Commands in queue       : 0
  Call Waiting            : Disabled
  Current device state    : start
  Desired device state    : start
  When change state       : now
  Calls/Channels          : 0
    Active                : 0
    Held                  : 0
    Dialing               : 0
    Alerting              : 0
    Incoming              : 0
    Waiting               : 0
    Releasing             : 0
    Initializing          : 0
CLI> core show channeltypes
Type             Description                              Devicestate   Presencestate Indications   Transfer     
-------------    -------------                            ------------- ------------- ------------- -------------
Dongle           Huawei 3G Dongle Channel Driver          yes           no            yes           no           
Recorder         Bridge Media Recording Channel Driver    no            no            yes           no           
Announcer        Bridge Media Announcing Channel Driver   no            no            yes           no           
Console          OSS Console Channel Driver               no            no            yes           no           
CBAnn            Conference Bridge Announcing Channel     no            no            yes           no           
CBRec            Conference Bridge Recording Channel      no            no            no            no           
PJSIP            PJSIP Channel Driver                     yes           no            yes           yes          

System check:

# lsusb
Bus /dev/usb Device /dev/ugen2.2: ID 12d1:1001 Huawei Technologies Co., Ltd. E161/E169/E620/E800 HSDPA Modem
# ls -al /dev/ | grep -E "cua"
crw-rw----   1 uucp      dialer    0x9f Nov 12 14:19 cuaU0.0
crw-rw----   1 uucp      dialer    0xa0 Nov 12 14:19 cuaU0.0.init
crw-rw----   1 uucp      dialer    0xa1 Nov 12 14:19 cuaU0.0.lock
crw-rw----   1 uucp      dialer    0xa5 Nov 12 16:21 cuaU0.1
crw-rw----   1 uucp      dialer    0xa6 Nov 12 14:19 cuaU0.1.init
crw-rw----   1 uucp      dialer    0xa7 Nov 12 14:19 cuaU0.1.lock
crw-rw----   1 uucp      dialer    0xab Nov 12 17:44 cuaU0.2
crw-rw----   1 uucp      dialer    0xac Nov 12 14:19 cuaU0.2.init
crw-rw----   1 uucp      dialer    0xad Nov 12 14:19 cuaU0.2.lock

The only warning in console, when calling GSM->SIP at the end of connection:

WARNING[102589][C-00000002]: channel.c:1079 channel_indicate: [Dongle/vodafone-0100000001] Don't know how to indicate condition 22

VasOleMil commented 1 year ago

Updated modem firmware to the latest 11.314.17.00.00->11.315.05.00.00, still no audio at GSM->SIP in Asterisk:

CLI> dongle show devices
ID           Group State      RSSI Mode Submode Provider Name  Model      Firmware          IMEI             IMSI             Number        
vodafone     1     Free       16   5    4       Vodafone UA    E169       11.315.05.00.00   35963801387****  25501515034****  Unknown  

Using simple configs for test purpase;

dongle.conf

[general]
interval=15
smsdb=/var/db/asterisk/smsdb
csmsttl=600

[defaults]
context=default                     
group=0                             
rxgain=0                            
txgain=0                            
autodeletesms=yes                   
resetdongle=yes                     
u2diag=-1                           
usecallingpres=yes                  
callingpres=allowed_passed_screen   
disablesms=no   
language=en                         
mindtmfgap=45                       
mindtmfduration=80                  
mindtmfinterval=200                 
callwaiting=auto                    
disable=no                          
initstate=start     
exten=+38095*******                 
dtmf=relax  

[vodafone]
context=vodafone-incoming
exten=+38095*******
audio=/dev/cuaU0.1
data=/dev/cuaU0.2
imei=35963801387****
imsi=25501515034****
group=1
rxgain=0
txgain=0
resetdatacard=yes
u2diag=0
usecallingpres=yes
callingpres=allowed_passed_screen
disablesms=no

pjsip.conf

;===============TRANSPORT================================================================
[transport-udp-nat]
type=transport
protocol=udp
bind=0.0.0.0
local_net=192.168.0.0/24
external_media_address=176.36.XXX.XXX
external_signaling_address=176.36.XXX.XXX

;===============ENDPOINT TEMPLATES=======================================================

[endpoint-basic](!)
type=endpoint
context=internal
disallow=all
allow=ulaw

[auth-userpass](!)
type=auth
auth_type=userpass

[aor-single-reg](!)
type=aor
max_contacts=1
remove_existing=yes
remove_unavailable=yes

;===============EXTENSION 6000

[6000](endpoint-basic)
auth=auth6000
aors=6000

[auth6000](auth-userpass)
password=6000
username=6000

[6000](aor-single-reg)

;===============EXTENSION 6001

[6001](endpoint-basic)
auth=auth6001
aors=6001

[auth6001](auth-userpass)
password=6001
username=6001

[6001](aor-single-reg)

extensions.conf

[vodafone-incoming-sms]
exten => sms,1,Noop(Incoming SMS from ${CALLERID(num)} ${BASE64_DECODE(${SMS_BASE64})})
exten => sms,n,System(echo '${STRFTIME(${EPOCH},,%Y-%m-%d %H:%M:%S)} - ${DONGLENAME} - ${CALLERID(num)}: ${BASE64_DECODE(${SMS_BASE64})}' >> /var/log/asterisk/sms.log)
exten => sms,n,Hangup()

[vodafone-incoming-ussd]
exten => ussd,1,Noop(Incoming USSD: ${BASE64_DECODE(${USSD_BASE64})})
exten => ussd,n,System(echo '${STRFTIME(${EPOCH},,%Y-%m-%d %H:%M:%S)} - ${DONGLENAME} - ${CALLERID(num)}: ${BASE64_DECODE(${USSD_BASE64})}' >> /var/log/asterisk/ussd.log)
exten => ussd,n,Hangup()

[vodafone-incoming]
include => vodafone-incoming-sms
include => vodafone-incoming-ussd

;redirect to internal number
exten => +38095*******,1,Dial(PJSIP/6000,60)

;play hellow world
;exten => +38095*******,1,Answer(500)
;exten => +38095*******,n,Playback(hello-world)
;exten => h,n,Hangup()

[internal]

exten = _6XXX,1,Dial(PJSIP/${EXTEN})

;external number call filter
exten => _38050XXXXXXX,1,Dial(Dongle/vodafone/+${EXTEN},240,tT)
exten => _38066XXXXXXX,1,Dial(Dongle/vodafone/+${EXTEN},240,tT)
exten => _38095XXXXXXX,1,Dial(Dongle/vodafone/+${EXTEN},240,tT)

;gsm provider call
exten => 111,1,Dial(Dongle/vodafone/${EXTEN},240,tT)
VasOleMil commented 1 year ago

CLI Debug

CLI> rtp set debug on
RTP Packet Debugging Enabled
CLI> core set verbose 10
Console verbose was 1 and is now 10.

CLI: GSM->SIP with hold

    -- Executing [+38095*******@vodafone-incoming:1] Dial("Dongle/vodafone-0100000000", "PJSIP/6000,60") in new stack
    -- Called PJSIP/6000
[Nov 13 02:24:50] WARNING[103721][C-00000001]: channel.c:1079 channel_indicate: [Dongle/vodafone-0100000000] Don't know how to indicate condition 22
    -- PJSIP/6000-00000000 is ringing
       > 0x804c55000 -- Strict RTP learning after remote address set to: 192.168.0.98:4010
    -- PJSIP/6000-00000000 answered Dongle/vodafone-0100000000
    -- Channel PJSIP/6000-00000000 joined 'simple_bridge' basic-bridge <4a608c57-f008-41d9-868c-7ac92f846b3b>
    -- Channel Dongle/vodafone-0100000000 joined 'simple_bridge' basic-bridge <4a608c57-f008-41d9-868c-7ac92f846b3b>
       > 0x804c55000 -- Strict RTP learning after remote address set to: 192.168.0.98:4010
    -- Started music on hold, class 'default', on channel 'Dongle/vodafone-0100000000'
       > 0x804c55000 -- Strict RTP learning after remote address set to: 192.168.0.98:4010
    -- Stopped music on hold on Dongle/vodafone-0100000000
Sent RTP packet to      192.168.0.98:4010 (type 00, seq 017366, ts 000160, len -000013)
...
Sent RTP packet to      192.168.0.98:4010 (type 00, seq 017656, ts 046560, len -000013)
    -- Channel PJSIP/6000-00000000 left 'simple_bridge' basic-bridge <4a608c57-f008-41d9-868c-7ac92f846b3b>
    -- Channel Dongle/vodafone-0100000000 left 'simple_bridge' basic-bridge <4a608c57-f008-41d9-868c-7ac92f846b3b>
  == Spawn extension (vodafone-incoming, +38095*******, 1) exited non-zero on 'Dongle/vodafone-0100000000'

CLI: GSM->SIP no hold

-- Executing [+38095*******@vodafone-incoming:1] Dial("Dongle/vodafone-0100000001", "PJSIP/6000,60") in new stack
    -- Called PJSIP/6000
[Nov 13 02:30:08] WARNING[103786][C-00000002]: channel.c:1079 channel_indicate: [Dongle/vodafone-0100000001] Don't know how to indicate condition 22
    -- PJSIP/6000-00000001 is ringing
       > 0x80a6e0000 -- Strict RTP learning after remote address set to: 192.168.0.98:4012
    -- PJSIP/6000-00000001 answered Dongle/vodafone-0100000001
    -- Channel PJSIP/6000-00000001 joined 'simple_bridge' basic-bridge <afa86dec-0822-4b0c-8b3e-82a0bdde4cba>
    -- Channel Dongle/vodafone-0100000001 joined 'simple_bridge' basic-bridge <afa86dec-0822-4b0c-8b3e-82a0bdde4cba>
    -- Channel PJSIP/6000-00000001 left 'simple_bridge' basic-bridge <afa86dec-0822-4b0c-8b3e-82a0bdde4cba>
    -- Channel Dongle/vodafone-0100000001 left 'simple_bridge' basic-bridge <afa86dec-0822-4b0c-8b3e-82a0bdde4cba>
  == Spawn extension (vodafone-incoming, +38095*******, 1) exited non-zero on 'Dongle/vodafone-0100000001'

CLI: SIP->GSM no hold

    -- Executing [38050*******@internal:1] Dial("PJSIP/6000-00000004", "Dongle/vodafone/+38050*******,240,tT") in new stack
    -- Called Dongle/vodafone/+38050*******
    -- Dongle/vodafone-0100000004 is making progress passing it to PJSIP/6000-00000004
       > 0x80367b000 -- Strict RTP learning after remote address set to: 192.168.0.98:4018
Sent RTP packet to      192.168.0.98:4018 (type 00, seq 003931, ts 000160, len -000013)
....
Sent RTP packet to      192.168.0.98:4018 (type 00, seq 004691, ts 121760, len -000013)
    -- Dongle/vodafone-0100000004 answered PJSIP/6000-00000004
    -- Channel Dongle/vodafone-0100000004 joined 'simple_bridge' basic-bridge <7c615bb8-961f-4a6f-89b6-ef0915589a84>
    -- Channel PJSIP/6000-00000004 joined 'simple_bridge' basic-bridge <7c615bb8-961f-4a6f-89b6-ef0915589a84>
Sent RTP packet to      192.168.0.98:4018 (type 00, seq 004692, ts 121920, len -000013)
...
Sent RTP packet to      192.168.0.98:4018 (type 00, seq 004808, ts 140480, len -000013)
    -- Channel PJSIP/6000-00000004 left 'simple_bridge' basic-bridge <7c615bb8-961f-4a6f-89b6-ef0915589a84>
  == Spawn extension (internal, 38050*******, 1) exited non-zero on 'PJSIP/6000-00000004'
    -- Channel Dongle/vodafone-0100000004 left 'simple_bridge' basic-bridge <7c615bb8-961f-4a6f-89b6-ef0915589a84>
VasOleMil commented 1 year ago

Found reason, audio now works in both sides, after changing transport settings. Asterisk server work in Wire while clients have WiFi connection, thus direct_media=no, in spite of all of them are in the same network 192.168.0.0 without NAT:

pjsip.conf

;===============TRANSPORT================================================================
[transport-udp-nat]
type=transport
protocol=udp
bind=0.0.0.0
local_net=192.168.0.0/24
local_net=127.0.0.0/32
external_media_address=176.36.XXX.XXX
external_signaling_address=176.36.XXX.XXX

;===============ENDPOINT TEMPLATES=======================================================

[endpoint-basic](!)
type=endpoint
context=internal
disallow=all
allow=ulaw
transport=transport-udp-nat
direct_media=no

[auth-userpass](!)
type=auth
auth_type=userpass

[aor-single-reg](!)
type=aor
max_contacts=1
remove_existing=yes
remove_unavailable=yes

;===============EXTENSION 6000

[6000](endpoint-basic)
auth=auth6000
aors=6000

[auth6000](auth-userpass)
password=6000
username=6000

[6000](aor-single-reg)

;===============EXTENSION 6001

[6001](endpoint-basic)
auth=auth6001
aors=6001

[auth6001](auth-userpass)
password=6001
username=6001

[6001](aor-single-reg)
wdoekes commented 1 year ago

Thanks for clearing things up! :)

Could be that you have (Wifi) "client isolation/separation" on. Then direct traffic would be dropped.