MacroSIP
EnglishРусский中文

Asterisk 与 FreePBX:通过 chan_dongle 收发短信

**警告。**本方案依据 Asterisk 和 chan_dongle 的文档编写,尚未在真实的 PBX 上试过。请把它当作起点,测试时留意 Asterisk 控制台(asterisk -rvvv)。

工作原理

  1. 收到短信时,chan_dongle 会在 dongle.conf 中 context= 指定的上下文里、以分机 sms 启动一个拨号计划通道。发送方号码在 CALLERID(num) 中,正文在 ${SMS} 中。
  2. 拨号计划用 MessageSend 把它变成 SIP MESSAGE,发往 PJSIP endpoint(即分机号)。
  3. Asterisk 把 MESSAGE 发到该分机注册的 Contact,路径与 INVITE 相同。因此只要 MacroSIP 以该分机号注册,消息就会到达 MacroSIP。
  4. MacroSIP 的回复以 MESSAGE 的形式到达 PBX,进入该 endpoint 的 message_context。拨号计划在那里把它转给另一个分机,或用 DongleSendSMS 通过调制解调器发出。

FreePBX

FreePBX 没有这方面的图形界面。把拨号计划写入 /etc/asterisk/extensions_custom.conf,把 endpoint 选项写入 /etc/asterisk/pjsip.endpoint_custom_post.conf,然后执行 fwconsole reload。

配置

; extensions_custom.conf
; incoming SMS from the modem -> extension 1001
[from-dongle-sms]            ; the same name as context= in dongle.conf
exten => sms,1,NoOp(SMS from ${CALLERID(num)}: ${SMS})
 same => n,Set(MESSAGE(body)=${SMS})
 same => n,MessageSend(pjsip:1001,${CALLERID(num)})
 same => n,Hangup()

; messages from MacroSIP: to other extensions, or out through the modem
[messages]
exten => _XXXX,1,MessageSend(pjsip:${EXTEN},${MESSAGE(from)})
 same => n,Hangup()
exten => _+X.,1,DongleSendSMS(dongle0,${EXTEN},${MESSAGE(body)})
 same => n,Hangup()
; pjsip.endpoint_custom_post.conf
[1001](+)
message_context=messages

请把 1001、dongle0 和号码匹配模式换成您自己的。

在 MacroSIP 中的表现

已知限制

另见 消息 和 故障排除。