-
Notifications
You must be signed in to change notification settings - Fork 0
/
funny.html
33 lines (31 loc) · 1.28 KB
/
funny.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<!DOCTYPE html>
<html>
<head>
<title>Bluetooth Audio Streamer</title>
</head>
<body>
<h2>Bluetooth Audio Streamer</h2>
<input type="file" id="fileInput" />
<button id="connectBtn">Connect to Serial</button>
<p id="status"></p>
<script>
let writer;
let fileReader;
let chunkSize = 40; // Send 20 bytes as hex (40 hex characters)
let serialPort;
document.getElementById('fileInput').addEventListener('change', function(event) {
const file = event.target.files[0];
if (file) {
fileReader = new FileReader();
fileReader.onload = (e) => processFile(e.target.result);
fileReader.readAsText(file);
}
});
async function connectToSerial() {
try {
document.getElementById('status').textContent = 'Requesting Bluetooth Device...';
serialPort = await navigator.serial.requestPort();
document.getElementById('status').textContent = 'Opening Serial Port...';
await serialPort.open({ baudRate: 115200 });
writer = serialPort.writable.getWriter();
document.getElementById('status').textContent = 'Connected to Serial