[App_rpt-users] Access Command Mode With A Macro

Tim Sawyer tim.sawyer at me.com
Wed Jul 31 23:43:03 EDT 2013


For this sort of functionality (and more) check out https://github.com/tsawyer/allmon
--
Tim
:wq

On Jul 31, 2013, at 7:09 PM, Bryan D. Boyle <bdboyle at bdboyle.com> wrote:

> On 7/31/2013 9:41 PM, Bryan D. Boyle wrote:
>> simply, no
> 
> That being said...there's lots of tricks you can do.  For instance, if
> you have a web server open on the same lan segment or subnet accessible
> from the asterisk box, you can make sure the manager function is
> open...and, using a script (I have no idea where it came from, so, if
> anyone claims authorship...that's fine, I got it from Paul KC2VRJ)
> called newcontrol.php, and a web page that posts values to it, you can
> pretty much control your repeater from a web page (put some
> authentication around it, ok?)
> 
> And, oh, you'll have to pick up the StarAstAPI.php script that's
> distributed under the GNU Lesser license.
> Note, this also happens over a clear channel by default, so, you
> probably don't want to do this across the net...better, perhaps to stand
> up a simple web server on the asterisk box itself and use the looparound
> address to talk to it...
> 
> --
> <?php
> 
> # Title:        newcommand.php
> # Author:       Unknown, but provided to me by Paul Nannery KC2VRJ
> #               Full credit acknowledged if original author ID'd
> # Mods by:      Bryan Boyle WB0YLE
> # Date:         8 December 2012
> #
> # This bit of php script takes two values:
> # the first being the node to talk to,
> # and the second, the DTMF command that's being sent
> # and echoing it out.
> #
> 
> if ($_POST) {
>        $node = $_POST['node'];
>        $cmd = $_POST['cmd'];
> }
> else {
>        $node = $argv[1];
>        $cmd = $argv[2];
> echo "Command $cmd is being sent to $node\n\n";
> }
> # Include StarAstAPI:
> 
> require_once './StarAstAPI.php';
> 
> # Connect and log in:
> #
> 
> $ami = new AstClientConnection();
> 
> #
> # Login is from the /etc/asterisk/manager.conf credentials as
> # configured in your base directory on your system.
> #                 user      password      ast system   port
> #                  vv          vv             vv        vv
> 
> if ($ami->Login( 'admin', 'changeme', 'asteriskboxIPAddress', 5038 )) {
>    $rp = $ami->GetResponse('1');
>    //echo $rp->ToString();
> } else {
>    exit(1);
> }
> # Send the following packet:
> #     ACTION: Command
> #     command: rpt fun $node# $command
> #
> 
> $data = new AstPacketData;
> $data->AddKVPair( 'Action'  , 'Command' );
> $data->AddKVPair( 'command' , "rpt fun $node $cmd" );
> $packet = new AstPacket;
> $packet->SetAstPacketType( 'Action' );
> $packet->SetAstPacketData( $data );
> $ami->SendPacket( $packet );
> 
> #
> # Log out -- not strictly necessary, but cleaner:
> #
> 
> $ami->Logoff();
> 
> #
> # Unfortunately, StarAstAPI isn't totally discreet.
> # It does this:
> # echo "Logoff Called from somewhere ...";
> # socket_close($this->mSocket);
> #
> 
> echo "\n";
> ?>
> --
> 
> Sample page that calls this script with pull-down values (not totally
> HTML compliant, I just did the bare minimum with the header values...):
> 
> <html>
> <head>
> <title>Test Control Form</title>
> </head>
> <body>
> 
>        <h3>Node Control</h3>
>         <form target="_self" method="post" action="newcontrol.php">
>                <table border="0">
>                <tr>
>                <td>Node Number:</td>
>                <td>
>                <select name="node">
>                <option value="XXXXX">220 Machine</option>
>                <option value="XXXXX">900 Machine</option>
>                <option value="XXXXX">Bucks Hub</option>
>                <option value="XXXXX">440 Machine</option>
>                <option value="XXXXX">R&D/Development Hub</option>
>                <option value="XXXXX">144 Machine</option>
>                </select>
>                </td>
>                </tr>
>                <tr>
>                <td>Command to run:</td>
>                <td>
>                <select name="cmd">
>                <option value="*XXXX">Play Weather (220)</option>
>                <option value="*XXXX">Play Forecast (220)</option>
>                <option value="*XXXX">W3SK Connect</option>
>                <option value="*XXXX">W3SK Disconnect</option>
>                </select>
>                </td>
>                </tr>
>                <tr><td></td>
>                <td>
>                <input type="submit" value="Transmit" />
>                </td>
>                </tr>
>                </table>
>                </form>
> <div id="response"></div>
> </body>
> </html>
> 
> ----
> 
> Note, these are just a proof of concept/hacked together page...the
> option values for the select name="cmd" in the web page are the DTMF
> commands that call the function stanza for the node in question.  SO,
> while all my nodes may have a common *1XXXX disconnect sequence (bing
> connected to the same hub in question, they can either 1) send directly
> a DTMF sequence to a node, 2) call a cmd,script to run a shell script,
> or 3) call a cmd,shell/executable program to do something.
> 
> Improvements are left as an exercise to the reader.  Note, these ideas
> are so primitive, they really need to be tweaked. But some more grist
> for the mill.
> 
> BB
> 
> 
> _______________________________________________
> App_rpt-users mailing list
> App_rpt-users at ohnosec.org
> http://ohnosec.org/cgi-bin/mailman/listinfo/app_rpt-users




More information about the App_rpt-users mailing list