Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
Yrr0r committed Jul 13, 2022
0 parents commit 11642f2
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# OS generated files #
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
desktop.ini
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# WebBLE with Paperang

The only thing this can do right now is print a self-diagnostics page.

Connect, then hit print.

## Some useful BLE related constants:

- Service ID: `49535343-fe7d-4ae5-8fa9-9fafd205e455`

- Characteristic ID: `49535343-6daa-4d02-abf6-19569aca69fe`
1 change: 1 addition & 0 deletions bulma.min.css

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<head>
<script src="script.js"></script>
<link rel="stylesheet" href="bulma.min.css">
</head>
<body>
<div class="container">
<p class="title">WebBLE with Paperang</p>
<div class="block">
<button class="button" onclick="connect();">connect</button>
<button class="button" onclick="selfdiag()">Diagnostics</button>
</div>
</div>
</body>
22 changes: 22 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

var btservice;
var sockchar;
// service: 49535343-fe7d-4ae5-8fa9-9fafd205e455
// characteristic: 49535343-6daa-4d02-abf6-19569aca69fe

async function connect(){
let printer = await navigator.bluetooth.requestDevice({
acceptAllDevices:true,
optionalServices:['49535343-fe7d-4ae5-8fa9-9fafd205e455']
});
console.log(printer);

let pserver = await printer.gatt.connect();
btservice = await pserver.getPrimaryService('49535343-fe7d-4ae5-8fa9-9fafd205e455');
sockchar = await btservice.getCharacteristic('49535343-6daa-4d02-abf6-19569aca69fe');
}

async function selfdiag(){
let cmdstr = Uint8Array.from([2,27,0,1,0,0,70,137,94,158,3]);
sockchar.writeValue(cmdstr);
}

0 comments on commit 11642f2

Please sign in to comment.