Fix bug on reconnect
This commit is contained in:
parent
af18739ed1
commit
e68f136a13
20
core.js
20
core.js
@ -150,8 +150,10 @@ async function ds4_info() {
|
|||||||
append_info(l("Board Model"), ds4_hw_to_bm(hw_ver_minor) + b_info);
|
append_info(l("Board Model"), ds4_hw_to_bm(hw_ver_minor) + b_info);
|
||||||
|
|
||||||
// All ok, safe to lock NVS, query it and get BD Addr
|
// All ok, safe to lock NVS, query it and get BD Addr
|
||||||
|
nvstatus = await ds4_nvstatus();
|
||||||
|
|
||||||
|
if(nvstatus == 0)
|
||||||
await ds4_nvlock();
|
await ds4_nvlock();
|
||||||
await ds4_nvstatus();
|
|
||||||
bd_addr = await ds4_getbdaddr();
|
bd_addr = await ds4_getbdaddr();
|
||||||
append_info(l("Bluetooth Address"), bd_addr);
|
append_info(l("Bluetooth Address"), bd_addr);
|
||||||
|
|
||||||
@ -402,18 +404,28 @@ async function ds4_calibrate_sticks() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function ds4_nvstatus() {
|
async function ds4_nvstatus() {
|
||||||
|
try {
|
||||||
await device.sendFeatureReport(0x08, alloc_req(0x08, [0xff,0, 12]))
|
await device.sendFeatureReport(0x08, alloc_req(0x08, [0xff,0, 12]))
|
||||||
data = lf("ds4_nvstatus", await device.receiveFeatureReport(0x11))
|
data = lf("ds4_nvstatus", await device.receiveFeatureReport(0x11))
|
||||||
// 1: temporary, 0: permanent
|
// 1: temporary, 0: permanent
|
||||||
ret = data.getUint8(1, false);
|
ret = data.getUint8(1, false);
|
||||||
if(ret == 1) {
|
if(ret == 1) {
|
||||||
$("#d-nvstatus").html("<font color='green'>" + l("locked") + "</font>");
|
$("#d-nvstatus").html("<font color='green'>" + l("locked") + "</font>");
|
||||||
|
return 1;
|
||||||
} else if(ret == 0) {
|
} else if(ret == 0) {
|
||||||
$("#d-nvstatus").html("<font color='red'>" + l("unlocked") + "</font>");
|
$("#d-nvstatus").html("<font color='red'>" + l("unlocked") + "</font>");
|
||||||
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
$("#d-nvstatus").html("<font color='purple'>unk " + ret + "</font>");
|
$("#d-nvstatus").html("<font color='purple'>unk " + ret + "</font>");
|
||||||
|
if(ret == 0 || ret == 1)
|
||||||
|
return 2;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
} catch(e) {
|
||||||
|
$("#d-nvstatus").html("<font color='red'>" + l("error") + "</font>");
|
||||||
|
return 2; // error
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function ds5_nvstatus() {
|
async function ds5_nvstatus() {
|
||||||
@ -429,6 +441,8 @@ async function ds5_nvstatus() {
|
|||||||
return 0; // permanent
|
return 0; // permanent
|
||||||
} else {
|
} else {
|
||||||
$("#d-nvstatus").html("<font color='purple'>unk " + dec2hex32(ret) + "</font>");
|
$("#d-nvstatus").html("<font color='purple'>unk " + dec2hex32(ret) + "</font>");
|
||||||
|
if(ret == 0 || ret == 1)
|
||||||
|
return 2;
|
||||||
return ret; // unknown
|
return ret; // unknown
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
@ -479,7 +493,6 @@ async function ds4_nvunlock() {
|
|||||||
async function ds5_system_info(base, num, length, decode = true) {
|
async function ds5_system_info(base, num, length, decode = true) {
|
||||||
await device.sendFeatureReport(128, alloc_req(128, [base,num]))
|
await device.sendFeatureReport(128, alloc_req(128, [base,num]))
|
||||||
var pcba_id = lf("ds5_pcba_id", await device.receiveFeatureReport(129));
|
var pcba_id = lf("ds5_pcba_id", await device.receiveFeatureReport(129));
|
||||||
console.log(pcba_id);
|
|
||||||
if(pcba_id.getUint8(1) != base || pcba_id.getUint8(2) != num || pcba_id.getUint8(3) != 2) {
|
if(pcba_id.getUint8(1) != base || pcba_id.getUint8(2) != num || pcba_id.getUint8(3) != 2) {
|
||||||
return l("error");
|
return l("error");
|
||||||
} else {
|
} else {
|
||||||
@ -549,8 +562,9 @@ async function ds5_info() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nvstatus = await ds5_nvstatus();
|
||||||
|
if(nvstatus == 0)
|
||||||
await ds5_nvlock();
|
await ds5_nvlock();
|
||||||
await ds5_nvstatus();
|
|
||||||
bd_addr = await ds5_getbdaddr();
|
bd_addr = await ds5_getbdaddr();
|
||||||
append_info(l("Bluetooth Address"), bd_addr, "hw");
|
append_info(l("Bluetooth Address"), bd_addr, "hw");
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
|
1
googlec4c2e36a49e62fa3.html
Normal file
1
googlec4c2e36a49e62fa3.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
google-site-verification: googlec4c2e36a49e62fa3.html
|
@ -607,7 +607,7 @@ dl.row dd { font-family: monospace; }
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<footer>
|
<footer>
|
||||||
<div class="d-flex flex-column flex-sm-row justify-content-between py-4 my-4 border-top" id="footbody">
|
<div class="d-flex flex-column flex-sm-row justify-content-between py-4 my-4 border-top" id="footbody">
|
||||||
<p><a target="_blank" href="https://github.com/dualshock-tools/dualshock-tools.github.io/commits/main/"><span class="ds-i18n">Version</span> 1.8</a> (2024-11-17) - <a href="#" class="ds-i18n" onclick="show_donate_modal();">Support this project</a> <span id="authorMsg"></span></p>
|
<p><a target="_blank" href="https://github.com/dualshock-tools/dualshock-tools.github.io/commits/main/"><span class="ds-i18n">Version</span> 1.9</a> (2025-01-05) - <a href="#" class="ds-i18n" onclick="show_donate_modal();">Support this project</a> <span id="authorMsg"></span></p>
|
||||||
|
|
||||||
<ul class="list-unstyled d-flex">
|
<ul class="list-unstyled d-flex">
|
||||||
<li class="ms-3"><a class="link-body-emphasis" href="mailto:ds4@the.al" target="_blank"><svg class="bi" width="24" height="24"><use xlink:href="#mail"/></svg></a></li>
|
<li class="ms-3"><a class="link-body-emphasis" href="mailto:ds4@the.al" target="_blank"><svg class="bi" width="24" height="24"><use xlink:href="#mail"/></svg></a></li>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user