|
async function tmobileHomeInternetDisableWifi() { |
|
const username = 'admin' |
|
const password = 'REPLACE-WITH-REAL-PASSWORD' // <<------- Make sure to replace this |
|
|
|
async function loginTmobile(username, password) { |
|
const resp = await fetch("http://192.168.12.1/TMI/v1/auth/login", { |
|
"headers": { |
|
"accept": "application/json", |
|
"accept-language": "en-US,en;q=0.9", |
|
"cache-control": "max-age=0", |
|
"content-type": "text/plain;charset=UTF-8" |
|
}, |
|
"referrer": "http://192.168.12.1/home", |
|
"referrerPolicy": "strict-origin-when-cross-origin", |
|
// "body": "{\"username\":\"admin\",\"password\":\"tug.ecologist.cover.facility\"}", |
|
body: JSON.stringify({ username, password }), |
|
"method": "POST", |
|
"mode": "cors", |
|
"credentials": "include" |
|
}); |
|
|
|
console.log('resp', { headers: resp.headers }) |
|
|
|
if (resp.ok) { |
|
const jsonValue = await resp.json(); // Get JSON value from the response body |
|
const authToken = jsonValue?.auth?.token |
|
return Promise.resolve(authToken); |
|
} else { |
|
return Promise.reject('Failed to get JSON respon value'); |
|
} |
|
} |
|
|
|
async function getAccessPointConfig(authToken) { |
|
const resp = await fetch("http://192.168.12.1/TMI/v1/network/configuration?get=ap", { |
|
headers: { |
|
"accept": "application/json", |
|
"accept-language": "en-US,en;q=0.9", |
|
"authorization": `Bearer ${authToken}`, |
|
"cache-control": "max-age=0" |
|
}, |
|
referrer: "http://192.168.12.1/networks", |
|
referrerPolicy: "strict-origin-when-cross-origin", |
|
body: null, |
|
method: "GET", |
|
mode: "cors", |
|
credentials: "include" |
|
}); |
|
|
|
console.log('ap config resp', resp) |
|
|
|
if (resp.ok) { |
|
const jsonValue = await resp.json(); // Get JSON value from the response body |
|
return Promise.resolve(jsonValue); |
|
} else { |
|
return Promise.reject('Failed to get JSON respon value'); |
|
} |
|
} |
|
|
|
function disableWifiProps(apConfig) { |
|
const configWifiOff = { |
|
...apConfig, |
|
'2.4ghz': { ...apConfig['2.4ghz'], isRadioEnabled: false }, |
|
'5.0ghz': { ...apConfig['5.0ghz'], isRadioEnabled: false }, |
|
} |
|
console.log('configWifiOff', configWifiOff) |
|
return configWifiOff |
|
} |
|
|
|
async function disableAccessPointWifi(authToken) { |
|
const apConfig = await getAccessPointConfig(authToken) |
|
const wifiOffConfig = disableWifiProps(apConfig) |
|
|
|
const resp = await fetch("http://192.168.12.1/TMI/v1/network/configuration?set=ap", { |
|
headers: { |
|
"accept": "application/json", |
|
"accept-language": "en-US,en;q=0.9", |
|
"authorization": `Bearer ${authToken}`, |
|
"cache-control": "max-age=0", |
|
"content-type": "text/plain;charset=UTF-8" |
|
}, |
|
referrer: "http://192.168.12.1/networks", |
|
referrerPolicy: "strict-origin-when-cross-origin", |
|
body: JSON.stringify(wifiOffConfig), |
|
method: "POST", |
|
mode: "cors", |
|
credentials: "include" |
|
}); |
|
|
|
console.log('ap config resp', resp) |
|
|
|
if (resp.ok) { |
|
const jsonValue = await resp.json(); // Get JSON value from the response body |
|
return Promise.resolve(jsonValue); |
|
} else { |
|
return Promise.reject('Failed to get JSON respon value'); |
|
} |
|
} |
|
|
|
const authToken = await loginTmobile(username, password) |
|
const result = await disableAccessPointWifi(authToken) |
|
return result |
|
} |
I suspect you aren't updating line 3 with the correct admin password you created when you set up your T-Mobile Internet router. I just ran this code myself (after updating the password) and it worked perfectly.