$format = 'csv'; } $types = @$argv[3]; $max_packets = @$argv[4]; // establish socket $s = new GrandstreamSYSLOG(); $s->bind($address); // prepare XML if ('xml' == $format) { $xml = new XmlWriter(); $xml->push('messages'); } // messages to listen for $messages = array_filter(explode(',', $types)); // start listening on callback $s->listen('printPacket', $max_packets, $messages); function printPacket($result) { global $format, $xml; switch ($format) { case 'php': var_export($result); break; case 'csv': $line = date('Y-m-d') . ',' . date('H:i:s') . ',' . $result['ip'] . ',' . $result['message']['type'] . ','; unset($result['message']['type']); unset($result['message']['packet']); foreach ($result['message'] as $field => $value) { $line .= "{$value},"; } print substr($line, 0, -1) . "\n";
#!/usr/bin/php -q <?php /* * @desc Interpret Grandstream SYSLOG onhook/powerup and request it picks up a new idle screen * @author Leo Brown * @date 2009-02-21 */ // dependencies require_once '../syslog/grandstream_syslog_decoder.php'; require_once '../telnet/GrandstreamAudioControl.class.php'; // establish socket $s = new GrandstreamSYSLOG(); if (!$s->bind($address = @$argv[1])) { exit; } // tapping driver_start, currently only for syslog, but could be reviewed $messages = array('on_hook', 'driver_start'); // start listening on callback $s->listen('notify', null, $messages); $device_states = array(); function notify($result) { $argv[1] = $result['ip']; $argv[2] = 'screen'; require '../sip/notify.php'; }
* @author Leo Brown * @date 2008-08-19 */ // dependencies require_once '../syslog/grandstream_syslog_decoder.php'; if (!class_exists('XmlWriter')) { require_once '../syslog/XmlWriter.class.php'; } require_once '../telnet/GrandstreamAudioControl.class.php'; // establish socket $s = new GrandstreamSYSLOG(); $s->bind($address = @$argv[1]); // messages to listen for $messages = array('off_hook', 'callmode_change'); // start listening on callback $s->listen('playTones', null, $messages); $device_states = array(); function playTones($result) { global $device_states; $ip = $result['ip']; switch ($result['message']['type']) { case 'callmode_change': $device_states[$ip] = $result['message']['new_mode']; break; // GXP unfortunately sends callmode/voicemode/audio path changes AFTER // off-hook for handset. Handsfree and headset set mode FIRST. // Approach is to assume handset // GXP unfortunately sends callmode/voicemode/audio path changes AFTER // off-hook for handset. Handsfree and headset set mode FIRST. // Approach is to assume handset