SIP to SMS bridging using chan_dongle

I have 3G USB dongle that also supports voice calls using the chan_dongle plugin. This plugin also supports sending and receiving SMS messages. The code copy to Sending SMS using chan_dongle

[dongle-incomming]
exten => sms,1,Verbose(1,Incoming SMS from ${CALLERID(num)} ${BASE64_DECODE(${SMS_BASE64})})
exten => sms,n,Set(MESSAGE(body))=${BASE64_DECODE(${SMS_BASE64})})
exten => sms,n,MessageSend(pjsip:101,${CALLERID(num)})
exten => sms,n,Hangup()

But, It works only one dongle and only one pjsip user
If i have many DONGLE drvices ${DONGLENAME}=dongle1 dongle2 dongle3
I need dongle1 sent to 101; dongle2 sent to 202 ;dongle3 sent to 303.
How to do it ? I think using ${DONGLENAME} to distinglish

You would need a different context for each dongle and a different message_context for each phone that wants to send messages. For the latter, you could use one context and select the dongle based on the MESSAGE(from). I suppose there might be something that you could read for the former.

Note that the Answer in messaging serves no purpose, as messages are out of session, so there is nothing to answer.

Note that chan_dongle is third party code and appears to no longer be supported.

As that variable isn’t referenced, you wouldn’t. You would set dongle-incomming1 in the chan_dongle.conf file section for dongle1.

It is possible that chan_dongle includes the dongle name in the channel name, when calling the sms extension, and it is possible it sets it in a channel variable, but I don’t know that for certain.

This doesn’t work well the other way, as a special channel name is used for out of dialogue messages received from SIP devices. However, it looks like you have removed the code for the other way.

I assume the agi-mqtt scipt is a red herring here,

Repeat this section for each dongle changing the name in the square brackets and the USB port or IMEI/IMSI for each one.

In each of these sections, add this line, but with the actual context for that dongle:

There isn’t enough information documented to allow the alternative of using a variable or the channel name to be progressed without experimentation, or deep reading of the source code.

As a general principle, though, peer support forums are not a place to get code written for you.

Sorry I m not disrespect the general principle. And thanks you chek USB port or IMEI/IMSI. I can ensure that I have correctly configured different dongles and IMEI.I’m not professional. I think it can be changed adding GotoIf. Forgive my programming level

[dongle-incomming]
exten => sms,1,Verbose(Incoming SMS from ${CALLERID(num)} ${BASE64_DECODE(${SMS_BASE64})})
exten => sms,n,GotoIF($[“${DONGLENAME}” != “dongle0”]?another)
exten => sms,n,Set(MESSAGE(body)=${BASE64_DECODE(${SMS_BASE64})})
exten => sms,n,MessageSend(pjsip:202,${CALLERID(num)})
;other dongle sms send
exten => sms,n,Hangup()
exten => sms,n(another),Set(MESSAGE(body)=${BASE64_DECODE(${SMS_BASE64})})
exten => sms,n,MessageSend(pjsip:101,${CALLERID(num)})
exten => sms,n,Hangup()

It works. Dongle0 sms send to 202. The others dongles sms send to 101.

I dont kown this line, i delete it
exten => sms,n,AGI(/opt/asterisk/agi-mqtt/mqtt,/opt/asterisk/agi-mqtt/mqtt.cfg,foo/sms,${BASE64_DECODE(${SMS_BASE64})})

It looks like DONGLENAME is half documented. Examples use it, but nowhere is it explained. However, I didn’t think you wanted to crash the script; I thought you wanted to use a different SIP destination. I also don’t know what the AGI is for.

If you still want to pair your dongle’s with your SIP extensions, the easiest way would probably be to use the corresponding extension names, rather than calling them dongle1, 2, 3, etc.

If you do want it to fail for all but dongle 1, simply use a different context for the other ones. Using ExecIF and Hangup would be better than a GoTo to a non-existent label.

It you don’t have the technical knowledge, you need to acquire it, or hire someone who has it. Forums like this are not places to get free design work done.

Thank you again,
About the high market share of commercial software, I cannot hire people who are proficient in asterisks.
If we can’t exchange code in the community, freepbx maybe will be difficult to popularize. Hoping more people will join it。

And if I need dongle1 sent to 101; dongle2 sent to 202 ;dongle2 sent to 303. Need many loop statements using ExecIF? This seems to be wrong。

