返回列表 發帖

教程 - Using your spare USB 3G modem with Asterisk (SMS and Voice - In and Out)

本帖最後由 ckleea 於 2011-5-13 19:41 編輯

與其讓你的手指退下來,不如物盡其用,駁上你的asterisk server 做多個FXO 口

注意:會可能有較多英文;需要有linux software compile experience,同裝linux package 經驗。

不過,相信是另一種方面實現voip 流動方案。

After some days of work, trial and errors, I am finally able to make it successful

I use a spare USB 3G modem to connect my asterisk 1.8 to do
1. Voice in and out (音質清晰)
- very clear (tested with bubblestar 兄 and others)

2. SMS in and out (短訊可打出打入)
- incoming to asterisk server - support Chinese and English; SMS can then forward to user by email
可以接受中英文短訊,然後經電郵轉發指定用戶
- outgoing - Only English message in asterisk command line
暫時只可以在asterisk CLI 發英文短訊

Future:
Waiting for frontend GUI program to do SMS

感謝:
雯雯借出手指試用
bubblestar 兄試通話quality

本帖最後由 ckleea 於 2011-4-1 10:30 編輯

基本準備:

1. working asterisk server

2. centos 5.5 server with support kernel, I use 2.6.38. The latest centos 5.5 official kernel is 2.6.18 which is not able to work with voice part. 好多沙聲成者冇聲

http://elrepo.org/tiki/tiki-index.php

3. one supported huawei USB 3G modem

(I use K3715; E180 should work; E169G works with SMS only)
Full list of supported device is available below
http://wiki.e1550.mobi/doku.php?id=requirements


The following will tell you how to check your USB modem is SIMS unlocked and Voice enabled
http://www.hkepc.com/forum/viewt ... &extra=page%3D1

Tools
dc-unlocker http://www.dc-unlocker.com/
firmware & dashbroad files http://dc-files.com/

4. one working sims card
我用People 儲值 SIMS卡
唔需要3G SIMS,2G 已經足夠,因為目的是通話及短訊,不是用來上網。

參考網頁
1. http://www.telecom-cafe.com/foru ... 1&highlight=usb
2. http://www.telecom-cafe.com/foru ... &extra=page%3D1

supported devices.PNG (27.67 KB)

supported devices.PNG

TOP

本帖最後由 ckleea 於 2011-4-1 10:33 編輯

準備軟件 software

http://code.google.com/p/datacard/downloads/list

Download at
http://code.google.com/p/datacar ... gz&can=2&q=

If you want tor try other driver, there is one called Celliax.

