Deactivate Trunk or outgoing route after x minutes of outgoing call

freepbx
Tags: #<Tag:0x00007fafbcf91618>

(Laurent B ) #1

Hi all.

I would like to know if there is a possibility to deactivate a trunk or an outgoing route after a counter of time of outgoing call, and enable it again after a specific reccuring date.

I have a SIM card that permits only 2 hours of free outgoing calls, then after this 2 hours, calls are extra invoiced.
I would like to be able to stop using the SIM card (GSM gateway with chan-dongle) after 2 hours of outgoing calls, then enable it again next month at anniversary date.

Maybe this can be an external script that stop dongle service and restart it after a period.
Any idea how to get the outgoing time counter on a specific trunk ?

Regards,
Laurent.


(Itzik) #2

I don’t know of a way to calculate the minutes, but what you can do, to disable/enable the Trunk is:

List Trunks

[root@pbx ~]# fwconsole trunks --list
+----+-------+---------------------+----------+
| ID | TECH  | Channel ID          | Disabled |
+----+-------+---------------------+----------+
| 1  | pjsip | flowroute           | off      |
| 2  | sip   | fpbx-1-QWm3eNC4UIDn | on       |
| 3  | sip   | fpbx-2-QWm3eNC4UIDn | off      |
| 4  | pjsip | Telnyx              | off      |
+----+-------+---------------------+----------+

Specifying a trunk to enable or disable

[root@pbx ~]# fwconsole trunks --enable 2
Enabling Trunk 2
 
[root@pbx ~]# fwconsole trunks --disable 2
Disabling Trunk 2

You can have a script that runs these fwconsole enable/disable commands

Source: Wiki


(Laurent B ) #3

Thanks for replying !

It seems that dongle can give some usefull informations using

dongle show device statistics dongle0

Device : dongle0
Queue tasks : 32129
Queue commands : 32153
Responses : 32166
Bytes of read responses : 193280
Bytes of written commands : 96659
Bytes of read audio : 453760
Bytes of written audio : 454720
Readed frames : 1418
Readed short frames : 0
Wrote frames : 1421
Wrote short frames : 0
Wrote silence frames : 1421
Write buffer overflow bytes : 0
Write buffer overflow count : 0
Incoming calls : 0
Waiting calls : 0
Handled input calls : 0
Fails to PBX run : 0
Attempts to outgoing calls : 1
Answered outgoing calls : 0
Answered incoming calls : 0
Seconds of outgoing calls : 0
Seconds of incoming calls : 0
ACD for incoming calls : -1
ACD for outgoing calls : -1
ASR for incoming calls : -1
ASR for outgoing calls : 0

I need to do some tests to check if “Seconds of outgoing calls” is volatile or not depending on power loss or else.


(Lorne Gaetz) #4

Third party module, Trunk Balancing can do this. It’s not been maintained in years, so may or may not work as expected: https://github.com/POSSA/freepbx-trunk-balancing


(Tom Ray) #5

I don’t think this will work for what they are looking for. First, it has no PJSIP support. Second, I just don’t think it has all the features that will be needed.

Something tells me that the Dial() string will need options to cut this call off during the call if needed. Got two hours of free calls, a call goes out and there’s 30 minutes left in free calling. The call is 1:30 long that’s 1 hour of billable usage on the service. Or there’s five minutes left of free time and it’s a 30 minute or more call.

So how do you look at handling that?


#6

Set the ‘absolute timeout’ of the channel to 7139 - current[seconds of outgoing calls ] in the predial hook.


(Tom Ray) #7

There’s going to be more to this then just setting timeouts on every call to just under two hours. Because that means every call can be up for just under two hours. This still means that usage charges can apply because if there is only 30 minutes on the balance and the call has a limit of just under two hours, you’re looking at a possible 60 minutes of charges.

Each call duration needs to be tracked, calculated and then based on those results set the desired time limits for a call. This isn’t going to be a 100% since if there are multiple calls at once they could overflow still without proper watching. At that point it might be a good idea to see what the shortest, longest and the average call times are and base timers off that.


(Laurent B ) #8

Hi all.

Thansk for ideas.
My need is because I use to receive calls via SIP channel, but sometimes it is’nt reliable (when reception is bad).
Activating SIP trunk and GSM gateway trunk will make my device ringing.
If GSM recption is good, my SIP account will ring, and I will be able to answer the call via SIP.
If GSM reception is poor, SIP account will not ring, but “normal” call via GSM gateway will ring, and I will be able to answer.

