From e6a48ceb2c461449192e46e3c5673a2b8643b3f5 Mon Sep 17 00:00:00 2001 From: Mark Haslinghuis Date: Wed, 10 Jul 2024 21:22:52 +0200 Subject: [PATCH] Fix ELRS UUID (#4096) Fix Buffer.from --- src/js/tabs/receiver.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/js/tabs/receiver.js b/src/js/tabs/receiver.js index c3308a4439..83130adab1 100644 --- a/src/js/tabs/receiver.js +++ b/src/js/tabs/receiver.js @@ -52,7 +52,13 @@ receiver.initialize = function (callback) { if (text) { const bindingPhraseFull = `-DMY_BINDING_PHRASE="${text}"`; const hash = CryptoES.MD5(bindingPhraseFull).toString(); - uidBytes = Uint8Array.from(Buffer.from(hash, 'hex')).subarray(0, 6); + // Buffer.from is not available in the browser + const bytes = hash.match(/.{1,2}/g).map(byte => parseInt(byte, 16)); + const view = new DataView(new ArrayBuffer(6)); + for (let i = 0; i < 6; i++) { + view.setUint8(i, bytes[i]); + } + uidBytes = Array.from(new Uint8Array(view.buffer)); } return uidBytes;