Skip to content

Commit 739bd23

Browse files
committed
Added OpenHaystack as per seemoo-lab/openhaystack#59 (comment)
1 parent 568fdf9 commit 739bd23

File tree

6 files changed

+95
-0
lines changed

6 files changed

+95
-0
lines changed

apps.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,19 @@
4646
{"name":".bootcde"}
4747
]
4848
},
49+
{ "id": "openhaystack",
50+
"name": "OpenHaystack (AirTag)",
51+
"icon": "icon.png",
52+
"version":"0.01",
53+
"description": "Copy a base64 key from https://github.com/seemoo-lab/openhaystack and make your device trackable as if it's an AirTag",
54+
"tags": "openhaystack,bluetooth,ble,tracking,airtag",
55+
"custom": "custom.html",
56+
"readme": "README.md",
57+
"needsFeatures":["BLE"],
58+
"storage": [
59+
{"name":".bootcde","url":"app.js"}
60+
]
61+
},
4962
{ "id": "blescanner",
5063
"name": "Bluetooth Scanner",
5164
"icon": "icon.png",

apps/openhaystack/ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.01: New App!

apps/openhaystack/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# OpenHaystack (AirTag)
2+
3+
Copy a base64 key from https://github.com/seemoo-lab/openhaystack and make your device trackable as if it's an AirTag
4+
5+
Based on https://github.com/seemoo-lab/openhaystack/issues/59
6+
7+
## Usage
8+
9+
* Follow the steps on https://github.com/seemoo-lab/openhaystack#how-to-use-openhaystack to install OpenHaystack and get a unique base64 code
10+
* Click the ≡ icon next to `OpenHaystack (AirTag)`
11+
* Paste in the base64 code
12+
* Click `Upload`

apps/openhaystack/app.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Your JS application in here
2+
g.clear();
3+
g.drawString("Your Espruino is working fine.", 0, 0, true);
4+
g.flip();

apps/openhaystack/custom.html

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
2+
<html>
3+
<head>
4+
<link rel="stylesheet" href="../../css/spectre.min.css">
5+
</head>
6+
<body>
7+
<p>Follow the steps on <a href="https://github.com/seemoo-lab/openhaystack#how-to-use-openhaystack">https://github.com/seemoo-lab/openhaystack</a> to install OpenHaystack and get a unique base64 code</p>
8+
<p>Then paste the key in below and click <b>Upload</b></p>
9+
10+
<p>Base64 key: <input type="text" id="key" class="form-input" value="..."></p>
11+
<p id="keyStatus">&nbsp;</p>
12+
13+
<p>Click <button id="upload" class="btn btn-primary">Upload</button></p>
14+
15+
16+
<script src="../../core/lib/customize.js"></script>
17+
18+
<script>
19+
function keyChanged() {
20+
var keyValue = document.getElementById("key").value.trim();
21+
var status = "👍 Key Ok.."
22+
if (keyValue.length!=40) status = "⚠️ Key should be 40 characters long";
23+
if (!keyValue.match(/^[A-Za-z0-9+\/=]+$/)) status = "⚠️ Key contains non-base64 characters";
24+
document.getElementById("keyStatus").innerText = status;
25+
}
26+
document.getElementById("key").addEventListener("changed", keyChanged);
27+
document.getElementById("key").addEventListener("keyup", keyChanged);
28+
// When the 'upload' button is clicked...
29+
document.getElementById("upload").addEventListener("click", function() {
30+
// get the text to add
31+
var keyValue = document.getElementById("key").value.trim();
32+
// build the app's text using a templated String
33+
var appJS = `/*
34+
OPENHAYSTACK
35+
A framework for tracking personal Bluetooth devices via Apple's massive Find My network
36+
https://github.com/seemoo-lab/openhaystack/issues/59#issuecomment-1303236903
37+
*/
38+
const key_b64 = ${JSON.stringify(keyValue)}";
39+
40+
function b64ToArray(str) {
41+
let bstr = atob(str);
42+
let arr = [];
43+
for (let i = 0; i < bstr.length; i++) {
44+
arr[i] = bstr.charCodeAt(i);
45+
}
46+
return arr;
47+
}
48+
49+
const key = b64ToArray(key_b64); // public key
50+
const mac = [ key[0] | 0b11000000, key[1], key[2], key[3], key[4], key[5] ].map(x => x.toString(16).padStart(2, '0')).join(':'); // mac address
51+
const adv = [ 0x1e, 0xff, 0x4c, 0x00, 0x12, 0x19, 0x00, key[6], key[7], key[8], key[9], key[10], key[11], key[12], key[13], key[14], key[15], key[16], key[17], key[18], key[19], key[20], key[21], key[22], key[23], key[24], key[25], key[26], key[27], key[0] >> 6, 0x00 ]; // advertising packet
52+
NRF.setAddress(mac);
53+
NRF.setAdvertising(adv, {interval:5000});
54+
`;
55+
// send finished app
56+
sendCustomizedApp({
57+
storage:[
58+
{name:".boot0", content:appJS},
59+
]
60+
});
61+
});
62+
63+
</script>
64+
</body>
65+
</html>

apps/openhaystack/icon.png

15.7 KB
Loading

0 commit comments

Comments
 (0)