With GSM gateway, only the two first hours are free of charge…

No matter if I have to pay a little…


#9

Off topic, but if your GSM dongle has an external antenna connector, using a rooftop antenna should greatly improve your data connectivity and eliminate the need for voice calls. With a high-gain Yagi, your signal will likely be at least 20 dB higher than with the antenna that came with the dongle. If your dongle is not 4G capable, replacement with a newer model can also help.

If you are stuck with voice calling (and this server is in France and you have coverage from these carriers), upgrading to ‘unlimited’ calls is quite inexpensive. See


and
https://www.red-by-sfr.fr/forfaits-mobiles/


#10

Try this from bash

rasterisk -x ‘dongle show device statistics dongle0’

then if you get an output

rasterisk -x ‘dongle show device statistics dongle0’ |grep ‘Seconds of outgoing calls’

. . . .


(Laurent B ) #11

@Stewart1
It’s already a Free SIM card, 2€.
My working conditions are
1 OVH SIP account
1 Freepbx in Raspberry Pi 3B+
3 numbers associated to the sip account (3 services)
3 different incoming music (one per number)
1 dongle with 2€ SIM card
But calls are limited to two hours per month.
1 sip extension linked to my mobile phone device

My GSM gateway is used when sip link is not possible at device location (too many location in France are badly covered in 3G/4G, only voice calls can be done and sometimes with difficulty).


#12

Sorry, I misunderstood your situation and mistakenly thought that your PBX was connected via unreliable mobile data.

Now, I understand that when forwarding calls to your mobile, if the mobile doesn’t have a usable data connection, you send a voice call instead. I assume that you have a fiber, cable or DSL connection for the PBX. Is that all correct?

Who is your ISP? Some offer unlimited calling to domestic mobiles from the fixed line that is included with your internet service. With others, you can add this option for a small monthly fee. The ISPs no longer support SIP connection to those lines, but you could use an FXO gateway to connect your PBX. A disadvantage of this approach is that you cannot pass the caller ID of the original caller.

There are some SIP providers with low rates to France mobile, though there are often quality issues. The Betamax companies are usually cheapest, though they often don’t pass caller ID correctly, in addition to sometimes poor quality. See http://www.voip-comparison.com/?ll=0&mb=1&sms=0&nonEu=0&country[]=72 and click on the rate column to sort.

Better quality and passing caller ID, see https://zadarma.com/en/tariffs/calls/france/#eu-popular .

Who is the operator for the mobile(s) you are forwarding to?


(Laurent B ) #13

My DSL operator is Free : 6 Mb download / 0.9 Mb upload.
I have a Pfsense to manage VoIP priorisation due to low DSL bandwidth, It works like a charm.
My mobile device is also Free mobile.


#14

The fixed line on most Freebox plans includes ‘unlimited’ calling to France mobile. All current offers except Freebox Mini have this feature.

You can connect this line to Asterisk with an FXO gateway or card. The cards for the Pi are pretty expensive – see https://www.mgraves.org/2018/09/asterisk-on-raspberry-pi-now-has-fxo-fxs-and-gsm-interfaces/ .

Gateways with one FXO port include Grandstream HT704 (old) and HT813 (current), Cisco/Linksys SPA3000 (really old) and SPA3102 (old), and Obihai OBi110 (old) and OBi212 (current).

The older equipment is often available used e.g. on eBay for very low prices, but beware that much of the Cisco/Linksys stuff is counterfeit.

An alternative is a SIP trunking provider with low rates to Free Mobile. Do you need to pass the caller ID of the original caller?


(Laurent B ) #15

My actual DSL do not include Mobile calling (Freebox V5).
I already thought for an FXO module but I found GSM gateway a funny experience to try before :slight_smile:

I will also buy a refurbished FXO gateway only for testing and why not use it when I will change my box (I will get full mobile calls included with a new box).

I find Freepbx very amazing, and I’m lucky I can have some time to play with.
Setting a GSM gateway is a funny experience, playing with Pfsense is also funny and very interesting… Setting a FXO will also be funny.
I do all of these for my own needs and also my own understanding.

Yes, I need the caller ID, but I already do a setting so that when I hang-up an incoming call, I can hear a voice prompt telling to me where from the call comes.
I also already prepended a texte before ID so I can see where from the call comes ,:smile:


(system) closed #16

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