Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

php script which no need of js nor nodejs #129

Open
raphio000 opened this issue Sep 25, 2023 · 3 comments
Open

php script which no need of js nor nodejs #129

raphio000 opened this issue Sep 25, 2023 · 3 comments
Labels

Comments

@raphio000
Copy link

HI,
using your work.
I wrote a translation in php which I think is easier to read and easier to encode the wifi passphrase
There is some little changes because it's for GoogleTV.

Unfortunately I must miss something with googleTV.
Maybe the mandatory connection to a google account.
Because after using this script I'm connected to the SSID (I Can see the device listed on the right SSID in my WIFI controller, with an IP in the range)
BUt then screen remains on "CONNECTED" and if I reboot I lost all the setup.

Any ideas ? anyone who wants to work on this ?

`<?php
// Set your Chromecast's IP, WiFi SSID, and WiFi Password
$CHROMECAST_IP = "192.168.XXX.XXX";
$WIFI_SSID = "XXX";
$WIFI_PASSWORD = "XXX";
$VERBOSITY = "-vvv";

echo "Connecting $CHROMECAST_IP to $WIFI_SSID with password $WIFI_PASSWORD\n";

// Get the device's public key
$info_json = shell_exec("curl $VERBOSITY --insecure --tlsv1.2 --tls-max 1.2 https://$CHROMECAST_IP:8443/setup/eureka_info?params=version,audio,name,build_info,detail,device_info,net,wifi,setup,settings,opt_in,opencast,multizone,proxy,night_mode_params,user_eq,room_equalizer,sign,aogh,ultrasound,mesh");
$info_dict = json_decode($info_json, true);

$CHROMECAST_PUBKEY = $info_dict["device_info"]["public_key"];

// Scan for and find the network we want to get the encryption parameters
shell_exec("curl $VERBOSITY --insecure --tlsv1.2 --tls-max 1.2 -X POST https://$CHROMECAST_IP:8443/setup/scan_wifi");
sleep(20);
$wifi_json = shell_exec("curl $VERBOSITY --insecure --tlsv1.2 --tls-max 1.2 https://$CHROMECAST_IP:8443/setup/scan_results");
$wifi_networks = json_decode($wifi_json, true);

foreach ($wifi_networks as $wifi_network) {
if ($wifi_network["ssid"] == $WIFI_SSID) {
$WIFI_AUTH_NUMBER = $wifi_network["wpa_auth"];
$WIFI_CIPHER_NUMBER = $wifi_network["wpa_cipher"];
break;
}
}

// Encrypt the password to the device
$public_key = "-----BEGIN RSA PUBLIC KEY-----\n" . $CHROMECAST_PUBKEY . "\n-----END RSA PUBLIC KEY-----";
openssl_public_encrypt($WIFI_PASSWORD, $encrypted_data, $public_key, OPENSSL_PKCS1_PADDING);
$ENCRYPTED_KEY = base64_encode($encrypted_data);

// Generate the command to connect
$CONNECT_COMMAND = json_encode([
"ssid" => $WIFI_SSID,
"wpa_auth" => $WIFI_AUTH_NUMBER,
"wpa_cipher" => $WIFI_CIPHER_NUMBER,
"enc_passwd" => $ENCRYPTED_KEY
]);

// And the command to save the connection
$SAVE_COMMAND = json_encode([
"keep_hotspot_until_connected" => true
]);

// Send the commands
shell_exec("curl $VERBOSITY --insecure --tlsv1.2 --tls-max 1.2 -H 'content-type: application/json' -d '$CONNECT_COMMAND' https://$CHROMECAST_IP:8443/setup/connect_wifi");
shell_exec("curl $VERBOSITY --insecure --tlsv1.2 --tls-max 1.2 -H 'content-type: application/json' -d '$SAVE_COMMAND' https://$CHROMECAST_IP:8443/setup/save_wifi");

$info_json = shell_exec("curl $VERBOSITY --insecure --tlsv1.2 --tls-max 1.2 -H 'content-type: application/json' -d '{"name": "Living room"}' https://$CHROMECAST_IP:8443/setup/set_eureka_info");

echo "Chromecast connected to WiFi.\n";

?>
`

@raphio000
Copy link
Author

YOu see I'm new on github,
I cannot even place code in a box

@raphio000
Copy link
Author

raphio000 commented Oct 9, 2023

Hi all and forget to mention to thank you for all this work.
Does anyone managed to configure a googleTV (ccwgtv) using scripts ?
If someone is working on itn I would be happy to help.
Allready been in the HOME app and check the http requests sent to CHromecast but cannot figure everything yet.

Thx everyone

Copy link

stale bot commented Jan 7, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant