FreeSwitch

FreeSWITCH 是一個自由開源的軟體型電話交換機。它採用 Mozilla Public License 授權協議,MPL 是一個開源的軟體協議。它的核心庫 libfreeswitch 可以嵌入其它系統或產品中,也可以做一個單獨的應用存在。

FreeSwitch Tips

FreeSwitch
FreeSwitch GUI

FreeSwitch CLI

fs_cli

fs_cli -x "sofia status"
> sofia status
> sofia status profile internal reg
> show registrations

> /quit
> version
> show calls
> show channels

> reloadxml
> sofia profile external restart
> sofia profile external killgw gwt
> sofia profile external rescan
> reload
> reloadxml
> reloadacl
> reload <mod_name>
> show modules

> status
> eval $${external_sip_ip}
> fsctl shutdown restart


> domain_exists sip.osslab.tw
> module_exists mod_event_socket

PostgreSQL

su - postgres
psql fusionpbx

fusionpbx=# \dt
fusionpbx=# \d v_gateways
fusionpbx=# select * from v_gateways;
fusionpbx=# select * from v_default_settings where default_setting_category='email';

FusionPBX

Links

Installation

Debian 11

wget -O - https://raw.githubusercontent.com/fusionpbx/fusionpbx-install.sh/master/debian/pre-install.sh | sh;

cd /usr/src/fusionpbx-install.sh/debian && ./install.sh

NAT Setting

Web Admin > Advanced > Variables > IP Addresses

重啟 freeswitch

systemctl restart freeswitch

驗證

Web Admin > Status > SIP Status

RTP Port

/etc/freeswitch/autoload_configs/switch.conf.xml:

<!-- RTP port range -->
<!-- If no definitation the port range would be 16384 - 32768 -->
<param name="rtp-start-port" value="16384"/>
<param name="rtp-end-port" value="17000"/>

Gateway to Asterisk

On FreePBX

  1. Added a custom context 'from-ext-sip-server' with the module Custom Contexts.
  2. FreePBX Admin > Connectivity > Custom Contexts > Add Context
    • Context: from-ext-sip-server
    • Description: Whatever
    • Outbound Routes: <allow-some-route>
  3. Add Trunk
    • Trunk Name: fusionpbx
    • PEER Details:
host=sip.osslab.tw
type=peer
context=from-ext-sip-server
nat=yes
insecure=port,invite

On FusionPBX

Web Admin > Accounts > Gateways > Add

Web Admin > Dialplan > Outbound Routes > Add

另一個方法:以 Bridge 取代 Gateway

Applications > Bridge

Advanced > Access Controls > Add

 Outbound Route 記得要選 Bridge。

Voicemail to Email

Web Admin > Accounts > Extensions > Select extension and Edit

Web Admin > Advanced > Default Settings > Email

Send Test Email

Web Admin > Status > Email Logs > TEST

Bug Fixed:

[ERR] switch_cpp.cpp:1465 [database] can not bind parameter: undefined parameter: email_from

Edit /usr/share/freeswitch/scripts/resources/functions/send_mail.lua

if (email_from == nil or email_from == "") then
        email_from = settings:get('email', 'smtp_from', 'text');
        from_name = settings:get('email', 'smtp_from_name', 'text');
end
-- added by Alang
-- fixed: [ERR] switch_cpp.cpp:1465 [database] can not bind parameter: undefined parameter: email_from
email_from = 'noreply@your.domain';

if (email_from == nil or email_from == "") then
        email_from = address;
elseif (from_name ~= nil and from_name ~= "") then
        email_from = from_name .. "<" .. email_from .. ">";
end

Voicemail Transcription

IBM Watson API

IBM Cloud > Watson > STT

FusionPBX > Advanced > Default Settings > 新增以下參數

Category Subcategory Type Value Enabled
voicemail transcribe_provider text watson True
voicemail watson_key text {your watson key} True
voicemail watson_url text {watson url} True
voicemail transcribe_language text en-US True
voicemail transcribe_enabled boolean true True
voicemail json_enabled boolean true True

按下 "Reload" 套用設定。

FusionPBX > Status > SIP Status

按下 "Flush Cache","Reload XML" 與 "Rescan"。

測試 STT API

# Audio file: audio-file.flac
curl -X POST -u "apikey:{API_KET}" \
--header "Content-Type: audio/flac" \
--data-binary @audio-file.flac \
"https://api.au-syd.speech-to-text.watson.cloud.ibm.com/instances/{GUID}/v1/recognize"

Auto Provisioning

Provision (Linksys PAP2T)

Web Admin > Advanced > Default Settings > Provision

Device

Web Admin > Accounts > Devices > ADD

Extension

Web Admin > Accounts > Extensions > Add 

驗證 Provision Configuration

瀏覽器輸入 http://<fusionpbx-ip-addr>/app/provision/?mac=<pap2t-mac-addr>

如果有輸出 XML 格式的參數設定檔內容,表示以上的設定正確。

Linksys PAP2T

PAP2T Web Admin > Provisioning

TIP: 如果發生無法註冊成功,且同一個 NAT 網路環境還有其他 SIP 終端裝置。試試修改 PAP2T 的 Local SIP port 為其他 port。

修改 PAP2T 的 Local Port (透過 FusionPBX)

Web Admin > Accounts > Devices > Select: <PAP2T-Mac-Addr> > Lines > Line 1

重啟 PAP2T 以便重新同步新設定。

Cisco IP Phone 8841

Let's Encrypt

WebRTC