http://www.voip-info.org/wiki/view/Celliax
I have tried to compile this but not ok because I am using asterisk 1.8 (not supported.

dc-unlocker to check your USB 3G modem's sims unlocked and voice function

VOIP client to test voice quality

My favorite is Zoiper and also Yate client

SSH to check the console status
Optional; but you need this for the setup.

TOP

本帖最後由 ckleea 於 2011-4-1 10:34 編輯

Update kernel.

If you are using Centos OS, you are likley to use kernel 2.6.18. You need to prepare to update the kernel > 2.6.32 because there is problem in handling /dev/ttyUSB?

How to
1. you need to go this site
http://elrepo.org/tiki/tiki-index.php

Import the public key:
rpm --import http://elrepo.org/RPM-GPG-KEY-elrepo.org

To install ELRepo for RHEL-5, SL-5 or CentOS-5:
rpm -Uvh http://elrepo.org/elrepo-release-5-2.el5.elrepo.noarch.rpm

2. install the latest mainline kernel
yum --enablerepo=elrepo-kernel install kernel-ml kernel-ml-devel

注意:風險存在,需要自行平估

3. a reboot is required to load the new kernel. You may need to edit the grub.conf to default booting to the new kernel.

4. a recompilation of DAHDI is usually required after rebooting. Make sure you have the latest
i.e. dahdi-linux-complete-2.4.1+2.4.1

To obtain latest dahdi, type
  1. cd /usr/src/asterisk
  2. wget [url]http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz[/url]
  3. tar zxvf dahdi-linux-complete-current.tar.gz
  4. cd dahdi-linux-complete-2.4.1+2.4.1
  5. make; make install; make config;
  6. service dahdi restart
複製代碼

TOP

本帖最後由 ckleea 於 2011-4-1 10:34 編輯

Download the latest chan_datacard driver from below
http://code.google.com/p/datacard/downloads/list

The latest is http://datacard.googlecode.com/files/chan_datacard-1.0.r310.tgz
  1. cd /usr/src/asteisk
  2. wget http://datacard.googlecode.com/files/chan_datacard-1.0.r310.tgz
  3. tar zxvf chan_datacard-1.0.r310.tgz
  4. cd chan_datacard-1.0.r310
  5. ./configure
  6. make
  7. make install
複製代碼

TOP

本帖最後由 ckleea 於 2011-4-1 03:41 編輯

Create datacard.conf in /etc/asterisk
  1. [general]

  2. interval=15                     ; Number of seconds between trying to connect to devices

  3. ;------------------------------ JITTER BUFFER CONFIGURATION --------------------------
  4. ;jbenable = yes                 ; Enables the use of a jitterbuffer on the receiving side of a
  5.                                 ; Datacard channel. Defaults to "no". An enabled jitterbuffer will
  6.                                 ; be used only if the sending side can create and the receiving
  7.                                 ; side can not accept jitter. The Datacard channel can't accept jitter,
  8.                                 ; thus an enabled jitterbuffer on the receive Datacard side will always
  9.                                 ; be used if the sending side can create jitter.

  10. ;jbforce = no                   ; Forces the use of a jitterbuffer on the receive side of a Datacard
  11.                                 ; channel. Defaults to "no".

  12. ;jbmaxsize = 200                ; Max length of the jitterbuffer in milliseconds.

  13. ;jbresyncthreshold = 1000       ; Jump in the frame timestamps over which the jitterbuffer is
  14.                                 ; resynchronized. Useful to improve the quality of the voice, with
  15.                                 ; big jumps in/broken timestamps, usually sent from exotic devices
  16.                                 ; and programs. Defaults to 1000.

  17. ;jbimpl = fixed                 ; Jitterbuffer implementation, used on the receiving side of a Datacard
  18.                                 ; channel. Two implementations are currently available - "fixed"
  19.                                 ; (with size always equals to jbmaxsize) and "adaptive" (with
  20.                                 ; variable size, actually the new jb of IAX2). Defaults to fixed.

  21. ;jbtargetextra = 40             ; This option only affects the jb when 'jbimpl = adaptive' is set.
  22.                                 ; The option represents the number of milliseconds by which the new jitter buffer
  23.                                 ; will pad its size. the default is 40, so without modification, the new
  24.                                 ; jitter buffer will set its size to the jitter value plus 40 milliseconds.
  25.                                 ; increasing this value may help if your network normally has low jitter,
  26.                                 ; but occasionally has spikes.

  27. ;jblog = no                     ; Enables jitterbuffer frame logging. Defaults to "no".
  28. ;-----------------------------------------------------------------------------------

  29. [defaults]
  30. ; now you can set here any not required device settings as template
  31. ; sure you can overwrite in any [device] section this default values

  32. context=datacard-incoming         ; context for incoming calls, SMS and USSD
  33. group=0                           ; calling group
  34. rxgain=3                          ; increase the incoming volume; may be negative
  35. txgain=-3                         ; increase the outgoint volume; may be negative
  36. autodeletesms=yes                 ; auto delete incoming sms
  37. resetdatacard=yes                 ; reset datacard during initialization with ATZ command
  38. u2diag=-1                         ; set ^U2DIAG parameter on device (0 = disable everything except modem function)
  39.                                       ; -1 not use ^U2DIAG command
  40. usecallingpres=yes                ; use the caller ID presentation or not
  41. callingpres=allowed_passed_screen ; set caller ID presentation. By default use default network settings
  42.                                            ; see http://www.the-asterisk-book.com/unstable/applikationen-setcallerpres.html
  43. disablesms=no                     ; disable of SMS reading from device when received. Enable this option to disable
  44.                                      ; sms reception. Use smsaspdu=yes to avoid problem when SMS is too long in TEXT mode.
  45. smsaspdu=1                        ; if 'yes' send SMS in PDU mode.
  46. language=UTF-8                    ; set channel default language
  47. mindtmfgap=45                     ; minimal interval from end of previews DTMF from begining of next in ms
  48. mindtmfduration=80                ; minimal DTMF tone duration in ms
  49. mindtmfinterval=200               ; minimal interval between ends of DTMF of same digits in ms

  50. callwaiting=yes                   ; if 'yes' allow incoming calls waiting; by default use network settings
  51.                                   ; if 'no' waiting calls just ignored
  52. disable=no                        ; if 'yes' no load this device and just ignore this section
  53. ;exten=+85267896789                ; exten for start incoming calls, only in case of Subscriber Number not available!,
  54.                                       ; also set to CALLERID(dnid)

  55. dtmf=inband                             ; control of incoming DTMF detection, possible values:
  56.                                      ;   off           - off DTMF tone detection, voice data passed to asterisk unaltered
  57.                                      ;              use this value for gateways or if you do not use IVR in diaplan
  58.                                       ;   inband - do DTMF tones detection
  59.                                       ;   relax  - like inband but with relaxdtmf option
  60.                                       ;  default is 'relax' for backward compatibility


  61. ; datacard required settings

  62. [datacard0]
  63. ;audio=/dev/hw-audio-0
  64. ;data=/dev/hw-data-0
  65. audio=/dev/ttyUSB1                ; tty port for audio connection;        
  66. data=/dev/ttyUSB2                 ; tty port for AT commands;

  67. exten=+85267896789

  68. ; or you can omit both audio and data parameters and use imei=123456789012345 and/or imsi=612849384756451
  69. ; imei and imsi must contain exactly 15 digits !
  70. ; imei/imsi discovery is available on Linux only

  71. ; K3715       
  72. imei=123456789012345
  73. imsi=612849384756451


  74. ; if you set audio and data parameter together with imei and/or imsi, audio and data is used.
  75. ; you can use both imei and imsi together. In this case exact match by imei and imsi is required.
  76. ;

  77. ;[datacard1]
  78. ;audio=/dev/ttyUSB4                ; tty port for audio connection;        
  79. ;data=/dev/ttyUSB5                 ; tty port for AT commands;  

  80. ; K3715       
  81. ;imei=
  82. ;imsi=

  83. ;[datacard2]
  84. ;audio=/dev/ttyUSB7                ; tty port for audio connection;        
  85. ;data=/dev/ttyUSB8                 ; tty port for AT commands;

  86. ; E169G
  87. ;imei=
  88. ;imsi=
複製代碼
create the datacard_extensions.conf
  1. [datacard-incoming]
  2. include => datacard-incoming-sms
  3. include => datacard-incoming-ussd
  4. exten => +85267896789,1,Answer()
  5. exten => +85267896789,n,GotoIf($[${CALLERID(num)} = 91234567]?Kwong-call)
  6. exten => +85267896789,n,Playback(number-not-answering)
  7. exten => +85267896789,n,Playback(vm-goodbye)
  8. exten => +85267896789,n,Hangup()
  9. exten => +85267896789,n(Kwong-call),GoTO(default,1001,1)
  10. exten => +85267896789,n,Hangup()

  11. [datacard-incoming-sms]
  12. exten => sms,1,Noop(Incoming SMS from ${CALLERID(num)} ${BASE64_DECODE(${SMS_BASE64})})
  13. exten => sms,n,Set(GLOBAL(isms)=/var/log/asterisk/sms/incoming/sms-${STRFTIME(${EPOCH},Hongkong,%G%m%d-%H%M%S)}.txt)
  14. exten => sms,n,System(echo '${STRFTIME(${EPOCH},Hongkong,%Y-%m-%d %H:%M:%S)} - ${DATACARD} - ${CALLERID(num)}: ${BASE64_DECODE(${SMS_BASE64})}' > ${isms})
  15. exten => sms,n,System(smtp-cli --from recipientemail --to senderemail --subject "You got a new SMS " --attach ${isms} --host=smtphost --user=username --pass=password)
  16. exten => sms,n,Hangup()

  17. [datacard-incoming-ussd]
  18. exten => ussd,1,Noop(Incoming USSD: ${BASE64_DECODE(${USSD_BASE64})})
  19. exten => ussd,n,Set(GLOBAL(iussd)=/var/log/asterisk/sms/incoming/ussd-${STRFTIME(${EPOCH},Hongkong,%C%y%m%d%H%M)}.txt)
  20. exten => ussd,n,System(echo '${STRFTIME(${EPOCH},Hongkong,%Y-%m-%d %H:%M:%S)} - ${DATACARD} - ${CALLERID(num)}: ${BASE64_DECODE(${SMS_BASE64})}' > ${iussd})
  21. exten => ussd,n,System(smtp-cli --from recipientemail --to senderemail --subject "You got a new SMS " --attach ${iussd} --host=smtphost --user=username --pass=password)
  22. exten => ussd,n,Hangup()
複製代碼
add this
#include "datacard_extensions.conf"

to [globals] of extensions.conf

add a dialplan for outgoing call in extensions.conf e.g.
  1. ;dial-out via 3G Modem
  2. [CallingRule_3GModem]
  3. exten => _82.,1,Dial(Datacard/datacard0/${EXTEN:2})
  4. exten => _82.,n,Hangup()
  5. ;exten => _82.,1,Macro(superdial,Datacard/g0/852${EXTEN:2})
  6. ;exten => _82.,2,Macro(superdial,SIP/pstn-spa3k-d1/${EXTEN:2})
複製代碼

TOP

本帖最後由 ckleea 於 2011-4-1 03:47 編輯

Datacard command in asterisk cli

          datacard callwaiting Enable/Disable Call-Waiting on the datacard
                  datacard cmd Send commands to port for debugging
               datacard reload Reload datacard
               datacard remove Remove datacard
                datacard reset Reset datacard now
              datacard restart Restart datacard
datacard show device settings Show Datacard device settings
    datacard show device state Show Datacard device state
datacard show device statistic Show Datacard device statistics
         datacard show devices Show Datacard devices state
         datacard show version Show module version
                  datacard sms Send SMS from the datacard
                datacard start Start datacard
                 datacard stop Stop datacard
                 datacard ussd Send USSD commands to the datacard

TOP

本帖最後由 ckleea 於 2011-4-1 03:49 編輯

How to send an SMS from asterisk cli

datacard sms datacard[0] recipientphone message
e.g. datacard sms datacard0 85291234567 Hello, it is a successful test of SMS sent from asterisk.

Within few seconds, mobile phone will receive the above SMS

TOP

本帖最後由 ckleea 於 2011-4-1 14:18 編輯

其他 driver
1. celliax
下面的 link 教點樣裝
http://ngoinabox.mahiti.org/howt ... lliax-with-centos53

TOP

本帖最後由 ckleea 於 2011-4-2 06:36 編輯

Examples of SMS received

They are from the operator

2011-04-02 05:46:24 - datacard0 - 85262264644: Sorry, your handset cannot be configured/updated for DATA settings. Please refer to the following APN: GPRS&streaming(peoples.net),MMS(peoples.mms)

2011-04-02 05:50:42 - datacard0 - 85262264644: 閣下之手機未能正確安裝/更新設定,請參考以下接入點:GPRS&streaming(peoples.net),MMS(peoples.mms)

TOP

呢個正啊,賣得錢咯野值得學
"GUI send SMS" 用個 app/web 去call Asterisk Manager API(AMI) 應該做到

我都開左 .net project 研究緊用個 App 去call AMI 做野,用Java、PHP都得~仲多好多sources,不過功課限制一定要C#

TOP

我比較期待可以SMS callback...
因為有不少國家/地區的電話是單向收費的...
只要發一個短訊(或國際短訊)...便可以低廉(甚至免費!)的價格去自建callback services...
比用漫遊的Callback廉宜不少呢...
而且這樣也不需要當地網絡/3G連線...通話質素可能會更好一點呢~

TOP

回復 12# 電腦超人


    Some VSPs provide WAP callback.

TOP

回復  電腦超人


    Some VSPs provide WAP callback.
Qnewbie 發表於 2011-4-1 01:41

但係唔係個個地區既SIM card提供上網服務...

TOP

本帖最後由 ckleea 於 2011-4-1 10:36 編輯

回復 12# 電腦超人

這個可以做到。因為可以對callerID number,用AGI programming去完成。

e.g.
exten => sms,n,System(echo '${STRFTIME(${EPOCH},Hongkong,%Y-%m-%d %H:%M:%S)} - ${DATACARD} - ${CALLERID(num)}: ${BASE64_DECODE(${SMS_BASE64})}' > ${isms})

need to parse ${CALLERID(num) and ${BASE64_DECODE(${SMS_BASE64})} to AGI for processing

TOP

返回列表