[SOLVED] two phone in one extension

Hi all!
I use trixbox 2.2.
I want to simulate this scenario: I’ve two sip phones in my office (179 and 180).
179 = the base station (siemens optipoint 410s)
180 = a cordless phone (siemens C450)

When I call 200 I want that both phone will ring, so in extension_custom.conf:

200 is a “virtual extension”, is used only for ring both phones…

For example, I answer from 179.
While I talking, if another call to 200 is incoming, I want that the line is BUSY…instead the “free” extension (in this case 180) will ring.

How is possible make BUSY, when 179 or 180 is talking in a conversation?
I want to perform the scenario of two analogic phone connected to one POTS line.

Thanks!!

You might try using the ChanIsAvail() command.

Check the state of each of the sip channels, and if they’re in use, skip to another command instead of Dial().

voip-info.org/wiki-Asterisk+cmd+ChanIsAvail

You could also check and set a variable just before the Dial() command you’ve created. If that variable is set, you jump to a new call treatment, instead of dialing the stations.

It might look something like this:

[sip_200]
exten => 200,1,GotoIf($[${CALL_IN_PROGRESS} = 1]?4)
exten => 200,2,Set(CALL_IN_PROGRESS=1)
exten => 200,3,Dial(SIP/179&SIP/180)
exten => 200,4,Busy()
exten => h,1,Set(CALL_IN_PROGRESS=0)
exten => h,2,Hangup()

I’ve solved this problem using an AGI php script:

#!/usr/bin/php -q
<?
require_once ('phpagi.php');
require_once ('phpagi-asmanager.php');
set_time_limit('1800');

$agi = new AGI();

$fp = fsockopen("127.0.0.1", 5038, $errno, $errstr, 30);
if (!$fp) {
        $agi->verbose("ERRORE NELLA CONNESSIONE");
}//if
else {
        $out = "Action: Login\r\n";
        $out .= "UserName: admin\r\n";
        $out .= "Secret: amp111\r\n\r\n";

        fwrite($fp, $out);
        $in = "Action: ExtensionState\r\n";
        $in .= "Exten: $argv[1]\r\n";
        $in .= "Context: default\r\n";
        $in .= "ActionID: 1234\r\n\r\n";
        $in .= "Action: Logoff\r\n\r\n";
        fwrite($fp,$in);
        while (!feof($fp)) $result.=fgets($fp, 128);
        fclose($fp);
}//else

if (trim(substr($result,strpos($result,"Status:")+8,1)) == "0") {$libero1="1";}
else $libero1="0";

$fp = fsockopen("127.0.0.1", 5038, $errno, $errstr, 30);
if (!$fp) {
        $agi->verbose("ERRORE NELLA CONNESSIONE");
}//if
else {
        $out = "Action: Login\r\n";
        $out .= "UserName: admin\r\n";
        $out .= "Secret: amp111\r\n\r\n";

        fwrite($fp, $out);
        $in = "Action: ExtensionState\r\n";
        $in .= "Exten: $argv[2]\r\n";
        $in .= "Context: default\r\n";
        $in .= "ActionID: 12345\r\n\r\n";
        $in .= "Action: Logoff\r\n\r\n";
        fwrite($fp,$in);
        while (!feof($fp)) $result.=fgets($fp, 128);
        fclose($fp);
}//else

if (trim(substr($result,strpos($result,"Status:")+8,1)) == "0")  {$libero2="1";}
else $libero2="0";

if ($libero1=="1" && $libero2=="1") 
{$agi->exec("Dial SIP/".$argv[1]."&SIP/".$argv[2]);}
else  $agi->exec("Busy");

$agi->hangup();
exit;

?>

In extension_custom.conf:

exten => 200,1,AGI(double.agi|177|178)

where 177 and 178 are the extensions in asterisk, passed as parameters in agi script and 200 is not an extension, but is the number you must dial.

BYE :smiley:

jacktaylor82,

While your solution will work, the solutions dufus suggested will be much more reliable and should run much faster. In addition they are much easier to maintain and implement for other extensions.