What you could do is when the script runs this part of the code:@mrdude Congrats on the 9.00 work you have been doing on the esp32 s2. I havent tried it out yet but it is looking very promising.
In my 9.00 web hosts I have started using a "return new Promise" that gets resolved when a addEventListner 'click' is detected for the manual insertion of the USB stage.
I've been trying to find a way to auto detect if a USB drive has been inserted using javascript and I came across this but unfortunatly it is not compatable with the PS4 browser. (or at least I could not get it to work)
https://developer.mozilla.org/en-US/docs/Web/API/WebUSB_API
https://developer.mozilla.org/en-US/docs/Web/API/USBConnectionEvent
Is there a similar function for the ESP that can physically detect when a USB drive is mounted?
If so this could be useful in eliminating the timing variable from when the code tells the ESP to mount a usb drive to the actual time of when it has done it.
I havent used the ESP32 S2 in a while but when I did I had it set ups as a network device rather than an access point but I found that during testing every time the timing of the USB mounting was slightly different. Could be a few hundred milliseconds or sometimes a couple of seconds.
If we could set the wait time for the kernel exploit to trigger when the ESP has detected that the USB has been mounted rather than a set time from when the enableUSB has been requested it might work a little better.
I dont know if any of this will be of any help but I thought I'd mention it just in case.
Code:
void enableUSB() {
dev.vendorID("PS4");
dev.productID("ESP32 Server");
dev.productRevision("1.0");
dev.onRead(onRead);
dev.mediaPresent(true);
dev.begin(8192, 512);
USB.begin();
enTime = millis();
hasEnabled = true;
}
Is add a function call to the end of that, that would send a web page to spiffs with something in it like this:
Code:
sessionStorage.setItem('usbenabled', true);
You could then then make a while loop in the loader which runs the temp page and looks for "sessionStorage.getitem" (the value), if it returns true it would know the usb has been mounted correctly.
After it reads the value - add a call in the loader to remove the temp web page from spiffs.
That should do what you want to achieve without messing about too much or caring about the browser.