Пример #1
0
function gupnp_device_proxy_available_cb($proxy, $arg)
{
    /* Get device info */
    $info = gupnp_device_info_get($proxy);
    if ($info['friendly_name'] == 'MediaTomb') {
        printf("Device is available:\n");
        foreach ($info as $key => $value) {
            printf("\t%-30s: %s\n", $key, $value);
        }
        printf("\n");
        gupnp_control_point_browse_stop($arg['cp_device']);
        $arg_service = array('udn' => $info['udn'], 'cp_service' => $arg['cp_service']);
        $cb_service = "gupnp_service_proxy_available_cb";
        gupnp_control_point_callback_set($arg['cp_service'], GUPNP_SIGNAL_SERVICE_PROXY_AVAILABLE, $cb_service, $arg_service);
        gupnp_control_point_browse_start($arg['cp_service']);
    }
}
Пример #2
0
}
/* Check and parse command line arguments */
if (count($argv) != 2) {
    usage();
    exit(-1);
}
if ($argv[1] == "on") {
    $mode = 'ON';
} elseif ($argv[1] == "off") {
    $mode = 'OFF';
} elseif ($argv[1] == "toggle") {
    $mode = 'TOGGLE';
} else {
    usage();
    exit(-1);
}
/* Create the UPnP context */
$context = gupnp_context_new();
if (!$context) {
    printf("Error creating the GUPnP context\n");
    exit(-1);
}
/* Create the control point, searching for SwitchPower services */
$cp = gupnp_control_point_new($context, "urn:schemas-upnp-org:service:SwitchPower:1");
/* Connect to the service-found callback */
$cb = "service_proxy_available_cb";
$arg = array('mode' => $mode, 'cp' => $cp);
gupnp_control_point_callback_set($cp, GUPNP_SIGNAL_SERVICE_PROXY_AVAILABLE, $cb, $arg);
/* Start for browsing */
gupnp_control_point_browse_start($cp);
Пример #3
0
    exit(-1);
}
$args = array();
for ($i = 1; $i < count($argv); $i++) {
    $tmp_args = explode('=', $argv[$i]);
    $args[$tmp_args[0]] = $tmp_args[1];
}
/* Create the UPnP context */
$context = gupnp_context_new();
if (!$context) {
    printf("Error creating the GUPnP context\n");
    exit(-1);
}
/* Create the control point, searching for SwitchPower services */
$cp_tvdevice = gupnp_control_point_new($context, "urn:schemas-upnp-org:device:tvdevice:1");
$cp_tvcontrol = gupnp_control_point_new($context, "urn:schemas-upnp-org:service:tvcontrol:1");
/* Connect to the service-found callback */
$arg = array('args' => $args, 'cp' => $cp_tvdevice);
$cb = "tvcontrol_device_proxy_available_cb";
gupnp_control_point_callback_set($cp_tvdevice, GUPNP_SIGNAL_DEVICE_PROXY_AVAILABLE, $cb, $arg);
$cb = "tvcontrol_device_proxy_unavailable_cb";
gupnp_control_point_callback_set($cp_tvdevice, GUPNP_SIGNAL_DEVICE_PROXY_UNAVAILABLE, $cb, $arg);
$arg = array('args' => $args, 'cp' => $cp_tvcontrol);
$cb = "tvcontrol_service_proxy_available_cb";
gupnp_control_point_callback_set($cp_tvcontrol, GUPNP_SIGNAL_SERVICE_PROXY_AVAILABLE, $cb, $arg);
$cb = "tvcontrol_service_proxy_unavailable_cb";
gupnp_control_point_callback_set($cp_tvcontrol, GUPNP_SIGNAL_SERVICE_PROXY_UNAVAILABLE, $cb, $arg);
/* Start for browsing */
gupnp_control_point_browse_start($cp_tvdevice);
gupnp_control_point_browse_start($cp_tvcontrol);