Skip to content

Commit e6a48ce

Browse files
authored
Fix ELRS UUID (#4096)
Fix Buffer.from
1 parent 3cffa09 commit e6a48ce

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/js/tabs/receiver.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,13 @@ receiver.initialize = function (callback) {
5252
if (text) {
5353
const bindingPhraseFull = `-DMY_BINDING_PHRASE="${text}"`;
5454
const hash = CryptoES.MD5(bindingPhraseFull).toString();
55-
uidBytes = Uint8Array.from(Buffer.from(hash, 'hex')).subarray(0, 6);
55+
// Buffer.from is not available in the browser
56+
const bytes = hash.match(/.{1,2}/g).map(byte => parseInt(byte, 16));
57+
const view = new DataView(new ArrayBuffer(6));
58+
for (let i = 0; i < 6; i++) {
59+
view.setUint8(i, bytes[i]);
60+
}
61+
uidBytes = Array.from(new Uint8Array(view.buffer));
5662
}
5763

5864
return uidBytes;

0 commit comments

Comments
 (0)