echo "=========================================================\n\n\n"; $local_path_1 = $_SERVER["PWD"] . "/ext/gupnp/examples/BinaryLight1.xml"; $server_path_1 = "/BinaryLight1.xml"; echo "=========================================================\n"; echo "[CALL]: gupnp_context_host_path({$context}, {$local_path_1}, {$server_path_1}) \n"; echo "---------------------------------------------------------\n"; $result = gupnp_context_host_path($context, $local_path_1, $server_path_1); echo "[RESULT]: "; var_dump($result); echo "=========================================================\n\n\n"; $local_path_2 = $_SERVER["PWD"] . "/ext/gupnp/examples/SwitchPower1.xml"; $server_path_2 = "/SwitchPower1.xml"; echo "=========================================================\n"; echo "[CALL]: gupnp_context_host_path({$context}, {$local_path_2}, {$server_path_2}) \n"; echo "---------------------------------------------------------\n"; $result = gupnp_context_host_path($context, $local_path_2, $server_path_2); echo "[RESULT]: "; var_dump($result); echo "=========================================================\n\n\n"; echo "=========================================================\n"; echo "[CALL]: gupnp_root_device_new({$context}, {$server_path_1}) \n"; echo "---------------------------------------------------------\n"; $device = gupnp_root_device_new($context, $server_path_1); echo "[RESULT]: "; var_dump($device); echo "=========================================================\n\n\n"; echo "=========================================================\n"; echo "[CALL]: gupnp_root_device_get_available({$device}) \n"; echo "---------------------------------------------------------\n"; $result = gupnp_root_device_get_available($device); echo "[RESULT]: ";
/* Status */ function query_status_cb($service, $variable, $value, $arg) { printf("[CALL] query_status_cb"); } /* By default the light is off */ $GLOBALS['status'] = false; printf("The light is now %s.\n", $GLOBALS['status'] ? "on" : "off"); /* Create the UPnP context */ $context = gupnp_context_new(); if (!$context) { printf("Error creating the GUPnP context\n"); exit(-1); } /* Host the directory that contains device and service description files */ gupnp_context_host_path($context, "./web", ""); /* Create root device */ $location = "/BinaryLight1.xml"; $dev = gupnp_root_device_new($context, $location); gupnp_root_device_set_available($dev, true); /* Get the switch service from the root device */ $service_type = "urn:schemas-upnp-org:service:SwitchPower:1"; $service = gupnp_device_info_get_service($dev, $service_type); if (!$service) { die("Cannot get SwitchPower1 service\n"); } /* Set callback for action GetStatus */ gupnp_device_action_callback_set($service, GUPNP_SIGNAL_ACTION_INVOKED, "GetStatus", "get_status_cb", "action data, GetStatus"); /* Set callback for action GetTarget */ gupnp_device_action_callback_set($service, GUPNP_SIGNAL_ACTION_INVOKED, "GetTarget", "get_target_cb", "action data, GetTarget"); /* Set callback for action SetTarget */