[dongle-incomming]
exten => sms,1,Verbose(Incoming SMS from ${CALLERID(num)} ${BASE64_DECODE(${SMS_BASE64})})
exten => sms,n,ExecIF($[“${DONGLENAME}” != “dongle1”]?)
exten => sms,n,Set(MESSAGE(body)=${BASE64_DECODE(${SMS_BASE64})})
exten => sms,n,MessageSend(pjsip:101,${CALLERID(num)})
exten => sms,n,Hangup()
;
exten => sms,n,ExecIF($[“${DONGLENAME}” != “dongle2”]?)
exten => sms,n,Set(MESSAGE(body)=${BASE64_DECODE(${SMS_BASE64})})
exten => sms,n,MessageSend(pjsip:202,${CALLERID(num)})
exten => sms,n,Hangup()
;
exten => sms,n,ExecIF($[“${DONGLENAME}” != “dongle3”]?)
exten => sms,n,Set(MESSAGE(body)=${BASE64_DECODE(${SMS_BASE64})})
exten => sms,n,MessageSend(pjsip:303,${CALLERID(num)})
exten => sms,n,Hangup()
;
exten => sms,n,ExecIF($[“${DONGLENAME}” != “dongle4”]?)
exten => sms,n,Set(MESSAGE(body)=${BASE64_DECODE(${SMS_BASE64})})
exten => sms,n,MessageSend(pjsip:404,${CALLERID(num)})
exten => sms,n,Hangup()

1 Like

Is there any people help

help…

Help…
if I need dongle1 sent to 101; dongle2 sent to 202 ;dongle2 sent to 303. Need many loop statements using ExecIF? This seems to be wrong。

[dongle-incomming]
exten => sms,1,Verbose(Incoming SMS from ${CALLERID(num)} ${BASE64_DECODE(${SMS_BASE64})})
exten => sms,n,ExecIF($[“${DONGLENAME}” != “dongle1”]?)
exten => sms,n,Set(MESSAGE(body)=${BASE64_DECODE(${SMS_BASE64})})
exten => sms,n,MessageSend(pjsip:101,${CALLERID(num)})
exten => sms,n,Hangup()
;
exten => sms,n,ExecIF($[“${DONGLENAME}” != “dongle2”]?)
exten => sms,n,Set(MESSAGE(body)=${BASE64_DECODE(${SMS_BASE64})})
exten => sms,n,MessageSend(pjsip:202,${CALLERID(num)})
exten => sms,n,Hangup()
;
exten => sms,n,ExecIF($[“${DONGLENAME}” != “dongle3”]?)
exten => sms,n,Set(MESSAGE(body)=${BASE64_DECODE(${SMS_BASE64})})
exten => sms,n,MessageSend(pjsip:303,${CALLERID(num)})
exten => sms,n,Hangup()
;
exten => sms,n,ExecIF($[“${DONGLENAME}” != “dongle4”]?)
exten => sms,n,Set(MESSAGE(body)=${BASE64_DECODE(${SMS_BASE64})})
exten => sms,n,MessageSend(pjsip:404,${CALLERID(num)})
exten => sms,n,Hangup()

You are saying here if the variable does NOT equal dongle1. Remove the exclamation mark.

Also you seem to have completely misunderstood ExecIF, An ExecIF without anything to run is useless.

Also, the quotes you have used are wrong, although they are probably harmless here, as all that is really needed is a character which is not a white space character. Note that the wrong quotes are in your raw posting, so are not an artefact of failing to markup the code correctly:

ExecIF($[“${DONGLENAME}” != “dongle1”]?)

1 Like

Why is this still not run as I wish?

[dongle-incomming]
exten => sms,n,GotoIF($[“${DONGLENAME}” = “dongle1”])
exten => sms,n,Set(MESSAGE(body)=${BASE64_DECODE(${SMS_BASE64})})
exten => sms,n,MessageSend(pjsip:101,${CALLERID(num)})
exten => sms,n,MessageSend(pjsip:111,${CALLERID(num)})
exten => sms,n,Hangup()
;
exten => sms,n,GotoIF($[“${DONGLENAME}” = “dongle2”])
exten => sms,n,Set(MESSAGE(body)=${BASE64_DECODE(${SMS_BASE64})})
exten => sms,n,MessageSend(pjsip:202,${CALLERID(num)})
exten => sms,n,Hangup()
;
exten => sms,n,GotoIF($[“${DONGLENAME}” = “dongle3”])
exten => sms,n,Set(MESSAGE(body)=${BASE64_DECODE(${SMS_BASE64})})
exten => sms,n,MessageSend(pjsip:303,${CALLERID(num)})
exten => sms,n,Hangup()

There is no destination on the GotoIF’s . I would have hoped that produced an error message.

The initial priority isn’t set, so will probably run on from the previous context.

The sixth and subsequent exten lines are unreachable. Execution will not go beyond the Hangup and there is nothing that will bypass it.

Please hire someone with coding skills to implement it, and maintain it in the longer term. Whilst people here could code something we couldn’t test it, we might do it in a way that was not optimal for your other needs, and I don’t believe you would be able to maintain it without continually coming back here.

Thanks

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.